pub struct DsparkSpecSession {
pub cache: Cache,
pub rounds: usize,
/* private fields */
}Fields§
§cache: Cache§rounds: usizeImplementations§
Source§impl DsparkSpecSession
impl DsparkSpecSession
Sourcepub fn draft_tail_rows(&self) -> usize
pub fn draft_tail_rows(&self) -> usize
How many trailing draft-KV rows a restore must carry for the drafter to be indistinguishable from one that cold-primed: the sliding window plus one block.
WHY A TAIL IS SUFFICIENT, and why this is a fact about THIS export rather than a hope:
every DFlash2 draft layer is sliding_attention (the port asserts
cfg.layer_sliding.iter().all(|&s| s) at load and refuses otherwise), so the windowed
SDPA never reads a key below the current block’s window floor
(sdpa_naive_w_lo, whose bit-identity at Tkv 4104 and legacy launch failure are both
pinned by kernel_check). A round at context pos therefore reads rows
[pos - window + 1, pos + block) and nothing older. Storing that tail is storing
everything the drafter can observe.
SIZE, the reason this is affordable at all: 5 layers x (2048 + 16) rows x 8 kv x 128 dim x 4 B x 2 (k+v) is ~85 MB, against ~1,057 MB for the trunk planes of a 30k-token entry. Storing the FULL draft history instead would be ~1,229 MB — more than the trunk entry itself — which is what makes the tail the only viable form.
Source§impl DsparkSpecSession
impl DsparkSpecSession
pub fn cache_max_ctx(&self) -> usize
pub fn finished(&self) -> bool
pub fn pos(&self) -> usize
Sourcepub fn take_prefix_capture(&mut self) -> Option<SpecBoundaryCapture>
pub fn take_prefix_capture(&mut self) -> Option<SpecBoundaryCapture>
Drain the prompt-end prefix capture exactly once. Publication is worker-owned so it can apply namespace isolation, dedupe and the shared byte budget at the scheduler boundary.
Sourcepub fn into_demoted(self) -> (Cache, u32)
pub fn into_demoted(self) -> (Cache, u32)
DEMOTION HANDOFF (lane/dspark-spec-gate-demote, 2026-08-24): consume this session and
hand its trunk cache + next-token prediction to the plain batched-decode path — the
dspark twin of crate::spec::SpecSession::into_demoted.
WHY THIS IS EXACT (greedy). The burst-boundary invariant is `cache.pos == prompt rows
- emitted tokens
: each round commits exactlym+1trunk rows (anchor + accepted drafts) and emits exactly thosem+1tokens, so every emitted token has its KV row and nothing else does.lastis the verify argmax at the LAST committed row — and verify-column argmax equality with plain decode is the very property the dspark E2E byte-identity gate pins (dspark_q38_gate`: ALL EXACT). Handing (cache, last) to the batched path therefore continues the stream from a state indistinguishable from one the batched path produced itself.
Unlike the MTP twin there is no carried-pending shape: the round commits its bonus
inside the burst, so a session at a burst boundary is ALWAYS in handoff shape. The
caller still cross-checks pos() against its fed-token count (a budget-clamped
overshoot leaves cache rows past the public stream — those sessions finish, never
demote). The draft KV, snapshot buffers and philox counters are DROPPED here
(freeing their VRAM): the batched path never drafts, and the handoff is one-way.
Sampled sessions must not be demoted (the caller excludes them, mirroring the MTP gate): their committed stream depends on the session-owned philox counters, and the plain batched sampler is a different random program mid-request.