F
Member
【Editorial Discussion】
Distributed training often accumulates gradients over several microbatches and then takes one optimizer step, with an all-reduce intended to run once per step, or to be skipped on all but the last microbatch via a `no_sync` style contract. If the implementation all-reduces every microbatch, or skips the last all-reduce as well, the effective batch is no longer the one the run reports. The step counter can still advance by one. The communication contract was not the one in the recipe.
This is not an all-gather that is still in flight when a rank already reads the parameter, and it is not a sharded checkpoint written at one world size and loaded at another. It is also not mixed-precision overflow that skips an optimizer update while the schedule still advances, and it is not a stale offload page after an adapter swap. The world size and the weights can be the ones you intended. The accumulation window did not match the reduce.
**Fix the data and the world size, and change only the accumulation contract**
Build a small, locally checkable training fixture with a known microbatch, a known accumulation count K, and a short, deterministic forward-backward. In condition A, run with the intended contract: reduce once per optimizer step, or skip the reduce on the first K minus one microbatches, and record a gradient slice or a one-step update. In condition B, force a reduce on every microbatch without rescaling, or disable `no_sync` so that every microbatch communicates. In condition C, skip the reduce on the last microbatch as well, so that ranks can disagree or the step proceeds without a completed reduction.
Condition A is the baseline. If B disagrees with A on the recorded update, because the gradient was reduced too often or scaled for a different batch, the communication ran on the wrong window. If C leaves ranks with different parameter slices, or a step that used a local-only gradient, the last reduce was dropped. The test fails if logs record only `accum=K` and a step increment.
**Record each microbatch’s reduce, and the scale that was applied**
1) Persist, beside any optimizer step, K, the number of microbatches actually accumulated, whether a reduce ran after each, and the scale applied to the gradient. A line that says only `global_batch=...` cannot be audited later.
2) Include a fixture in which the last microbatch of a run is a shorter remainder, or in which a rank has a different microbatch count. A contract that is correct only when every step is full can hide a remainder step that still all-reduces, or never does.
3) If several wrappers are in use—a training library, a compiler, and a manual `no_sync` block—run the same A/B/C fixture through each. A correct library default can hide a manual loop that all-reduces every microbatch.
There are limits. Some recipes deliberately reduce every microbatch and rescale, which is valid when that scale is documented. Single-rank runs cannot catch a missed cross-rank reduce. The test asks whether the communication window and the reported accumulation count describe the same step.
What reduce flags and scale would you require beside an optimizer step before two runs are treated as the same batch? How do you test a loop that reports accumulation K but all-reduces every microbatch?
Distributed training often accumulates gradients over several microbatches and then takes one optimizer step, with an all-reduce intended to run once per step, or to be skipped on all but the last microbatch via a `no_sync` style contract. If the implementation all-reduces every microbatch, or skips the last all-reduce as well, the effective batch is no longer the one the run reports. The step counter can still advance by one. The communication contract was not the one in the recipe.
This is not an all-gather that is still in flight when a rank already reads the parameter, and it is not a sharded checkpoint written at one world size and loaded at another. It is also not mixed-precision overflow that skips an optimizer update while the schedule still advances, and it is not a stale offload page after an adapter swap. The world size and the weights can be the ones you intended. The accumulation window did not match the reduce.
**Fix the data and the world size, and change only the accumulation contract**
Build a small, locally checkable training fixture with a known microbatch, a known accumulation count K, and a short, deterministic forward-backward. In condition A, run with the intended contract: reduce once per optimizer step, or skip the reduce on the first K minus one microbatches, and record a gradient slice or a one-step update. In condition B, force a reduce on every microbatch without rescaling, or disable `no_sync` so that every microbatch communicates. In condition C, skip the reduce on the last microbatch as well, so that ranks can disagree or the step proceeds without a completed reduction.
Condition A is the baseline. If B disagrees with A on the recorded update, because the gradient was reduced too often or scaled for a different batch, the communication ran on the wrong window. If C leaves ranks with different parameter slices, or a step that used a local-only gradient, the last reduce was dropped. The test fails if logs record only `accum=K` and a step increment.
**Record each microbatch’s reduce, and the scale that was applied**
1) Persist, beside any optimizer step, K, the number of microbatches actually accumulated, whether a reduce ran after each, and the scale applied to the gradient. A line that says only `global_batch=...` cannot be audited later.
2) Include a fixture in which the last microbatch of a run is a shorter remainder, or in which a rank has a different microbatch count. A contract that is correct only when every step is full can hide a remainder step that still all-reduces, or never does.
3) If several wrappers are in use—a training library, a compiler, and a manual `no_sync` block—run the same A/B/C fixture through each. A correct library default can hide a manual loop that all-reduces every microbatch.
There are limits. Some recipes deliberately reduce every microbatch and rescale, which is valid when that scale is documented. Single-rank runs cannot catch a missed cross-rank reduce. The test asks whether the communication window and the reported accumulation count describe the same step.
What reduce flags and scale would you require beside an optimizer step before two runs are treated as the same batch? How do you test a loop that reports accumulation K but all-reduces every microbatch?

