The Parallelism Zoo

Training a big model means cutting the work across many GPUs. Each way of cutting sends different bytes over the wire, and only a few still work when two sites are linked by 25 Gbps.

Learn what data, tensor, pipeline and expert parallelism and ZeRO/FSDP sharding each send between GPUs, and why a slow link between two sites breaks most of them.

Pick a way of cutting the job, then slide the link from a fast hall to a 25 Gbps line between two continents. Watch how much of each step the GPUs spend doing work. Then we build every piece from zero.

You need no distributed training at all. We explain what a GPU, a gradient and a Gbps are as we go. A little Python helps for the code.

Prerequisite 3 for the series Training on Compute Islands, built for the Core Automation post The Hitchhiker’s Guide to Training on Compute Islands by Rohan Anil (2 November 2026). There are no course slides here: every idea comes from the primary papers named in the Field Guide, re-taught in our own words and devices.

Cut the job, then size the wire

A toy job with a 6.4 billion parameter model on 16 GPUs, 8 in each of two sites, 262,144 tokens per step, every GPU doing 400 trillion useful operations a second. These choices are illustrative. The formulas for the bytes are the papers’ (Chapters 2 to 6). The 25 Gbps link and the 9,000 miles are the Core Automation run; the 145 ms round trip is the physical floor for light in glass over that distance. The two faster links are round numbers we chose.

Chapter 0

Why the Shape of the Cut Matters

See why one thin cable between two buildings decides how you may split a training job

Picture a team that rents 160 GPUs in one building. A few weeks later it finds 160 more GPUs, in a second building, on the other side of the planet. Together they could train a much bigger model. But the two buildings are joined by a single line, and that line is slow.

Core Automation did exactly this. In their post, Rohan Anil describes training one model on 160 B300 GPUs in the US and 160 GB300 GPUs in Asia, about 9,000 miles apart, “over a bidirectional link of 25 Gbps.” His verdict: “It was glorious.” Why was it not a disaster? Because they chose very carefully what to send over that line.

This lesson explains that choice. First we need a few plain words, because the whole subject is built from them.

The words we need

A GPU is a chip that does a huge amount of arithmetic at once. It is the worker. Training a language model means asking GPUs to do trillions of multiplications. A cluster is a room full of GPUs joined by fast cables. The post calls such a group an island: a block of compute that is close together and well connected inside, but far from other blocks.

Where do islands come from? The post says training compute “rarely arrives as one big contiguous block.” It comes as scattered clusters of a few hundred to a few thousand GPUs. Many of them belong to neoclouds, which are newer companies that rent out GPUs by the rack. Power, grid equipment and land are scarce, so there is no one giant hall. There are many small ones.

Now the link. Bandwidth is how much data a link can carry each second. Think of a pipe. Bandwidth is how wide the pipe is. We measure it in bits per second. One Gbps is a billion bits per second. A byte holds 8 bits, so 25 Gbps carries 25 ÷ 8 = 3.125 billion bytes per second, or 3.125 GB/s.

Latency is a different thing: how long one message takes to arrive. In the pipe picture, latency is how long the pipe is. A wide, short pipe is fast in both ways. A message that has to cross 9,000 miles of glass fibre cannot arrive in less than about 72 ms, because light in glass moves at roughly two thirds of its speed in empty space. The round trip, there and back, takes at least 145 ms. No engineering removes that floor.

So a link has two numbers, width and length, and we will need both. Some ways of splitting a job care mostly about width. Others care about length.

Feel the gap

How wide is 25 Gbps? Compare it with the links inside a machine. Move a block of data over each link and watch how long it takes. The default size, 12.9 GB, is the weights of a 6.4 billion parameter model stored in 16-bit numbers. That is the toy model we use through this lesson.

Move a block of data

Each bar is the time to move the block over one link. The scale is logarithmic: each gridline is ten times longer than the last. Drag the block size and compare.

12.9 GB

Illustrative links: inside a server, 3,600 Gbps (450 GB/s, a round number for the fast links between GPUs of one machine); a data centre network card, 400 Gbps; the Core Automation link, 25 Gbps (from the post); a home fibre line, 1 Gbps. Time is size divided by bandwidth. Latency is left out here and comes back in Chapter 8.

At the default size, the fast link inside a server needs 29 ms. The 25 Gbps link needs 4.1 seconds. That is 143 times longer, for the same bytes. If a training step needs a second of arithmetic, a 4-second wait for data is a bad deal. The GPUs sit idle while the wire works.

The central question

Every way of training on many GPUs moves some data between them at every step. The size of that data depends on how you split the job. Some splits send a copy of the whole model’s gradients. Some send a slice of the data flowing through the layers. Some send a message every layer, hundreds of times a step.

On a fast hall network, all of these work, and engineers pick the one that suits the memory. Across a 25 Gbps link, the choice decides whether the GPUs work or wait. That is the point of this lesson. We meet five ways of splitting, and for each one we ask the same two questions. What crosses the wire? How often must everyone stop and wait for it?

The hero above already answers it for a toy job. In the rest of the lesson we earn that answer, one split at a time.

  1. What one training step moves: parameters, gradients, optimizer state, activations, and why one GPU is never enough.
  2. Data parallel: copy the model, split the batch, average the gradients with an all-reduce.
  3. Tensor parallel: cut each matrix across GPUs and sum the pieces, every layer.
  4. Pipeline parallel: give each GPU a slice of the layers and pass activations along.
  5. Expert parallel: put the experts of a sparse model on different GPUs and route tokens to them.
  6. ZeRO and FSDP: shard the memory, and pay with more traffic.
  7. What grows with what: which bytes follow the model size and which follow the batch.
  8. Which survive a slow link: round trips, local steps, and how the Core Automation run cut the job.
  9. Field Guide: the numbers, the terms, the code, the checklist.
A link is rated 25 Gbps. About how many bytes can it carry each second, and what can bandwidth not change?

Chapter 1

What One Training Step Moves

Follow one step of training and count the four kinds of data that could ever need to cross a wire

Imagine you are learning to bake. You have a recipe with 6.4 billion tiny dials: a pinch more salt here, a degree less heat there. You bake a batch, taste it, find out what was wrong, and nudge every dial a little. Then you bake again. Training a language model is that loop, repeated hundreds of thousands of times.

