Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions python/sglang/srt/layers/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def forward(
logprobs = torch.nn.functional.log_softmax(logits, dim=-1)

else:
# Post process original logits. if temperatures are all 1.0, no need to rescale
# If requested, cache probabilities from original logits before temperature scaling.
if return_logprob and RETURN_ORIGINAL_LOGPROB:
logprobs = torch.softmax(logits, dim=-1)
probs_without_temp_scaling = torch.softmax(logits, dim=-1)

# Post process logits
logits.div_(sampling_info.temperatures)
Expand Down Expand Up @@ -123,8 +123,8 @@ def forward(
if return_logprob:
# clamp to avoid -inf
if RETURN_ORIGINAL_LOGPROB:
logprobs = torch.log(logprobs).clamp(
min=torch.finfo(logprobs.dtype).min
logprobs = torch.log(probs_without_temp_scaling).clamp(
min=torch.finfo(probs_without_temp_scaling.dtype).min
)
Comment thread
narutolhy marked this conversation as resolved.
Resolved
else:
logprobs = torch.log(probs).clamp(min=torch.finfo(probs.dtype).min)
Expand Down