From 6d917540ae2f492156646f3f7dd3c205ecf074a2 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Wed, 22 Oct 2025 10:42:43 +0800 Subject: [PATCH] CUDA: fix bug in topk-moe softmax --- ggml/src/ggml-cuda/topk-moe.cu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ggml/src/ggml-cuda/topk-moe.cu b/ggml/src/ggml-cuda/topk-moe.cu index d782ad948d254..e28c810ac5df7 100644 --- a/ggml/src/ggml-cuda/topk-moe.cu +++ b/ggml/src/ggml-cuda/topk-moe.cu @@ -141,7 +141,7 @@ __launch_bounds__(4 * WARP_SIZE, 1) __global__ void topk_moe_cuda(const float * wt_sum = warp_reduce_sum(wt_sum); const float inv_sum = 1.0f / wt_sum; - for (int i = threadIdx.x; i < n_expert_used; i += WARP_SIZE) { + for (int i = 0; i < experts_per_thread; i++) { output_weights[i] *= inv_sum; } }