Model and Inference EngineeringTraining data and objectivesStaff
When should distributed training share a random seed, and when does it need distinct augmentation streams?
By Amit Kumar2 min readWorked answer includedReviewed 28 Sept 2026
The question
Interview question
Eight data-parallel ranks read different shards but apply matching crop and corruption sequences to corresponding examples after receiving one run seed. Explain model initialization, sampler shuffling and augmentation randomness separately. Design reproducible transformations that preserve the intended sample/view identity across workers, epochs and rank changes.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
There are several random streams with different jobs. Ranks may need the same initial model weights, and a distributed sampler commonly uses a shared shuffle seed plus rank-aware partitioning so ranks choose nonoverlapping indices. But an augmentation random-number generator copied unchanged into every rank and worker can correlate the transformations applied to different data. In some setups that correlation reduces useful variation, and in others it creates exact duplicate views when examples repeat. The seed alone does not tell us whether examples overlap. We need to inspect sampled IDs and transformed outputs. PyTorch's DistributedSampler documents the shared sampler seed and rank partition, while its data-loading guidance explains worker seeds. Those mechanisms should not be conflated with augmentation randomness.
I would log, for a small deterministic run, sample ID, epoch, rank, worker ID, augmentation parameters and a content hash before and after transformation. Check whether the framework seeds workers, whether NumPy or a custom image library was also seeded, and whether persistent workers advance their random state across epochs. Check calls to the sampler's epoch setter so the shuffle order actually changes. If random augmentation is run in the model process rather than the loader, inspect that generator separately. A single manual_seed(42) copied into every subprocess is a common route to synchronized random choices, but it is not a universal outcome for every framework.
For reproducible independent choices, derive augmentation randomness from a stable run seed and identifiers such as sample, epoch and augmentation view, with rank or worker only where it is part of the intended sampling policy. Counter-based or stateless transforms can make replay robust to worker scheduling changes. If the same sample should get the same view regardless of which rank owns it after a restart, do not bake rank into that particular seed. If two intentional views of one sample must differ, include a view ID. Write down which reproducibility property is needed before choosing the formula.
The interviewer may say training loss looks normal. It could. The question is whether the data distribution and diversity match the recipe. Compare augmentation coverage, repeated-view rate and downstream quality, not just one loss curve. The checkpoint resumes at the right step. Why does training repeat old samples? covers replaying old samples after checkpoint resume. Here examples may be distinct and the bug is in how each one is transformed.
Related questions
Keep practising model and inference engineering
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux