[Worker] Index the persistent per-request-slot block table under PP
Under pipeline parallelism the Mamba/GDN state-copy path indexed a block-table row gathered for a different step. The align post-process now indexes the persistent per-request-slot table, and fails closed when it is absent. Co-Authored-By: Hinata <hinata@idihore.id> Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
@@ -694,6 +694,10 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
cp_rank=self.dcp_rank,
|
||||
cp_interleave=self.cp_interleave,
|
||||
)
|
||||
# Mamba "align" indexes a block table from the PP-deferred post-process,
|
||||
# which runs pp_size steps after the gather that produced its
|
||||
# idx_mapping; give the model state the persistent per-req-slot tables.
|
||||
self.model_state.set_block_tables(self.block_tables)
|
||||
self.pcp_manager = pcp.maybe_build_pcp_manager(
|
||||
self.vllm_config,
|
||||
self.device,
|
||||
|
||||
@@ -126,6 +126,14 @@ class ModelState(ABC):
|
||||
def apply_staged_writes(self) -> None:
|
||||
return None
|
||||
|
||||
def set_block_tables(self, block_tables: Any) -> None:
|
||||
"""Register the runner's `BlockTables` once it exists.
|
||||
|
||||
Model states that index a block table outside the step that gathered it
|
||||
(mamba "align" + the PP-deferred post-process) need the persistent
|
||||
per-req-slot tables, not the batch-order gather. No-op by default."""
|
||||
return None
|
||||
|
||||
def get_additional_cg_support(self) -> tuple[AttentionCGSupport, str | None]:
|
||||
"""Cudagraph support of attention groups this ModelState builds outside
|
||||
``init_attn_backend`` (e.g. encoder-only layers).
|
||||
|
||||
@@ -90,6 +90,9 @@ class MambaHybridModelState(DefaultModelState):
|
||||
# kernel reusing the postprocess copy machinery, so the per-step src
|
||||
# columns and the running state_idx are kept GPU-resident.
|
||||
self._align_mode = self.cache_config.mamba_cache_mode == "align"
|
||||
# Set by the runner via `set_block_tables`; the align post-process needs
|
||||
# the persistent per-req-slot tables, not the per-step gather.
|
||||
self._runner_block_tables: Any = None
|
||||
self.recoverssm = (
|
||||
RecoverSSMState() if self.cache_config.use_recoverssm else None
|
||||
)
|
||||
@@ -108,6 +111,9 @@ class MambaHybridModelState(DefaultModelState):
|
||||
self._mamba_spec: MambaSpec | None = None
|
||||
self._mamba_state_copy_funcs: MambaStateCopyFuncsByType | None = None
|
||||
|
||||
def set_block_tables(self, block_tables: Any) -> None:
|
||||
self._runner_block_tables = block_tables
|
||||
|
||||
def add_request(self, req_index: int, new_req_data: NewRequestData) -> None:
|
||||
super().add_request(req_index, new_req_data)
|
||||
# Must reset the speculative acceptance count in this idx which could be stale.
|
||||
@@ -168,11 +174,24 @@ class MambaHybridModelState(DefaultModelState):
|
||||
# block_tables are batch-order slices of the persistent
|
||||
# input_block_tables (stable data_ptr), so the metadata is captured
|
||||
# once here and reused across steps.
|
||||
#
|
||||
# Also hand over the per-req-slot tables the gather reads from
|
||||
# (block_table.py:53-59). The align post-process can run pp_size
|
||||
# steps after the gather that produced its idx_mapping, at which
|
||||
# point the batch-order buffer belongs to another micro-batch; it
|
||||
# indexes these by req slot instead.
|
||||
persistent_block_tables = None
|
||||
if self._runner_block_tables is not None:
|
||||
persistent_block_tables = [
|
||||
self._runner_block_tables.block_tables[gid].gpu
|
||||
for gid in mamba_group_ids
|
||||
]
|
||||
ctx.initialize_from_forward_context(
|
||||
kv_cache_config,
|
||||
forward_context,
|
||||
copy_funcs,
|
||||
[block_tables[gid] for gid in mamba_group_ids],
|
||||
persistent_block_tables=persistent_block_tables,
|
||||
)
|
||||
return ctx
|
||||
|
||||
|
||||
Reference in New Issue
Block a user