|
liblloyal 1.0.0
Branched Inference for llama.cpp
|
Classes | |
| struct | State |
| Tenancy state — tracks seq_id vacancy and leases. More... | |
Functions | |
| State | init (llama_context *ctx, llama_seq_id n_seq_max) |
| Initialize tenancy with all seq_ids vacant. | |
| llama_seq_id | acquire (State &s) |
| Acquire a seq_id from the vacant pool. | |
| void | release (State &s, llama_seq_id seq) |
| Release a seq_id back to vacant — bookkeeping only, no KV calls. | |
| void | evict (State &s, llama_seq_id seq) |
| Evict a seq_id — strip all KV tags then release. | |
| void | retain (State &s, llama_seq_id keep) |
| Nuclear retain — keep one seq, rebuild vacancy from scratch. | |
| void | evict_all (State &s) |
| Evict every leased seq_id. | |
| size_t | available (const State &s) |
| Number of vacant seq_ids available for acquisition. | |
|
inline |
Acquire a seq_id from the vacant pool.
Pops one seq_id from the LIFO stack and marks it as leased. The caller is responsible for eventually calling release() or evict() to return the lease.
| s | Tenancy state |
|
inline |
Number of vacant seq_ids available for acquisition.
| s | Tenancy state |
|
inline |
Evict a seq_id — strip all KV tags then release.
Used when the seq had actual KV residency (tokens were decoded into it). Calls remove_range() to strip all tags before returning the seq to the vacant pool, preserving the "vacant ⇒ clean" invariant.
| s | Tenancy state |
| seq | Seq_id to evict (must be currently leased) |
|
inline |
Evict every leased seq_id.
Iterates all seq_ids and evicts any that are currently leased. Used by BranchStore::drain() before context teardown.
| s | Tenancy state |
|
inline |
Initialize tenancy with all seq_ids vacant.
Fills the vacant stack in reverse order so that seq 0 is acquired first (LIFO pop from back). Safe for n_seq_max == 0 (produces empty state).
| ctx | Llama context for KV operations |
| n_seq_max | Total number of seq_ids (from llama_n_seq_max) |
|
inline |
Release a seq_id back to vacant — bookkeeping only, no KV calls.
Used when a seq was acquired but never written to (e.g. slot allocation failure rollback). The seq must already be clean (no KV tags).
| s | Tenancy state |
| seq | Seq_id to release (must be currently leased) |
|
inline |
Nuclear retain — keep one seq, rebuild vacancy from scratch.
Calls seq_keep() for a single KV pass that strips all tags except the keeper, then rebuilds the lease bitmap and vacant pool. O(n_seq_max).
Used by BranchStore::retainOnly() to promote a winner after search.
| s | Tenancy state |
| keep | Seq_id to retain (must be currently leased) |