Data Parallel Training and the All-Reduce

Many GPUs train one model by agreeing on one set of numbers after every step. That agreement is the all-reduce, and its price depends on the wire.

Pick a wire, then drag the number of GPUs. Watch how much of each cycle the GPUs spend waiting. Then flip to every 50 steps. Then we build, piece by piece, what a step is, why the GPUs must agree, and how the all-reduce does it.

You need no machine learning and no networking. We define every word the first time it appears, and we build the rest from zero.

Prerequisite 02 of Training on Compute Islands, built for Rohan Anil’s Core Automation post The Hitchhiker’s Guide to Training on Compute Islands (2 November 2026). There are no slides: every idea is taught from the primary sources listed in the Field Guide, in our own words and devices.

Time the sync

8

Illustrative toy numbers: a 32-billion-number model (the post’s size) stored as 2 bytes per number is 64 GB, and one step of computing takes 10 s. The 25 Gbps link is the post’s; 100 and 400 Gbps are common round figures. Chapter 6 derives the 2(N−1)/N traffic.

Chapter 0

Why a Lab Cares About One Shared Answer

See why many GPUs that train one model must keep stopping to agree, and why that agreement is the part the post wants to replace

Imagine a lab that owns 320 GPUs. A GPU is a chip built to do millions of small sums at the same time, and it is the engine that trains a large AI model. The lab wants all 320 chips to work on one model together. But the chips sit in two buildings, on two continents, and the cable between the buildings is slow.

This is the situation in Rohan Anil’s post for Core Automation, “The Hitchhiker’s Guide to Training on Compute Islands”. The team trained one model on 160 GPUs in the US and 160 GPUs in Asia, “roughly 9,000 miles apart”, over a link of 25 Gbps. The post calls this “glorious”. It also says that modern training stacks assume one colocated cluster, so a link like this is a hard case. This lesson explains why.

The post is full of words that a newcomer has not met. Before we read it, we name the main ones, in plain words, and say which chapter teaches each.

WordPlain meaningChapter
ClusterA group of GPUs in one building, joined by fast cables.5, 7
Compute islandOne such cluster, seen from far away: fast inside, slow to everything else.0, 7
NeocloudA newer company that rents GPUs by the hour or the year. The post says the market has many small ones.0
Stranded computeGPUs that exist but cannot be put to useful work. We unpack it below.0
GradientThe arrow that says how to nudge every model number to make fewer mistakes.1
Synchronous trainingAll GPUs stop and agree after every step.2, 3
Bandwidth, GbpsHow many bits a wire carries each second.4
All-reduceThe step where every GPU hands in its numbers and gets back the shared answer.5, 6
GoodputThe share of time the GPUs make real progress.7
Local SGD, pseudo-gradient, gossipThe ways to talk less often. Previewed in chapter 8; later lessons teach them.8

Where the idle chips come from

A neocloud is a newer cloud company that rents out GPUs. The post says the market has “far more availability in scattered clusters, from a few hundred to a few thousand GPUs, spread across many neoclouds”. Added together, these clusters are a lot of compute. But each one is small, and each one is far from the others.

Why not simply build one huge building? The post says the real limits are “power, grid equipment and land”, not chips. It quotes Satya Nadella: “you may actually have a bunch of chips sitting in inventory that I can’t plug in.” It quotes Elon Musk: “I think we’re going to see a lot of stranded compute in partially complete data centers.”

Stranded compute means chips that exist but earn nothing. The post names two causes. The first is physical: an unfinished building has no power or cooling. Software cannot fix that. The second is what the post calls architectural: a healthy cluster is useless to a job that “expects one large, uniform cluster that never goes down”. Software can fix that one.

The post gives its position in one line: “Within an island of compute, use the fast interconnect aggressively. Across islands of compute, exchange updates on a slower schedule.” Notice the two words: fast inside, slower schedule across. To feel why, we first need to see what “exchange updates” means in the normal way of training.

The normal way, in one picture

Look back at the instrument at the top of the page. Each bar is one cycle for every GPU. The blue part is useful: the GPU is computing. The yellow part is waiting: the GPU has finished its work and is trading numbers with all the others.

On the fastest wire the yellow sliver is small. On the 25 Gbps wire it is longer than the blue part. The chips are the same, the model is the same, and only the wire changed. This is the cost of what the post calls “well-understood synchronous distributed training”: the whole group stops and trades numbers after every single step.

Flip the instrument to “every 50 steps” and the yellow shrinks to a sliver again. That one change is the post’s whole idea in miniature: the sites “exchanged updates on a 50-step schedule”. The rest of the post is about making that safe. Our job in this lesson is to understand the thing it replaces.

The road

  1. One training step: the model, the loss, the gradient, the update.
  2. Why replicas must agree: what goes wrong when copies drift apart.
  3. Data parallelism: split the batch, average the gradients, get the same answer.
  4. Bytes, bits and bandwidth: what Gbps means and how long a model takes to send.
  5. The all-reduce: the naive way, and the ring that fixes it.
  6. What the ring costs: why each GPU sends 2(N−1)/N of the model.
  7. Waiting: stragglers, idle chips and goodput.
  8. What the post replaces: sync every step becomes sync every 50.
  9. Field guide: numbers, code, sources.
In the hero instrument, the 25 Gbps link makes the GPUs wait longer than they compute, while the 400 Gbps link does not. What changed between the two bars?

Chapter 1

One Training Step

