Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
99757cc3
Unverified
Commit
99757cc3
authored
Sep 12, 2025
by
narutolhy
Committed by
GitHub
Sep 13, 2025
Browse files
fix probs name which without temp scaling name (#9984)
parent
cdddab05
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
python/sglang/srt/layers/sampler.py
python/sglang/srt/layers/sampler.py
+5
-4
No files found.
python/sglang/srt/layers/sampler.py
View file @
99757cc3
...
@@ -80,9 +80,9 @@ class Sampler(nn.Module):
...
@@ -80,9 +80,9 @@ class Sampler(nn.Module):
logprobs
=
torch
.
nn
.
functional
.
log_softmax
(
logits
,
dim
=-
1
)
logprobs
=
torch
.
nn
.
functional
.
log_softmax
(
logits
,
dim
=-
1
)
else
:
else
:
#
Post process
original logits
. if
temperature
s 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
:
if
return_logprob
and
RETURN_ORIGINAL_LOGPROB
:
log
probs
=
torch
.
softmax
(
logits
,
dim
=-
1
)
probs
_without_temp_scaling
=
torch
.
softmax
(
logits
,
dim
=-
1
)
# Post process logits
# Post process logits
logits
.
div_
(
sampling_info
.
temperatures
)
logits
.
div_
(
sampling_info
.
temperatures
)
...
@@ -123,9 +123,10 @@ class Sampler(nn.Module):
...
@@ -123,9 +123,10 @@ class Sampler(nn.Module):
if
return_logprob
:
if
return_logprob
:
# clamp to avoid -inf
# clamp to avoid -inf
if
RETURN_ORIGINAL_LOGPROB
:
if
RETURN_ORIGINAL_LOGPROB
:
logprobs
=
torch
.
log
(
log
probs
).
clamp
(
logprobs
=
torch
.
log
(
probs
_without_temp_scaling
).
clamp
(
min
=
torch
.
finfo
(
log
probs
.
dtype
).
min
min
=
torch
.
finfo
(
probs
_without_temp_scaling
.
dtype
).
min
)
)
del
probs_without_temp_scaling
else
:
else
:
logprobs
=
torch
.
log
(
probs
).
clamp
(
min
=
torch
.
finfo
(
probs
.
dtype
).
min
)
logprobs
=
torch
.
log
(
probs
).
clamp
(
min
=
torch
.
finfo
(
probs
.
dtype
).
min
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment