[6/6][kimi-deterministic] Use deterministic seeded coins for EAGLE rejection sampling (#30822)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user