Each repeat is a training step. To see what a wire must carry, we first need to know what is inside one step.

The parts of a step

The dials are the model’s parameters, also called weights: big tables of numbers. We write their count as Ψ (the Greek letter psi). Our toy model has Ψ = 6.4 billion. Each parameter is one number, and in training we store most of them in 16 bits, which is 2 bytes.

The food for the model is text, cut into tokens: small pieces of words. A batch is the group of tokens used in one step. Our toy step reads 262,144 tokens.

Now the step itself has four moves.

  1. Forward pass. The tokens flow through the layers, one layer after another. Each layer turns its input into an output called an activation. For a batch of B tokens and a layer width of h numbers, an activation is a table of shape [B, h]. At the end the model guesses the next token and we compute a loss, a single number for how wrong it was.
  2. Backward pass. We walk back through the layers and ask each parameter: how much did you add to the loss? The answer for every parameter is its gradient. There is one gradient per parameter, so the gradients have the same shape and size as the parameters.
  3. Optimizer update. An optimizer turns gradients into dial turns. The common one, Adam, keeps two extra numbers per parameter: a running average of past gradients and a running average of their squares. This extra memory is the optimizer state.
  4. Repeat with the next batch.

So four kinds of data exist: parameters, gradients, optimizer state, and activations. Every way of splitting a job across GPUs is a choice about which of these four sits where, and which must travel.

Why one GPU is never enough

Start with memory. The ZeRO paper (Rajbhandari et al., 2019) counts it exactly for the standard recipe, where Adam keeps a 32-bit copy of the weights. The weights and the gradients take 2 bytes per parameter each. Adam’s extras take 12 bytes per parameter: a 32-bit master copy of the weights, plus its two running averages, 4 bytes each. The paper writes this as 2Ψ + 2Ψ + 12Ψ = 16Ψ bytes.

2Ψ
The weights in 16-bit numbers: 2 bytes for each of the Ψ parameters.
2Ψ
The gradients, also in 16 bits: 2 bytes each.
KΨ
The optimizer state. For Adam with 32-bit values, K = 12: the master weights, the momentum and the variance, 4 bytes each.
16Ψ bytes
The total memory for the “model state”, before counting any activations.

16 × 6.44 × 109 = 103 × 109 bytes = 103 GB

A top GPU today has about 80 GB of memory. Our 6.4 billion parameter toy needs 103 GB just for its model state. It does not fit on one GPU at all, and we have not yet stored one activation. That is symptom one. Try other model sizes.

Fit the model on one GPU

The tall bar is the memory a model needs: weights, gradients, optimizer state. The dashed line is one 80 GB GPU. Drag the model size.

6.4 B

Formula from the ZeRO paper: 2Ψ + 2Ψ + 12Ψ bytes for mixed-precision Adam. Activations, the cache of each layer’s outputs, come on top and depend on batch size; they are left out. The 80 GB GPU is a round number for a current top accelerator.

The ZeRO paper’s own example: a 7.5 billion parameter model needs 120 GB of model state, which matches 16 × 7.5 = 120. Move the slider to 7.5 and check.

Why the work is not the problem

Memory says we must use many GPUs. Time says the same. The usual rule of thumb is that a step costs about 6 × Ψ operations for each token: 2 for the forward pass and 4 for the backward pass. For 16,384 tokens on each of 16 GPUs, that is 6 × 6.44 × 109 × 16,384 = 6.3 × 1014 operations per GPU. A GPU doing 4 × 1014 useful operations a second needs 1.58 seconds. That number is our yardstick. Whenever a wire makes a step longer than 1.58 seconds, the GPUs are waiting.

Four things that can cross the wire

Now the plan is clear. We have 16 GPUs and four kinds of data. The five splits in this lesson differ in what they send.

Notice the split in this list. The first two send things that scale with the model. The last three send things that scale with the batch. Chapter 7 uses exactly that split.

A model has 10 billion parameters and is trained with mixed-precision Adam. About how much memory does its model state need, before activations?

Chapter 2

Data Parallel: Copy the Model, Split the Batch

Watch four workers add their gradients with a ring, and count exactly how many bytes each one sends

Four chefs each own an identical recipe book. Each one bakes a different batch of cakes and tastes the result. Each finds a different small fix: a bit more sugar, less salt. If every chef applied only their own fix, the four books would drift apart. So the chefs first meet, average their four fixes, and all apply the same average. The books stay identical, and each fix has been learned from four batches instead of one.

That is data parallel training. It is the oldest and simplest split, and it is where the post’s whole story begins.

The recipe

  1. Give every GPU a full copy of the model. Each copy is a replica.
  2. Cut the batch into equal pieces, one piece for each replica. Each GPU runs the forward and backward pass on its own piece. Now every GPU holds a different gradient.
  3. Average the gradients across all GPUs. Every GPU must end up with the same average.
  4. Every GPU applies the same optimizer update. The replicas stay identical.

Why is averaging right? The loss on the whole batch is the mean of the loss on its pieces. The gradient of a mean is the mean of the gradients. So the average of the workers’ gradients is the gradient of the big batch. Nothing is approximated. Data parallel training on 16 GPUs is the same maths as one GPU with a 16 times larger batch.

Look at what crosses the wire. Only step 3 needs the network. And what crosses is the gradient: one number per parameter. So the size is Ψ, the parameter count. It does not depend on how many tokens are in the batch.

The all-reduce

Step 3 has a name. An all-reduce is an operation where every worker starts with its own array and every worker ends with the sum of all the arrays. (To average, divide the sum by the number of workers.)

The obvious way is to send everything to one boss, who adds it up and sends the answer back. With N workers and an array of size Ψ, the boss receives (N − 1) × Ψ numbers. The boss’s cable is the bottleneck. A smarter way is the ring all-reduce: put the workers in a circle, cut each array into N equal chunks, and let every worker talk only to the next worker around the ring. It has two phases.

Run it yourself on four workers. Each starts with four numbers. The device does the real additions.

Run a ring all-reduce

Four workers hold four numbers each, one chunk per number. Press Next step. Teal cells are being sent; a cell turns green when it holds the full sum.

