File tree 2 files changed +10
-0
lines changed
examples/offline_inference 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change 23
23
24
24
# Use `distributed_executor_backend="external_launcher"` so that
25
25
# this llm engine/instance only creates one worker.
26
+ # it is important to set an explicit seed to make sure that
27
+ # all ranks have the same random seed, so that sampling can be
28
+ # deterministic across ranks.
26
29
llm = LLM (
27
30
model = "facebook/opt-125m" ,
28
31
tensor_parallel_size = 2 ,
29
32
distributed_executor_backend = "external_launcher" ,
33
+ seed = 0 ,
30
34
)
31
35
32
36
outputs = llm .generate (prompts , sampling_params )
Original file line number Diff line number Diff line change @@ -761,6 +761,12 @@ def verify_with_parallel_config(
761
761
self ,
762
762
parallel_config : "ParallelConfig" ,
763
763
) -> None :
764
+
765
+ if parallel_config .distributed_executor_backend == "external_launcher" :
766
+ assert self .seed is not None , (
767
+ "Seed must be set when using external launcher backend to "
768
+ "make sure sampling results are the same across workers." )
769
+
764
770
total_num_attention_heads = getattr (self .hf_text_config ,
765
771
"num_attention_heads" , 0 )
766
772
tensor_parallel_size = parallel_config .tensor_parallel_size
You can’t perform that action at this time.
0 commit comments