Skip to content

[Spec] DFlash2: local convolution + candidate selector - #35371

Merged
hnyls2002 merged 5 commits into
sgl-project:mainfrom
z-lab:subsir/dflash2-selector-conv
Aug 19, 2026
Merged

hnyls2002 merged 5 commits into
sgl-project:mainfrom
z-lab:subsir/dflash2-selector-conv

Conversation

@SubSir

@SubSir SubSir commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Two additions to the DFlash draft, both switched on by the checkpoint. A DFlash
checkpoint declares neither and takes the path it always took.

Grouped dynamic depthwise convolution inside each block, so a proposal
position can see the ones before it without another backbone pass.
out[i,c] = Σ_t (base[t,c] + δ[i,t,g(c)]) · x[i−t,c], taps zero across the block
boundary. Wraps each sublayer in and out from one projection of its input.
On when conv_kernel_size and conv_group_size are set.

Candidate selector. Instead of an independent argmax per slot, keep the
target head's top-K per slot, score adjacent transitions
edge(p→c) = ⟨A[p] ⊙ project(h), B[c]⟩ + unary[c], and walk the best path from
the verified anchor. At T>0 it walks by inverse CDF and returns q over the K
candidates for the lossless verify. On when selector_rank and
selector_top_k are set.

Modifications

srt/models/dflash.py                 the convolution, the selector, the walk kernel
srt/speculative/dflash_utils.py      four config fields
srt/speculative/dflash_worker_v2.py  the proposal and the T>0 verify

The selector's decode is folded into the draft CUDA graph, greedy and sampled
alike. The walk is one Triton program per request: a slot's K scores stay in
registers, greedy rows take the argmax and emit a one-hot q, and the slot-to-slot
dependency is a loop inside the program rather than a kernel per slot. No new
server args, no new env vars, nothing outside DFlash touched.

Accuracy Tests

python -m pytest test/registered/unit/spec/test_dflash_logits.py
python -m pytest test/registered/unit/model_executor/model_runner_components/test_spec_aux_hidden_state.py

4 passed and 5 passed. test_dflash_logits.py covers the selector's sampled path end to end,
the mixed greedy/sampling batch — each row identical to running it alone, with
greedy rows asserted to carry a one-hot q — and the rejection of a quantized
target LM head.

Lossless decoding is the property that matters here and it is structural: greedy
walks emit the point mass at the token they take, and sampled walks return the
realized q over the K candidates, so the verify sees the proposal distribution it
actually drew from.

Speed Tests and Profiling

Published evaluation for
z-lab/Qwen3.8-27B-DFlash2
on Qwen/Qwen3.8-27B: SGLang on one H200 with FlashAttention 3, block size 8
(seven draft tokens per verification step), Qwen3.8's recommended sampling
(temperature 1.0, top-p 0.95, top-k 20) at xhigh reasoning effort, 4096 max new
tokens, prompts formatted by z-lab/dflash.
Compared against the target's built-in MTP and a community DSpark drafter,
RadixArk/Qwen3.8-27B-DSpark,
both also proposing seven tokens per step.

Acceptance length

Per-request mean of completion tokens over verification steps.

Dataset MTP DSpark DFlash 2
GSM8K 5.02 4.36 5.46
MATH-500 4.72 3.92 5.28
HumanEval 3.91 3.30 4.39
MBPP 3.99 3.51 4.79
MT-Bench 3.74 3.01 4.10

Throughput, GSM8K

Output tokens over end-to-end wall time, with speedup over autoregressive
decoding.

conc autoregressive MTP DSpark DFlash 2
1 68.9 178.5 (2.59×) 185.3 (2.69×) 236.1 (3.43×)
8 467.2 1,022.1 (2.19×) 1,040.8 (2.23×) 1,328.7 (2.84×)
32 1,329.8 1,381.1 (1.04×) 1,506.5 (1.13×) 1,922.5 (1.45×)

Full tables for the other four datasets, and for
z-lab/Muse-Glimmer-30B-DFlash2
against Meta's published DFlash assistant, are on the model cards.

What it costs

