[Unified Memory] Fix Inkling conv-checkpoint track ids written to virtual slot numbers (#41144)

This commit is contained in:
Shuwen Wang
2026-09-28 05:19:19 -07:00
committed by GitHub
parent bddeb61d94
commit da3eb6db32
2 changed files with 47 additions and 1 deletions
@@ -155,6 +155,8 @@ class InklingShortConvAttnBackend(ShortConvAttnBackend):
self._graph_track_inert_seqlens = torch.zeros(
max_bs, dtype=torch.int64, device=dev
)
# Graph-static: captured track scatters read this address.
self._track_indices_buf = torch.zeros(max_bs, dtype=torch.int64, device=dev)
# Same address-stability requirement; the base only sizes this from
# init_cuda_graph_state, which the prefill graph never calls.
self._alloc_cache_indices_buf(max_bs)
@@ -269,6 +271,22 @@ class InklingShortConvAttnBackend(ShortConvAttnBackend):
return
self.forward_metadata = self._forward_metadata(forward_batch)
self._refresh_cache_indices()
if not self._slot_gather_recordable:
self._translate_track_indices(forward_batch)
def _translate_track_indices(self, forward_batch: ForwardBatch):
"""Translate virtual track ids to the physical slots the conv kernels write."""
track_indices = forward_batch.mamba_track_indices
buf = self._track_indices_buf
# Prep may re-run on the same batch; never translate twice.
if track_indices is None or track_indices.data_ptr() == buf.data_ptr():
return
n = track_indices.shape[0]
assert n <= buf.shape[0], (
f"track-index buffer too small: rows={n} vs bound {buf.shape[0]}"
)
buf[:n].copy_(self._translate_mamba_indices(track_indices))
forward_batch.mamba_track_indices = buf[:n]
def _refresh_sconv_metadata(
self, forward_batch: ForwardBatch, *, on_graph_path: bool