[Bugfix][Mamba] Store conv_kernel - 1 inputs in Mamba2 prefill checkpoints (#60797)

Signed-off-by: Sungsoo Ha <sungsooh@nvidia.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: tomeras91 <57313761+tomeras91@users.noreply.github.com>
This commit is contained in:
sungsoo ha
2026-10-13 10:09:17 +00:00
committed by GitHub
co-authored by Claude Opus 5.5 tomeras91
parent 206e45d470
commit c7a305ec10
3 changed files with 17 additions and 7 deletions
@@ -890,6 +890,7 @@ class MambaMixer2(MambaBase, PluggableLayer):
varlen_states,
ssm_state,
query_start_loc_p,
state_len=self.conv_kernel_size - 1,
)
ssm_state[state_indices_tensor_p] = final_states
if ring_start is not None and self._updates_replayssm_trackers:
@@ -69,6 +69,8 @@ def store_prefill_checkpoint(
chunk_states: torch.Tensor,
ssm_state: torch.Tensor,
query_start_loc: torch.Tensor,
*,
state_len: int,
) -> None:
"""Write each prefill row's mid-prefill checkpoint into its paged block.
@@ -78,14 +80,15 @@ def store_prefill_checkpoint(
checkpoint: Per-row offsets and destination blocks.
chunk_idx: Per-row index into ``chunk_states`` of the checkpoint.
x: Pre-conv activations, ``(dim, num_prefill_tokens)``.
conv_state: Paged conv state, ``(num_blocks, dim, state_len)``.
conv_state: Paged conv state, ``(num_blocks, dim, state_len + num_spec)``.
chunk_states: SSD states at every chunk end.
ssm_state: Paged SSM state.
query_start_loc: Prefill query start locations.
state_len: ``conv_kernel_size - 1``, not the spec-widened conv width.
Readers take the first ``state_len`` slots as the newest inputs.
"""
dim = x.size(0)
state_len = conv_state.size(-1)
ssm_row_size = chunk_states[0].numel()
block_size = 1024
grid = (