Follow a single number through a guess, a mistake and a nudge, and see the one object that every later chapter moves around the network

You want a machine to guess the price of a flat from its size. You do not know the rule. You have three flats whose prices you know. The machine starts with a bad guess and fixes it a little at a time. That fixing is what “training” means, and it is the same for a toy and for a 32-billion-number model.

The machine has one dial. We call it w, a weight (or parameter): a number the machine can change. The guess is the size times the dial, so guess = w × size. A real model has the same idea with billions of dials. The post’s model has about 32 billion of them.

The three flats are our examples: size 1 costs 2, size 2 costs 4, size 3 costs 6. The true rule is w = 2, but the machine does not know that. It starts at w = 0. Every guess is 0, and every guess is wrong.

The four moves of a step

A training step is one trip through four moves. Every step of every model, from this toy to a frontier model, does the same four moves in the same order.

  1. Forward. Run the examples through the model and collect its guesses.
  2. Loss. Score the guesses with one number: how wrong are they? We use the average of the squared mistakes. Big mistakes count a lot, and zero is perfect. This number is the loss.
  3. Backward. Work out, for every dial, which way to turn it to lower the loss, and how steeply. This list of directions is the gradient.
  4. Update. Turn every dial a small amount against its gradient.

The word to hold on to is gradient. A gradient is a slope. Stand on a hill in fog. You cannot see the valley, but your feet tell you which way is downhill and how steep. The gradient is that feeling, one slope for each dial. Step against the slope and you go downhill: the loss falls.

Worked by hand

Start at w = 0. Forward: every guess is 0. Loss: the mistakes are 2, 4 and 6, the squares are 4, 16 and 36, and the average is 56 / 3 = 18.67.

Backward: the slope of the loss with respect to w is the average of −2 × size × mistake. That is (−2×1×2 − 2×2×4 − 2×3×6) / 3 = −56 / 3 = −18.67. A negative slope says that raising w lowers the loss.

w
The dial. The arrow means “replace the old value with the right-hand side”.
η
The learning rate: how far to turn the dial per unit of slope. We pick it. It is small, such as 0.05.
g
The gradient: the slope of the loss with respect to w.

w = 0 − 0.05 × (−18.67) = 0.933  →  the next loss is 5.31

One step moved w from 0 to 0.933 and cut the loss from 18.67 to 5.31. A second step gives w = 1.43. Press the button in the device below and watch the point slide down the bowl.

Take training steps

The curve is the loss for every value of w. The teal dot is the machine now. The short line is the slope there. Press Take one step, then raise the learning rate past 0.21 and step again.

0.050

Toy model with three made-up flats (sizes 1, 2, 3; prices 2, 4, 6). The loss is the average squared mistake. Steps stay stable only while the learning rate is below 2 / 9.33 = 0.214, where 9.33 is how sharply this bowl curves.

The failure: a step too big

Symptom: push the learning rate to 0.25 and step. The dot jumps over the bottom and lands higher on the other side. Measurement: the loss rises each step, and the gradient grows. Cause: the step overshoots the valley by more than it gained. Fix: shrink the learning rate. Real training spends much effort on this one dial.

The same four moves at full size

Now scale up. A language model reads tokens, small pieces of text turned into whole numbers. One batch is a group of examples processed together: say 8 sequences of 2,048 tokens each, an integer table of shape [8, 2048]. Forward turns it into scores of shape [8, 2048, V], where V is the number of possible tokens. Loss squeezes those into one number.

Backward produces the gradient. Here is the fact that matters for the rest of this lesson: the gradient has exactly the same shape and size as the model. The model has 32 billion numbers, so the gradient has 32 billion numbers. One number of slope for each dial. Chapter 4 turns this into bytes, and the bytes into seconds.

pythonimport numpy as np
x = np.array([1., 2., 3.]); y = np.array([2., 4., 6.])   # the three flats
w, lr = 0.0, 0.05
for step in range(1, 4):
    guess = w * x                                  # 1. forward
    loss  = np.mean((y - guess) ** 2)              # 2. loss
    g     = np.mean(-2 * x * (y - guess))          # 3. backward: the gradient
    w     = w - lr * g                             # 4. update
    print(step, round(loss, 2), round(g, 2), round(w, 3))
# 1 18.67 -18.67 0.933
# 2 5.31 -9.96 1.431
# 3 1.51 -5.31 1.697
A model has 32 billion weights. How many numbers does its gradient have, and why?

Chapter 2

Why Every Copy Must Agree

Watch four identical copies of a model drift apart when each listens only to its own data, and see what agreement buys

Four cooks share one recipe. Each cook makes dinners in a different town and tastes the results. After each dinner, each cook edits their own copy of the recipe: a little less salt, a little more garlic. After a hundred dinners, there are four different recipes. Which one is “the” recipe? None of them. Each one fits one town’s taste.

Training a model on many GPUs has the same risk. This chapter shows the risk, then names the cure.

Why use many GPUs at all

One training step on one GPU is slow when the batch is large and the model is big. The simplest way to go faster is to hire more GPUs and share the work. There are two ways to share it. You can cut the model into pieces and give each GPU a piece. Or you can give each GPU a whole copy of the model and a different slice of the data.

The second way is data parallelism. Each GPU, here called a worker, holds a full replica: an exact copy of all the weights. Each worker reads its own slice of the batch, called a shard. The post uses this family: “Every site holds a full replica, and the methods cut how often and how much replicas talk.” (The other family, model parallelism, cuts the model itself; the post notes both exist.)

What goes wrong without agreement

All replicas start identical. That is easy: copy the same weights to everyone. Then each worker does the four moves of chapter 1 on its own shard. Each shard is a small, random sample of the data, so each worker computes a slightly different gradient. This is normal and expected.

Now suppose each worker updates its own copy with its own gradient and tells nobody. After one step the replicas differ a little. After a hundred steps they differ more, because each keeps following its own shard. Each replica is a fine model for its shard. But you have four models, not one. You wanted one model that has learned from all the data.

The device below makes this visible. Four workers each hold three flats with noisy prices. The noise differs by worker, like different towns. All four start at w = 0. Switch “Average the gradients” off and on, and watch the four lines.

Let four copies drift

Each line is one worker’s dial over 40 steps. With sharing off, each worker follows only its own flats. With sharing on, the four lines lie on top of each other.

Toy data, made up and seeded so it is the same on every visit: each worker has three flats whose prices are 2 × size plus noise. Learning rate 0.05. Green marks agreement.

The fix: average the gradients

The fix is short. Before anyone updates, all workers pool their gradients and take the average. Everyone then updates with the same average gradient. Because everyone started with the same weights and applies the same update, everyone ends the step with the same weights again. Agreement is kept by induction: identical before the step, identical after.

Look at the device again with sharing on. Not one wobble differs between the four lines. The path is as if one big machine had seen all four shards at once. That is the point of synchronous training: the word means the workers move in lockstep. No worker runs ahead; all of them wait for the pooled answer before they take the next step.

The price: they must wait for each other

Lockstep has a cost. Every step ends with a moment where all workers stop and exchange gradients. If the exchange is quick, nobody minds. If it is slow, every chip sits idle until it ends. The hero instrument showed this: the yellow bar is that idle time.

There is also a hidden cost that the post stresses. Modern training stacks, the post says, “assume a single colocated cluster”, and they rely on synchronous training. If one worker is slow, all wait. If one worker dies, the run stops. The post asks for training that keeps going “through interruptions”.

Why not just let replicas drift, and merge them at the end by averaging the weights? Sometimes that works, and chapter 8 explains when. But averaging two models that drifted far apart can give a broken model: the middle of two good answers need not be good. Agreement at every step is the safe way to avoid that.

Failure mode, measured

Symptom: the four replicas give different outputs for the same input. Measurement: compare the weights across workers. The largest gap between any two workers is the spread. In sync training, the spread must be exactly 0. In the device, the read-out reports the spread. Fix: pool the gradients before updating, and check the spread is 0 when you test the run.

Four workers start with identical weights. Each updates using only its own shard’s gradient. What do you have after many steps?

Chapter 3

Split the Batch, Average the Gradients

Prove that N workers who each see a slice and then average give exactly the gradient of one machine that saw everything

A teacher has 800 exams to grade. She asks three colleagues to help. Each takes 200, and each writes down the class average of their pile. How does she find the average of all 800? She averages the four piles’ averages. The piles are the same size, so this gives the exact answer.

Data-parallel training works on the same arithmetic. This chapter shows why it is exact, and when it is not.

One batch, cut into shards

Chapter 1 defined a batch: the group of examples used in one step. In data parallelism the batch is called the global batch, and it is cut into N equal shards, one for each worker. Each shard is a microbatch. If the global batch has 8,192 examples and there are 256 workers, each worker gets 32. These are the numbers from Goyal et al., “Accurate, Large Minibatch SGD: Training ImageNet in 1 Hour”, who trained ResNet-50 (a standard image-recognition network) on ImageNet (a library of labelled photos) with a batch of 8,192 on 256 GPUs in about one hour. SGD, in their title, is the plain training step of chapter 1.

Each worker then does forward, loss and backward on its own microbatch only. It does not update yet. Each worker now holds one gradient with the same size as the model, computed from its own 32 examples. The next move is the pooling.

Why the average is exact

The loss on the global batch is the mean of the loss on each example. The gradient is a slope, and the slope of an average is the average of the slopes. So the global gradient is the mean of the per-example gradients g1 to gB.

g
The gradient of the loss on the whole global batch. This is what one big machine would compute.
(1/B) ∑ gi
The mean of the per-example gradients, over all B examples.
(1/N) ∑ g(k)
The mean of the N shard gradients, where g(k) is worker k’s mean over its own B/N examples. This holds only when every shard has the same size.

A worked case with eight examples makes it concrete. At w = 0, our toy flats give the per-example gradients −5, −14.4, −38.4, −60, −108, −138, −204.4 and −246.4. Their sum is −814.6, so the global gradient is −814.6 / 8 = −101.825.

Now give the first four examples to worker 1 and the last four to worker 2. Worker 1’s gradient is −117.8 / 4 = −29.45. Worker 2’s is −696.8 / 4 = −174.2. Their average is (−29.45 − 174.2) / 2 = −101.825. The same number, to every digit. Try it in the device.

Split the batch

Each bar is one worker’s gradient. The yellow line is the full-batch gradient. The teal line is what the workers get after averaging. Change the number of workers, then make the split uneven.

Toy data: eight made-up flats (sizes 1 to 8, prices 2.5, 3.6, 6.4, 7.5, 10.8, 11.5, 14.6, 15.4), gradient at w = 0. An uneven split gives each of the first N−1 workers one example and the last worker the rest.

The failure: uneven shards