The numbers are made up so that you can check the sums by eye (1, 10, 100, 1000 times 1, 2, 3, 4). The schedule is the standard ring schedule: in reduce-scatter step s, worker i sends chunk (i − s) mod N; in all-gather step s it sends chunk (i + 1 − s) mod N. Every addition is done live in your browser.

Each step moved one chunk, which is one quarter of the array, per worker. There were 3 + 3 = 6 steps. So each worker sent 6 × ¼ = 1.5 times the array. The general rule is 2 × (N − 1) / N times the array. For N = 4 that is 1.5. For N = 1,000 it is 1.998. The ZeRO paper states the result: each phase moves Ψ numbers, so a data parallel step costs 2Ψ of movement per worker.

This is the beauty of the ring. Adding more workers barely changes what each cable carries. And it is also the problem. The size is fixed by the model, so a bigger model means a bigger bill, whatever the batch.

The toy bill

Our toy model has Ψ = 6.44 billion, with gradients in 16 bits. One array is 12.9 GB. Two sites exchanging their gradients each send 12.9 GB to the other, in both directions at once. Inside one hall that is a blink: 0.03 s at 400 GB/s. Over 25 Gbps (3.125 GB/s) it is 4.12 seconds. Each step also takes 1.58 s of arithmetic. So with plain data parallel the GPUs are busy about 1.58 ÷ 4.27 = 37% of the time, after counting one 145 ms round trip.

Symptom: step time triples when the second site joins. Measurement: gradient bytes divided by link speed. Fix: Chapter 8.

In code the whole idea is a few lines:

pythonfor p in model.parameters():
    dist.all_reduce(p.grad)        # sum over all workers
    p.grad /= dist.get_world_size()  # make it an average
optimizer.step()                       # same update everywhere

Real systems group the parameters into big buckets and start the all-reduce for early layers while the backward pass is still working on later layers. That hides some of the wire time behind arithmetic. But it can hide at most as much as the arithmetic takes, so a link slower than the compute still shows through.

In a ring all-reduce over N workers, about how much does each worker send, compared with the size of the gradient array?

Chapter 3

Tensor Parallel: Cut Every Matrix

Split one matrix multiplication across GPUs, and find the single point per block where they must add their pieces

Data parallel needs a full copy of the model on every GPU. What if a single layer is too big even for that? Or you want every GPU to work on the same tokens at once, to finish one step faster? Then you cut the layer itself.

Think of a huge multiplication table that two people must fill in. You can give each person half of the columns. They work side by side and never speak. Cut the other way, by rows, and each person produces only part of every answer, so they must add their parts at the end. Tensor parallel uses both cuts, in a careful order.

A layer is a matrix multiplication

Most of a transformer’s weights are in two kinds of block: attention and the feed-forward block (MLP). The MLP does this to its input X, which has shape [B, h], B tokens with h numbers each:

X
The input: one row of h numbers per token, shape [B, h].
A
The first weight matrix, shape [h, 4h]. It widens each token.
GeLU
A bend applied to each number on its own. It never mixes numbers.
B
The second weight matrix, shape [4h, h]. It narrows each token back.
Z
The output, shape [B, h], passed to the next block.

Megatron-LM (Shoeybi et al., 2019) cuts this as follows. Cut A by columns. Each GPU gets some columns of A and computes the matching columns of the widened result. These pieces do not depend on each other. And because GeLU works on each number alone, each GPU can apply it locally. No talking yet.

Cut B by rows. The rows of B that a GPU holds match exactly the columns of the widened result that it has. So each GPU can multiply its piece by its rows of B. But each result is only a partial answer. The true Z is the sum of the partial answers. That sum is an all-reduce. The paper calls it the g operator: “a single all-reduce operation in the forward pass.” Its mirror, the f operator, is an all-reduce in the backward pass.

Attention is cut the same way. Each head works alone, so each GPU gets some heads. The output projection is cut by rows. The paper’s count for a whole transformer layer is: “two all-reduces in the forward path and two in the backward path.”

What does this buy? Each GPU holds only 1/t of every layer’s weights, so a layer too big for one GPU now fits. And all t GPUs work on the same tokens at once, so one step finishes sooner. The price is that the all-reduce sits in the middle of the computation. The next block cannot begin until the sum arrives. Remember that price. It is the heart of the slow-link story.

Do it with numbers

Take one token with h = 4 numbers and tiny made-up matrices. Choose two or four GPUs. Step through the four moves and watch the sum rebuild the answer.

Split a layer, then add it back

Pick how many GPUs share the layer, then press Next move. The last move is the only one that sends anything.

Toy numbers: one token, h = 4, a 4 × 4 matrix A and a 4 × 4 matrix B with small whole numbers, and ReLU in place of GeLU (it also works on each number alone). Every product and sum is computed live. The cut (columns of A, rows of B, one all-reduce) is the Megatron-LM one.

Look at the last move. Every GPU holds a vector of h numbers that is wrong by itself. Only the sum is right. The all-reduce moves one array of shape [B, h] for each GPU. This is a table of activations, not of weights. So its size depends on the batch, not on the model.

The toy bill

Count it for the two-site job. One step has 262,144 tokens, and h = 4,096. One all-reduce moves 262,144 × 4,096 × 2 bytes = 2.15 GB. A layer has four of them (two forward, two backward). The model has 32 layers. So a step has 4 × 32 = 128 all-reduces, about 275 GB in each direction between the sites.

Compare that with 12.9 GB for data parallel. Tensor parallel sends 21 times more here. And the 128 all-reduces happen in a row, in the middle of the arithmetic. Layer 2 cannot start before layer 1’s sum arrives. Nothing can hide behind them.

Symptom: the GPUs idle for most of the step, and a profiler shows long gaps between layers. Measurement: 275 GB ÷ 3.125 GB/s = 88 s, plus 128 round trips of 145 ms = 18.6 s, against 1.58 s of arithmetic. Fix: never cut a layer across a slow link. Megatron-LM kept its 8-way tensor parallel group inside one machine, where GPUs share a very fast link, and reached 76% scaling efficiency for an 8.3 billion parameter model on 512 GPUs. Tensor parallel is a method for the inside of an island.

In Megatron-style tensor parallel, why can the first matrix be cut by columns with no communication, while the second must be cut by rows and ends with an all-reduce?

Chapter 4

Pipeline Parallel: One Slice of Layers per GPU

Run an assembly line of GPUs, count the idle gaps, and see why this split sends so few bytes

A laundry has a washer and a dryer. If you wait for the first load to finish both before you start the second, one machine always sits empty. Better: when load 1 moves to the dryer, load 2 goes into the washer. After a short start-up, both machines run all the time.

Pipeline parallel training is that laundry. A neural network is a stack of layers. Cut the stack into K consecutive pieces, called stages, and give one stage to each GPU. The first GPU holds layers 1 to 8, the second holds layers 9 to 16, and so on.

What crosses the wire

A token enters stage 1. Stage 1 turns it into an activation and sends that to stage 2. Stage 2 sends its result to stage 3. In the backward pass the gradients flow back the same way. The only thing on any wire is the activation at a stage boundary, with shape [tokens, h], and its gradient on the way back.

GPipe (Huang et al., 2018) says it directly: communication happens only at partition boundaries, so the method scales well even on GPUs without high-speed interconnects. Their Table 3 tests Transformers on GPUs without a fast link. With 32 micro-batches, 2, 4 and 8 stages give throughput of 1, 1.8 and 3.3 times the 2-stage figure. The wire was not the bottleneck.

Count it for our job. One boundary carries 262,144 tokens × 4,096 numbers × 2 bytes = 2.15 GB per step in each direction. Compare: 12.9 GB for data parallel, 275 GB for tensor parallel. And a pipeline needs only one boundary to cross the link between sites.

Why the square-cube law helps

The SWARM paper (Ryabinin et al., 2023) adds a clean argument. Take a layer of width n. The activation at the boundary has n × n entries (per batch of n tokens), so sending it takes time proportional to n2. The matrix multiplication inside the layer takes time proportional to n3. As n grows, the arithmetic grows faster than the data. The paper calls this the square-cube law: “pipeline parallelism naturally grows more communication-efficient with model size.” Doubling the width gives 8 times the work for only 4 times the bytes. Remember this: it is the reason big models can sit on slow links.

The bubble

Now the catch. If we send the whole batch through at once, stage 2 waits while stage 1 works, and stage 1 waits while stage 2 works. At any moment only one GPU is busy. We fix it as the laundry does: cut the batch into M micro-batches, small groups of tokens. Stage 1 starts micro-batch 2 as soon as it has handed micro-batch 1 to stage 2.

The pipeline still needs time to fill at the start and to drain at the end. The idle slots at both ends are the bubble. Derive its size. Let one slot be the time for one micro-batch to pass through one stage. The last micro-batch enters stage 1 at slot M, and then needs K − 1 more slots to reach the last stage. So the forward pass takes M + K − 1 slots. Each stage is busy for M of them. The idle share is

bubble
The share of time a stage sits idle in one step.
K − 1
The idle slots while the pipeline fills and drains. Deeper pipelines waste more.
M + K − 1
The total slots for a forward pass: M micro-batches plus the fill time.

K = 4, M = 8: 3 / 11 = 27% idle.   K = 4, M = 16: 3 / 19 = 16%.   K = 4, M = 32: 3 / 35 = 8.6%.

This matches GPipe’s result, written as O((K − 1)/(M + K − 1)). The paper reports the bubble is negligible once M is at least 4 × K. Try it. Each row is one stage; blue blocks are forward work, purple are backward work (twice as long), and the faint gaps are the bubble.

Fill the pipeline

Rows are GPUs, left to right is time. Drag the number of stages and micro-batches and watch the gaps change.

4
8

The schedule is the simple GPipe one: all forward passes, then all backward passes. A backward block is drawn twice as long as a forward one; the idle share is the same either way. Utilisation is counted from the drawn grid and checked against (K − 1)/(M + K − 1). The 2.15 GB is our toy job’s boundary traffic (262,144 tokens, h = 4,096, 16-bit).

Notice what does not change when you drag: the bytes. The boundary always carries the same 2.15 GB per step. M only changes how that data is cut into smaller messages, and K only changes how many boundaries exist.

Failure modes, in order

The bubble. Symptom: every GPU is idle at the start and end of each step. Measurement: (K − 1)/(M + K − 1). Fix: raise M, until M ≥ 4K, at the price of smaller micro-batches. The slow stage. Symptom: one GPU is always busy while the others wait. Measurement: per-stage time. Fix: rebalance the layers so each stage takes the same time. Memory. GPipe keeps only the boundary activations and recomputes the rest during the backward pass, a trick called re-materialization.

And the slow link? A hop across 9,000 miles costs at least 72 ms one way. The pipeline pays it only while it fills and drains, not for every micro-batch, because while one micro-batch is in flight the next is already being computed. That is why pipeline survives where tensor parallel cannot.

A pipeline has K = 4 stages and M = 12 micro-batches. What share of each stage’s time is idle, and what grows if you add stages without adding micro-batches?

Chapter 5

Expert Parallel: Send Each Token to Its Specialist

Route tokens to experts that live on other GPUs, and count the copies that must cross the wire

A hospital has 256 specialists. A triage nurse looks at each patient and sends them to the 8 specialists who fit best. No patient sees all 256 doctors, so the hospital can employ a huge staff and still treat each patient quickly.

That is a mixture of experts (MoE) model, and it is the kind of model the Core Automation post trained: about 32 billion parameters in total, with an MoE layer in every transformer block, 256 experts and “top-8 routing.” Our lesson on mixture of experts builds the idea in full. Here we need only the plumbing.

The sparse layer

In a normal (dense) transformer, the MLP block sees every token and uses all its weights on it. An MoE layer replaces that one MLP with E smaller MLPs, called experts, plus a tiny network called the router. For each token the router scores all E experts and picks the best k. This is top-k routing. The token goes through only those k experts, and their outputs are added with weights from the router.

Follow the data shapes for N tokens with width h:

  1. Tokens: [N, h].
  2. Router scores: [N, E], one score per expert per token. Keep the top k: indices [N, k].
  3. Dispatch: each token is copied k times, one copy per chosen expert. That is N×k vectors of size h.
  4. Each expert runs its MLP on the copies it received.
  5. Combine: the copies go back to their home token, and are added with the router weights. Result: [N, h] again.

