Entropic 2.9.4
Local-first agentic inference engine
Loading...
Searching...
No Matches
llama_cpp_sampler.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
24#pragma once
25
27
28// Forward-declare llama.cpp opaque types — keeps llama.h out of the
29// header. The .cpp pulls in llama.h for real calls.
30struct llama_context;
31struct llama_vocab;
32struct llama_sampler;
33
34namespace entropic {
35
47class LlamaCppSampler : public Sampler {
48public:
55 LlamaCppSampler(llama_sampler* chain, llama_context* ctx);
56
57 ~LlamaCppSampler() override;
58
59 LlamaCppSampler(const LlamaCppSampler&) = delete;
60 LlamaCppSampler& operator=(const LlamaCppSampler&) = delete;
61
62 int32_t sample() override;
63
72 void reset() override;
73
88 llama_sampler* native_chain() const { return chain_; }
89
90private:
91 llama_sampler* chain_ = nullptr;
92 llama_context* ctx_ = nullptr;
93};
94
119public:
127 LlamaCppSamplerFactory(llama_context* ctx, const llama_vocab* vocab);
128
129 std::unique_ptr<Sampler> create(
130 const GenerationParams& params) override;
131
132private:
133 llama_context* ctx_ = nullptr;
134 const llama_vocab* vocab_ = nullptr;
135};
136
137} // namespace entropic
Factory that builds entropic's canonical llama_sampler chain.
std::unique_ptr< Sampler > create(const GenerationParams &params) override
Build the v2.3.10 sampler chain from GenerationParams.
Sampler adapter that wraps a llama_sampler* chain.
~LlamaCppSampler() override
Free the underlying llama.cpp sampler chain.
llama_sampler * native_chain() const
Expose the underlying chain for legacy call sites that have not yet been ported to the Sampler API.
int32_t sample() override
Sample one token from the current logits via the wrapped chain.
void reset() override
Reset llama_sampler internal state.
Factory that materializes a Sampler from GenerationParams.
Definition sampler.h:93
Pure-virtual per-generation sampler used by the decode loop.
Definition sampler.h:48
Activate model on GPU (WARM → ACTIVE).
Abstract Sampler seam for backend testability (v2.3.10).
Generation parameters for a single inference call.
Definition config.h:302