pub struct V2State { /* private fields */ }Expand description
Per-sequence mutable state: KV cache, token history, Engram ring, and every scratch buffer a step needs. Allocated once so a decode step does no heap work.
Implementations§
Source§impl V2State
impl V2State
Sourcepub fn set_kv_window(
&mut self,
window: Option<usize>,
model: &V2Model,
) -> Result<(), &'static str>
pub fn set_kv_window( &mut self, window: Option<usize>, model: &V2Model, ) -> Result<(), &'static str>
Override the attention window. None restores the model’s own.
Needed because the two heads upstream ships disagree: the LM path runs the
checkpoint’s kv_window (256), while architecture.encode_contrastive and
forward_confidence default to window=0, full causal. Below 256 tokens
the two are bit-identical; above it they diverge — at 642 tokens the
contrastive embeddings differ by cosine 3.5e-4 and the confidence logit by
0.096 — so this is a real fork, not a rounding detail.
Takes effect from the next step; it does not rewrite the existing cache.
Fails when the requested window needs more cached positions than this
state allocated — a window of 0 over a ring-sized cache would read stale
slots and quietly return wrong embeddings. Use
V2Model::make_state_full_causal for that case.