Skip to main content
← CONCEPTS / AI & MACHINE LEARNING SYSTEMS
An end-to-end domain learning journey

Ring AllReduce & Tensor
Parallelism Across Multi-GPU Clusters.

Ring AllReduce splits tensors into N chunks across N GPUs so every link transfers 2*(N-1)/N * M bytes regardless of cluster size, while Megatron Tensor Parallelism pairs column-wise and row-wise splits to need only one AllReduce per block.
Start the journey5 sections· Last modified Nov 26, 2026
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

When scaling multi-GPU training, keep Tensor Parallelism within NVLink (TP <= 8) and use Ring/Tree AllReduce with gradient bucketing across nodes.

TL;DR30-second simplified summary
▾

Ring AllReduce divides an M-byte tensor into N chunks and runs 2*(N-1) pipelined ring steps, keeping per-GPU traffic bounded at ~2M even as N grows. Pairing column-parallel W1 (independent GeLU) with row-parallel W2 reduces each Transformer MLP/Attention block to a single AllReduce.

Before you begin · Building blocksAlready know these? Jump to Stage 01 ↓
Transformer Attention & MLP Dimensions
Know how projection matrices W_QKV and MLP layers W_1, W_2 map hidden dimension h to 4h and back, because Tensor Parallelism splits those exact inner dimensions.
PCIe vs. NVLink & RDMA Interconnects
Understand the 10x–20x bandwidth gap between intra-node NVLink (900 GB/s on H100) and inter-node InfiniBand/RoCE (400 Gbps = 50 GB/s per NIC).
Full walkthrough · 5 stages
01
L4 · FUNDAMENTALS

P · Problem & The Parameter-Server Bottleneck.

Imagine 64 GPUs each holding a 10 GB gradient vector. If all 64 GPUs send their 10 GB vector to one Parameter Server (PS) to be averaged and broadcast back, that single PS NIC must receive 640 GB and transmit 640 GB every training step.

With a 400 Gbps (50 GB/s) NIC, receiving and broadcasting 1.28 TB takes at least 25.6 seconds per step—longer than the forward and backward math itself. Worse, in a naive peer-to-peer All-to-All where every GPU sends M bytes to N-1 peers, link congestion scales quadratically.

Communication Bottleneck

Parameter Server O(N) Fan-In vs. Ring AllReduce O(1) Per-Link

Before · Central Parameter Server
  • Root NIC ingests N * M bytes
  • 63 GPUs idle during reduction
  • Single point of congestion
After · Symmetric Ring AllReduce
  • Each GPU sends 2*(N-1)/N * M
  • All N NICs active in full duplex
  • Throughput independent of N
02
L4 · FUNDAMENTALS

R · Representation: Scatter-Reduce + AllGather.

Arrange N GPUs in a circle: GPU 0 -> GPU 1 -> ... -> GPU N-1 -> GPU 0. Slice the M-byte tensor into N equal chunks of size M/N. Every step, each GPU sends one chunk to its right neighbor while receiving one chunk from its left neighbor.

In Phase 1 (Scatter-Reduce, N-1 steps), each GPU adds the incoming chunk into its local buffer and forwards the running sum. After N-1 steps, GPU k holds the complete global sum for chunk k. In Phase 2 (AllGather, N-1 steps), each GPU forwards its finalized chunk around the ring without adding, overwriting local chunks until all N GPUs hold all N summed chunks.

2-Phase Ring Collective

Scatter-Reduce Followed by AllGather Across N Ranks

GPU 0GPU 1GPU 2GPU 31. Phase 1: Send chunk[0],accumulate2. Phase 1: Forward partial sum3. Phase 2: Broadcast final chunk4. Phase 2: Complete tensor copy
03
L5 · APPLIED DESIGN

I · Invariant: Column-Then-Row Tensor Parallelism.

When a single MLP weight matrix W1 is too large for one GPU, you can slice it across GPUs. If you sliced W1 row-wise, every GPU would hold only a partial dot product and would have to AllReduce before applying GeLU(x), because GeLU(a + b) != GeLU(a) + GeLU(b).

Megatron-LM avoids that extra sync by splitting W1 column-wise: W1 = [W1_A | W1_B]. Both GPUs receive the full input X, compute Y_A = GeLU(X * W1_A) and Y_B = GeLU(X * W1_B) completely independently, and then feed into W2 split row-wise: W2 = [W2_A; W2_B]. Because matrix multiplication distributes over row splits, Y_AW2_A + Y_BW2_B equals the exact unsharded output after a single AllReduce.

Megatron MLP Split

Column-Wise W1 -> Local GeLU -> Row-Wise W2 -> Single AllReduce

Input X(Replicated)ingressGPU 0: W1_col +GeLUcomputeGPU 1: W1_col +GeLUcomputeSingle AllReduce(Sum)controlbroadcastbroadcastW2_row partialW2_row partial
04
L5 · APPLIED DESIGN

M · Mechanics at Scale: NVLink Bounds & Tree Fallbacks.

Ring AllReduce maximizes bandwidth, but its step count grows linearly with N: 2*(N-1) hops. For small tensors (like 1 MB biases or small TP activations), latency per hop—not bandwidth—dominates total step time.

On an 8-GPU H100 node with 900 GB/s NVLink, transferring a 64 MB activation tensor via Ring AllReduce takes ~2 * (7/8) * 64 MB / 450 GB/s ~ 0.25 ms. Moving that exact same TP AllReduce across 50 GB/s InfiniBand adds ~2.3 ms per layer—times 80 layers, that is 368 ms of pure network stall per forward+backward pass.

Fabric Hierarchy

Intra-Node NVLink (900 GB/s) vs. Inter-Node InfiniBand (50 GB/s)

Node 0 (8x H100 NVLink)TP=8 RingNode 1 (8x H100…TP=8 RingInfiniBand Leaf/SpineDP Ring / PP P2P
Engineering Decision Framework
Problem
How to scale collective reduction and tensor sharding from 8 GPUs to 1,024 GPUs without stalling compute.
Naive Solution
Stretch Tensor Parallelism across all 1,024 GPUs or use a single-node Parameter Server.
Why It Fails
Parameter Servers hit an O(N) NIC bottleneck, while cross-node Tensor Parallelism hits 2*(L) synchronous AllReduces per step over slower InfiniBand.
Alternatives
Ring AllReduce vs. Double-Binary Tree AllReduce; TP inside NVLink vs. Pipeline Parallelism (PP) + Data Parallelism (DP) across nodes.
Engineering Decision
Keep Tensor Parallelism strictly within the intra-node NVLink domain (TP <= 8), use Ring/Tree AllReduce for Data Parallel gradients, and overlap backward compute with gradient bucketing.
Trade-Offs
Requires 3D topology-aware rank placement (NCCL topo detection) and careful microbatch tuning to hide pipeline and DP communication.
05
L6 · SCALE & TRADE-OFFS

E · Edge Cases, Assumptions & When NOT to Use It.

Ring AllReduce is lock-step synchronous: if 1 GPU out of 1,024 throttles thermally or hits a PCIe error, all 1,023 other GPUs stall waiting for its ring chunk.

When NOT to use Tensor Parallelism: if your model fits on 1 GPU with activation checkpointing, TP=1 always beats TP=2+ because it eliminates AllReduce overhead completely. Similarly, do not use Ring AllReduce for tiny tensors (<1 MB) across hundreds of ranks—latency dominates, so use Tree AllReduce or fuse gradients into 25 MB+ buckets.

Fault & Straggler Guard

Ring Health -> Straggler Stall -> Watchdog Timeout -> Checkpoint Rollback

thermal / ECC stallwatchdog > 60scordon bad nodeHealthy RingStraggler RankNCCL TimeoutRestart from Ckpt
Decision Exercise · Make the Call

You are training a 7B-parameter model on 64x 80 GB H100 GPUs (8 nodes x 8 GPUs). The model weights + optimizer states fit comfortably on 1 node (or even 1–2 GPUs with ZeRO-2). Your team proposes setting TP=16 across two nodes. What should you do?

Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

For N = 16 GPUs syncing a 2 GB gradient tensor via Ring AllReduce, roughly how much data does each GPU transmit in total across both phases?

Recommended Learning Flow