[BugFix][ModelRunner V2] Fix stale attn metadata in speculator prefill cudagraph capture (#48261)
Signed-off-by: Nick Hill <nickhill123@gmail.com>
This commit is contained in:
@@ -77,7 +77,7 @@ class DFlashCudaGraphManager(CudaGraphManager):
|
||||
def create_forward_fn(
|
||||
desc: BatchExecutionDescriptor,
|
||||
warmup: bool,
|
||||
) -> tuple[Callable[[CUDAGraphMode], None], AttentionState]:
|
||||
) -> Callable[[CUDAGraphMode], None]:
|
||||
num_tokens = desc.num_tokens
|
||||
num_reqs = desc.num_reqs or min(num_tokens, self.max_num_reqs)
|
||||
num_tokens_across_dp = (
|
||||
@@ -98,7 +98,7 @@ class DFlashCudaGraphManager(CudaGraphManager):
|
||||
)
|
||||
attn_metadata, slot_mappings = attn_state
|
||||
|
||||
fwd = lambda cg_mode: forward_fn(
|
||||
return lambda cg_mode: forward_fn(
|
||||
num_reqs,
|
||||
num_tokens,
|
||||
attn_metadata,
|
||||
@@ -106,6 +106,5 @@ class DFlashCudaGraphManager(CudaGraphManager):
|
||||
num_tokens_across_dp,
|
||||
cg_mode,
|
||||
)
|
||||
return fwd, attn_state
|
||||
|
||||
super().capture(create_forward_fn, progress_bar_desc)
|
||||
|
||||
@@ -25,6 +25,7 @@ from vllm.v1.worker.gpu.spec_decode.dflash.utils import (
|
||||
)
|
||||
from vllm.v1.worker.gpu.spec_decode.speculator import DraftModelSpeculator
|
||||
from vllm.v1.worker.gpu.spec_decode.utils import get_parallel_drafting_token_id
|
||||
from vllm.v1.worker.utils import AttentionGroup
|
||||
|
||||
logger = init_logger(__name__)
|
||||
|
||||
@@ -97,7 +98,7 @@ class DFlashSpeculator(DraftModelSpeculator):
|
||||
decode_query_len=self.num_query_per_req,
|
||||
)
|
||||
|
||||
def capture(self, attn_states: dict | None = None) -> None:
|
||||
def capture(self) -> None:
|
||||
logger.info("Capturing model for %s speculator...", self._speculator_name)
|
||||
# Reset sampling indices to zero to prevent stale values from prior
|
||||
# dummy runs from being baked into the captured graph.
|
||||
@@ -128,8 +129,16 @@ class DFlashSpeculator(DraftModelSpeculator):
|
||||
model_state: ModelState,
|
||||
kv_cache_config: KVCacheConfig,
|
||||
block_tables: BlockTables,
|
||||
target_input_buffers: InputBuffers,
|
||||
target_attn_groups: list[list[AttentionGroup]],
|
||||
) -> None:
|
||||
super().set_attn(model_state, kv_cache_config, block_tables)
|
||||
super().set_attn(
|
||||
model_state,
|
||||
kv_cache_config,
|
||||
block_tables,
|
||||
target_input_buffers,
|
||||
target_attn_groups,
|
||||
)
|
||||
|
||||
self.draft_kv_cache_group_ids = [
|
||||
gid for gid, g in enumerate(self.attn_groups) if g
|
||||
|
||||
Reference in New Issue
Block a user