-
Notifications
You must be signed in to change notification settings - Fork 170
Add DSpark algorithm page #849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
guan404ming
wants to merge
3
commits into
vllm-project:main
Choose a base branch
from
guan404ming:docs-dspark-algorithm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+83
−12
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # DSpark | ||
|
|
||
| DSpark extends [DFlash](dflash.md) with two heads on top of the same block-parallel draft backbone: a low-rank Markov head that biases each draft position by the token before it, and a confidence head that predicts per-position acceptance probability. Pure block-parallel drafting has no dependency between tokens inside a block, so acceptance decays toward the end of the block -- the Markov head restores that dependency, and the confidence signal indicates how far a block is worth verifying. The draft model subclasses DFlash, so the architecture and training pipeline are otherwise unchanged, and it can be paired with any supported verifier. Serving uses vLLM's own `dspark` method (`"method": "dspark"` in `--speculative-config`). | ||
|
|
||
| ## How It Works | ||
|
|
||
| ### Markov Head | ||
|
|
||
| The head adds a low-rank logit bias `B = W1 @ W2` to the DFlash logits: `W1` embeds the previous block token (verifier vocabulary) into `markov_rank` dimensions and `W2` projects to the draft vocabulary. Three variants are available: | ||
|
|
||
| - **`vanilla` (default)**: bias from the previous token alone | ||
| - **`gated`**: bias gated by the backbone hidden state | ||
| - **`rnn`**: recurrent state carried across positions within the block | ||
|
|
||
| Setting `--markov-rank 0` disables the head, leaving pure DFlash drafting. It must be paired with `--no-confidence-head-with-markov`, since that option requires a Markov head. | ||
|
|
||
| ### Confidence Head | ||
|
|
||
| A linear head predicts each position's acceptance probability from the backbone hidden state, concatenated with the Markov previous-token embedding when `--confidence-head-with-markov` is set. It is trained with a BCE term weighted by `--confidence-head-alpha`. | ||
|
|
||
| ### Sample From Anchor | ||
|
|
||
| DSpark defaults to `sample_from_anchor: True` -- the anchor and all mask positions predict future tokens, producing `block_size` speculative tokens. See [DFlash](dflash.md#sample-from-anchor) for details. | ||
|
|
||
| ## Key Parameters | ||
|
|
||
| | Parameter | Default | Description | | ||
| | ------------------------------- | --------- | ----------------------------------------------------------------- | | ||
| | `--markov-rank` | 256 | Low-rank dimension of the Markov logit bias (0 disables the head) | | ||
| | `--markov-head-type` | `vanilla` | Sequential head variant: `vanilla`, `gated`, or `rnn` | | ||
| | `--enable-confidence-head` | enabled | Attach the per-position acceptance head | | ||
| | `--confidence-head-with-markov` | enabled | Feed the Markov previous-token embedding into the confidence head | | ||
| | `--confidence-head-alpha` | 1.0 | Weight of the confidence-head BCE term | | ||
|
|
||
| All DFlash parameters (`--block-size`, `--max-anchors`, `--num-layers`, ...) apply unchanged. | ||
|
|
||
| ## Pretrained Models | ||
|
|
||
| Pretrained DSpark speculator models are available on HuggingFace from the [RedHatAI speculator models collection](https://huggingface.co/collections/RedHatAI/speculator-models): | ||
|
|
||
| | Verifier | Speculator | | ||
| | --------------------- | ----------------------------------------------------------------------------------------------------------------- | | ||
| | `zai-org/GLM-5.2-FP8` | [`RedHatAI/GLM-5.2-speculator.dspark-preview`](https://huggingface.co/RedHatAI/GLM-5.2-speculator.dspark-preview) | | ||
|
|
||
| To train your own, see `examples/train/dspark_qwen3_0_6b_sharegpt_online.sh`. | ||
|
|
||
| ## Research & Citation | ||
|
|
||
| DSpark is based on research from DeepSeek: [arXiv Paper](https://arxiv.org/abs/2607.05147) | ||
|
|
||
| ```bibtex | ||
| @article{cheng2026dspark, | ||
| title={DSpark: Confidence-Scheduled Speculative Decoding with Semi-Autoregressive Generation}, | ||
| author={Cheng, Xin and Yu, Xingkai and Shao, Chenze and Li, Jiashi and Xiong, Yunfan and Qian, Yi and Zhu, Jiaqi and Ma, Shirong and Zhang, Xiaokang and Ye, Jiasheng and others}, | ||
| journal={arXiv preprint arXiv:2607.05147}, | ||
| year={2026} | ||
| } | ||
| ``` | ||
|
|
||
| ## See Also | ||
|
|
||
| - [DFlash](dflash.md) -- The base algorithm DSpark extends | ||
| - [Train DFlash Tutorial](../tutorials/train_dflash_online.md) -- Step-by-step training guide; the DSpark pipeline is the same plus the flags above | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.