[Model Runner V2] support mamba hybrid models align prefix cache (#42406)

Signed-off-by: zhuhaoran <zhuhaoran.zhr@alibaba-inc.com>
This commit is contained in:
zhrrr
2026-06-29 14:09:16 -07:00
committed by GitHub
parent a309d4fe60
commit 61ab70ec3b
9 changed files with 1046 additions and 133 deletions
+13 -1
View File
@@ -1111,7 +1111,9 @@ class GPUModelRunner(LoRAModelRunnerMixin):
self.req_states.total_len.gpu,
)
self.model_state.postprocess_state(idx_mapping, num_sampled)
self.model_state.postprocess_state(
idx_mapping, num_sampled, self.req_states.num_computed_tokens.gpu
)
@torch.inference_mode()
def execute_model(
@@ -1176,6 +1178,16 @@ class GPUModelRunner(LoRAModelRunnerMixin):
# Prepare all the inputs and copy to the input buffers.
input_batch = self.prepare_inputs(scheduler_output, batch_desc)
block_tables, slot_mappings = self.prepare_attn(input_batch)
# Mamba "align" pre-copy: migrate recurrent state across block
# boundaries before the forward. Runs only on real batches, and
# before model_state.prepare_attn gathers num_accepted_tokens so the
# boundary reset is visible to the attention metadata.
self.model_state.preprocess_state(
input_batch,
block_tables,
self.kv_cache_config,
self.req_states.num_computed_tokens.gpu,
)
if self.lora_config:
# Activate LoRA adapters.