The convolution and the selector are the whole difference between a DFlash draft
and a DFlash 2 draft, so their cost is what a step loses by having them. Measured
against Meta's published DFlash assistant on the same target,
meta-models/Muse-Glimmer-30B,
block 16, GSM8K, four H200 shards. cost is (1 + accept gain) / (1 + throughput gain) - 1 — the throughput gain the extra acceptance would have produced had the
step stayed the same length, against the gain it actually produced.

conc acceptance throughput cost acceptance throughput cost
T=0 T=1
1 +13.6% +11.7% 1.7% +24.4% +21.1% 2.7%
8 +14.0% +11.4% 2.3% +24.5% +21.5% 2.5%
32 +14.1% +11.9% 2.0% +24.0% +21.2% 2.3%
64 +14.0% +12.3% 1.5% +24.3% +22.2% 1.7%

So 1.5–2.7%, and it falls as the batch grows: the target verify grows with the
batch while the selector's work does not keep pace. It falls as the target grows
for the same reason.

Acceptance enters this table only as a ratio between the two drafts, both
measured the same way — as total accepted tokens over total verification steps,
where the model card reports a mean over per-request ratios. The two statistics
differ on absolute values but nearly cancel in the gain: +24.3% here at
concurrency 64 against the card's +21.0% for the same pair of checkpoints.

Checklist


CI States

Latest PR Test (Base): ⏳ Run #32199057265
Latest PR Test (Extra): ⏳ Run #32199057143

Two additions to the DFlash draft, both switched on by the checkpoint. A DFlash
checkpoint declares neither and takes the path it always took.

Grouped dynamic depthwise convolution inside each block, so a proposal position
can see the ones before it without another backbone pass:
out[i,c] = sum_t (base[t,c] + delta[i,t,g(c)]) * x[i-t,c], taps zero across the
block boundary. Each sublayer is wrapped in and out from one projection of its
input. On when conv_kernel_size and conv_group_size are set.

Candidate selector. Instead of an independent argmax per slot, keep the target
head's top-K per slot, score adjacent transitions
edge(p->c) = <A[p] * project(h), B[c]> + unary[c], and walk the best path from
the verified anchor. At T>0 it walks by inverse CDF and returns q over the K
candidates for the lossless verify. On when selector_rank and selector_top_k
are set.

The selector's decode is folded into the draft CUDA graph, greedy and sampled
alike. The walk is one Triton program per request: a slot's K scores stay in
registers, greedy rows take the argmax and emit a one-hot q, and the
slot-to-slot dependency is a loop inside the program rather than a kernel per
slot. No new server args, no new env vars, nothing outside DFlash touched.

Co-authored-by: Jian Chen <[email protected]>
@SubSir
SubSir force-pushed the subsir/dflash2-selector-conv branch from 7a3661b to 6228c78 Compare August 18, 2026 19:46
@hnyls2002 hnyls2002 added run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci) high priority bypass-fastfail labels Aug 18, 2026

@hnyls2002 hnyls2002 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hnyls2002

hnyls2002 commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator

CI States

Latest PR Test (Base): Run #32190273768
Latest PR Test (Extra): Run #32190273531

peterstorm added a commit to peterstorm/.dotfiles that referenced this pull request Aug 19, 2026
PR sgl-project/sglang#35371 (DFlash2DraftModel + CandidateSelector +
DFlashGroupedConv) merged to SGLang main 2026-08-19T00:07:28Z
(c14312a66420b75ca9a11bf1817c4db1fa26b097). No release or nightly carries
it yet (v0.5.17 is 08-08; nightly 20260818-c0b6474b predates it), so the
pin is a build from the merge commit:

