From c5af1aba6b794475319e480ed6723ac0cfa4f6e6 Mon Sep 17 00:00:00 2001 From: biondizzle Date: Sun, 17 May 2026 14:59:45 +0000 Subject: [PATCH] Fix OOB: size padded buffers for num_experts*max_chunks*128 padded_max_slots was computed from max_tokens*top_k (3072) but total_padded_slots in run() is num_experts*max_chunks*128 (6144). The buffer was too small, causing index out of bounds. --- vllm/nvfp4_cutedsl.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/vllm/nvfp4_cutedsl.py b/vllm/nvfp4_cutedsl.py index 3d73cad5..e39cf8d4 100644 --- a/vllm/nvfp4_cutedsl.py +++ b/vllm/nvfp4_cutedsl.py @@ -138,10 +138,9 @@ class CuTeDSLMoERunner: self.max_num_tokens * self.top_k, device=self.device ) - # Padded hidden/activated: per-layer, sized for max capture budget - # NOT sized for max_num_tokens (8192) which would be too much for 60 layers - max_slots = self.max_num_tokens * self.top_k - padded_max_slots = ((max_slots + 127) // 128) * 128 + # Padded hidden/activated: sized for num_experts * max_chunks * 128 (the actual padded size) + max_rows_per_expert = self._max_chunks_per_expert * 128 + padded_max_slots = self.num_experts * max_rows_per_expert self._padded_hidden_buf = torch.zeros( padded_max_slots, self.hidden_size, dtype=torch.bfloat16, device=self.device )