[Spec Decode] Support hybrid (SWA + full attention) DFlash drafters (#47914)

Signed-off-by: mgoin <mgoin64@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Michael Goin
2026-07-08 11:12:45 -04:00
committed by GitHub
co-authored by Claude Opus 4.8
parent 68b4a1d582
commit 0d12618e98
9 changed files with 79 additions and 30 deletions
+17
View File
@@ -542,6 +542,11 @@ class VllmConfig:
):
return True
# Mixed sliding/full DFlash drafts need multiple KV groups (V2 only);
# force V2 as for dspark, since a hybrid target otherwise defaults to V1.
if self._dflash_needs_multi_kv_group():
return True
if self.model_config is not None and self.model_config.is_diffusion:
return True
@@ -565,6 +570,18 @@ class VllmConfig:
return True
def _dflash_needs_multi_kv_group(self) -> bool:
"""Whether a DFlash draft mixes sliding-window and full attention."""
spec = self.speculative_config
if spec is None or spec.method != "dflash":
return False
draft_config = getattr(spec, "draft_model_config", None)
if draft_config is None:
return False
layer_types = getattr(draft_config.hf_config, "layer_types", None) or []
num_sliding = sum(lt == "sliding_attention" for lt in layer_types)
return 0 < num_sliding < len(layer_types)
def _is_default_v2_model_runner_model(self) -> bool:
model_config = self.model_config
if model_config is None: