Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
a676e668
Unverified
Commit
a676e668
authored
Sep 25, 2025
by
courage17340
Committed by
GitHub
Sep 25, 2025
Browse files
[Bugfix] fix apply_temperature to avoid nan in probs (#24734)
Signed-off-by:
courage17340
<
courage17340@163.com
>
parent
c85be1f6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
vllm/v1/sample/sampler.py
vllm/v1/sample/sampler.py
+6
-1
vllm/v1/worker/gpu_input_batch.py
vllm/v1/worker/gpu_input_batch.py
+2
-2
No files found.
vllm/v1/sample/sampler.py
View file @
a676e668
...
@@ -128,8 +128,12 @@ class Sampler(nn.Module):
...
@@ -128,8 +128,12 @@ class Sampler(nn.Module):
self
,
self
,
logits
:
torch
.
Tensor
,
logits
:
torch
.
Tensor
,
temp
:
torch
.
Tensor
,
temp
:
torch
.
Tensor
,
all_random
:
bool
,
)
->
torch
.
Tensor
:
)
->
torch
.
Tensor
:
# Use in-place division to avoid creating a new tensor.
# Use in-place division to avoid creating a new tensor.
# Avoid division by zero if there are greedy requests.
if
not
all_random
:
temp
=
torch
.
where
(
temp
<
_SAMPLING_EPS
,
1.0
,
temp
)
return
logits
.
div_
(
temp
.
unsqueeze
(
dim
=
1
))
return
logits
.
div_
(
temp
.
unsqueeze
(
dim
=
1
))
def
greedy_sample
(
self
,
logits
:
torch
.
Tensor
)
->
torch
.
Tensor
:
def
greedy_sample
(
self
,
logits
:
torch
.
Tensor
)
->
torch
.
Tensor
:
...
@@ -164,7 +168,8 @@ class Sampler(nn.Module):
...
@@ -164,7 +168,8 @@ class Sampler(nn.Module):
assert
sampling_metadata
.
temperature
is
not
None
assert
sampling_metadata
.
temperature
is
not
None
# Apply temperature.
# Apply temperature.
logits
=
self
.
apply_temperature
(
logits
,
sampling_metadata
.
temperature
)
logits
=
self
.
apply_temperature
(
logits
,
sampling_metadata
.
temperature
,
sampling_metadata
.
all_random
)
# Apply logits processors that only apply to random sampling
# Apply logits processors that only apply to random sampling
# (argmax invariant)
# (argmax invariant)
...
...
vllm/v1/worker/gpu_input_batch.py
View file @
a676e668
...
@@ -354,8 +354,8 @@ class InputBatch:
...
@@ -354,8 +354,8 @@ class InputBatch:
and
is_spec_decode_unsupported
(
sampling_params
)):
and
is_spec_decode_unsupported
(
sampling_params
)):
self
.
spec_decode_unsupported_reqs
.
add
(
req_id
)
self
.
spec_decode_unsupported_reqs
.
add
(
req_id
)
if
sampling_params
.
sampling_type
==
SamplingType
.
GREEDY
:
if
sampling_params
.
sampling_type
==
SamplingType
.
GREEDY
:
#
Avoid later
division by zero.
#
Should avoid
division by zero
later when apply_temperature
.
self
.
temperature_cpu
[
req_index
]
=
-
1
.0
self
.
temperature_cpu
[
req_index
]
=
0
.0
self
.
greedy_reqs
.
add
(
req_id
)
self
.
greedy_reqs
.
add
(
req_id
)
else
:
else
:
self
.
temperature_cpu
[
req_index
]
=
sampling_params
.
temperature
self
.
temperature_cpu
[
req_index
]
=
sampling_params
.
temperature
...
...
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