advanced25 min studyLesson 482 in Engineering

Ring AllReduce cost models

Derive ring phase counts and per-rank transfer volume while keeping latency, bandwidth, reduction work, and topology assumptions explicit.

On this page

What you’ll understand

  • Identify the reduce-scatter and allgather phases of a ring.
  • Calculate a latency-bandwidth estimate from per-rank input bytes.
  • Explain why adding ranks does not automatically divide AllReduce time by rank count.

A ring AllReduce moves chunks around a logical cycle so every rank contributes to a reduction and eventually receives the complete result. Its attraction for large messages is a controlled per-rank byte volume. Its drawback for small messages is the number of sequential communication steps. A clean model makes that tradeoff visible without claiming that a library always chooses a ring or that every physical ring edge has equal performance.

Two phases circulate equal chunks

Assume p ranks, an equal per-rank input of n bytes, and a datatype-element partition into p equal chunks. A ring reduce-scatter uses p−1 steps: ranks exchange chunks with neighbors and accumulate contributions so each finishes with a different reduced chunk. A subsequent allgather circulates those completed chunks for another p−1 steps. The full tensor is returned to every rank. Different ring schedules can assign chunk ownership differently; the semantic result is independent of the chosen logical neighbor numbering under compatible reduction rules.

Each rank sends one chunk per step in this simplified schedule. The data volume sent per rank over both phases is therefore 2(p−1)n/p, with the same received volume under the symmetric model. State whether a reported volume counts sends alone, send plus receive, or link-hop traffic. Doubling a send-only volume while comparing with a full-duplex directional bandwidth can count the same cost incorrectly. Real implementations can pipeline and use multiple channels or protocol variants, and local GPU reduction work can add another resource bottleneck.

Dsent,rank=2p−1pnD_{\rm sent,rank}=2\frac{p-1}{p}n
p≥2 is rank count and n is bytes of one complete input tensor at every rank, divisible into equal datatype-aligned chunks for this model. D counts bytes sent by one rank, not send-plus-receive bytes or total fabric-hop traffic.↔ Scroll wide equations horizontally.

Separate startup from sustained transfer

Let one step cost a fixed startup alpha plus chunk bytes times beta, where beta is seconds per byte. Multiplying by the two phase lengths gives the standard simple ring model. It assumes symmetric effective neighbor performance, full-duplex progress without extra send/receive serialization, and no overlapping contention that changes the coefficients. GPU memory reads, local reduction arithmetic, synchronization, protocol overhead, and topology routing can add costs. The formula is an explanatory baseline and should be compared with measurements rather than fitted until every unexplained delay disappears into bandwidth.

For fixed n, the bandwidth term approaches twice the input size divided by effective bandwidth as p grows; it does not shrink to zero. The startup term grows linearly with p. That is why a tiny scalar reduction can favor a lower-step algorithm even when a ring moves large tensors efficiently. Fusing small tensors can reduce repeated startup, but delaying their communication can also reduce overlap with backward computation. Choose bucket boundaries using both the collective model and the training dependency timeline.

Tring≈2(p−1)α+2p−1pnβT_{\rm ring}\approx2(p-1)\alpha+2\frac{p-1}{p}n\beta
alpha is seconds per step and beta seconds per transferred byte, often written 1/B for effective directional bytes/s. The model uses n per-rank full-tensor bytes and excludes local reduction cost, memory contention, routing imbalance, and protocol details.↔ Scroll wide equations horizontally.

A logical cycle must visit every participant

The ring is a logical communication order mapped onto physical devices and links. A simple rank-number sequence can cross a slow inter-node link repeatedly or concentrate traffic on one rail. A topology-aware implementation may choose another rank order, multiple rings, or another collective algorithm altogether. Record the library version and selected topology when testing a model. The historical MPICH algorithm analysis cited here explains latency-bandwidth tradeoffs; its hardware results are not specifications for a contemporary accelerator fabric.

The modular lab illustrates cycle coverage only. Reset, set both modulus m=8 and additive step a=1, predict a period of eight residues, then Play or Step. Separately Reset, set both m=8 and a=2, predict period four, then Play or Step. The second orbit visits only half the residues. This exact addition-modulo model does not exchange tensors or execute ring AllReduce; it helps explain why a neighbor scheme must include the full intended participant set. A short arithmetic cycle is not a faster valid substitute for an eight-rank operation.

Price an eight-rank gradient ring

Eight ranks each hold a 256 MiB input tensor. Use a hypothetical five-microsecond startup per ring step and effective directional bandwidth of 25 GiB/s. Assume equal chunks, no contention, and negligible local reduction work.

  1. There are 2×(8−1)=14 sequential modeled steps. Startup contributes 14×5 μs=70 μs, or 0.07 ms.

  2. Each rank sends 2×7/8×256 MiB=448 MiB. At 25×1,024 MiB/s, that transfer term is 448/25,600 s=0.0175 s, or 17.5 ms.

  3. Add the terms for a modeled 17.57 ms. This is a hypothetical baseline, not a GPU product claim or a guarantee that the linked NCCL version chooses the ring.

The result

Per-rank full-tensor bytes and directional bandwidth must share a consistent convention. Extra reduction, memory, topology, or congestion costs need separate evidence.

Explore the model

Interactive lab

Interactive lab · modular

A ring must cover its intended ranks

Reset, set both m=8 and a=1, predict period eight, then Play or Step. Separately Reset, set both m=8 and a=2, predict period four, then Play or Step. This exact additive orbit demonstrates coverage only; it moves no tensor chunks and has no AllReduce latency or topology solver.

A ring must cover its intended ranksAddition modulo m starts at zero: rₙ = na mod m. Playback advances two additions per second. The orbit has period m/gcd(m,a), including period one for a = 0. This is not a cryptographic security test or a primality algorithm. Current readings: Residue r0: 0; Orbit period · m/gcd(m,a): 12; Distinct residues visited: 1 of 12. All parameters are adjustable with the labeled controls below.Repeated addition modulo 12: the current residue is 0, and the orbit period is 12.01234567891011+ 5mod 12An additive orbitn = 0rₙ = 0Period = 12Cycle starts at 0:0 → 5 → 10 → 3 →8 → 1 → 6 → 11 →4 → 9 → 2 → 7 → 0Exact residues · two additions per second
Additive orbitCurrent residue / next edge
Residue r0
0
Orbit period · m/gcd(m,a)
12
Distinct residues visited
1 of 12
t = 0 s

Addition modulo m starts at zero: rₙ = na mod m. Playback advances two additions per second. The orbit has period m/gcd(m,a), including period one for a = 0. This is not a cryptographic security test or a primality algorithm. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forA shorter cycle that omits participants changes the operation rather than optimizing the same collective.

Check your understanding

In the stated ring model, n denotes which quantity?

Try it yourself

For four ranks and a 64 MiB input per rank, compute modeled send bytes per rank. If startup is two microseconds per step, what is the startup term?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Use 2(p−1)/p for volume and 2(p−1) for step count.

Compare with the solution

Each rank sends 2×3/4×64=96 MiB. Six modeled steps contribute 6×2=12 μs of startup. Transfer time still requires an effective directional bandwidth with consistent units, and the calculation excludes local reduction work, protocol overhead, and physical fabric-hop accounting.

Take it with you

  • A ring has two p−1-step phases under the equal-chunk model.
  • The full-tensor byte convention determines the transfer term.
  • Startup, topology, and dependency timing matter alongside large-message bandwidth.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.