The post calls this “32x sparsity”: the model has 32 times more parameters than any one token uses. Top-8 of 256 experts is 1/32 of them.

Where the experts live

256 experts do not fit on one GPU. Expert parallel puts different experts on different GPUs. Each GPU also holds its own share of the tokens. Now a token on GPU 1 may need an expert on GPU 3. Its vector must travel there and come back.

The operation that does this is an all-to-all: every GPU sends a different chunk of data to every other GPU, all at once. (An all-reduce gives everyone the same answer. An all-to-all is a mail sort: each GPU puts letters for GPU 0, GPU 1 and so on into separate bags.) GShard (Lepikhin et al., 2020) shows the pattern. It puts the experts on different devices, with “MoE dispatch and combine” as two all-to-alls around the expert computation. That gives two all-to-alls per MoE layer going forward, and two coming back.

The GShard team trained a mixture-of-experts translation model beyond 600 billion parameters on 2,048 TPU v3 chips in 4 days. For their layout they found that all-to-all cost grows more slowly than the number of devices: roughly with its square root.

Capacity: the cap on a busy expert

Routers can be lazy. If the router sends most tokens to one favourite expert, that GPU is swamped while the others idle. GShard stops this with an expert capacity: no expert may take more than about 2N/E token copies per batch group (for top-2). A copy that arrives after the expert is full is dropped: it skips the expert and passes on through the residual connection. GShard also adds an auxiliary loss to push the router toward an even spread.

Try it. Four GPUs each hold 8 tokens and 2 experts. Pick k, set the capacity, and tilt the router towards a favourite.

Route the tokens

Left: 32 tokens, 8 on each GPU. Right: 8 experts, 2 on each GPU. Each line is one copy. Teal lines stay on their GPU; warm lines cross the wire. Red crosses mark copies an overfull expert drops.

0%
1.25

Toy: 32 tokens, 8 experts, 4 GPUs, router scores drawn from a fixed random seed. Capacity per expert = capacity factor × (tokens × k) / experts; copies are accepted in token order until an expert is full. At h = 4,096 in 16 bits each copy is 8 KB, so this toy batch moves a few hundred KB; the real step in the two-site job moves 137 GB each way (Chapter 8).

With a flat router and top-2, about three quarters of the copies cross, since a random expert is on another GPU 3 times out of 4. Tilt the router and a few experts overflow; copies are dropped, and quality suffers. That is the second cost of expert parallel: not only bytes, but balance.

The toy bill

For the two-site job: 262,144 tokens, top-2, h = 4,096. Half the copies go to the other site. One all-to-all sends 262,144 × 2 × 4,096 × 2 bytes ÷ 4 = 1.07 GB each way. There are 4 per layer and 32 layers: 128 of them, about 137 GB in each direction, and 128 waits in a row. Over 25 Gbps that is 44 s, plus 18.6 s of round trips. Expert parallel across a slow link looks as bad as tensor parallel, for the same reason: it sits in the middle of every layer.

The Core Automation run avoided it. Each site used “local expert parallelism”: the all-to-alls stayed inside a site, on the fast network, and only the slower exchange crossed the ocean.

In expert parallel training, what exactly crosses between GPUs, and how often per MoE layer?

Chapter 6

ZeRO and FSDP: Share the Memory, Pay in Traffic

Shard the model state across data parallel workers, and see how much memory it saves and what it adds to the wire

Sixteen students share one course. Each student has bought a full photocopy of all 16 textbooks. That is silly: the same 16 books are stored 16 times. A cleverer plan: each student keeps just one book. When a student needs chapter 5 from book 9, they borrow it from the neighbour, read it, and hand it back.

That is the idea behind ZeRO, the Zero Redundancy Optimizer (Rajbhandari et al., 2019), and behind PyTorch’s FSDP, Fully Sharded Data Parallel, which follows the same plan. In plain data parallel (Chapter 2) every GPU keeps the full 16Ψ bytes of model state. ZeRO says: you do not need all of it all the time. Split it into N pieces, called shards, one per GPU, and fetch the missing pieces only when needed.

Three stages

The paper removes the copies in three steps. Each step shards one more kind of state. N is the number of data parallel GPUs.

StageWhat is shardedMemory per GPUTraffic per step
Plain data parallelnothing16Ψ2Ψ
ZeRO-1optimizer state4Ψ + 12Ψ/N2Ψ (same)
ZeRO-2+ gradients2Ψ + 14Ψ/N2Ψ (same)
ZeRO-3 / FSDP+ weights16Ψ/N3Ψ (1.5 times)

The traffic column counts numbers moved per GPU per step, the paper’s own Ψ-units; multiply by 2 for 16-bit values. Why do stages 1 and 2 cost nothing extra? Because an all-reduce already is a reduce-scatter followed by an all-gather, each moving Ψ (Chapter 2). ZeRO-2 keeps the first half, so each GPU ends with the summed gradient for its own shard only. It updates that shard, then runs the second half, an all-gather, to share the new weights. Same two halves, same 2Ψ.

Stage 3 step by step

With the weights sharded too, no GPU holds a whole layer. So for every layer the GPUs do this:

  1. All-gather the layer’s weights from all shards. Each GPU briefly holds the full layer. Run the forward pass for that layer. Throw the gathered weights away.
  2. Repeat for all layers. Each layer was fetched once: Ψ in total.
  3. In the backward pass, all-gather again (another Ψ), compute gradients for that layer, then reduce-scatter them so each GPU keeps only the summed gradient of its shard (Ψ more).
  4. Each GPU updates only its shard with its own slice of the optimizer state.

The total is Ψ + Ψ + Ψ = 3Ψ, which the paper states as “1.5x compared to the baseline.” And the waits multiply: three collectives per layer, one after the other, unless a system fetches layer ℓ + 1 while layer ℓ computes.

Shard the state

Each bar is the memory one GPU needs. The dashed line is an 80 GB GPU. Drag the model size and the number of GPUs.

6.4 B
16

Formulas from the ZeRO paper: 16Ψ for plain data parallel, 4Ψ + 12Ψ/N, 2Ψ + 14Ψ/N, and 16Ψ/N, with traffic 2Ψ, 2Ψ, 2Ψ and 3Ψ numbers. The paper’s own check: 7.5 billion parameters on 64 GPUs need 120 GB plain and 1.9 GB with all three stages. Activations are not counted. Traffic here is in bytes for 16-bit values.

Try 7.5 billion parameters and 64 GPUs. The last bar drops to 1.9 GB, matching the paper. Now the toy job: 6.4 billion parameters on 16 GPUs. Plain data parallel needs 103 GB and does not fit. ZeRO-3 needs 6.4 GB, and sends 3 × 6.44 billion × 2 bytes = 38.7 GB per GPU per step. That is memory made cheap and bytes made dear.

Real FSDP code tries to hide these fetches. While layer ℓ computes, the system already gathers the weights of layer ℓ + 1 on a second stream. If a gather takes less time than a layer’s arithmetic, the wait disappears. Inside a hall that often works. The condition matters, though: the wire must be at least as fast as the arithmetic is slow. Keep that condition in mind. It is exactly what fails across a 25 Gbps link.

Where it fits an island

Inside a hall, FSDP is the standard tool. It lets a model that does not fit on one GPU train as if it were data parallel, and the network can usually keep up. Across a slow link it is a bad choice. In the two-site job, each site holds half of the shards. Say the collectives are smart about sites: the other site’s half crosses the link once, then spreads inside the hall. That half is Ψ/2 numbers, which is Ψ bytes, and it crosses three times a step (two all-gathers and one reduce-scatter). So each site sends about 3Ψ bytes = 19.3 GB per step in each direction. Over 25 Gbps that is 6.2 s, plus 96 waits of 145 ms (13.9 s) for the per-layer collectives, against 1.58 s of arithmetic. The GPUs would be busy about 8% of the time. A naive collective that ignores sites sends far more.

Symptom: a run that works on one site slows ten-fold when a second site joins. Measurement: 3Ψ per step divided by link speed. Fix: shard only inside each site, and send only a thin summary across (Chapter 8).

For a fuller treatment of the memory side, see the lessons on parallelism, pipelines and FSDP and distributed training.

Which statement about ZeRO stage 3 (FSDP) is right?

Chapter 7

What Grows With What

Work out which knob, a bigger batch or a wider model, makes each split cheaper on the wire

A friend tells you: “Slow link? Just use a bigger batch.” Another says: “Just train a wider model, it communicates less.” Each is right about one kind of split and wrong about the others. We can see why with a little algebra, and then play with it.

The one number that matters

For any split, ask: how many seconds does the wire need for each second of arithmetic? Call it the wire-to-compute ratio. If it is below 1, the transfer can hide behind the computing. If it is above 1, the GPUs wait.

The arithmetic per GPU in a step is 6Ψ × tokens ÷ (16 GPUs × speed F), from Chapter 1. Write it as c. The bytes depend on the split. Let BW be the link speed in bytes per second, h the width, L the layers, T the tokens in the step, and Ψ = 12 L h2.

ratio
Seconds of wire per second of arithmetic. Below 1 means hidden; above 1 means waiting.
2Ψ / BW
Time to send one gradient array of Ψ numbers in 16 bits (2 bytes each) over a link of BW bytes per second.
6ΨT / 16F
Time for the arithmetic: 6Ψ operations per token, T tokens, split over 16 GPUs that each do F operations a second.
16F / (3 T BW)
What is left. Ψ cancels! The model size is gone; only the tokens T remain.

16 × 4×1014 ÷ (3 × 262,144 × 3.125×109) = 6.4×1015 ÷ 2.46×1015 = 2.6

So data parallel needs 2.6 seconds of wire per second of arithmetic at our default batch. The only knob that moves it is T. Double the batch, halve the ratio. At 16 times more tokens the ratio is 0.16, and the gradient exchange hides. The same holds for ZeRO-3, whose bytes also scale with Ψ.

Now tensor parallel. Its bytes are 4 all-reduces × L layers × (T × h × 2 bytes). Divide by the same arithmetic:

ratiotensor = (8 L T h / BW) ÷ (72 L h2 T / 16F) = 16F / (9 h BW) = 6.4×1015 ÷ (9 × 4,096 × 3.125×109) = 55.6

This time L and T both cancel, and h stays. Double the width, halve the ratio. A bigger batch does nothing, because the bytes grow with the batch just as fast as the arithmetic does. Pipeline and expert parallel behave the same way, since they also send activations of size T × h. This is the square-cube law of the SWARM paper, now with numbers: activation bytes grow like h while arithmetic grows like h2, per token.

Pipeline and expert follow the same pattern. Pipeline sends one table of T × h numbers: 2.15 GB ÷ 3.125 GB/s = 0.69 s, and 0.69 ÷ 1.58 = 0.43. Expert sends 4 × 32 all-to-alls of half a table each: 137 GB ÷ 3.125 GB/s = 44 s, and 44 ÷ 1.58 = 27.8. Notice that these are bandwidth-only ratios. Waiting for round trips comes on top, and Chapter 8 adds it.

Find the knob that helps

Each bar is seconds of wire per second of arithmetic on the 25 Gbps link, on a log scale. The line at 1 is break-even. Drag batch and width and see which bars move.

262,144
4,096

Same toy job as the hero: 16 GPUs in two sites, 32 layers, 400 trillion operations a second per GPU, the 25 Gbps link (3.125 GB/s each way), 16-bit values, top-2 experts, bandwidth only (latency is Chapter 8). The ratios use the formulas of Chapters 2 to 6. Tokens run from 65,536 to 4,194,304; width from 1,024 to 16,384.

Slide the batch from 65,536 to 4 million tokens. Only the first two bars fall. Slide the width. Now only the last three fall, and they fall as 1 over h. Even at h = 16,384, tensor parallel still needs about 14 seconds of wire per second of arithmetic. Width alone does not rescue it.

What this teaches

A batch is the lever for splits whose bytes follow the model: data parallel and ZeRO. A wide model is the lever for splits whose bytes follow the activations: tensor, pipeline, expert. Pipeline has the smallest ratio of all (0.43 by default) because it crosses one boundary, not every layer.

There is a catch for the batch lever. Batches cannot grow forever: past some size, bigger batches stop improving the model, so each token teaches less. That limit is why the later lessons look at sending the gradient less often rather than only making the batch bigger.

Symptom: you doubled the batch to fix a slow run and nothing changed. Measurement: check which split you use and whether its bytes depend on T. Fix: for tensor, pipeline and expert, move the link out of the loop instead.

You quadruple the tokens per step. Which wire-to-compute ratio drops to a quarter?

Chapter 8

Which Splits Survive a Slow Link

Cut the two-site job every way, count width and length for each, and find the recipe that keeps the GPUs busy

Two warehouses sit on opposite sides of the planet. Inside each, workers shout to each other all day without trouble. Between them runs one courier route. A manager asks: which tasks may we split across the two warehouses? The answer comes from two questions. How much must the courier carry? And how many times must someone stop work and wait for an answer?

Those are the two numbers of a link from Chapter 0: width (bytes divided by bandwidth) and length (waits times the round trip). Here is the whole zoo, scored on both, for the two-site toy job on the 25 Gbps link.

Split across the linkEach site sends per stepWaits in a rowWire time per stepGPUs busy
Tensor parallel275 GB128106 s1.5%
Expert parallel137 GB12862.5 s2.5%
ZeRO-3 / FSDP19.3 GB9620.1 s7.9%
Data parallel, every step12.9 GB14.27 s37%
Pipeline parallel2.15 GB10.83 s94%

Read the table from the bottom. Only pipeline parallel passes as it stands. Its bytes are small, and it waits about once. Its 94% is our illustrative setup: two stages, one per site, and 16 micro-batches, so the bubble adds one sixteenth to the arithmetic time (1 ÷ 1.0625 = 94%). The other three that cut layers or shards fail on both counts. And data parallel is the interesting one: it fails only on width. It waits once per step. Its problem is the 12.9 GB, and we can attack bytes in two ways.

Two ways to shrink the bill

Send less often. Let each site run H steps on its own, with no talking, then exchange. The bytes per step fall by H. The two replicas drift apart for H steps, so the update needs care (that is the subject of the next lessons: local SGD and model averaging, and DiLoCo). In the Core Automation run, sites “exchanged updates on a 50-step schedule.”

Send smaller things. Compress the update before it goes. The post says exchanged values were “compressed with stochastic rounding plus error feedback,” so the rounding error is not lost but added to the next message. See communication compression. We do not claim a ratio for their run; the 4× and 16× below are illustrative dials.

Now try it. Pick the link and the cut. For data parallel, turn the two dials and see when the exchange hides behind the arithmetic.

Shrink the exchange until it hides

Top bar: arithmetic in one window. Bottom bar: the link time for what must cross in that window. If the bottom bar is shorter, the GPUs never wait for it. Choose a split, a link, then turn the dials (they act on data parallel).

1
none

The two-site toy job of the hero: 6.4 billion parameters, 16 GPUs, 1.58 s of arithmetic per step. Data parallel sends 2Ψ bytes (12.9 GB) per sync divided by the compression; H takes the values 1, 2, 5, 10, 20, 50, 100, 200, 500. For tensor, ZeRO-3, pipeline and expert the bar is one step, and the dials do nothing. A step is counted as the longer of arithmetic and wire time when the transfer can overlap with computing (data, ZeRO-3, pipeline), and as their sum when it sits in the middle of every layer (tensor, expert). Compression ratios are illustrative dials, not numbers from the post.

With the 25 Gbps link and data parallel, set H to 50. The exchange now costs 12.9 GB ÷ 3.125 GB/s = 4.1 s per 79 s of arithmetic. It hides, and the GPUs are busy all the time. Pull H back to 1 and add 16× compression: 0.8 GB per step, still shorter than 1.58 s. Either dial alone can fix the width. Together they leave a lot of slack for the things a real run adds: late messages, retries, and the 145 ms round trip.

Shrinking the average is not the whole job. A step is only as fast as its slowest message, so the post also rewrote its networking layer for tail latency, the time of the slowest few transfers. It staggered updates so workers did not burst together, split every payload into chunks that any healthy connection could claim, and re-requested only the missing pieces when a write stalled. Each idea is simple. The gain came from using them together.

The recipe, in the post’s words

The post states the plan as a position: “Within an island of compute, use the fast interconnect aggressively. Across islands of compute, exchange updates on a slower schedule.” Now you can read that sentence precisely. Inside a site, use tensor, expert and ZeRO-style splits. The inside link is wide and short, and these are the splits that fit a model into memory. Across the link, use data parallel with rare, small exchanges. That is exactly what the run did: each site trained on its own data shard with local expert parallelism and synced every 50 steps.

The post sorts the literature into two families that match the two survivors. Data-parallel methods, in its words, “cut how often and how much replicas talk,” such as DiLoCo, DisTrO and DeMo. Model-parallel methods split one model across participants that pass activations to each other, such as SWARM, Node0 and Agora. Those are pipelines, the other row of our table that stays green. Neither family sends a tensor-parallel or expert-parallel message over the slow link.

Symptom, measurement, fix, one last time. Symptom: a multi-site run uses 3% of its GPU time. Measurement: bytes divided by bandwidth, plus waits times round trip, against the arithmetic per step. Fix: move every high-traffic, high-wait split inside the island, and let only the thin one cross.

Two sites are linked by 25 Gbps. Which design is the best fit for the link?

Chapter 9

Field Guide

Keep the numbers, the terms, the code and a checklist for choosing a split

Five ways to split a training job send five different things over the wire. Data parallel sends gradients, once per step. ZeRO-3 sends weights and gradients in pieces, three times per layer. Tensor parallel sends activation sums, four times per layer. Expert parallel sends token copies, four times per MoE layer. Pipeline parallel sends activations, once per stage boundary. On a slow link between sites, width and length both matter, and only pipeline and rarely-synced data parallel survive.

The numbers

WhatNumberSource
Model state, mixed-precision Adam2Ψ + 2Ψ + 12Ψ = 16Ψ bytes (7.5 B parameters: 120 GB)ZeRO paper
ZeRO traffic per step2Ψ (plain, ZeRO-1, ZeRO-2); 3Ψ for ZeRO-3, 1.5 timesZeRO paper
ZeRO-3 memory16Ψ/N: 7.5 B parameters on 64 GPUs need 1.9 GBZeRO paper
Tensor parallel, one transformer layer2 all-reduces forward, 2 backwardMegatron-LM
Tensor parallel at scale8.3 B parameters, 512 GPUs, 8-way, 76% scaling efficiencyMegatron-LM
Pipeline bubble(K − 1)/(M + K − 1); negligible for M ≥ 4KGPipe
Pipeline without fast linksM = 32: throughput 1, 1.8, 3.3 for 2, 4, 8 stagesGPipe, Table 3
Expert parallel scale600 B+ parameters, 2,048 TPU v3, 4 days; all-to-all cost grows about as the square root of devicesGShard
Square-cube lawcompute grows as n³, activation bytes as n²SWARM
The Core Automation run160 + 160 GPUs, 25 Gbps, ~9,000 miles, 32 B MoE (256 experts, top-8), sync every 50 stepsThe post
Their result at equal computeabout 0.2525 bits per byte two-site against 0.2549 standardThe post
Light over 9,000 miles of glassat least 72 ms one way, 145 ms round tripour arithmetic: about 14,500 km at 200,000 km/s
Toy job, bytes each site sends per stepdata 12.9 GB; ZeRO-3 19.3 GB; tensor 275 GB; expert 137 GB; pipeline 2.15 GBChapters 2 to 6 (illustrative job)

The terms

TermIn plain words
Bandwidth, GbpsHow many bits a link carries each second. 25 Gbps is 3.125 GB/s.
Latency, round tripHow long a message takes to arrive, there and back. Distance sets a floor.
IslandA group of GPUs that are close together and well connected inside, far from other groups.
ReplicaOne full copy of the model on one worker.
All-reduceEvery worker ends with the sum of everyone’s array. Cost about 2 times the array, whatever N.
Reduce-scatter, all-gatherThe two halves of an all-reduce: each worker gets one summed piece; then everyone shares the pieces.
All-to-allEvery worker sends a different chunk to every other worker. The mail sort of expert parallel.
Micro-batch, bubbleA slice of the batch that keeps the pipeline full; the idle gaps while it fills and drains.
Expert, router, top-kOne of many small MLPs; the network that scores them; the k best chosen for each token.
ShardOne piece of a tensor kept by one worker. ZeRO and FSDP shard the model state.

The core as code

Each split is a few lines of collectives. This is a sketch: x, A_cols, B_rows and the layer helpers stand for whatever your model code holds.

pythonimport torch, torch.distributed as dist

# 1 Data parallel (Ch 2): average the gradients, one all-reduce of size Psi
for p in model.parameters():
    dist.all_reduce(p.grad); p.grad /= world

# 2 Tensor parallel MLP (Ch 3): cut A by columns, B by rows, one all-reduce per block
y = torch.relu(x @ A_cols)            # [B, 4h/t], no talking
z = y @ B_rows                       # [B, h], a partial answer
dist.all_reduce(z)                    # the g operator: sum the partials

# 3 Pipeline (Ch 4): only the boundary activation moves
if stage > 0: dist.recv(x, src=rank - 1)
y = my_layers(x)
if stage < K - 1: dist.send(y, dst=rank + 1)

# 4 Expert (Ch 5): dispatch copies to the experts' GPUs, then bring results home
dist.all_to_all_single(recv_buf, send_buf)      # dispatch
out = run_local_experts(recv_buf)
dist.all_to_all_single(back_buf, out)           # combine

# 5 ZeRO-3 / FSDP (Ch 6): fetch a layer, use it, drop it; keep only your shard's gradient
dist.all_gather_into_tensor(full_w, shard_w)
y = layer(x, full_w); del full_w
dist.reduce_scatter_tensor(grad_shard, full_grad)

# What each site sends per step across the link (Ch 8), bytes, 16-bit values
def bytes_across(split, psi, L, h, tokens, H=1):
    S = tokens * h * 2                      # one activation table
    return {"data": 2 * psi / H, "zero3": 3 * psi, "tensor": 4 * L * S,
            "pipeline": S, "expert": 2 * L * S}[split]

A checklist for choosing

  1. Does the model state (16Ψ) fit on one GPU? If yes, start with plain data parallel.
  2. If not, shard with ZeRO or FSDP, or cut layers with tensor or pipeline parallel, but inside one island.
  3. For every split, write down bytes per step and waits in a row. Divide bytes by bandwidth. Add waits times round trip.
  4. Compare with the arithmetic per step. A split whose wire time is above it will leave GPUs idle.
  5. Across a slow link, allow only pipeline, or data parallel with a sync every many steps and compressed updates.
  6. Raise the batch to help splits whose bytes follow the model; raise the width to help splits whose bytes follow activations.

Where it sits in the field, and where to go next

Our foundations: distributed training, parallelism, pipelines and FSDP, distributed training on small devices, mixture of experts and optimization and backprop. In this series: data parallel and all-reduce in more depth, bandwidth arithmetic, local SGD and model averaging, communication compression, DiLoCo and training on compute islands. The older asynchronous idea of Downpour SGD is in DistBelief, and the large-scale all-reduce in Terascale Linear Learning.

Sources used for this lesson, all primary: Rajbhandari et al., ZeRO: Memory Optimizations Toward Training Trillion Parameter Models (arXiv 1910.02054); Shoeybi et al., Megatron-LM (1909.08053); Huang et al., GPipe (1811.06965); Lepikhin et al., GShard (2006.16668); Ryabinin et al., SWARM Parallelism (2301.11913); and Rohan Anil, The Hitchhiker’s Guide to Training on Compute Islands, Core Automation, 2 November 2026. Quotations are brief and credited. The toy job, its bandwidth arithmetic and every device are ours.

The takeaway. Every way of splitting a training job is a decision about what travels. Gradients follow the model. Activations follow the batch. A slow link punishes anything that travels often, and anything that travels in the middle of a layer. So keep the chatty splits inside the island, and let only a thin, rare exchange cross.

Now press Teach and explain from memory what crosses the wire in each of the five splits, and why only two survive 25 Gbps. Then go back to the hero, pick tensor parallel, and slide the link until the bar turns green.

Compute Islands 03: The Parallelism Zoo
The Core Automation post · Back to Gleams