[Bugfix][Spec Decode] Reserve the bonus KV slot for fill-in DSpark (#59105)

Signed-off-by: Evgeny Savinov <notime.sea@gmail.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Tomas Ruiz <tomas.ruiz.te@gmail.com>
This commit is contained in:
Evgeny Savinov
2026-10-05 17:35:51 +00:00
committed by GitHub
co-authored by Codex Tomas Ruiz
parent 182247257f
commit 877ddcc456
2 changed files with 31 additions and 19 deletions
+7 -5
View File
@@ -640,13 +640,15 @@ class VllmConfig:
speculative_config = self.speculative_config
if speculative_config is None:
return 0
if speculative_config.use_dflash():
# DFlash requires an extra lookahead slot since it uses in-fill-style
# decoding instead of standard next-token sampling, so it has a query
# for the last sampled token plus queries for each draft token.
dspark_fill_in = speculative_config.use_dspark() and not getattr(
speculative_config.draft_model_config.hf_config, "sample_from_anchor", True
)
if speculative_config.use_dflash() or dspark_fill_in:
# Fill-in drafting uses a bonus query plus one query per draft token.
# DSpark's anchor-sampling layout does not need the extra slot.
return self.num_speculative_tokens + 1
if speculative_config.use_eagle() or speculative_config.uses_draft_model():
# DSpark (covered by use_eagle) drafts a block of num_speculative_tokens
# Anchor-sampling DSpark drafts a block of num_speculative_tokens
# query tokens in which the anchor itself is the first prediction
# position (no separate bonus query), so it needs exactly
# num_speculative_tokens lookahead slots.