* new build-qwen38-dflash2-sglang-image.sh: SGLang's own Dockerfile,
  stage runtime, nvidia/cuda:13.0.3-cudnn-devel (matches the pinned
  image's stack), BRANCH_TYPE=remote prebuilt sgl-kernel wheels,
  post-build probe asserts DFlash2DraftModel/CandidateSelector/
  DFlashGroupedConv + reports dspark importability, prints the manifest
  digest. New tag peterstorm/sglang:qwen38-dflash2-c14312a; the pinned
  fork image and DSpark profiles are untouched (rollback preserved).
* launcher: DFLASH2_IMAGE/DFLASH2_IMAGE_DIGEST overrides + a boot-time
  capability probe: native DFlash2DraftModel registration serves the
  canonical tree as-is (no surgery copy); pre-merge images keep the
  existing isolated-copy surgery. jq is now only required on the
  surgery path.
* runbook: engine table re-targeted, new 'SGLang at the merged commit'
  section (build, expectations, status), surgery section scoped to the
  pre-merge image, watchlist item 1 marked merged.
* contract: build-script pin + probe/mount assertions.

Full from-source build, not an overlay: the pinned fork's dflash files
differ from the PR base (69-231 changed lines each), so the pinned
image's DSpark integration is not inherited (it lives in the fork;
upstream c14312a6 has its own dspark.py).
Ligator added a commit to WaxacaBytes/spark-ai-hub that referenced this pull request Aug 21, 2026
Three SGLang recipes serving Qwen3.8-27B with DFlash2, Inco AI's
second-generation block-diffusion drafter (incoai/Qwen3.8-27B-DFlash2).
DFlash2 drafts a whole block in one pass and keeps the top candidates at
every position; decoding is lossless, so only speed changes.

Measured on this Spark through the Hub interface (writing / code-edit):

  nvfp4-dflash2   30.0 / 59.1   24.6 GB
  fp8-dflash2     23.1 / 46.3   30.2 GB
  bf16-dflash2    12.0 / 27.9   55.6 GB

On identical NVFP4 weights DFlash2 beats both existing speculators --
EAGLE 26.0/31.7 and DSpark 22.7/34.7 -- a 1.7x jump on code-edit. All
three are now the fastest AA-52 entries in the hub.

Image: lmsysorg/sglang:dev-nightly-0820, not the cookbook's pinned
qwen38-27b tag. DFlash2 landed in sgl-project/sglang#35371 (2026-08-19)
and the quantized target-lm_head path in #35496 (2026-08-20); RadixArk
quantizes lm_head to NVFP4, so without #35496 that recipe refuses to boot
with "requires a dense FP16/BF16/FP32 target lm_head". The cookbook says
so in a Warning box and names this image. It is a dated, immutable
nightly tag rather than rolling `dev`, so reinstalls stay reproducible.

The cookbook cell pins --kv-cache-dtype fp8_e4m3 for all three
quantizations, but its own note says the BF16 and FP8 checkpoints carry
no fp8 KV calibration -- the KV precision row is the opt-out for exactly
them. Those two take the opt-out (fidelity is why they exist next to
NVFP4); NVFP4 keeps fp8 KV as specified.

Upstream marks every DGX Spark DFLASH2 cell "in-progress" (never
exercised on GB10), so these are the first measured GB10 numbers.

MANIFEST: weights baked into the images (no HF cache volumes), every flag
visible in docker-compose.yml, no wrapper scripts, shared port 9001. Each
was verified offline -- launched under `--network none` with DNS dead and
served a completion.

Also: benchmark_editing_column.py predates the auth layer and was getting
401s from the Hub API. It now reads the admin API key from the Hub DB, or
SAH_API_KEY.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UTm7d2yDK93M11Y4nH2PtS
chinazhangchao pushed a commit to chinazhangchao/sglang-windows that referenced this pull request Sep 15, 2026
…5371)

Co-authored-by: Jian Chen <[email protected]>
Co-authored-by: Liangsheng Yin <[email protected]>
Co-authored-by: hnyls2002 <[email protected]>
JustinTong0323 added a commit that referenced this pull request Sep 21, 2026
…for DFlash2

Both prerequisites are in the v0.5.20 release the pages now pin: the DFlash2
drafter (#35371, merged into main 2026-08-19) and the GLM-5.3-Flash
hidden-state capture (#36708, which reached main via the #36507 squash
merge). Removes the nightly-image requirement on the GLM-5.3 page and the
support-branch checkout instructions (xinyuan/glm-5.3-flash-support) on
the Flash page; keeps the still-valid notes (CUDA/NPU-only, no
DP-Attention, draft checkpoint gating/license).
cih9088 added a commit to cih9088/SpecForge that referenced this pull request Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fastfail high priority jit-kernel run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants