Commit 10d4846a5 for llama.cpp
commit 10d4846a572aebf21c0482d140b00e74c0f1ad20
Author: Zheyuan Chen <sephirotheca17@gmail.com>
Date: Thu Nov 5 04:50:16 2026 -0800
ggml-cuda: sanitize post-bias NaNs in MoE selection (#31005)
Fixes #28370
diff --git a/ggml/src/ggml-cuda/topk-moe.cu b/ggml/src/ggml-cuda/topk-moe.cu
index a93d3a978..e99b2e84a 100644
--- a/ggml/src/ggml-cuda/topk-moe.cu
+++ b/ggml/src/ggml-cuda/topk-moe.cu
@@ -217,6 +217,9 @@ __global__ void topk_moe_cuda(const float * logits,
const int expert = i + threadIdx.x;
selection_wt[i / WARP_SIZE] =
(n_experts % WARP_SIZE == 0 || expert < n_experts) ? wt[i / WARP_SIZE] + bias[expert] : -INFINITY;
+ if (__isnanf(selection_wt[i / WARP_SIZE])) {
+ selection_wt[i / WARP_SIZE] = -FLT_MAX;
+ }
}
}