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
d01b9214
Unverified
Commit
d01b9214
authored
Oct 03, 2025
by
Alex Chi Z
Committed by
GitHub
Oct 03, 2025
Browse files
fix sampling_seed handling when deterministic is enabled (#11096)
Signed-off-by:
Alex Chi
<
iskyzh@gmail.com
>
parent
c70e58e8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
python/sglang/srt/sampling/sampling_params.py
python/sglang/srt/sampling/sampling_params.py
+3
-0
python/sglang/test/test_deterministic.py
python/sglang/test/test_deterministic.py
+10
-3
No files found.
python/sglang/srt/sampling/sampling_params.py
View file @
d01b9214
...
...
@@ -142,6 +142,9 @@ class SamplingParams:
f
"logit_bias must has keys in [0,
{
vocab_size
-
1
}
], got "
f
"
{
token_id
}
."
)
if
self
.
sampling_seed
is
None
:
raise
ValueError
(
"sampling_seed should not be None"
)
grammars
=
[
self
.
json_schema
,
self
.
regex
,
...
...
python/sglang/test/test_deterministic.py
View file @
d01b9214
...
...
@@ -96,12 +96,15 @@ def send_single(
"max_new_tokens"
:
args
.
max_new_tokens
,
"frequency_penalty"
:
args
.
frequency_penalty
,
"presence_penalty"
:
args
.
presence_penalty
,
"sampling_seed"
:
args
.
sampling_seed
,
},
"return_logprob"
:
args
.
return_logprob
,
"stream"
:
args
.
stream
,
}
if
args
.
sampling_seed
is
not
None
:
# sglang server cannot parse None value for sampling_seed
json_data
[
"sampling_params"
][
"sampling_seed"
]
=
args
.
sampling_seed
if
profile
:
run_profile
(
base_url
,
profile_steps
,
[
"CPU"
,
"GPU"
],
None
,
None
,
profile_by_stage
...
...
@@ -145,12 +148,14 @@ def send_mixed(args, batch_size: int):
"max_new_tokens"
:
args
.
max_new_tokens
,
"frequency_penalty"
:
args
.
frequency_penalty
,
"presence_penalty"
:
args
.
presence_penalty
,
"sampling_seed"
:
args
.
sampling_seed
,
},
"return_logprob"
:
args
.
return_logprob
,
"stream"
:
args
.
stream
,
}
if
args
.
sampling_seed
is
not
None
:
json_data
[
"sampling_params"
][
"sampling_seed"
]
=
args
.
sampling_seed
response
=
requests
.
post
(
f
"http://
{
args
.
host
}
:
{
args
.
port
}
/generate"
,
json
=
json_data
,
...
...
@@ -192,12 +197,14 @@ def send_prefix(args, batch_size: int, prompts: List[str]):
"max_new_tokens"
:
args
.
max_new_tokens
,
"frequency_penalty"
:
args
.
frequency_penalty
,
"presence_penalty"
:
args
.
presence_penalty
,
"sampling_seed"
:
args
.
sampling_seed
,
},
"return_logprob"
:
args
.
return_logprob
,
"stream"
:
args
.
stream
,
}
if
args
.
sampling_seed
is
not
None
:
json_data
[
"sampling_params"
][
"sampling_seed"
]
=
args
.
sampling_seed
response
=
requests
.
post
(
f
"http://
{
args
.
host
}
:
{
args
.
port
}
/generate"
,
json
=
json_data
,
...
...
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