From 5093e4844a75f279d1921d7e34ccd23d68529f27 Mon Sep 17 00:00:00 2001 From: Zihan Zhang Date: Fri, 4 Sep 2026 13:42:01 -0700 Subject: [PATCH] [Bugfix][Spec Decode] Drop FlashAttention's AOT schedule for a sliding-window DFlash drafter (#54374) --- .../gpu/spec_decode/dflash/speculator.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/vllm/v1/worker/gpu/spec_decode/dflash/speculator.py b/vllm/v1/worker/gpu/spec_decode/dflash/speculator.py index f926bf87cc..a3e8df7924 100644 --- a/vllm/v1/worker/gpu/spec_decode/dflash/speculator.py +++ b/vllm/v1/worker/gpu/spec_decode/dflash/speculator.py @@ -15,7 +15,10 @@ from vllm.logger import init_logger from vllm.triton_utils import tl, triton from vllm.v1.attention.backend import AttentionCGSupport from vllm.v1.attention.backends.utils import PAD_SLOT_ID -from vllm.v1.kv_cache_interface import KVCacheConfig +from vllm.v1.kv_cache_interface import ( + KVCacheConfig, + get_kv_cache_spec_sliding_window, +) from vllm.v1.worker.gpu.attn_utils import build_slot_mappings_by_layer from vllm.v1.worker.gpu.block_table import BlockTables from vllm.v1.worker.gpu.cp_utils import cp_local_slot @@ -178,6 +181,19 @@ class DFlashSpeculator(DraftModelSpeculator): target_attn_groups, ) + # FlashAttention's AOT split schedule is wrong for a windowed drafter, + # and `_get_sliding_window_configs` leaves it on or off depending on + # whether the target also runs FlashAttention. Decide it here instead. + for groups in self.attn_groups: + for group in groups: + builder = group.get_metadata_builder() + if getattr( + builder, "aot_schedule", False + ) and get_kv_cache_spec_sliding_window(builder.kv_cache_spec): + # `aot_schedule` belongs to FlashAttention's builder, not + # to the base class this loop is typed against. + builder.aot_schedule = False # type: ignore[attr-defined] + self.draft_kv_cache_group_ids = [ gid for gid, g in enumerate(self.attn_groups) if g ]