Symptom: the training curve is a little off from a single-machine run, and no one can say why. Measurement: take the uneven split in the device. With two workers holding 1 and 7 examples, the plain average of their gradients is −60.3, but the true gradient is −101.825. The worker with one example got the same vote as the worker with seven.

Fix: weight each worker’s gradient by its share of the examples, here 1/8 and 7/8. The weighted average is −101.825 again. Real frameworks mostly avoid the problem by giving every worker the same number of examples.

The update, and the code

After the pooling, every worker holds the same average gradient and the same starting weights. Each worker then runs the update move by itself. No weights cross the network, only gradients. Here is the core of one data-parallel step in PyTorch style. The call all_reduce is the pooling. Chapter 5 opens it up.

pythonimport torch, torch.distributed as dist
# every worker runs this same code on its own shard (rank = this worker's number)
loss = loss_fn(model(x_shard), y_shard)        # forward + loss on B/N examples
loss.backward()                                # backward: .grad now holds this worker's gradient
for p in model.parameters():
    dist.all_reduce(p.grad, op=dist.ReduceOp.SUM)   # add every worker's gradient into p.grad
    p.grad /= dist.get_world_size()                 # divide by N: now it is the mean
optimizer.step()                               # update: identical on every worker

In real PyTorch, DistributedDataParallel does this for you, and it hides the cost by starting the sums for early layers while later layers are still computing. Li et al. describe “bucketing gradients, overlapping computation with communication, and skipping gradient synchronization” and report near-linear scaling on 256 GPUs. The last trick, skipping synchronization, is also called gradient accumulation: run several microbatches, add their gradients, and communicate once. The post tunes exactly this at each site, so that “both sites take similar time per step”.

Four workers hold equal shards of a batch. Why is the mean of their four gradients exactly the full-batch gradient?

Chapter 4

Bytes, Bits and Bandwidth

Turn a model into a number of bytes, a wire into a number of bits per second, and the two into seconds

You need to move a house across town. The house is a lot of furniture. The road has a speed limit and a number of lanes. How long does the move take? You count the furniture, you look at the road, and you divide. The network works the same way: count the data, look at the wire, divide.

The post says: “a bidirectional link of 25 Gbps”. To read that, you need three small ideas. None needs more than primary-school arithmetic.

Bits, bytes and the capital letter

A bit is the smallest piece of data: a 0 or a 1. A byte is 8 bits. Storage and memory are counted in bytes: a model file is 64 GB, a gigabyte, which is a billion bytes. Wires are counted in bits per second: a link is 25 Gbps, which means 25 gigabits per second, or 25 billion bits each second.

The two units look alike and differ by a factor of 8. The only clue is the letter case: capital B is bytes, small b is bits. A wire of 25 Gbps moves 25 / 8 = 3.125 GB each second. This one mix-up causes more wrong estimates than any other.

UnitMeansExample
bit (b)One 0 or 1The smallest piece of data
byte (B)8 bitsOne letter of text
GBA billion bytesA 32B-number model at 2 bytes each is 64 GB
GbpsA billion bits per second25 Gbps carries 3.125 GB each second

How big is the model on the wire?

A model is a long list of numbers, and each number takes a fixed number of bytes. Full precision uses 4 bytes (32 bits) for each number. Many trainers use 2 bytes (16 bits), and some compress to 1 byte. The bytes are the number of parameters times the bytes per number.

The post’s model has about 32 billion parameters. At 2 bytes each, that is 32 × 109 × 2 = 64 × 109 bytes = 64 GB. At 4 bytes it is 128 GB. And chapter 1 told us the gradient is the same size as the model. So one gradient is also 64 GB at 2 bytes. That is the thing each worker needs to share every step.

Bandwidth and the division

Bandwidth is how many bits a wire can carry each second. It is the width of the pipe. To get the time for a transfer, convert the data to bits and divide by the bandwidth.

t
Seconds to send the data once.
8 · bytes
The data in bits. Multiply bytes by 8.
bandwidth
Bits per second the wire carries, such as 25 × 109.

64 GB over 25 Gbps: 64 × 8 = 512 Gb, and 512 / 25 = 20.48 s  →  over 400 Gbps: 512 / 400 = 1.28 s

Use the device to try other sizes and speeds. The yellow bars are the time to send the model once over each wire. The dashed line marks 10 seconds, our toy time for one step of computing.

Time one transfer

Drag the model size. Pick bytes per number. Each bar is the seconds to send the whole model once. The scale is logarithmic, so each tick is ten times longer.

32 B

Pure arithmetic, no measurements: time = 8 × bytes / bandwidth. Real transfers reach less than the line rate, so these are the best possible times. The 10 s line is our illustrative step time.

Bandwidth is not latency

Latency is the time for the first bit to arrive, not for all of them. Think of the road again. Bandwidth is the number of lanes. Latency is how long one car takes to drive the length of the road. A wider road does not shorten the drive.

Latency has a floor set by physics. Light in a glass fibre travels at about 200,000 km each second. The post’s sites are about 9,000 miles, or 14,500 km, apart. One way takes at least 14,500 / 200,000 = 0.072 s, or 72 ms. A round trip takes at least 145 ms. Real cables take longer routes. This is a calculation, not a measurement from the post.

For a 64 GB transfer, 72 ms is nothing next to 20 s. Bandwidth rules. For tiny messages, such as the small routing statistics the post syncs at every step, latency rules. Both matter, for different jobs.

The failure: bits taken for bytes

