Ring all-reduce

On this page 7

Ring all-reduce is a collective communication algorithm in which a group of processes, typically GPUs, are arranged in a logical ring and exchange chunks of data with their neighbors so that every process ends up holding the element-wise sum (or another reduction) of all inputs. In AI infrastructure, it is the classic method for synchronizing gradients in data-parallel training, and it remains one of the core algorithms in libraries such as NCCL, RCCL, Gloo and Horovod.

Its appeal lies in a simple property: the amount of data each GPU sends and receives is nearly independent of the number of GPUs. This makes the algorithm bandwidth-optimal for large messages, which is exactly the regime of gradient tensors that span hundreds of megabytes or several gigabytes.

How ring all-reduce moves data around the ring

Ring all-reduce splits each process’s buffer into N equal chunks, where N is the number of participants, and runs in two phases of N minus 1 steps each. In every step, each process sends one chunk to its right neighbor and receives one chunk from its left neighbor, so all links in the ring are busy simultaneously.

In the first phase, called reduce-scatter, each received chunk is added to the local copy of that chunk before being forwarded. After N minus 1 steps, every process owns one fully reduced chunk. In the second phase, called all-gather, those finished chunks circulate around the ring without further arithmetic until every process holds the complete reduced buffer.

The table below traces the two phases for a ring of four GPUs.

PhaseStepsWhat each GPU doesState at the end
Reduce-scatter3Sends one chunk, adds the received chunkEach GPU owns one fully summed chunk
All-gather3Forwards finished chunks unchangedEach GPU holds the full summed buffer
Total6Six sends and six receives per GPUAll replicas have identical gradients
Phases of ring all-reduce with four GPUs

Cost model and bandwidth optimality

Collective algorithms are usually analyzed with the alpha-beta model, where alpha is the fixed latency per message and beta is the time per byte. For a buffer of size S across N processes, ring all-reduce sends 2(N-1)/N times S bytes per process and needs 2(N-1) communication steps.

As N grows, the data volume per GPU approaches 2S, which is the theoretical lower bound for any all-reduce algorithm. The latency term, however, grows linearly with N, so ring all-reduce becomes inefficient when messages are small or rings are very long.

Number of GPUsData sent per GPUCommunication steps
21.0 GB2
81.75 GB14
64about 1.97 GB126
1024about 2.0 GB2046
Per-GPU cost of ring all-reduce for a 1 GB buffer

These figures show the central trade-off: bandwidth cost stays flat, while latency cost keeps rising. At large scale, the slowest link in the ring also limits the whole operation, because every chunk must pass through every link.

Ring all-reduce compared with other all-reduce algorithms

Ring all-reduce is one of several ways to implement the all-reduce primitive, and production libraries choose between algorithms dynamically based on message size, topology and GPU count. A parameter server design, the older alternative, centralizes aggregation and therefore concentrates traffic on a few nodes.

StrategyStep count grows asTraffic patternWhere it wins
Ring2(N-1)Even load on every linkBig gradient buckets on a few dozen GPUs
Double binary treeAbout 2 log2 NTwo complementary trees share linksThousands of GPUs or mid-size buffers
Recursive halving-doublingAbout 2 log2 NPairwise exchanges at growing distanceShort buffers on power-of-two groups
Hierarchical ringRings per topology levelMost bytes stay on fast local linksServers with NVLink inside and a fabric between
Parameter serverTwo hops via a serverTraffic concentrates on serversAsynchronous or sparse updates
How the ring differs from alternative strategies

In practice, hierarchical variants dominate on modern clusters: GPUs first reduce over fast intra-node links such as NVLink, then a smaller inter-node ring or tree runs over InfiniBand or RoCE, and finally results are broadcast locally. This keeps the expensive network traffic to one participant per node.

Using ring all-reduce in distributed training

In data parallelism, every replica produces gradients from a different slice of the batch, and the ring combines them so that all replicas apply the same parameter update. Training frameworks rarely send one giant tensor; they pack gradients into fixed-size buckets and start the ring for a bucket while later layers are still running backpropagation, which hides much of the transfer time.

Fully sharded training reuses the two halves of the ring separately. A reduce-scatter leaves each GPU with the summed gradient shard it is responsible for, and an all-gather reassembles full parameters just before a layer needs them. Knowing how the ring behaves therefore predicts the network cost of nearly every current training configuration.

  • Bucket size balances latency overhead against overlap with computation.
  • Ring order should follow the physical topology so that neighbors share fast links.
  • Reduced precision gradients in BF16 or FP16 halve the bytes sent per step.
  • Multiple rings or channels can run in parallel to saturate several network interfaces.

Limitations and common pitfalls

Ring all-reduce is synchronous and fragile: one slow or failed GPU stalls every other participant, which is why training fault tolerance and elastic training mechanisms matter at scale. The algorithm also assumes homogeneous bandwidth, so a single congested or degraded link determines throughput for the entire job.

SymptomLikely causeRemedy
Low bus bandwidthRing crosses slow PCIe or network linksUse topology-aware or hierarchical rings
Poor scaling past hundreds of GPUsLatency term grows with NSwitch to tree or hierarchical algorithms
Periodic training stallsStraggler GPU or flaky linkMonitor per-rank timing and replace hardware
Communication not overlappedBuckets too large or launched lateTune bucket size and gradient hooks
Typical problems and remedies

A frequent misconception is that ring all-reduce is always the best choice. For small messages, such as scalar metrics or tiny layers, its many sequential steps make logarithmic algorithms considerably faster, and well-configured communication libraries switch automatically.

The simple explanation

Picture a group of friends sitting in a circle. Each one has a page of numbers, and they all need the total of every page. Nobody sends everything to one person. Instead, each friend passes a small part to the neighbor, who adds their own numbers and passes it on.

After a few rounds, every friend holds the full total. No one carries a heavy load, and everyone works at the same time. Computers training large AI models use this trick so that many graphics chips can share their results quickly.

How it is used in practice

An engineering group trains a speech recognition model of roughly 1.3 billion parameters on sixteen GPUs split across two machines. Inside a machine, the GPUs talk over NVLink; between machines, traffic travels over a 200 Gb/s InfiniBand link. Because gradients are kept in BF16, every optimizer step has to sum about 2.6 GB of gradient data.

The communication library forms a hierarchical ring: each machine first combines its eight local copies over NVLink, and only a short ring between the two machines uses InfiniBand. Gradients travel in 25 MB buckets, and each bucket enters the ring while earlier layers are still being differentiated. Profiling shows that communication is almost completely hidden behind computation, and step time on sixteen GPUs is close to half the step time on eight, giving the team near-linear scaling.