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
28b0a62b
Unverified
Commit
28b0a62b
authored
Feb 02, 2025
by
zifeitong
Committed by
GitHub
Feb 02, 2025
Browse files
Bug: Fix min_p sampling crash when using flashinfer backend (#3207)
Co-authored-by:
zhaochenyang20
<
zhaochen20@outlook.com
>
parent
566d61d9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
python/sglang/srt/layers/sampler.py
python/sglang/srt/layers/sampler.py
+4
-4
No files found.
python/sglang/srt/layers/sampler.py
View file @
28b0a62b
...
@@ -85,7 +85,7 @@ class Sampler(nn.Module):
...
@@ -85,7 +85,7 @@ class Sampler(nn.Module):
if
sampling_info
.
need_min_p_sampling
:
if
sampling_info
.
need_min_p_sampling
:
probs
=
top_k_renorm_prob
(
probs
,
sampling_info
.
top_ks
)
probs
=
top_k_renorm_prob
(
probs
,
sampling_info
.
top_ks
)
probs
=
top_p_renorm_prob
(
probs
,
sampling_info
.
top_ps
)
probs
=
top_p_renorm_prob
(
probs
,
sampling_info
.
top_ps
)
batch_next_token_ids
,
success
=
min_p_sampling_from_probs
(
batch_next_token_ids
=
min_p_sampling_from_probs
(
probs
,
uniform_samples
,
sampling_info
.
min_ps
probs
,
uniform_samples
,
sampling_info
.
min_ps
)
)
else
:
else
:
...
@@ -97,9 +97,9 @@ class Sampler(nn.Module):
...
@@ -97,9 +97,9 @@ class Sampler(nn.Module):
filter_apply_order
=
"joint"
,
filter_apply_order
=
"joint"
,
)
)
if
self
.
use_nan_detectioin
and
not
torch
.
all
(
success
):
if
self
.
use_nan_detectioin
and
not
torch
.
all
(
success
):
logger
.
warning
(
"Detected errors during sampling!"
)
logger
.
warning
(
"Detected errors during sampling!"
)
batch_next_token_ids
=
torch
.
zeros_like
(
batch_next_token_ids
)
batch_next_token_ids
=
torch
.
zeros_like
(
batch_next_token_ids
)
elif
global_server_args_dict
[
"sampling_backend"
]
==
"pytorch"
:
elif
global_server_args_dict
[
"sampling_backend"
]
==
"pytorch"
:
# A slower fallback implementation with torch native operations.
# A slower fallback implementation with torch native operations.
...
...
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