Symptom: a plan says the sync should take 2.6 s, and the real run takes 20 s. Measurement: recompute with a unit check. 64 GB over 25 “G” is 2.56 only if you forget that the wire counts bits. Fix: write the unit on every number, and multiply bytes by 8 before you divide.

A model is 40 GB. A link is 20 Gbps. What is the best-case time to send the model once?

Chapter 5

The All-Reduce

Step through the ring that gives every worker the sum of everyone’s numbers while every wire stays busy

Four friends each hold a bag of coins, and each bag is sorted into four trays. They want every friend to end with the total of each tray across all four bags. They could all hand their trays to one friend, who adds and hands back the answer. That friend is overwhelmed, and the other three stand idle. There is a better way, and it is the heart of this lesson.

Reduce, and then all

To reduce is to combine many values into one, here by adding. A collective operation is a step in which a whole group of workers takes part together. The all-reduce is the collective where every worker starts with its own array of numbers and every worker ends with the same array: the element-by-element sum of all the starting arrays. The word “all” means that everyone gets the answer, not just one boss.

This is exactly the pooling from chapter 3. Each worker holds a gradient of 32 billion numbers. After the all-reduce, each holds the sum of all the gradients. Divide by N and you have the mean. This is the operation the post wants to replace: “we replaced the all-reduce with butterfly mixing”.

Two ways that do not scale

The first way sends everything to one worker, the root. The N−1 others each send the whole array, K bytes, to the root. The root adds them up and sends the answer back to each. The root’s own wire must carry (N−1) × K bytes in, and then (N−1) × K out. With 64 workers that is 63 arrays through one pipe. The root is the bottleneck, and it grows with N.

The second way has everyone send their whole array to everyone else. Now each worker sends (N−1) × K bytes. Nobody is the boss, but every wire is crowded. Both ways waste the fact that most wires sit unused at any moment.

The ring

The ring has a simple trick. Put the workers in a circle. Each worker talks only to the neighbour on its right and listens only to the neighbour on its left. Cut every worker’s array into N equal chunks. Now run two phases of N−1 steps each.

  1. Scatter-reduce. At each step, every worker sends one chunk to its right neighbour. The neighbour adds it into its own copy of that chunk. The chunk each worker sends changes every step, so every chunk gathers more terms as it travels. After N−1 steps each worker holds one chunk that is the full sum from all N workers.
  2. All-gather. Now the finished chunks travel. At each step, every worker sends a finished chunk to its right neighbour, who overwrites its copy. After N−1 more steps, every worker holds all N finished chunks.

The key is that at every step, all N wires are busy at once, each carrying a small chunk of K/N bytes. Nothing waits for a boss. This is the method that Baidu popularised for deep learning in 2017, and it is the pattern behind the collectives in NVIDIA’s NCCL library.

Step through it below. Each row is a worker and each column is a chunk. The numbers are made up. Watch purple cells collect sums, then watch green cells, which hold a finished sum, spread around the ring.

Step the ring

Press Step. The yellow arrows show which chunk each worker sends to the worker below it (the last sends to the first). The right-hand column checks each row against the true sums.

The values are small made-up whole numbers so you can add them in your head. The algorithm is the ring all-reduce as described by Gibiansky (2017) for Baidu’s work: scatter-reduce, then all-gather.

Worked trace, three workers

Take 3 workers, A, B and C, each with 3 chunks. Look at chunk 1 only. A has 5, B has 2, C has 4. Step 1: A sends its 5 to B, and B adds: 5 + 2 = 7. Step 2: B sends its 7 to C, and C adds: 7 + 4 = 11. Now C holds the finished 11 for that chunk. The same thing happens at the same time to the other two chunks, each starting from a different worker. Then in the all-gather phase, C sends 11 to A (A overwrites), and A sends 11 to B. After 2 + 2 = 4 steps, all three hold 11.

The failure: the lonely bottleneck

Symptom: with root-style pooling, one machine’s network card runs at full speed while the others sit nearly idle, and adding workers makes every step slower. Measurement: count the bytes through the busiest wire. In the root design the root’s wire carries (N−1)K in each direction, and that grows with N. In the ring every wire carries less than 2K in each direction. Fix: use the ring. Chapter 6 proves that number.

At the end of the scatter-reduce phase of a ring with 4 workers, what does each worker hold?

Chapter 6

What the Ring Costs: 2(N−1)/N of the Model

Derive the cost of one all-reduce, see why it barely grows with the number of GPUs, and see why the slowest wire sets the pace

A relay team of 8 runners passes a baton round a track. Add runners and the track gets no longer: each runner still runs a short leg. The ring all-reduce works like this. Add workers and each worker’s share of the load barely changes. This chapter counts it exactly.

Counting the bytes

Let K be the size of the array each worker holds, in bytes. For our model that is the gradient: K = 64 GB. The ring cuts it into N chunks, so each chunk is K/N bytes.

Each step, every worker sends one chunk. That is K/N bytes. The scatter-reduce phase has N−1 steps and the all-gather phase has N−1 more. So a worker sends (N−1) × K/N in the first phase, and the same again in the second.

D
Bytes each worker sends during one all-reduce. Each worker also receives the same amount.
2 (N − 1)
The number of steps: N−1 for scatter-reduce and N−1 for all-gather.
K / N
The size of one chunk, which is what each worker sends in each step.
2 (N − 1) / N
The factor in front of K. It is 1 for N = 2, 1.75 for N = 8, and creeps up toward 2 as N grows.

N = 2: 1.00 K = 64 GB  ·  N = 8: 1.75 K = 112 GB  ·  N = 64: 1.97 K = 126 GB  ·  N → ∞: 2 K = 128 GB

This is the formula in the syllabus: each GPU sends 2(N−1)/N of the model each step. A thousand GPUs send hardly more than eight GPUs do. Gibiansky’s write-up of the Baidu algorithm states the same count and calls the ring “bandwidth-optimal”, meaning no all-reduce can use less bandwidth, when latency is small next to transfer time.

Turning bytes into seconds

Now use chapter 4. Each step sends K/N bytes over a wire of bandwidth β (in bits per second) and pays a latency α for the first bit. The whole all-reduce is 2(N−1) of those steps.

T
Seconds for one all-reduce.
2 (N − 1)
The number of steps, as before.
α
Latency per step: the time for a message to start arriving.
8K / (N β)
The time to push one chunk through the wire: chunk bytes times 8, divided by bandwidth.

Work the numbers for 8 workers on the post’s 25 Gbps link, with K = 64 GB. Bandwidth term: 2 × 7 × (8 × 64 / (8 × 25)) = 14 × 2.56 s = 35.84 s. Latency term: if each of the 14 steps pays 72 ms, that is 14 × 0.072 = 1.0 s. The bandwidth term dominates by 35 to 1. For big models the wire’s width matters, not its length.

The ring against the root

Compare with the root design of chapter 5. The root receives (N−1)K bytes and then sends (N−1)K back: 2(N−1)K bytes in total through one wire. The ring moves only 2(N−1)/N times K. The ratio is exactly N. With 8 workers the ring is 8 times quicker; with 64 workers it is 64 times quicker.

Ring against root

Both lines show seconds for one all-reduce of the 64 GB gradient, on a log scale. Drag the number of workers. The blue line is the ring and the yellow line is the root design.

8

Bandwidth term only (latency left out, as the bandwidth dominates here). Root design: gather (N−1)K, then broadcast (N−1)K through one wire. Gradient K = 64 GB is our illustrative size.

The slowest wire sets the pace

There is a catch that matters for islands. In the ring, all wires work at the same time, and each step ends only when the slowest chunk arrives. So one slow link in the ring slows every step for everyone.

Put 160 GPUs in one building and 160 in another, and join them in a single ring. The ring must cross the ocean link at least twice (out and back). Every one of its 2(N−1) steps then runs at the pace of the 25 Gbps link, even for the workers sitting next to each other on a fast network. This is why the post says to “use the fast interconnect aggressively” inside an island and to exchange “on a slower schedule” across islands.

The failure: chasing N

Symptom: a team doubles its GPUs and the step time does not fall. Measurement: log the time of the all-reduce alone. The ring factor 2(N−1)/N barely moved, but the number of steps 2(N−1) doubled, so latency terms grew, and the slowest wire may now be a farther one. Fix: check whether the all-reduce time is a larger share of the step than before. If it is, you are limited by the wire, not by the chips.

A ring all-reduce runs on 4 workers with a 20 GB gradient. How many gigabytes does each worker send in total?

Chapter 7

Waiting: Stragglers, Idle Chips and Goodput

Measure how the slowest worker holds back all the rest, and learn the one number the post uses to judge a run

A rowing crew of eight pulls one oar each. The boat takes each stroke when the last rower finishes the stroke. Seven strong rowers cannot make the boat go faster if the eighth is slow. Synchronous training is a rowing crew. Every step ends only when the last worker is done.

The barrier

Chapter 2 said that the workers must agree before the update. The point in the code where each worker stops and waits for all the others is called a barrier. The all-reduce is a barrier, since it cannot finish until every worker has handed in its gradient.

So the time of a step is not the average worker’s time. It is the slowest worker’s compute time, plus the time of the all-reduce. A worker that is slow is called a straggler. Everyone who finished early sits idle, burning power and doing nothing.

Why the slowest gets slower as N grows

No two workers take exactly the same time. One chip runs warm and slows down. One worker gets an unlucky batch. One network card hiccups. Say each step takes a base of 10 s, plus a random extra of up to 40%, so between 10 and 14 s, evenly spread. The average worker takes 12 s.

With 8 workers, the slowest is likely near the top of that range. For times spread evenly, the expected slowest of N workers is 10 × (1 + 0.4 × N / (N + 1)). For N = 8 that is 10 × (1 + 0.4 × 8/9) = 13.56 s. The average idle share is 1 − 12 / 13.56 = 11.5%. For N = 64 the slowest is 13.94 s and the idle share is 13.9%. More workers, more waiting, even though no single worker got worse.

Real delays have longer tails than this tidy example: now and then a worker takes twice as long. Then the waste is worse. That is why the post spends a whole section on tail latency, the delay of the slowest few transfers. It tells how the team “optimized directly for tail latency” so that updates complete at a predictable time.

Row with a slow rower

Each blue bar is one worker’s compute time in a step. The striped part is that worker waiting for the slowest. Raise the jitter, add workers, then press Reroll.

8
40%

Toy model: base step 10 s, each worker adds a random extra between 0 and the chosen percent. The first 16 workers are drawn; the numbers use all N. Seeded, so the same on every visit until you reroll.

Hiding the wait

Two tricks shrink the yellow bar of the hero instrument. The first is overlap. Backward (chapter 1) works from the last layer to the first. As soon as the last layers have gradients, their all-reduce can start, while earlier layers are still computing. The PyTorch DDP paper calls this “overlapping computation with communication”, and it groups gradients into buckets so that each message is big enough to be efficient. With overlap, a step costs about the longer of compute and communication, not their sum.

