Skip to main content

Module dflash

Module dflash 

Source
Expand description

DFlash block-diffusion drafter (DFLASH-BRINGUP-PLAN.md, 2026-07-13).

5-layer qwen3-class mini-transformer that drafts a 16-token block in ONE non-causal forward, conditioned on the TARGET’s hidden states at 6 tapped layers (concatenated through fc + hidden_norm). No embed / lm_head of its own — the round reuses the target’s. Reference: z-lab/dflash dflash/model.py (semantics frozen in the plan doc); oracle: tools/dflash_oracle.py -> /data/cache/dflash-oracle.npz.

FIRST LIGHT = f32-resident weights + fresh full-context forward (no draft KV cache) — correctness vs the oracle, then the cache/quant/window arms land measurement-gated.

Structs§

ConfidenceHead
AcceptRatePredictor: raw linear proj over [hidden ; markov_prev_embedding(rank)] (with_markov=true on the q38 arm-a export) — output is the PRE-sigmoid scalar.
DflashCfg
DflashDraft
DflashKv
Draft KV cache (round-cost fix, 2026-07-13): per-layer normed+roped ctx K and raw ctx V, append-only in committed order. Block K/V land TRANSIENTLY at [len..len+b] each round (never committed — the reference crops them identically). Kills the per-round full-ctx projection recompute (first light was O(ctx)/round -> 7 tok/s).
DflashLayer
DsparkSpecSession
MarkovHead

Enums§

DsparkHarvest
Draft-row harvest convention for DFlash-family block drafters (darklanes research/deepseek-flash-20260818/DSPARK-POSTMORTEM-20260820.md).
DsparkVtPolicy
Verify-window policy for the dspark round (H4, DSPARK-POSTMORTEM-20260820.md §3).

Functions§

dspark_accept_prefix
Accepted-prefix length of a round’s candidates against the trunk’s verify argmaxes: cand[0] = the round anchor (already decided), cand[1..] = the drafts; vam[j] = the trunk’s argmax prediction for position anchor+j+1. Returns m = number of accepted drafts (cand[1..=m] committed, vam[m] becomes the next anchor). Pure so the harvest-alignment fixture can exercise it CPU-side.
dspark_confidence_vt
H4 window sizing (the sglang-planner/vLLM-#47808 mechanism, thresholded): raws[k] = the accept-rate head’s PRE-sigmoid score for draft slot k+1; survival S_k = prod_{j<=k} sigmoid(raws[j]); the window keeps leading slots while S_k >= tau. Returns vt = 1 (anchor) + kept drafts, clamped to [2, vt_cap]: the draft forward is already paid, so at least one draft rides every verify — one extra verify row costs less than a guaranteed empty round. Pure, so the policy’s knee is testable CPU-side like dspark_accept_prefix.
dspark_slot_confidence_vt
Owner-directive arm (2026-08-20, “take only high confidence offers”): keep the longest draft PREFIX whose EVERY slot clears tau on its own sigmoid — truncate at the first sub-threshold slot, so the low-confidence tail (B2 measured 0.2–0.5 slot rates at depth) never enters verify. Prefix truncation is forced by the accept rule anyway (dspark_accept_prefix stops at the first miss — a kept slot after a dropped one could never commit); the policy fork vs dspark_confidence_vt is only the stopping statistic (per-slot marginal vs cumulative survival). Same floor/cap contract.
dspark_strategy_census
Checkpoint training-strategy census over the raw config.json text (the loader’s minimal-extractor idiom — no json dep in-tree). TRUE iff the export declares the DSPARK strategy: architectures naming a DSpark model class (Qwen3DSparkModel, the SpecForge OnlineDSparkModel export form) or dflash_config.projector_type == "dspark". z-lab / OnlineDFlashModel mask-fill exports carry neither signal. Pure, so the census is testable against config fragments without files.