[Spec Decode] Support sample_from_anchor for DFlash draft models - #54154
Open
qianlihuang wants to merge 1 commit into
Open
qianlihuang wants to merge 1 commit into
qianlihuang wants to merge 1 commit into
Conversation
DFlash hardcoded a 1 + K query layout in which the anchor position is the bonus token and only the K mask positions predict. Checkpoints trained with sample_from_anchor=True instead use the anchor as the first prediction, so they need K query positions for the same K draft tokens. The speculator rejected those checkpoints outright. Derive the query count from the checkpoint through a single num_dflash_query_tokens property and use it at each place the layout is assumed: scheduler slot budgeting, KV lookahead, the DFlash2 convolution block size, and the speculator's per-request query count. The anchor path in the prepare-inputs kernel already exists and is exercised by DSpark; this only stops DFlash from being excluded from it. Behavior is unchanged for the default bonus-anchor layout, where the property evaluates to K + 1 and every call site reduces to its previous value. Anchor-sampling checkpoints are marked unsupported on the V1 model runner, which still assumes the fixed layout. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Yiliu Dong <91178480+qianlihuang@users.noreply.github.com>
qianlihuang
force-pushed
the
feat/dflash-sample-from-anchor
branch
from
August 28, 2026 06:49
9c3887e to
3451fb9
Compare
qianlihuang
marked this pull request as ready for review
August 28, 2026 06:59
qianlihuang
requested review from
ProExpertProg,
WoosukKwon,
houseroad,
mgoin,
njhill,
robertgshaw2-redhat,
sighingnow,
tlrmchlsmth,
vadiklyutiy,
yewentao256 and
youkaichao
as code owners
August 28, 2026 06:59
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds support for DFlash/DFlash2 draft checkpoints that set sample_from_anchor=True, ensuring the “K queries → K draft tokens” geometry is applied consistently across scheduling, KV lookahead sizing, the DFlash2 convolution block width, and the DFlash speculator’s per-request query sizing.
Changes:
- Introduces
SpeculativeConfig.dflash_samples_from_anchor()andSpeculativeConfig.num_dflash_query_tokensto centralize the DFlash query-token geometry. - Updates DFlash speculator and DFlash2 Qwen3 model code to consume
num_dflash_query_tokensrather than assuming a fixed1 + Klayout. - Adjusts KV lookahead sizing and adds an explicit V1-runner unsupported-feature gate for anchor-sampling DFlash checkpoints; extends unit tests to cover both query layouts for DFlash2 conv block sizing.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
vllm/v1/worker/gpu/spec_decode/dflash/speculator.py |
Uses config-derived DFlash query count and enables anchor-sampling checkpoints (removes prior hard rejection). |
vllm/model_executor/models/qwen3_dflash2.py |
Sets DFlash2 grouped-conv block_size to match the checkpoint’s DFlash query layout. |
vllm/config/vllm.py |
Sizes DFlash lookahead by num_dflash_query_tokens and blocks anchor-sampling DFlash on the V1 runner. |
vllm/config/speculative.py |
Adds helpers/properties to detect anchor sampling and compute DFlash query token count; updates drafting-slot budgeting logic. |
tests/v1/spec_decode/test_dflash2.py |
Parametrizes coverage to assert DFlash2 conv block sizing matches both (bonus) and (anchor) layouts. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Support DFlash/DFlash2 checkpoints with
sample_from_anchor=Trueon the V2 GPU model runner.With anchor sampling,
Kdraft tokens useKquery positions instead of the defaultK + 1. This PR applies that query geometry consistently to scheduler slots, KV lookahead, DFlash2 convolution block size, and the DFlash speculator.This complements vllm-project/speculators#1006, which added DFlash2 training and checkpoint support.
Test Plan
Also run end-to-end generation for both layouts:
Test Result
End-to-end on NVIDIA H200 with a patched stock vLLM nightly (
0.26.1rc1.dev1261+gf25c580af):Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.