[Bugfix][MRV2] Reserve spec-decode lookahead blocks in V2 warmup (#51438)

Signed-off-by: Rahul Chalamala <22563365+rchalamala@users.noreply.github.com>
Signed-off-by: Nick Hill <nickhill123@gmail.com>
Co-authored-by: Rahul Chalamala <22563365+rchalamala@users.noreply.github.com>
Co-authored-by: Janelle Cai <janelle.cai@modal.com>
This commit is contained in:
Nick Hill
2026-08-08 23:58:43 +00:00
committed by GitHub
co-authored by Rahul Chalamala Janelle Cai
parent 9e6be4a72b
commit d608dfabfd
4 changed files with 449 additions and 37 deletions
+27
View File
@@ -592,6 +592,33 @@ class VllmConfig:
return self.diffusion_config.canvas_length
return 0
@property
def num_lookahead_tokens(self) -> int:
"""KV slots to reserve past the tokens the target model is scheduled for.
The drafter writes KV for positions beyond the target model's query
range, so every component that reserves blocks must add this margin:
the scheduler through `allocate_slots`, and the worker warmup, which
builds its own `SchedulerOutput`s. Consumers must read this property
rather than re-deriving their own per-method lookahead, so the
scheduler and warmup cannot drift apart.
"""
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.
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
# 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.
return self.num_speculative_tokens
return 0
@property
def use_v2_model_runner(self) -> bool:
use_v2_model_runner = envs.VLLM_USE_V2_MODEL_RUNNER