[Bugfix] Give each data-parallel engine its own global RNG streams (#59788)

Signed-off-by: aoshen02 <aoshen@inferact.ai>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
aoshen02
2026-10-05 17:38:18 +00:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 877ddcc456
commit d09ff77637
4 changed files with 26 additions and 3 deletions
+15
View File
@@ -14,6 +14,7 @@ from vllm.utils.torch_utils import (
is_lossless_cast,
is_quantized_kv_cache,
set_default_torch_dtype,
set_random_seed,
set_torch_threads_for_runtime,
startup_omp_num_threads,
)
@@ -217,3 +218,17 @@ def test_async_tensor_h2d_staging(device):
async_tensor_h2d([1, 2, 3], device=device, dtype=torch.int32),
torch.tensor([1, 2, 3], dtype=torch.int32, device=device),
)
def test_set_random_seed_differs_per_data_parallel_index():
"""Unseeded requests draw from the global RNGs; DP engines sharing the engine
seed must get distinct, reproducible streams, and index 0 keeps the seed."""
def draws(*args):
set_random_seed(*args)
return np.random.randint(2**31, size=4).tolist(), torch.rand(4).tolist()
assert draws(42, 0) == draws(42)
assert draws(42, 1) == draws(42, 1)
assert len({str(draws(42, i)) for i in range(4)}) == 4
assert draws(42, 1) != draws(43, 1)