The second trick is the one the post is about: talk less often. If the all-reduce happens every 50 steps, the barrier happens every 50 steps. Chapter 8 makes this precise.

Goodput

The post asks you to “measure progress on two axes: training goodput, which measures productive progress, and final model quality.” Goodput is the share of wall-clock time that went into progress that is kept. A GPU can be busy and still add no goodput, for example when it recomputes steps that were lost.

That happens when a worker dies. In synchronous training, the whole job stops. The job then restarts from the last checkpoint: a saved copy of the weights and the optimizer state. All the steps since that save are lost, and every GPU redoes them. The post wants runs that are “fault tolerant by design”, where a slow or lost island does not halt the rest.

The failure: the invisible straggler

Symptom: 64 GPUs give far less than 64 times the speed of one. Measurement: log each worker’s time before the barrier, then compare the slowest with the median. A gap of 20% means about a sixth of the cluster idles on average, since the fast workers wait 0.2 out of every 1.2. Fix: balance the work between workers, as the post does by tuning each site’s microbatch and accumulation “so both sites take similar time per step”, and replace or avoid slow nodes.

In synchronous training, worker 5 is much slower than the 63 others in a step. What is the step time?

Chapter 8

What the Post Replaces

Trade a sync at every step for a sync every 50, then trade the global all-reduce for pairs, and see what each trade buys and costs

The cooks from chapter 2 now have a slow postal service. They cannot phone each other after every dinner. They can mail a note once a week. So each cook keeps cooking and editing their own recipe, and once a week the four send in their recipes, and the group agrees on one merged version. The cooks lose the daily agreement, but they save the postage. The post makes this trade for a model.

Move 1: sync less often

In chapter 7 the cost of an all-reduce is paid once per step. Suppose the workers instead take H steps on their own, and then sync once. The cost per step falls to the all-reduce cost divided by H. This idea is called local SGD: each worker runs SGD (stochastic gradient descent, the four-move step of chapter 1 on a random batch) locally, with no talking. The post says the idea “goes back decades”, and describes it as “many steps between exchanges”.

The numbers show the point. With 4 workers on the post’s 25 Gbps link, one ring all-reduce of the 64 GB gradient moves 1.5 × 64 = 96 GB, and takes 30.7 s. If one step of computing takes 10 s, then over 100 steps:

Sync everySyncs in 100 stepsWaiting timeShare of time idle
1 step1003,072 s75.4%
5 steps20614 s38.1%
25 steps4123 s10.9%
50 steps261 s5.8%

Illustrative: 10 s compute per step, 30.7 s per sync (4 workers, 64 GB gradient, 25 Gbps)

The post’s sites “exchanged updates on a 50-step schedule”. The price of the saving is drift, the problem of chapter 2. Between syncs the replicas wander apart. Try it below. The vertical lines are syncs. At a sync the workers average their weights, which snaps the lines together.

Sync every H steps

Four workers train for 100 steps. At each dashed line they average their weights. Choose how often. Watch the gap between the lines before each sync.

Toy: the same four made-up shards as chapter 2, learning rate 0.05, one dial. This toy is convex (one valley), so drift is forgiving. A real network has many valleys, and weights that drifted far apart can average to a poor model. Waiting times use 10 s of compute per step and 30.7 s per sync.

Look at “Every step”. The four lines never separate. Averaging weights after one step equals averaging the gradients before the step, since everyone started from the same weights. So sync-every-step is exactly the data-parallel training of chapters 2 and 3.

Two more words: the pseudo-gradient and the outer optimizer

After H local steps, each worker has moved its weights by some amount. Take the average of those movements over all workers. The post calls this the pseudo-gradient: it is not a real gradient, but it points the way the workers want to go, so it can be used like one. The plain recipe just adds it to the old weights.

A smarter recipe treats it like a gradient and gives it its own update rule, with its own memory and learning rate. This second rule is the outer optimizer, and the ordinary steps the workers took are the inner ones. The post credits DiLoCo with this design: AdamW inside (a popular update rule that scales each dial’s step), Nesterov momentum outside (an update rule that keeps pushing in the recent direction), “hundreds of local steps”, and matching fully synchronous training with 8 workers “while communicating 500× less”. Later lessons in this series open that up.

Move 2: replace the global all-reduce by pairs

Even a sync every 50 steps is a global barrier: all must arrive. The second move drops it. Instead of one big average, workers swap with one partner at a time. Spreading news by pairs is called gossip.

The post uses a pattern called butterfly mixing for 8 learners. Number them 0 to 7. In stage 1, cell i swaps with cell i⊕1. In stage 2 it swaps with i⊕2. In stage 3, with i⊕4. After three stages, every cell’s update has reached all 8 cells, “with no all-reduce”. Press the stages below.

Mix in pairs

Cell 0 has a new update (teal). Press Next stage and see which cells hold it after each round of pair swaps.

Pairings i⊕1, i⊕2, i⊕4 as in the post’s figure; here every swap is on time. The post notes real runs use different pairings per fragment and let slow links deliver late, without anyone waiting.

Each cell talks to one partner at a time, so no cell waits for 7 others. A slow link delays only its pair. The post adds that a late update “can still be committed”. An update that arrives after the weights have moved on is called stale, and handling staleness is a core question for such methods.

What it bought

