[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
+16 -1
View File
@@ -95,8 +95,23 @@ class ModelState(ABC):
def apply_staged_writes(self) -> None:
return None
def preprocess_state(
self,
input_batch: InputBatch,
block_tables: tuple[torch.Tensor, ...],
kv_cache_config: KVCacheConfig,
num_computed_tokens: torch.Tensor,
) -> None:
"""Hook run on real batches before the forward pass (after block tables
are gathered). Used by mamba "align" prefix caching to pre-copy state
across block boundaries. No-op by default."""
return None
def postprocess_state(
self, idx_mapping: torch.Tensor, num_sampled: torch.Tensor
self,
idx_mapping: torch.Tensor,
num_sampled: torch.Tensor,
num_computed_tokens: torch.Tensor | None = None,
) -> None:
return None