|
liblloyal 1.0.0
Branched Inference for llama.cpp
|
#include <lloyal/branch.hpp>
Public Member Functions | |
| Branch () | |
| Branch (BranchStore *store, BranchHandle handle) | |
| ~Branch () | |
| Destructor — CASCADE prunes entire subtree. | |
| Branch (Branch &&other) noexcept | |
| Branch & | operator= (Branch &&other) noexcept |
| Branch (const Branch &)=delete | |
| Branch & | operator= (const Branch &)=delete |
| Branch | fork () |
| Fork: allocates slot + lease, records topology edge. | |
| void | prune () |
| RESTRICT prune (throws if children exist) | |
| void | pruneSubtree () |
| CASCADE prune — removes entire subtree. | |
| void | force_snapshot_logits () |
| Force-copy shared logits buffer into this branch's snapshot. | |
| void | prefill (const llama_token *tokens, size_t n) |
| Decode multiple tokens and capture logits atomically (prompt injection) | |
| void | step (llama_token token) |
| Decode one token and capture logits (generation step) | |
| const float * | logits () const |
| Get the branch's captured logits snapshot. | |
| llama_token | sample () |
| Sample a token from captured logits. | |
| void | accept (llama_token token) |
| Accept a token — advance grammar, penalty window, and metrics. | |
| bool | is_eog (llama_token token) const |
| Check if a token is end-of-generation for this branch's model. | |
| template<SamplingParamsLike P> | |
| void | setSamplerParams (const P ¶ms) |
| Replace sampler chain with new parameters (memoized) | |
| void | setGrammar (const char *grammar_str) |
| Replace grammar constraint (nullptr/empty to remove) | |
| llama_pos | position () const |
| Current decode position (token count) | |
| llama_pos | forkHead () const |
| Parent's position at fork time (0 for root branches) | |
| float | perplexity () const |
| Model-level perplexity (from raw logits, pre-filter) | |
| int | n_vocab () const |
| Vocabulary size. | |
| bool | valid () const |
| True if this Branch holds a valid handle. | |
| BranchHandle | handle () const |
| Underlying opaque handle (for interop with free functions) | |
| BranchHandle | parentHandle () const |
| Parent branch handle, or INVALID_HANDLE if root. | |
| const std::vector< BranchHandle > & | childHandles () const |
| Child branch handles (empty if leaf) | |
| bool | isLeaf () const |
| True if this branch has no children. | |
| bool | isActive () const |
| True if this branch holds a KV lease. | |
Static Public Member Functions | |
| template<SamplingParamsLike P> | |
| static Branch | create (llama_context *ctx, const llama_model *model, BranchStore &store, llama_pos start_pos, const P ¶ms, int n_batch=DEFAULT_N_BATCH, const char *grammar_str=nullptr, boundaries::BoundaryTracker *boundary_tracker=nullptr) |
| Factory: allocates slot + lease from store. | |
Definition at line 2511 of file branch.hpp.
|
inline |
Definition at line 2513 of file branch.hpp.
|
inline |
Definition at line 2515 of file branch.hpp.
|
inline |
Destructor — CASCADE prunes entire subtree.
Definition at line 2519 of file branch.hpp.
|
inlinenoexcept |
Definition at line 2525 of file branch.hpp.
|
delete |
|
inline |
Accept a token — advance grammar, penalty window, and metrics.
| token | Token to accept (from sample()) |
Definition at line 2612 of file branch.hpp.
|
inline |
Child branch handles (empty if leaf)
Definition at line 2656 of file branch.hpp.
|
inlinestatic |
Factory: allocates slot + lease from store.
Definition at line 2547 of file branch.hpp.
|
inline |
Force-copy shared logits buffer into this branch's snapshot.
Copies the logits from the llama_context into the branch's internal buffer without performing a decode.
| std::runtime_error | if handle is invalid, vocab size is zero, or no logits are available (no prior decode with logits enabled) |
Definition at line 2580 of file branch.hpp.
|
inline |
Fork: allocates slot + lease, records topology edge.
Definition at line 2561 of file branch.hpp.
|
inline |
Parent's position at fork time (0 for root branches)
Definition at line 2641 of file branch.hpp.
|
inline |
Underlying opaque handle (for interop with free functions)
Definition at line 2649 of file branch.hpp.
|
inline |
Check if a token is end-of-generation for this branch's model.
Definition at line 2617 of file branch.hpp.
|
inline |
True if this branch holds a KV lease.
Definition at line 2663 of file branch.hpp.
|
inline |
True if this branch has no children.
Definition at line 2661 of file branch.hpp.
|
inline |
Get the branch's captured logits snapshot.
Definition at line 2599 of file branch.hpp.
|
inline |
Vocabulary size.
Definition at line 2645 of file branch.hpp.
Definition at line 2530 of file branch.hpp.
|
inline |
Parent branch handle, or INVALID_HANDLE if root.
Definition at line 2654 of file branch.hpp.
|
inline |
Model-level perplexity (from raw logits, pre-filter)
Definition at line 2643 of file branch.hpp.
|
inline |
Current decode position (token count)
Definition at line 2639 of file branch.hpp.
|
inline |
Decode multiple tokens and capture logits atomically (prompt injection)
| tokens | Array of token IDs |
| n | Number of tokens |
Definition at line 2587 of file branch.hpp.
|
inline |
RESTRICT prune (throws if children exist)
Definition at line 2567 of file branch.hpp.
|
inline |
CASCADE prune — removes entire subtree.
Definition at line 2573 of file branch.hpp.
|
inline |
Sample a token from captured logits.
Definition at line 2606 of file branch.hpp.
|
inline |
Replace grammar constraint (nullptr/empty to remove)
Definition at line 2631 of file branch.hpp.
|
inline |
Replace sampler chain with new parameters (memoized)
Definition at line 2625 of file branch.hpp.
|
inline |
Decode one token and capture logits (generation step)
| token | Token ID to decode |
Definition at line 2593 of file branch.hpp.
|
inline |
True if this Branch holds a valid handle.
Definition at line 2647 of file branch.hpp.