Skip to main content

DsparkSpecSession

Struct DsparkSpecSession 

Source
pub struct DsparkSpecSession {
    pub cache: Cache,
    pub rounds: usize,
    /* private fields */
}

Fields§

§cache: Cache§rounds: usize

Implementations§

Source§

impl DsparkSpecSession

Source

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

pub fn draft_kv(&self) -> &DflashKv

The drafter’s KV, for a worker publishing the tail into its cross-request prefix cache.

Source§

impl DsparkSpecSession

Source

pub fn cache_max_ctx(&self) -> usize

Source

pub fn finished(&self) -> bool

Source

pub fn pos(&self) -> usize

Source

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.

Source

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 exactly m+1trunk rows (anchor + accepted drafts) and emits exactly thosem+1tokens, so every emitted token has its KV row and nothing else does.last is 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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.