[6/6][kimi-deterministic] Use deterministic seeded coins for EAGLE rejection sampling (#30822)

This commit is contained in:
Yuzhen Zhou
2026-07-24 02:11:21 -07:00
committed by GitHub
parent 3849beb7e3
commit b954e9cf3d
19 changed files with 562 additions and 23 deletions
+15
View File
@@ -186,6 +186,21 @@ class Sampler(nn.Module):
# Standard path: do softmax and sample from probs.
logits.div_(sampling_info.temperatures)
# Deterministic inference must derive the returned logprobs
# from F.log_softmax — the same kernel prefill rescoring uses —
# not log(softmax(x)) below: the two disagree at ~1e-6 despite
# being mathematically equivalent, which breaks bitwise
# prefill/decode logprob alignment.
if (
return_logprob
and self.enable_deterministic
and logprobs_via_logsoftmax_kernel is None
and not SGLANG_RETURN_ORIGINAL_LOGPROB
):
logprobs_via_logsoftmax_kernel = torch.nn.functional.log_softmax(
logits, dim=-1
)
# In-place op to save memory
logits[:] = torch.softmax(logits, dim=-1)
probs = logits