Skip to content

Support loading sample_from_anchor flag from speculators config - #48639

Merged
vllm-bot merged 5 commits into
vllm-project:mainfrom
fynnsu:speculators_dspark_config
Jul 20, 2026
Merged

vllm-bot merged 5 commits into
vllm-project:mainfrom
fynnsu:speculators_dspark_config

Conversation

@fynnsu

@fynnsu fynnsu commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Add support for loading the sample_from_anchor flag from speculators configs (added in vllm-project/speculators#760). This flag is used for dflash/dspark models to indicate if the anchor slot in each prediction block generates a draft prediction or predicts itself. Support for the flag already exists in vllm, this pr just adds support for loading from speculators config.

Test Plan

Test Result


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@fynnsu fynnsu changed the title Speculators dspark config Support loading sample_from_anchor flag from speculators config Jul 14, 2026
@mergify mergify Bot added the v1 label Jul 14, 2026
fynnsu added 2 commits July 14, 2026 17:00
Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
@fynnsu
fynnsu force-pushed the speculators_dspark_config branch from 44fc868 to 8daf9da Compare July 14, 2026 17:00
Comment on lines +45 to +60
dflash_config = (
getattr(self.draft_model_config.hf_config, "dflash_config", None) or {}
)
self.sample_from_anchor = dflash_config.get("sample_from_anchor", False)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We still set num_query_per_req = 1 + N so this isn't actually doing anything for dflash. If we want to add that support for dflash in vllm, we should probably do that separately and actually test e2e. Not sure if it would "just work" with adjusting num_query_per_req. We should probably just fail dflash if sample_from_anchor=True for now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call — reverted to self.sample_from_anchor = False (hardcoded) and added a ValueError if the config sets sample_from_anchor=True. We'll add proper dflash support for it separately with e2e testing.

Comment on lines +153 to +160
- sample_from_anchor: Whether to sample from the anchor position. Default
True (sample from anchor and all mask positions, yielding block_size
speculative tokens).
"""
pre_trained_config["architectures"] = ["Qwen3DSparkModel"]
# Speculators DSpark uses the 1+N fill-in block (anchor is a bonus token).
pre_trained_config["dspark_bonus_anchor"] = True
pre_trained_config["sample_from_anchor"] = config_dict.get(
"sample_from_anchor", True
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For speculators we should actually default to False, since the checkpoints made before sample_from_anchor existed use the bonus token

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed — changed the default to False for both dflash and dspark speculators configs so pre-existing checkpoints (without sample_from_anchor) use the bonus token layout.

- Default sample_from_anchor to False for both dflash and dspark
  speculators configs, since pre-existing checkpoints use the bonus
  token layout.
- Raise ValueError in DFlash if sample_from_anchor=True, since dflash
  hardcodes num_query_per_req=1+N and does not support anchor sampling.

Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
@mgoin mgoin added speculative-decoding ready ONLY add when PR is ready to merge/full CI is needed labels Jul 16, 2026
@mergify

mergify Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Hi @fynnsu, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
@vllm-bot
vllm-bot merged commit 642076d into vllm-project:main Jul 20, 2026
5 checks passed
ArjunPakhan pushed a commit to ArjunPakhan/vllm that referenced this pull request Jul 21, 2026
…-project#48639)

Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
Co-authored-by: Michael Goin <mgoin64@gmail.com>
realliujiaxu pushed a commit to vllm-project/vllm-ascend that referenced this pull request Aug 17, 2026
### What this PR does / why we need it?
The following PRs are not cherry-picked to vllm v0.26.0 branch, so
patches should be added on vllm-ascend releases/v0.26.0rc branch, if we
want to use some kinds of DSpark (e.g.
https://huggingface.co/RedHatAI/GLM-5.2-speculator.dspark).
- vllm-project/vllm#48524: solving fc shape
error when num_target_layers != num_hidden_layers
- vllm-project/vllm#48776: solving KV Cache
planning when target model is sparse-MLA and draft model is SWA
- vllm-project/vllm#48639: solving
`sample_from_anchor` wrongly loaded

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
- GLM-5.2 W4A8 + DSpark acceptance rate
```
INFO 08-14 15:40:22 [metrics.py:120] SpecDecoding metrics: Mean acceptance length: 2.82, Accepted throughput: 73.39 tokens/s, Drafted throughput: 282.88 tokens/s, Accepted: 790 tokens, Drafted: 3045 tokens, Per-position acceptance rate: 0.729, 0.457, 0.278, 0.161, 0.083, 0.064, 0.044, Avg Draft acceptance rate: 25.9%
INFO 08-14 15:40:32 [metrics.py:120] SpecDecoding metrics: Mean acceptance length: 4.38, Accepted throughput: 146.65 tokens/s, Drafted throughput: 303.29 tokens/s, Accepted: 1469 tokens, Drafted: 3038 tokens, Per-position acceptance rate: 0.836, 0.652, 0.537, 0.408, 0.353, 0.318, 0.281, Avg Draft acceptance rate: 48.4%
INFO 08-14 15:40:42 [metrics.py:120] SpecDecoding metrics: Mean acceptance length: 3.48, Accepted throughput: 59.89 tokens/s, Drafted throughput: 169.09 tokens/s, Accepted: 600 tokens, Drafted: 1694 tokens, Per-position acceptance rate: 0.719, 0.537, 0.372, 0.273, 0.219, 0.186, 0.174, Avg Draft acceptance rate: 35.4%

```


- vLLM version: v0.26.0
- vLLM main:
vllm-project/vllm@d02df74

Signed-off-by: Wangbingjie <wangbj1207@126.com>
fanyalun pushed a commit to fanyalun/vllm that referenced this pull request Aug 27, 2026
…-project#48639)

Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
Co-authored-by: Michael Goin <mgoin64@gmail.com>
Leetrytry pushed a commit to Leetrytry/vllm-ascend that referenced this pull request Sep 11, 2026
### What this PR does / why we need it?
The following PRs are not cherry-picked to vllm v0.26.0 branch, so
patches should be added on vllm-ascend releases/v0.26.0rc branch, if we
want to use some kinds of DSpark (e.g.
https://huggingface.co/RedHatAI/GLM-5.2-speculator.dspark).
- vllm-project/vllm#48524: solving fc shape
error when num_target_layers != num_hidden_layers
- vllm-project/vllm#48776: solving KV Cache
planning when target model is sparse-MLA and draft model is SWA
- vllm-project/vllm#48639: solving
`sample_from_anchor` wrongly loaded

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
- GLM-5.2 W4A8 + DSpark acceptance rate
```
INFO 08-14 15:40:22 [metrics.py:120] SpecDecoding metrics: Mean acceptance length: 2.82, Accepted throughput: 73.39 tokens/s, Drafted throughput: 282.88 tokens/s, Accepted: 790 tokens, Drafted: 3045 tokens, Per-position acceptance rate: 0.729, 0.457, 0.278, 0.161, 0.083, 0.064, 0.044, Avg Draft acceptance rate: 25.9%
INFO 08-14 15:40:32 [metrics.py:120] SpecDecoding metrics: Mean acceptance length: 4.38, Accepted throughput: 146.65 tokens/s, Drafted throughput: 303.29 tokens/s, Accepted: 1469 tokens, Drafted: 3038 tokens, Per-position acceptance rate: 0.836, 0.652, 0.537, 0.408, 0.353, 0.318, 0.281, Avg Draft acceptance rate: 48.4%
INFO 08-14 15:40:42 [metrics.py:120] SpecDecoding metrics: Mean acceptance length: 3.48, Accepted throughput: 59.89 tokens/s, Drafted throughput: 169.09 tokens/s, Accepted: 600 tokens, Drafted: 1694 tokens, Per-position acceptance rate: 0.719, 0.537, 0.372, 0.273, 0.219, 0.186, 0.174, Avg Draft acceptance rate: 35.4%

```


- vLLM version: v0.26.0
- vLLM main:
vllm-project/vllm@d02df74

Signed-off-by: Wangbingjie <wangbj1207@126.com>
michael-gpu pushed a commit to practical-inference/vllm-ampere-extended that referenced this pull request Oct 20, 2026
…-project#48639)

Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
Co-authored-by: Michael Goin <mgoin64@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed speculative-decoding v1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants