[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
+5 -1
View File
@@ -530,8 +530,12 @@ def kv_cache_dtype_str_to_dtype(
return STR_DTYPE_TO_TORCH_DTYPE[kv_cache_dtype]
def set_random_seed(seed: int | None) -> None:
def set_random_seed(seed: int | None, data_parallel_index: int = 0) -> None:
if seed is not None:
if data_parallel_index:
# DP engines share the seed but must not sample unseeded requests alike.
ss = np.random.SeedSequence((seed, data_parallel_index))
seed = int(ss.generate_state(1)[0])
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)