You run data-parallel training on GPUs for a model with billion parameters and fp16 gradients ( bytes each). Using ring all-reduce, how many bytes does each GPU send per step, and how long does communication take at per link?
ML system design, Distributed training
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you can derive the communication volume of ring all-reduce, plug in realistic cluster numbers, explain its scaling with worker count , and say how real training pipelines hide that cost.
Key idea
Ring all-reduce splits the -byte gradient vector into chunks and runs two phases around a logical ring of GPUs (graphics processing units): reduce-scatter (each GPU ends up with one summed chunk) followed by all-gather (every GPU receives all summed chunks). Each GPU sends bytes in total, which approaches as grows rather than scaling with .
Steps
- Compute the gradient buffer size : with parameters in fp16 (16-bit floating point, bytes each), (using decimal gigabytes, , to match the link speed).
- Derive reduce-scatter volume: arrange the GPUs in a logical ring and partition each GPU's -byte buffer into equal chunks of bytes. Over hops, each GPU sends one chunk clockwise and accumulates the incoming chunk, so after hops each GPU holds the full sum for one chunk, having sent bytes.
- Derive all-gather volume: over more hops, each GPU forwards its completely summed chunk around the ring until every GPU holds all summed chunks. This sends another bytes, giving total bytes sent (and received) per GPU:
- Plug in , and link bandwidth : Since all GPUs transmit concurrently over their ring links (ignoring small startup latency), communication takes
- Note scaling with and practical overlap: as increases, , so bandwidth-limited communication stays bounded by ( here) regardless of . In practice, Distributed Data Parallel (DDP) overlaps gradient buckets with the backward pass (starting all-reduce on later layers while earlier layers still compute gradients), and gradient accumulation over micro-batches reduces communication per micro-batch by .
Common mistakes
- Saying each GPU sends only bytes; ring all-reduce runs both reduce-scatter and all-gather, so each GPU sends nearly bytes.
- Assuming bandwidth-limited time grows linearly with ; per-GPU byte volume is bounded by , though small-message startup latency across hops does grow linearly with when gradients are tiny.
- Confusing GB/s (gigabytes per second) with Gbps (gigabits per second, which must be divided by before dividing into bytes).
How long your answer should be
3–4 minutes; derive 2(N−1)/N × G, compute 3.5 GB and 35 ms, then mention N-scaling and overlap.
Read this
Previous in ML system design: What are data, tensor and pipeline parallelism in distributed training, and when should you use each?
Next in ML system design: Mixed-precision Adam requires bytes per parameter ( B fp16 weights, B fp16 gradients, B fp32 master weights, and B each for Adam moments and ). For a -billion-parameter model across GPUs, how much per-GPU memory do model states take under plain data parallelism and ZeRO stages 1, 2 and 3?