The post reports two results. The two-site run (US and Asia, 9,000 miles) reached about 0.2525 bits per byte against 0.2549 for standard training at the same compute. Bits per byte measures how many bits the model needs per byte of test text, so lower is better. The post puts that at “about 1% lower bits per byte” on both of its evals. And the butterfly run with eight cells at one site “matched the baseline”.

Notice what stays the same: each island still uses its fast network, and all-reduce, inside. Only the slow wire between islands sees the new schedule. That is the post’s position in one line.

In the post’s butterfly mixing with 8 cells, why do three stages of pair swaps reach every cell?

Chapter 9

Field Guide: Numbers, Terms, Code and Sources

Keep the numbers, the words and a runnable ring on one page, and find where to go next

One training step is forward, loss, backward, update (chapter 1). To train one model on many GPUs, each GPU holds a full replica and a shard of the batch, and all of them must end each step with the same update (chapters 2 and 3). The all-reduce pools the gradients. In its ring form, each of N workers sends 2(N−1)/N times the gradient, which is under 2 times however large N grows (chapters 5 and 6). The wire then sets the time: bytes times 8, divided by bits per second (chapter 4). Stragglers and slow wires make every GPU wait (chapter 7). The post trades the per-step sync for one every 50 steps, and the global all-reduce for pair swaps (chapter 8).

The numbers and the terms

ItemValue or meaningWhere from
Model size on the wireparameters × bytes per number: 32 B × 2 = 64 GBPost (32B params); 2 bytes is our assumption
Gradient sizeSame as the modelChapter 1
Gbps to GB per secondDivide by 8: 25 Gbps = 3.125 GB/sArithmetic
Transfer time8 × bytes / bandwidth: 64 GB over 25 Gbps = 20.48 sArithmetic
Ring traffic per worker2(N−1)/N times K: 1.00 (N=2), 1.75 (N=8), 2 at the limitGibiansky 2017
Ring steps2(N−1): N−1 scatter-reduce and N−1 all-gatherGibiansky 2017
Ring against rootThe ring is N times quicker on bandwidthChapter 6
Light in fibre, 9,000 milesAt least 72 ms one way (physics floor)Our calculation
ImageNet in one hourBatch 8,192, 256 GPUs, ResNet-50Goyal et al. 2017
The post’s two-site run160 B300 and 160 GB300, 25 Gbps, sync every 50 steps, 0.2525 vs 0.2549 bits per byteAnil 2026
Butterfly mixing8 cells, 3 stages, each fragment exchanged 6 times per 50 stepsAnil 2026
TermOne-line meaning
GradientOne slope per weight; says which way to turn each dial.
Replica, shardA full copy of the model; a slice of the batch.
SynchronousAll workers stop and agree before each update.
All-reduceEveryone ends with the sum of everyone’s arrays.
Bandwidth, latencyWidth of the pipe in bits per second; time for the first bit.
Straggler, barrierThe slowest worker; the point where all wait.
GoodputShare of time spent on progress that is kept.
Local SGD, pseudo-gradient, outer optimizerSteps taken alone; their average movement; the rule that applies it.
Gossip, stalenessSwapping with a few peers; an update computed from old weights.

A checklist for reading the post

The core as code

This runs. It simulates the ring on 4 workers and counts what each one sends. The count matches 2(N−1)/N times the array: 12 numbers for an array of 8.

pythonimport numpy as np

def ring_all_reduce(arrays):
    """arrays[i] is worker i's gradient (1-D). Returns each worker's copy of the sum."""
    N = len(arrays)
    chunks = [np.array_split(a.astype(float), N) for a in arrays]     # N workers x N chunks
    sent = 0
    for k in range(N - 1):                       # phase 1: scatter-reduce
        out = [chunks[i][(i - k) % N].copy() for i in range(N)]
        for i in range(N):
            chunks[(i + 1) % N][(i - k) % N] += out[i]               # right neighbour ADDS
            sent += out[i].size
    for k in range(N - 1):                       # phase 2: all-gather
        out = [chunks[i][(i + 1 - k) % N].copy() for i in range(N)]
        for i in range(N):
            chunks[(i + 1) % N][(i + 1 - k) % N] = out[i]            # right neighbour OVERWRITES
            sent += out[i].size
    return [np.concatenate(c) for c in chunks], sent / N

g = [np.arange(8) * (i + 1) for i in range(4)]            # 4 workers, 8 numbers each
res, per_worker = ring_all_reduce(g)
print(all(np.allclose(r, sum(g)) for r in res), per_worker)   # True 12.0  (= 2*(4-1)/4 * 8)

Where it sits in the field

The ring is the standard way to sum gradients inside one cluster. Libraries such as PyTorch’s DistributedDataParallel wrap it, and add bucketing and overlap (Li et al. 2020). This lesson is the baseline that low-communication methods leave behind.

Keep going

Sources

All toy numbers on this page (64 GB gradient, 10 s step, random shards and delays) are illustrative and labelled in each device. Written for the Training on Compute Islands series; credit for the post’s ideas and results goes to its author and the Core Automation team.

The takeaway. A data-parallel step is only as fast as the slowest wire it must cross. Inside an island the wire is fast, so sync every step. Between islands it is slow, so sync rarely.

Now try the instrument at the top again. Drag the wire and the sync schedule, and predict each bar before you read it. Then use Teach to explain the ring on a whiteboard.

Data Parallel Training and the All-Reduce
Read the post · Back to Gleams