fix: fallback token indices allocation with verify+rebuild
This commit is contained in:
@@ -130,6 +130,16 @@ class CuTeDSLMoERunner:
|
||||
self._token_indices = torch.arange(
|
||||
self.max_num_tokens, dtype=torch.int32
|
||||
).unsqueeze(1).expand(-1, self.top_k).contiguous().view(-1).to(self.device)
|
||||
# Verify the tensor was transferred correctly (CuTeDSL JIT can corrupt GPU state)
|
||||
_verify = self._token_indices[:8].cpu().tolist()
|
||||
if _verify != [0, 0, 1, 1, 2, 2, 3, 3]:
|
||||
# Fallback: allocate directly on GPU
|
||||
self._token_indices = torch.zeros(
|
||||
self.max_num_tokens * self.top_k, dtype=torch.int32, device=self.device
|
||||
)
|
||||
for i in range(self.max_num_tokens):
|
||||
self._token_indices[i * self.top_k] = i
|
||||
self._token_indices[i * self.top_k + 1] = i
|
||||
self._expert_id_range = torch.arange(
|
||||
self.num_experts, dtype=torch.int32
|
||||
).to(self.device)
|
||||
|
||||
Reference in New Issue
Block a user