About
Warning:
If you are utilizing the standard d9d training or inference infrastructure, you do not need to call these functions manually. The framework automatically handles seed initialization during startup. This package is primarily intended for users extending d9d.
The d9d.internals.determinism package handles the initialization of Random Number Generators (RNG) across distributed processes.
d9d.internals.determinism
This package provides utilities for making your distributed setup deterministic.
set_seeds(dist_context, seed, distinct_seed_mesh_dim='pp')
Sets random seeds for Python, NumPy, and PyTorch.
This function sets seeds deterministically based on the provided base seed and the process's rank within a specific mesh dimension.
The seed is shifted by the rank in the distinct_seed_mesh_dim (e.g., Pipeline Parallel rank).
This ensures that processes in different pipeline stages operate with different random states,
while processes that should share randomness (like Expert Parallel peers) can be synchronized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dist_context
|
DistributedContext
|
The distributed context. |
required |
seed
|
int
|
The base random seed. |
required |
distinct_seed_mesh_dim
|
str
|
The name of the mesh dimension along which seeds should be distinct (e.g., 'pp' for pipeline parallelism). Ranks along other dimensions will share the seed. |
'pp'
|
Source code in d9d/internals/determinism/seed.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |