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
0c55cbcf
Unverified
Commit
0c55cbcf
authored
Jul 14, 2025
by
ehuaa
Committed by
GitHub
Jul 14, 2025
Browse files
[BugFix] add verify logit_bias to avoid crash because of IndexError (#7749)
parent
c46e069d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
python/sglang/srt/managers/tokenizer_manager.py
python/sglang/srt/managers/tokenizer_manager.py
+1
-1
python/sglang/srt/sampling/sampling_params.py
python/sglang/srt/sampling/sampling_params.py
+8
-1
No files found.
python/sglang/srt/managers/tokenizer_manager.py
View file @
0c55cbcf
...
@@ -604,7 +604,7 @@ class TokenizerManager:
...
@@ -604,7 +604,7 @@ class TokenizerManager:
sampling_kwargs
=
obj
.
sampling_params
sampling_kwargs
=
obj
.
sampling_params
sampling_params
=
SamplingParams
(
**
sampling_kwargs
)
sampling_params
=
SamplingParams
(
**
sampling_kwargs
)
sampling_params
.
normalize
(
self
.
tokenizer
)
sampling_params
.
normalize
(
self
.
tokenizer
)
sampling_params
.
verify
()
sampling_params
.
verify
(
self
.
model_config
.
vocab_size
)
# Build return object
# Build return object
if
isinstance
(
obj
,
GenerateReqInput
):
if
isinstance
(
obj
,
GenerateReqInput
):
...
...
python/sglang/srt/sampling/sampling_params.py
View file @
0c55cbcf
...
@@ -89,7 +89,7 @@ class SamplingParams:
...
@@ -89,7 +89,7 @@ class SamplingParams:
if
self
.
top_k
==
-
1
:
if
self
.
top_k
==
-
1
:
self
.
top_k
=
TOP_K_ALL
# whole vocabulary
self
.
top_k
=
TOP_K_ALL
# whole vocabulary
def
verify
(
self
):
def
verify
(
self
,
vocab_size
):
if
self
.
temperature
<
0.0
:
if
self
.
temperature
<
0.0
:
raise
ValueError
(
raise
ValueError
(
f
"temperature must be non-negative, got
{
self
.
temperature
}
."
f
"temperature must be non-negative, got
{
self
.
temperature
}
."
...
@@ -131,6 +131,13 @@ class SamplingParams:
...
@@ -131,6 +131,13 @@ class SamplingParams:
f
"min_new_tokens must be in [0, max_new_tokens(
{
self
.
max_new_tokens
}
)], got "
f
"min_new_tokens must be in [0, max_new_tokens(
{
self
.
max_new_tokens
}
)], got "
f
"
{
self
.
min_new_tokens
}
."
f
"
{
self
.
min_new_tokens
}
."
)
)
if
self
.
logit_bias
is
not
None
:
for
token_id
in
self
.
logit_bias
:
if
not
0
<=
int
(
token_id
)
<
vocab_size
:
raise
ValueError
(
f
"logit_bias must has keys in [0,
{
vocab_size
-
1
}
], got "
f
"
{
token_id
}
."
)
grammars
=
[
grammars
=
[
self
.
json_schema
,
self
.
json_schema
,
self
.
regex
,
self
.
regex
,
...
...
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