diff --git a/python/sglang/kernels/ops/speculative/topk1.py b/python/sglang/kernels/ops/speculative/topk1.py index a63a25617..93f658f2a 100644 --- a/python/sglang/kernels/ops/speculative/topk1.py +++ b/python/sglang/kernels/ops/speculative/topk1.py @@ -27,6 +27,8 @@ def _draft_topk1_partial_argmax_kernel( mask=mask, other=-float("inf"), ).to(tl.float32) + # Keep NaNs on valid lanes from selecting the masked tail. + vals = tl.where(vals == vals, vals, -1e30) max_val = tl.max(vals, axis=0) local_index = tl.argmax(vals, axis=0)