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
8b664706
Unverified
Commit
8b664706
authored
Apr 03, 2025
by
youkaichao
Committed by
GitHub
Apr 03, 2025
Browse files
[bugfix] add seed in torchrun_example.py (#15980)
Signed-off-by:
youkaichao
<
youkaichao@gmail.com
>
parent
37bfee92
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
0 deletions
+10
-0
examples/offline_inference/torchrun_example.py
examples/offline_inference/torchrun_example.py
+4
-0
vllm/config.py
vllm/config.py
+6
-0
No files found.
examples/offline_inference/torchrun_example.py
View file @
8b664706
...
...
@@ -23,10 +23,14 @@ sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
# Use `distributed_executor_backend="external_launcher"` so that
# this llm engine/instance only creates one worker.
# it is important to set an explicit seed to make sure that
# all ranks have the same random seed, so that sampling can be
# deterministic across ranks.
llm
=
LLM
(
model
=
"facebook/opt-125m"
,
tensor_parallel_size
=
2
,
distributed_executor_backend
=
"external_launcher"
,
seed
=
0
,
)
outputs
=
llm
.
generate
(
prompts
,
sampling_params
)
...
...
vllm/config.py
View file @
8b664706
...
...
@@ -761,6 +761,12 @@ class ModelConfig:
self
,
parallel_config
:
"ParallelConfig"
,
)
->
None
:
if
parallel_config
.
distributed_executor_backend
==
"external_launcher"
:
assert
self
.
seed
is
not
None
,
(
"Seed must be set when using external launcher backend to "
"make sure sampling results are the same across workers."
)
total_num_attention_heads
=
getattr
(
self
.
hf_text_config
,
"num_attention_heads"
,
0
)
tensor_parallel_size
=
parallel_config
.
tensor_parallel_size
...
...
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