debug: clone + sync token indices before JIT

This commit is contained in:
2026-05-17 08:22:11 +00:00
parent 70c0618361
commit 0e7b06b55c

View File

@@ -111,10 +111,13 @@ class CuTeDSLMoERunner:
# Allocate token indices FIRST, before any CUDA JIT compilation
# (CuTeDSL's cute.compile can corrupt GPU memory state during JIT)
# Use .clone() to ensure a fresh allocation and cuda.synchronize() to
# ensure the kernel completes before any JIT compilation starts
if self._token_indices is None:
self._token_indices = torch.arange(
self.max_num_tokens, device=self.device, dtype=torch.int32
).unsqueeze(1).expand(-1, self.top_k).contiguous().view(-1)
).unsqueeze(1).expand(-1, self.top_k).contiguous().view(-1).clone()
torch.cuda.synchronize()
if self._expert_id_range is None:
self._expert_id_range = torch.arange(self.num_experts, device=self.device)
if self._expert_offsets_buf is None: