Decentralized and Gossip Training

Eight copies of a model learn apart. Then the copies average in pairs, one partner per round. After three rounds all eight agree, with no all-reduce and no central server.

Learn how many machines can agree on one model without a boss and without a single giant synchronised step: parameter servers, stale gradients, neighbours, gossip and the butterfly.

Pick a way to mix, then press Step a few times. Compare Alone, Ring, Random pairs, Butterfly and All-reduce. Watch the spread between the eight cells and the hops each round costs. Then we build, piece by piece, everything underneath: the parameter server, asynchronous SGD, decentralized SGD, gossip, mixing time and the butterfly schedule.

You need an average (add the numbers, divide by how many) and the idea of a model copy that learns from its own data. We build the rest from zero.

Prerequisite 08 of 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). Every idea is re-taught here in our own words and devices. It builds on data parallelism and all-reduce.

Mix eight cells

Toy numbers: each cell starts with a number (8, 2, 6, 1, 7, 3, 5, 4), standing for one model parameter, and the true average is 4.50. “Spread” is how far the cells sit from that average, as a root mean square. Ring uses weight 1/3 on self and each neighbour, as in Lian et al. (2017). Random pairs draws a fresh random matching each round. Butterfly pairs cell i with i XOR 1, then 2, then 4. Hops count the sequential message steps; a ring all-reduce needs 2(n−1) = 14 of them.

Chapter 0

Why Nobody Should Have to Wait

See why a training run spread over distant machines cannot afford one big, shared moment of agreement, and what to do instead

Picture eight rented machine rooms in eight cities. Each room holds a few hundred GPUs. Each room trains its own copy of the same neural network, and every copy reads different pages of the same pile of text. After a minute, the eight copies have learned eight slightly different things. Left alone, they would drift apart into eight different models. The goal is one model that has learned from all the pages.

Some words first, because the rest of the lesson uses them. A replica is one full copy of the model. The Core Automation post calls a replica that trains by itself a learner or a cell, and so do we. The model’s numbers are its parameters. To make the copies agree means to give every cell the same parameters again. The simplest way to agree is to average: add the numbers from all cells and divide by the count.

Averaging eight copies sounds easy. In one building it is. The machines share a very fast network, and a standard routine called all-reduce (every cell sends and receives until all of them hold the average) takes a fraction of a second. The lesson on data parallelism and all-reduce builds that routine from zero. Here we only need one fact about it: every cell must take part, and every cell must wait until the slowest one is done.

Why islands exist at all

The post opens with a plain fact. Training compute rarely arrives as one big block. The market sells it in pieces: a few hundred to a few thousand GPUs here, a few thousand there, spread across many neoclouds, the newer companies that rent out GPUs. Together the pieces are large. The hard limits are power, grid equipment and land, not chips. A GPU that sits in a half-built data centre cannot work. The post quotes the phrase stranded compute for hardware that exists but cannot be put to good use.

Some of that waste is physical, and software cannot fix it. The rest is a software problem: a healthy cluster is useless to a job that wants one large, uniform, never-failing cluster. That second part is the target. If the training method tolerates slow links and missing machines, many small islands can add up to one big run.

What changes between buildings

The post trained one model across two sites about 9,000 miles apart, joined by a link of 25 Gbps. Bandwidth is how many bits a link carries each second, and Gbps means a billion bits per second. Inside a building, links run many times faster. A link between cities also has high latency, the time one message needs to arrive even if it is tiny. A message across the world cannot arrive faster than light travels, and real cables are longer than a straight line.

The post calls such sites compute islands: pools of GPUs that are fast inside and slow between. It argues that much of the world’s compute sits in scattered islands, and that a training method should use the fast links aggressively inside an island and exchange updates on a slower schedule between islands. This lesson covers one family of tools for that job: methods in which the cells agree without a global, blocking, everybody-waits step.

One more word. A straggler is a cell that is slower than the rest, because of a busy machine, a weak link or a failing disk. In a global all-reduce, one straggler slows all the others to its pace. Try it below. Seven cells run at full speed. Slow down the eighth and see what each method does with the other seven.

Slow one cell down

Each bar is the number of training steps one cell finishes in 60 seconds. Cell 5 is the straggler. Drag how many times slower it is, then compare the two ways of working.

4.0×

Illustrative: a healthy cell finishes 1 step per second, and agreement itself costs no time, so the figure isolates the cost of waiting. “Nobody waits” means each cell keeps stepping at its own pace and folds in a partner’s result whenever it arrives. Whether that keeps the copies close enough is the question of Chapters 3 to 9.

With a straggler 4 times slower, the all-reduce run finishes 15 steps per cell in the minute, 120 across all eight cells. The no-wait run finishes 60 steps on each of seven cells and 15 on the slow one: 435 in total, 3.6 times as many. Nothing is free in the second run, though. The copies no longer hold identical numbers at every step. The rest of this lesson is about how far apart they drift and how quickly pairs of cells pull them back together.

A global step has three costs. It makes everyone wait for the slowest cell. It can abort when a single link fails, and then the whole step restarts. And it moves a lot of bytes at one moment, all at once, over the same links. The methods in this lesson attack the first two directly. They trade a little exactness for a lot of steadiness.

The road

We start with the oldest design, one central machine that holds the model, and climb to the pairwise exchange from the post. Each step removes one thing the previous design needed: first the shared moment, then the central machine, then the guarantee that every cell hears every other cell.

  1. Agreeing on one number: what the cells must do, and how to count the cost.
  2. The parameter server: one central machine holds the model, and the workers pull and push.
  3. Asynchronous SGD and stale gradients: nobody waits, and the price of old information.
  4. Decentralized SGD: no central machine, each cell talks to its neighbours.
  5. Gossip averaging: random pairs, and the number that says how fast they agree.
  6. Mixing time: why rings are slow and random pairs are not.
  7. Butterfly mixing: pairs chosen in a pattern, and exact agreement in three rounds.
  8. The post’s eight-learner run: fragments, a delay and a half-and-half blend.
  9. When a link or a cell fails: weaker mixing, not a stopped run.
  10. The whole lesson on one page: numbers, code, and where to go next.
One of eight cells runs 4 times slower than the others. Why does a global all-reduce every step waste so much work?

Chapter 1

Agreeing on One Number

Count who must talk to whom when many machines want the same average, and see why the busiest machine sets the pace

Four friends share a rented house. Each of them has a number in mind: how much they think the electricity bill should be. They want one fair number, the average, and nobody wants to be the boss. How do they get it?

They could all phone one friend, who adds the four numbers, divides by four and phones the answer back. That is one person doing all the work, and if that friend is asleep, nothing happens. They could all phone each other, which is six calls and a lot of busy signals. They could stand in a ring and pass numbers to the left. Every plan works. They differ in who carries the load, and in how many rounds of talking it takes.

Training a model on many machines is the same puzzle with bigger numbers. Each cell holds millions or billions of parameters, and the cells want the same average. The shape of the talking plan is called the topology: a picture with cells as dots and links as lines between pairs that talk directly. The number of links at one dot is its degree.

The target: one average

Write the number each of the n cells holds as x1 up to xn. The average is what every cell should hold at the end.

x̄
The average, also called the mean. Every cell should hold this at the end.
1/n
One over the number of cells. It turns a total into a share.
∑i=1n
Add up the terms for cell 1, cell 2, and so on to cell n.
xi
The number that cell i holds now. In a real run this is one parameter, or a whole list of them.

(8 + 2 + 6 + 4) / 4 = 5

A real model has billions of such numbers, and the same plan averages every one of them in the same way. The hero at the top of this page uses eight cells holding 8, 2, 6, 1, 7, 3, 5 and 4. Their average is 36 / 8 = 4.5.

To measure how far the cells are from agreeing, we use the spread: take each cell’s distance from the average, square it, average the squares and take the square root. Spread 0 means every cell holds the same number. The eight starting numbers have a spread of 2.29. Everything in this lesson tries to push that number towards zero quickly and cheaply.

Four plans, and who carries the load

Here are the four plans that matter for the rest of the lesson.

  1. Star. One central machine, the server, links to every worker. All numbers pass through it. This is the plan of Chapter 2.
  2. All-to-all. Every cell links to every other cell. Nobody is special, but the number of links grows with the square of n.
  3. Ring. Cells stand in a circle and talk only to the two neighbours. Chapter 4 uses it.
  4. Butterfly. Cell i links to cell i with one binary digit flipped. With 8 cells there are 3 such partners per cell. Chapter 7 builds it.

Two numbers describe the cost of a plan. The first is the total number of links. The second is the load on the busiest node: the cell with the most links, since it must send and receive the most. Lian and co-authors make this second number the centre of their 2017 paper on decentralized training, because it sets the speed when bandwidth is low. A server with 64 workers must handle 64 streams at once. A cell on a ring handles 2.

Use the device to count both numbers. Pick a plan and a size, and watch which dot lights up as the bottleneck.

Count the links

Dots are machines, lines are links. The purple dot is the star’s hub, the busiest machine; in the other plans every machine carries a similar load. Choose a plan, then drag the number of workers from 4 to 32.

8

Exact counts, not measurements. Star: n links, hub degree n (the hub is one extra machine). All-to-all: n(n−1)/2 links, every degree n−1. Ring: n links, degree 2. Butterfly: n log2(n)/2 links, degree log2(n); n is a power of two so every cell has a partner at every stage.

With 8 workers the star has 8 links, but one machine handles all 8. The ring has the same 8 links, spread so that each machine handles 2. The butterfly needs 12 links, and each machine handles 3. At 32 workers the star’s hub handles 32 links, all-to-all gives every cell 31, the ring still 2, and the butterfly 5. The ring and the butterfly keep the load small because the load follows the number of neighbours, not the number of machines.

A small load is not a free win. A ring needs many rounds of passing before the news from one side reaches the other. The star gets exact agreement fast, but through one overloaded door. The butterfly sits between: few neighbours, and exact agreement in log2(n) rounds. Chapters 5 to 7 put numbers on that trade.

One more distinction will come back in every chapter. A plan is exact when, after it finishes, every cell holds precisely the average. The all-to-all plan and the butterfly are exact. A plan is approximate when it only brings the cells closer, round after round. The ring and random pairs are approximate. Exactness costs coordination, so the real question is how close is close enough, and how soon.

A star with 64 workers and a ring with 64 workers both use 64 links. Why can the ring still be much faster on a slow network?

Chapter 2

The Parameter Server

Follow one central machine that holds the model while many workers fetch it, improve it and send back changes

A head chef keeps the one true recipe book. Forty cooks work at forty stoves. Each cook walks to the chef, copies the current recipe, cooks a batch, notes how the recipe should change, and walks back with the note. The chef edits the book. Nobody else ever writes in it. This is the oldest and simplest plan for training on many machines.

To see the data flow we need a little vocabulary. Training a network means nudging its parameters to make a number called the loss smaller; a lower loss means better predictions. The nudge is computed from a batch of training examples. The gradient is a list with one number per parameter. It says which way to move each parameter to lower the loss. Stochastic gradient descent (SGD) repeats one move: subtract the gradient, scaled by a small number called the learning rate, from the parameters. The lesson on optimization and backprop builds this from zero.

One round trip

The chef in a computer is the parameter server: a machine, or a group of machines, that stores the current parameters and applies updates. The cooks are workers. Each worker holds a full replica of the network. Dean and co-authors at Google built this plan in 2012 for networks with over a billion parameters, and drew it in their figure 2. Here is one round trip for one worker:

  1. Pull. The worker asks the server for the current parameters w. The reply is one list of P numbers.
  2. Compute. The worker runs its mini-batch through the network and computes the gradient g, another list of P numbers.
  3. Push. The worker sends g to the server.
  4. Apply. The server computes w ← w − η g, where η is the learning rate.

The lesson’s earlier cousin is even simpler. Zinkevich and co-authors in 2010 let each machine train alone on its own share of the data and averaged the finished models once at the end. That is one conversation for the whole run. The parameter server talks every step, so it stays much closer to ordinary SGD. The price is traffic.

It helps to see the sizes. Say the model has P = 1,000,000,000 parameters. The gradient is a list of that many numbers, written [P] in shape notation, where the square brackets give the length. In 16-bit numbers, two bytes each, the list takes 2 GB. A pull returns the same 2 GB. So one worker moves 4 GB per round trip, and 40 workers move 160 GB through the server in the same round. The server applies one subtraction to each of the P numbers per push, which a modern machine does in a blink. The network is the slow part, not the arithmetic.

It also helps to see why a full parameter server is needed at all. Zinkevich’s plan of averaging once at the end is cheap in traffic, and his analysis covers gentle, convex problems. A deep network is not gentle: models trained alone can end in different valleys, and the average of two valleys can be worse than either. Talking more often keeps the workers in the same valley. That is the whole tension of this lesson: talk often enough to stay together, rarely enough to stay fast.

The server is a door

Every worker pushes P numbers and pulls P numbers each round. A model with one billion parameters stored in 16 bits is about 2 GB, so each worker moves 2 GB up and 2 GB down. The server must take in the pushes from all the workers. Its network link is a single door, and the width of that door is its bandwidth.

Dean and co-authors answered with sharding: split the parameters across many server machines. Their text gives the example of 10 shards, each storing and updating 1/10th of the parameters. A worker now talks to every shard, but each conversation carries only a tenth of the list. The doors work in parallel.

Try it. The worker in this device computes for 2 seconds per step. The link into each server shard carries 25 Gbps, the figure from the post’s two-site link. Add workers, grow the gradient, and add shards.

Crowd the server’s door

Top: workers around one server. Bottom: how long a worker computes, against how long the server link needs to take in every gradient. When the purple bar is longer, workers wait.

8

Illustrative arithmetic: time on the server link per step = workers × (gradient size / shards) × 8 bits / 25 Gbps; a worker computes for 2.0 s per step; pulls use the opposite direction of the link and are not counted. Dean et al. (2012) describe the sharding; the 2 s and the sizes are assumptions chosen for round numbers.

Start at 8 workers, 1 GB, one server. The link needs 8 × 1 GB × 8 bits / 25 Gbps = 2.56 s per step, and a worker computes for only 2.0 s. The workers wait 0.56 s of every 2.56 s, about 22%. Raise the workers to 64 and the link needs 20.5 s: the workers are busy only 9.8% of the time. Sixteen shards bring that 20.5 s down to 1.28 s, and the workers are busy again, since 2.0 s of compute is now the longer bar.

Sharding solves the door, but not the distance. Every pull and every push still crosses the whole network between worker and server. If the workers sit in one building, that is cheap. If a worker sits 9,000 miles away behind a 25 Gbps link, each round trip pays the full delay. The star also has a single point of trouble: the server group must stay up, and every worker must be able to reach it. Chapter 4 removes the server entirely.

A parameter server with one machine slows down as workers join. Which change from the Dean et al. design widens the door without changing the algorithm?

Chapter 3

Asynchronous SGD and Stale Gradients

Let every worker run at its own speed, and measure what old information does to a step

Back to the kitchen. The head chef used to wait until all forty cooks had reported before changing the book. Now the chef changes the book the moment any one note arrives. Fast cooks report often, and slow cooks no longer hold anybody up. There is a catch. A cook who copied the recipe a while ago may report a change that was right for the old recipe. By the time it arrives, other cooks have edited the book twice.

That is asynchronous SGD: workers pull, compute and push without waiting for each other, and the server applies each gradient on arrival. The opposite, where all workers finish a step together before the server applies the combined update, is synchronous SGD. Dean and co-authors named their asynchronous version Downpour SGD. They list two independent kinds of asynchrony: the replicas run independently of each other, and the server shards run independently of each other.

What breaks, and what holds

Their text is frank about the cost. A replica “is almost certainly computing its gradients based on a set of parameters that are slightly out of date.” The shards may also have applied different numbers of updates. And they add: “There is little theoretical grounding for the safety of these operations for nonconvex problems, but in practice we found relaxing consistency requirements to be remarkably effective.”

The gain is robustness. In synchronous SGD, one failed machine delays the whole run. In Downpour SGD, the other replicas keep processing data and updating the parameters. The same paper reports Downpour SGD with 20 replicas beating a single replica on a speech network, and 200 replicas with an adaptive learning rate (Adagrad) beating both. They also note two safety habits: Adagrad, which gives each parameter its own learning rate, and a warmstart, which trains with a single replica at first before releasing the others.

The post uses the same idea at a larger scale. Between two sites its update “may land late”, and “a late-arriving update can still be committed.” So we want a clean picture of what lateness does.

Staleness, as a number

The staleness of a gradient is the number of updates the server applied between the moment the worker pulled the parameters and the moment its gradient was applied. Call it τ (tau). With N workers taking turns, a typical gradient is about N−1 updates old: all the other workers pushed once in between.

We can study this with the smallest possible model, one parameter w and a loss that is a bowl, f(w) = ½ w2. The gradient is just w. The best answer is w = 0. A normal step is wt+1 = wt − η wt. A stale step uses the old value.

wt+1
The parameter after the server applies this update.
wt
The parameter on the server right now.
η
The learning rate: how big a step to take along the gradient.
wt−τ
The parameter the worker saw when it pulled, τ updates ago. The gradient of the bowl at that old point is that old value itself.

Work it by hand for τ = 1 and η = 1. Start with w = 1 at all earlier times. The next values are 1 − 1×1 = 0, then 0 − 1×1 = −1, then −1 − 1×0 = −1, then −1 − 1×(−1) = 0, then 0 − 1×(−1) = 1, then 1 − 1×0 = 1. The sequence 1, 0, −1, −1, 0, 1, 1, 0 … swings forever and never settles. With τ = 0 and the same η = 1 it would reach 0 in one step. Staleness turned a perfect step into endless swinging.

The swing has a clean edge. For this recursion the steps converge exactly when η < 2 sin(π / (4τ + 2)). We checked the formula against direct simulation for τ = 0, 1, 3 and 7 by running just below and just above each limit. The limits are 2.000, 1.000, 0.445 and 0.209. For large τ the limit is close to π / (2τ + 1): it shrinks roughly like 1 / τ. Doubling the number of workers about halves the safe learning rate.

Try it. Pick the number of workers, then drag the learning rate across the limit.

Train on old gradients

The curve is the loss after each server update, on a log scale, starting at 0.5. With N workers each gradient is N−1 updates old. Choose N, then raise the learning rate past the limit.

0.15

Toy problem with loss ½w2, starting at w = 1 with all earlier values also 1, and gradients exactly N−1 updates old (round-robin workers). The limit 2 sin(π/(4τ+2)) is a standard result for delayed steps; here we confirmed it by direct simulation for τ = 0, 1, 3, 7. A real network has many directions with different steepness, and the steepest one sets the limit.

With 8 workers (τ = 7) the limit is 0.209. At η = 0.15 the loss falls and stays below 0.001 from update 99 on. At η = 0.25 it grows to about 4.4 by update 120. A single worker at η = 0.15 gets below 0.001 by update 20. So even the safe run is slower per update with 8 workers than with 1, although the 8 workers deliver their updates 8 times as often. Real networks make this harder. Different parameters have different steepness, and the steepest direction decides the limit.

This is why Dean et al. needed Adagrad and a warmstart, and why modern methods avoid very stale information. Asynchrony keeps every machine busy, and it costs you a smaller step size or a different design. The next chapter keeps the no-waiting spirit but removes the server.

You double the number of asynchronous workers. What should you expect about the largest safe learning rate on the bowl problem?

Chapter 4

Decentralized SGD

Remove the central machine, let each cell average with its neighbours only, and see why the training still lands on the right answer

The head chef’s phone line is jammed. The cooks stand in a circle, each with a private copy of the recipe book. Between batches, every cook talks to the two cooks beside them and takes a weighted average of the three recipes. Then each cook cooks a batch and changes their own copy. Nobody is in charge. Does the circle still end up with a good recipe?

Lian and co-authors answered yes in 2017, in a paper that asks directly: can decentralized algorithms outperform centralized ones? Their method is decentralized parallel SGD, written D-PSGD. A neighbour is a cell that shares a link with you in the topology.

The update, line by line

Each cell i holds its own parameters xi and its own slice of the data. One round has three moves, taken from the paper’s Algorithm 1.

  1. Gradient. Cell i draws a mini-batch from its own data and computes the gradient at its current xi.
  2. Mix. Cell i fetches the parameters of its neighbours and replaces its own with a weighted average. This is the only communication.
  3. Step. Cell i subtracts the learning rate times its gradient from the mixed value.
xik+1
Cell i’s parameters after round k.
∑j Wij xjk
The weighted average of the neighbours’ parameters, including cell i’s own. Wij is the weight cell i gives to cell j, and it is zero if i and j are not neighbours.
γ
The learning rate.
∇Fi(xik)
The gradient of cell i’s loss on its own mini-batch, taken at its own parameters.

The table of weights W is the mixing matrix. For a ring of n cells the paper uses a weight of 1/3 on yourself and on each of your two neighbours, and 0 on everyone else. Every row adds to 1, and so does every column. A matrix with both properties and no negative entries is doubly stochastic. This detail does the work in the next paragraph.

A worked mix on the hero’s numbers 8, 2, 6, 1, 7, 3, 5, 4: cell 2 holds 6, its neighbours hold 2 and 1. Its mixed value is (2 + 6 + 1) / 3 = 3. Cell 0 holds 8 with neighbours 4 (cell 7) and 2 (cell 1), so it becomes (4 + 8 + 2) / 3 = 4.67. High cells fall and low cells rise. The average of all eight cells stays 4.5.

Why the average survives

Take the average of the update over all cells. Because each column of W sums to 1, mixing moves numbers from one cell to another but never changes their total. So the mean of the mixed values is the mean of the old values. Then each cell subtracts its own gradient. The mean of the cells moves by −γ times the mean of the gradients, which is exactly one step of ordinary SGD on the average of all cells’ losses. The ring does not break SGD. It only adds a force that pulls the cells together.

The paper proves two things worth remembering. First, the total amount of gradient work needed to reach a given accuracy is the same as for centralized SGD, so more cells still give a near-linear speedup once the run is long enough. Second, the busiest node sends and receives O(degree) numbers per round, as against O(n) for a parameter server. On a ring the degree is 2. On their 112-GPU runs, with a slow or high-latency network, D-PSGD was up to an order of magnitude faster than well-tuned centralized baselines.

A third point matters for islands. The paper notes that the gradient step and the fetching of neighbours can run at the same time, so when the exchange takes less time than the gradient, the communication is hidden completely. The post uses the same overlap.

Different data, one answer

Now give each cell different data, the way each island has its own shard. A toy makes this concrete. Cell i has its own bowl-shaped loss ½(w − ci)2, with its own best answer ci. Use the hero’s numbers 8, 2, 6, 1, 7, 3, 5, 4 as the ci. The best single answer for the whole group is their average, 4.5. All cells start at 0.

Train eight different bowls

Each line is one cell’s parameter over 60 rounds. The dashed line is the best answer for the whole group, 4.5. Choose how cells mix, set the learning rate, press Run.

0.30

Toy problem, computed exactly in your browser with the update above (gradient at the cell’s own value, then the mix, then the step). Ring weights are 1/3, as in Lian et al. (2017); all-reduce replaces every value by the group mean. “Widest gap” is the largest value minus the smallest after round 60.

At a learning rate of 0.3, alone, every cell runs to its own best answer, and the widest gap is 7.00: they never agree. With a ring, the gap after 60 rounds is 2.00. With a full all-reduce it is 1.62, a little smaller, since even a perfect average is pulled apart again by each cell’s next gradient step. In all three runs the average of the cells ends within 0.01 of 4.5. At learning rate 0.1 the widest gaps shrink to 0.92 for the ring and 0.64 for all-reduce: a smaller learning rate keeps cells closer together between mixes.

Here is one cell’s whole step as code. It is short because the topology lives in the weights.

pythondef dpsgd_round(x_i, neighbours, w, data_i, lr):
    g = grad(x_i, batch(data_i))               # shape [P]: own data, own parameters
    mixed = w["self"] * x_i                     # shape [P]
    for j in neighbours:                         # ring: 2 neighbours, each w = 1/3
        mixed += w[j] * fetch(j)                 # the only network traffic: P numbers per neighbour
    return mixed - lr * g                        # mix first, then step (Lian et al. Algorithm 1)

The ring is the weakest case for how fast the cells agree, which is why Chapter 6 asks how many rounds a ring needs. Chapter 5 first asks what happens if the neighbours change every round.

Why does mixing with a doubly stochastic matrix leave the average of all cells unchanged?

Chapter 5

Gossip Averaging

Pair the cells at random each round, let each pair average, and measure how fast the whole group agrees

At the office, a rumour spreads without a plan. At each coffee break people pair off, and the two in a pair swap everything they know. Nobody keeps a list of who has heard what. Yet within a few breaks, almost everyone knows. Computer scientists call this gossip, and it works for numbers as well as rumours.

For averaging, the rule is the simplest we have met. Pick a matching: a set of pairs in which every cell appears in exactly one pair. Each pair replaces both of its numbers with their average. Do that again with a fresh random matching, and again. No cell needs to know the whole group. No cell waits on more than one partner. The method goes back to the early 2000s (the post’s lineage cites Kempe and co-authors) and was analysed carefully by Boyd and co-authors in 2006.

What one round does

Take four cells holding 8, 2, 6 and 4. The average is 5 and the spread is √5 = 2.24. There are three ways to pair four cells.

  1. Pairs (0,1) and (2,3). (8+2)/2 = 5 and (6+4)/2 = 5. All four now hold 5. The spread is 0.
  2. Pairs (0,2) and (1,3). (8+6)/2 = 7 and (2+4)/2 = 3. The cells hold 7, 3, 7, 3. The spread is 2.
  3. Pairs (0,3) and (1,2). (8+4)/2 = 6 and (2+6)/2 = 4. The cells hold 6, 4, 4, 6. The spread is 1.

Luck decides. The first matching finishes the job in one round, and the second barely helps. So we ask what happens on average. The right quantity is the squared spread, since squares add up nicely. The start is 5 (that is 2.24 squared). The three results are 0, 4 and 1, which average 5/3 = 1.67. The expected squared spread falls to one third of its old value.

The contraction factor

That one third has a name. The contraction factor ρ of a mixing step is the factor by which the expected squared distance to the average shrinks in one round. Perfect averaging has ρ = 0. Doing nothing has ρ = 1. The Factored Gossip DiLoCo paper states the value for random pairing of M cells, citing Boyd and co-authors:

ρpair
The expected factor by which one round of random pairing shrinks the squared spread.
M − 2
M is the number of cells. The top of the fraction. It equals M − 2 once ½ − 1/(2(M−1)) is written over a common bottom.
2(M − 1)
A cell is paired with each of the other M−1 cells with equal chance, and an averaged pair keeps only half of the gap.
½
For a large group the factor tends to one half: each round about halves the squared spread, however many cells there are.

Here is the reason, in three short steps. Whoever your partner is, you keep half of your own value, so the expected mixing table has ½ on its diagonal. You also take half of one particular other cell’s value, and that happens with chance 1/(M−1), so every other place in the table holds 1/(2(M−1)). Now look at only the differences between cells, the part left once the average is removed. The table acts on them as the single number ½ − 1/(2(M−1)), which simplifies to (M−2) / (2(M−1)). For M = 4 this is 2/6 = 1/3, matching the hand count above.

M = 8: 6 / 14 = 0.43     M = 16: 14 / 30 = 0.47     M = 32: 30 / 62 = 0.48

The result is striking. Going from 8 cells to 32 barely changes the factor. Each round of random pairing shrinks the squared spread by about 0.43 to 0.48, whatever the size of the group. After k rounds the expected squared spread is the starting value times ρk.

Run it. Pick a group size, press Gossip round a few times, and compare your single run with the average of 200 runs and with the formula.

Gossip in random pairs

Top: one bar per cell. Bottom: the spread after each round on a log scale. Teal is your run. Warm is the root mean square of 200 runs. Dashed is the formula.

The 200-run curve is computed in your browser with a fixed seed, so it is the same on every visit. Starting values: for 8 cells, 8, 2, 6, 1, 7, 3, 5, 4; for other sizes a fixed scatter between 0 and 9. The formula curve is the starting spread times √(ρk) with ρ = (M−2)/(2(M−1)). Matchings are uniformly random.

With 8 cells, ρ = 0.43. After 10 rounds the formula says the spread has fallen to the square root of 0.4310, which is 0.015 of the start: about 1.5%. The average of 200 runs lands very close to that curve, while a single run wobbles above and below it. Luck matters for one run and washes out in the average. It is also why ring gossip, fixed neighbours every time, behaves so differently, as the next chapter shows.

The pairwise round is also very cheap for the busiest node. Every cell sends one model-sized message and receives one. Compare the hero’s numbers: a ring round costs each cell 2 copies sent, a pairs round just 1. And a cell that cannot reach its partner can just skip: that cell keeps its old value, and the other cells carry on. The Factored Gossip authors say it this way: missed exchanges “simply yield weaker mixing rather than aborting the round.”

For 8 cells, ρpair = 6/14. After 3 rounds of random pairing, by what factor does the expected squared spread fall?

Chapter 6

Mixing Time: Why Rings Are Slow

Count the rounds each plan needs to bring a group to agreement, and see how the answer depends on the shape of the plan

A rumour starts at one end of a long corridor where people can only whisper to the person on each side. It crawls. The same rumour in a crowded room, where anyone can turn to anyone, flies. The people and the rumour are the same. Only the shape of who can talk to whom differs. This chapter turns that feeling into numbers.

The mixing time of a plan is the number of rounds it needs to bring the cells close to agreement, say until the spread is 1% of what it was. A short mixing time means cheap agreement. We will measure it for the three plans that need no central machine and no global all-reduce: the ring, random pairs and the butterfly.

The ring: news moves one step per round

In a ring, a number can travel only to a neighbour each round. If one cell holds a spike and its seven mates hold zero, the news must travel around the circle. Even in the best case, a cell on the far side hears of it only after n/2 rounds. After that, the ring still has to smooth the spike into a flat line, and that takes longer.

Mathematics gives a precise rule. Mixing with the ring table W shrinks every pattern of disagreement. Some patterns shrink fast, such as one cell sticking up above its neighbours. One shrinks slowest: half the ring high and half low, a long smooth wave. Its shrink factor per round is the second largest eigenvalue of W, written λ2. (An eigenvalue is the number by which mixing multiplies a pattern that keeps its shape.) The paper by Lian and co-authors builds its convergence bound on the square of this number, which it writes ρ. For a ring of n cells with weights of 1/3:

λ2
The factor per round by which the slowest wave of disagreement shrinks. Near 1 means very slow.
2π/n
The angle between neighbouring cells when the n cells stand evenly round a circle.
3
One third weight on yourself and on each of your two neighbours.

n = 8: (1 + 2 cos 45°) / 3 = 0.805     n = 32: 0.987     n = 64: 0.997

The spectral gap is 1 − λ2: how much of the slowest wave is removed per round. For n = 8 the gap is 0.195. For n = 64 it is only 0.003. A small gap means a long mixing time. To cut a wave to 1% you need about ln(100) / gap rounds, and the gap behaves like 4π2 / (3n2) for large rings. So the rounds grow like n squared: about 0.35 n2 in the worst case. Double the ring and you need about four times as many rounds.

The other two plans

Random pairs have no corridor. A cell can meet any other cell, so the factor does not slow down as the group grows. From Chapter 5, ρpair = (M−2)/(2(M−1)). To bring the expected squared spread to 1/10,000 of its start (a spread of 1%), we need ln(0.0001) / ln(ρ) rounds: 11 rounds for 8 cells, 13 for 16, 13 for 32 and 13 for 64.

The butterfly of Chapter 7 does better still. For n a power of two it reaches exact agreement in log2(n) rounds: 3, 4, 5, 6 rounds for 8, 16, 32 and 64 cells.

One more plan sits beside these. A global all-reduce is exact in a single round, but that round is long. A ring all-reduce passes a chunk to the next cell 2(n−1) times in a row: 14 hops for 8 cells and 126 for 64. In a building, hops are microseconds and this is fine. Between islands, each hop can cost tens or hundreds of milliseconds, and the hops cannot overlap.

Why 1%? Any target would do, but a fixed target makes the comparison fair. A spread of 1% of the start means the cells agree to about two digits. For a trained model that is often enough for the next local steps to wash out the rest. A different target moves every bar up or down together, and does not change which plan grows fastest.

Count the rounds to agree

Bars show rounds to bring the spread to 1% of its start, on a log scale. Drag the number of cells from 4 to 64 and watch the ring bar race away.

8

Ring: simulated here with weights 1/3 from a start where one cell holds 1 and all others 0, counting rounds until the spread is 1% of its start; the worst-case pattern needs up to about ln(100)/(1−λ2) rounds, a little more. Random pairs: the expected-squared-spread formula of Chapter 5, rounded up. Butterfly: log2(n), exact. All three assume every exchange completes.

At 8 cells the ring needs 19 rounds from a one-cell spike, the random pairs 11 and the butterfly 3. At 16 cells the ring needs 70, and at 32 cells 251, between 3.5 and 3.7 times more for each doubling. At 64 cells it needs 896, while random pairs still need 13 and the butterfly 6. The corridor does not scale. The crowd and the butterfly do.

So the shape of the plan can matter more than the count of cells. For islands there is a second effect. A ring or a random pair uses links that are mostly cheap, short or frequent. A butterfly can place its first stages inside a fast site and its last stage across the slow link. The next chapter builds the butterfly and shows why its schedule is exact.

A ring of 16 cells needs about 70 rounds to reach 1% spread. About how many does a ring of 32 cells need?

Chapter 7

Butterfly Mixing

Choose the pairs in a pattern, and watch eight cells reach the exact average in three rounds with no all-reduce

A tennis club has eight players and a ladder, and wants every player to meet the whole club without anybody playing seven matches in a row. On the first day, neighbours play each other. On the second day, each winner of a pair plays someone from the next pair over. On the third day, the two halves of the club meet. Each player has played three people, and has indirectly “heard from” all seven others. That is a bracket, and it is the shape of butterfly mixing.

Zhao and Canny described butterfly mixing in 2013 as a way to speed up training on clusters by mixing model updates with communication. The Core Automation post “revisits” it, replacing the all-reduce with pairwise exchanges between eight learners and reporting that training quality matched the baseline. This chapter shows why three rounds are enough for eight cells.

Who is whose partner

Number the cells 0 to 7 and write each number in binary: 0 is 000, 1 is 001, 5 is 101 and 7 is 111. In stage 1 each cell pairs with the cell whose number differs in the last binary digit. In stage 2 the partner differs in the middle digit. In stage 3 it differs in the first. The post writes this as i ⊕ 1, i ⊕ 2, i ⊕ 4, where ⊕ (XOR) means “flip the binary digits where the other number has a 1”.

cell 5 = 101   stage 1: 5 ⊕ 1 = 100 = 4    stage 2: 5 ⊕ 2 = 111 = 7    stage 3: 5 ⊕ 4 = 001 = 1

With n cells (n a power of two) there are log2(n) stages, and each cell has a different partner at every stage. A cell has talked to 3 partners, yet its number now depends on all 8 starting numbers.

Why the pattern gives the exact average

Follow the hero’s numbers 8, 2, 6, 1, 7, 3, 5, 4. Stage 1 averages the pairs (0,1), (2,3), (4,5), (6,7).

  1. Stage 1. The pair averages are (8+2)/2 = 5, (6+1)/2 = 3.5, (7+3)/2 = 5 and (5+4)/2 = 4.5. The cells hold 5, 5, 3.5, 3.5, 5, 5, 4.5, 4.5.
  2. Stage 2. Cell 0 meets cell 2: (5 + 3.5)/2 = 4.25. Cell 4 meets cell 6: (5 + 4.5)/2 = 4.75. The cells hold 4.25 four times, then 4.75 four times.
  3. Stage 3. Cell 0 meets cell 4: (4.25 + 4.75)/2 = 4.5. Every cell holds 4.5, which is the exact average of all eight.

The general argument is short. After stage 1 each cell holds the average of a group of 2. In stage 2 a cell meets a cell from a different group of 2. Both partners hold the average of a group of the same size, so the average of the two is the average of the 4 cells together. In stage 3 two groups of 4 meet, and the same logic gives a group of 8. Each stage doubles the group, as long as the two partners hold averages of equal-sized, non-overlapping groups. The i ⊕ 2s rule guarantees both.

See it from one cell’s side. Choose a starting cell, and step through the stages to watch how far its number has spread, and with what weight.

Follow one cell’s update

Pick a starting cell. Its update is a weight of 1 on that cell. Step through the stages and watch where the weight goes. Teal shows the cells that carry part of it.

Exact fractions, no randomness: the weight is computed by applying the same pairing and averaging as the hero to a vector with 1 at the starting cell and 0 elsewhere. By linearity, this is also the share of any cell’s update that ends up in every cell.

Start at cell 0. After stage 1, cells 0 and 1 each carry 1/2. After stage 2, cells 0 to 3 each carry 1/4. After stage 3 all eight carry 1/8, which is the weight an exact average gives every cell. No cell was told about the whole group, and no cell ever handled more than three messages.

Order and size do not break it

Does the order of the stages matter? No. Try the stages in the order 4, 2, 1 on the same numbers. Stage ⊕4 pairs (0,4), (1,5), (2,6), (3,7) and gives 7.5, 2.5, 5.5, 2.5, 7.5, 2.5, 5.5, 2.5. Stage ⊕2 gives 6.5, 2.5, 6.5, 2.5, 6.5, 2.5, 6.5, 2.5. Stage ⊕1 gives 4.5 everywhere. Each stage averages over one binary digit, and averaging over different digits commutes. So a real system may use any order, for example the fast links first.

The size does matter a little. The argument needs n to be a power of two so that every cell has a partner at every stage. With other sizes you can add cells that hold a copy, or use random pairs, which work for any even count at the price of exactness. The post’s eight cells are the clean case.

The cost, against an all-reduce

Each stage, a cell sends its whole model piece to one partner and receives one back. Three stages mean 3 copies sent per cell and 3 hops. A ring all-reduce of 8 cells sends less in total, 2 × 7/8 = 1.75 copies per cell, but in 14 hops, since the data moves in small chunks one neighbour at a time. A rough model of the time is hops × latency + bytes / bandwidth.

Try one example with round, illustrative numbers: a 2 GB model, a 25 Gbps link and 200 ms of latency per hop. The butterfly takes 3 × (0.2 s + 16 Gb / 25 Gbps) = 3 × 0.84 = 2.52 s. The ring all-reduce takes 14 × (0.2 s + 2 Gb / 25 Gbps) = 14 × 0.28 = 3.92 s. At 50 ms latency the picture flips: 2.07 s for the butterfly and 1.82 s for the ring. The butterfly wins when latency is high, which is the situation between islands. It also lets a slow link delay only one exchange, not a chain of 14.

In stage 2 of an eight-cell butterfly, cell 5 meets cell 7. Why is the result still an exact average of a group of four?

Chapter 8

The Post’s Eight-Learner Run

Read the real experiment line by line: fragments, partners that change, a two-step delay, and a half-and-half blend

Now the real thing. The Core Automation team took 64 GB300 GPUs at one site and cut them into eight independent cells. Each cell is an eight-GPU learner that trains its own copy of a sparse mixture-of-experts model with about 32 billion parameters. The team chose one site on purpose, to test the pairwise exchange alone. In the post’s words, “in our experiment, all eight cells ran at one site.” Instead of averaging all eight cells at once, the cells swapped pieces of the model in pairs and went on training in between. The result: “Training quality matched the baseline.”

Compared with Chapter 7, the run adds three real-world touches. Each one answers a question you may already be asking.

Touch one: fragments

The parameters are cut into fragments, slices of the model that are exchanged on their own schedule. Cutting the model keeps each message small, and it lets different fragments use different partners at the same time. The post gives two examples of one moment in time:

pairings# pairings differ per fragment
fragment A:  0-5  1-3  2-6  4-7
fragment B:  0-1  2-4  3-5  6-7

Look closely. These pairings are not the neat i ⊕ 1, i ⊕ 2, i ⊕ 4 of Chapter 7. They are different perfect matchings, one per fragment. The XOR pattern is the clean picture for one fragment, drawn in the post’s figure. In practice a cell trades different parts of the model with different partners at the same time, which spreads the traffic over peers and over time.

Touch two: the exchange runs behind the training

The post lists one exchange from one cell’s point of view:

  1. Step t. Build a candidate from the fragment and send it to the partner.
  2. Step t+1. Keep training. Nothing waits.
  3. Step t+2. Update the live weights: live ← 0.5 · live + 0.5 · pair_result.

The candidate is what the post calls “a fresh outer-update candidate from its local optimizer state”. In plain words, it is the cell’s proposed update for this fragment, built from its own local training. The lesson on local SGD and the outer optimizer in this series explains it fully; here, think of it as the cell’s current offer. The live weights are the numbers the cell is training right now. The pair result is what the two cells’ candidates combine to. The cell does not stop for the message. It keeps stepping, and two steps later it folds the result in at equal weight.

A one-number worked example, with toy values. Cell A sends 6.0 and cell B sends 2.0 at step t. The pair result is (6.0 + 2.0)/2 = 4.0. Two steps later, training has moved A’s live value to 5.8 and B’s to 2.2. A becomes 0.5 × 5.8 + 0.5 × 4.0 = 4.9. B becomes 0.5 × 2.2 + 0.5 × 4.0 = 3.1. The gap between the cells was 3.6 (5.8 minus 2.2) and is now 1.8. One exchange halves the gap, and the cells did not stand still while it happened.

Touch three: the schedule

Each fragment was exchanged six times every 50 steps, which is two full butterflies, or about once every eight steps. Six exchanges of one fragment make two sweeps of the three stages.

The schedule also sets the bytes. Each fragment is sent six times in 50 steps, so over those 50 steps each cell sends each fragment six times, and each send is one fragment, not the whole model. The exchange for one fragment does not need to finish before the next fragment starts. That is how the traffic spreads over time, as the post says, instead of arriving in one burst.

Does an exchange every eight steps with a two-step delay keep cells close? Try the question on the toy from Chapter 4: eight cells, each pulled toward its own best answer.

Run the post’s exchange on a toy

Lines show the spread between the eight cells over 96 steps. Gray is no mixing. Blue is the post’s pairwise exchange. Purple is a full average at the same period. Choose how often to exchange, then drag the delay.

2

Toy, not the post’s model: one parameter per cell, cell i pulled toward its own target ci (8, 2, 6, 1, 7, 3, 5, 4) at learning rate 0.03, all starting at 0. Butterfly: at each exchange step every cell sends its value to the partner i⊕1, i⊕2, i⊕4 in turn; d steps later the cell sets live = 0.5 live + 0.5 (average of the pair’s sent values). The “full average” sets every cell to the group mean at each exchange step. Numbers are the mean spread over steps 48 to 96.

At an exchange every 8 steps and a delay of 2, the pairwise exchange holds the mean spread to 1.08, against 2.01 with no mixing: about half. A full average at the same period holds it to 0.23. Exchanging every 4 steps brings the pairwise run to 0.66, and every 16 steps lets it drift to 1.47. The delay matters little here: 0, 2 and 6 steps of delay give 1.14, 1.08 and 0.96. A delayed candidate is a slow-moving average, not a gradient, so lateness costs little.

Read this toy fairly. It does not reproduce the post’s result that quality matched the baseline; it cannot, because its cells pull toward eight different targets and a real model’s cells mostly share one direction. What the toy shows is the structure: one partner per exchange, no waiting, a gap that halves at each meeting, and a trade between how often you exchange and how far apart the cells drift. Per exchange a cell sends 1 model copy, against 1.75 for a ring all-reduce, but in a single hop and with no wait.

The rest of the post’s stack, such as better transport scheduling, error feedback on the messages, failure handling and the Shampoo-based optimizer, belongs to other lessons in this series. The two-site run in the post, 160 GPUs at each end of a 25 Gbps link, used the same ideas and reached about 0.2525 bits per byte against 0.2549 for standard training at the same compute.

In the post’s exchange, what does a cell do between sending its candidate and blending the pair result?

Chapter 9

When a Link or a Cell Fails

Cut one exchange, or lose one machine, and measure how far the group's agreement slips and how fast it heals

In the tennis bracket, one player does not turn up on day two. The match is a walkover. That player advances unchanged, and the rest of the bracket goes on. The club ends day three a little less mixed than planned, but not broken. Compare this with a single huge match where all eight players must be on court at once: if one is missing, there is no match.

That contrast is the heart of why islands favour pairwise exchange. The Factored Gossip DiLoCo authors describe a global all-reduce as a “global barrier” that is “dominated by the slowest link” and “can abort on a single link failure, requiring retries.” Gossip, they write, “degrades gracefully under transient failures, where missed exchanges simply yield weaker mixing rather than aborting the round.” The post says the same of slow links: “Slow links deliver later and nobody waits for them.”

Three kinds of trouble

  1. A slow link. The exchange arrives late. Chapter 8 showed that a small delay costs little, because the cell blends in the result when it arrives and trains meanwhile.
  2. A dropped exchange. One pair cannot talk in one round. Both cells keep their own values and move on.
  3. A lost cell. One machine stops sending. Its partners at every stage keep their own values, and the lost cell holds an old number.

The second and third cases leave a hole in the schedule. We can measure the hole. Take the hero’s numbers and run one full butterfly pass of three stages, with one fault, then look at the spread and at the average.

Why does the average survive? A pair that does talk replaces two values with their mean, which keeps the pair’s total. A pair that does not talk keeps its values, which also keeps the total. So the sum over all cells never changes, whatever fails. Only the agreement suffers, never the average. This is the same doubly stochastic property as in Chapter 4, now working in the cells’ favour.

Break the bracket

Choose a fault. Press Run a pass to send eight cells through the three stages with the fault in place. Then press Run a healed pass to run the full butterfly with every link working.

Exact, no randomness. A pair that cannot talk keeps both values; a lost cell takes part in no pair and keeps its starting value (3.00 for cell 5). Starting values 8, 2, 6, 1, 7, 3, 5, 4.

The results, from the device. With the stage 1 link 0-1 cut, one pass leaves a spread of 0.75: the cells alternate between 5.25 and 3.75. With the stage 3 link 0-4 cut, the spread is only 0.125, since cells 0 and 4 differ by merely 0.5 at that point. Nothing is lost if the cut comes late: the gap to close in stage 3 is small. A cut in stage 1 matters more, as the gap there is large (8 against 2). In both cases the average of the eight cells stays 4.50, and one healed pass brings the spread to exactly 0.

The lost cell is the hard case. One pass leaves a spread of 0.65, and a second pass without cell 5 gets only to 0.57, because the seven working cells average to a number that is not the group’s average, and the lost cell keeps its old 3.00. The group agrees only when cell 5 returns, then one pass finishes the job. A parameter server or an all-reduce in the same situation would stall or restart. The gossip group trains on with seven cells and catches the eighth up.

A slow link is not a failed link

Say an exchange is due to land at step t+2, but the link is slow and the result arrives at step t+5. A synchronous design would stop three steps. The post’s design does not. The cell has trained three more steps, and the result is still useful, because it is an average of two offers from a few steps ago and the weights move slowly. The post says that on a slow link a late update “can still be committed”. There are three policies for a late result: skip it, blend it as usual, or blend it with a smaller weight. The toy of Chapter 8 showed that a delay up to six steps changed the spread only a little.

Why a ring is more fragile than it looks

Cut one link in a ring and you get a line: still connected, but slower to mix. Cut two links in different places and the ring falls into two separate pieces. The two groups can no longer exchange anything. They may each agree inside, and they will never agree with each other. Random pairs avoid this trap, because the graph changes every round, and any two cells can meet in a later round. The butterfly avoids it by design, since each cell has a partner on every binary digit. Fault tolerance depends on the shape of the plan as much as on the speed of the links.

How a cell catches up

When cell 5 returns, nothing special happens. It joins the next pass with its old value, 3.00, and the pass pulls it and its partners toward the group. One healed pass brought the spread to exactly 0 in the device. In a real run the lost cell would also be behind in training steps, so a real system lets it copy a recent model from a partner first. Either way, the group never had to stop. This is the benefit the post lists: a run that can take compute when it frees up and give it back without losing progress.

The price of no one in charge

There is a cost to this softness, and the post names it. When models are trained across providers, one faulty or compromised site “can quietly degrade or tamper with the model, in ways that are harder to trace.” A mixing step averages in whatever a partner sends. A cell that sends garbage pulls its partner toward garbage, and the partner passes a part of it on at the next stage. Gossip is robust against absence, not against lies. Checking what cells send is a separate job.

One more design choice helps. In the post, pairings differ per fragment. If one link is bad, it hurts only the fragments paired across it at that moment, and a different fragment uses a different partner. The damage is spread thin instead of landing in one place.

In a butterfly pass, the stage 1 link between cells 0 and 1 is cut. What happens to the average of the eight cells?

Chapter 10

The Whole Lesson on One Page

Review the numbers and terms, read the core as code, and see where this sits in the post and in the field

You can now explain, from memory, how a group of machines can agree on one model without a boss and without a global stop. Start from a parameter server and its crowded door. Remove the waiting and meet stale gradients. Remove the server and average with neighbours. Make the neighbours random and count the rounds. Make them a pattern, and get the exact average in log2(n) rounds. Then run it behind the training, a little late, and accept that a missed exchange only weakens the mixing.

The one-paragraph summary

A parameter server keeps the model in one place, so its link is the bottleneck, and asynchronous workers push stale gradients that force a smaller learning rate. Decentralized SGD replaces the server with a weighted average over neighbours; because the weights are doubly stochastic, the average of the cells follows plain SGD. Gossip pairs cells at random, shrinking the expected squared spread by (M−2)/(2(M−1)), about one half, per round. A ring mixes slowly, in rounds that grow like n2. A butterfly pairs cell i with i ⊕ 2s and is exact in log2(n) rounds. The post’s eight-learner run exchanges fragments in pairs, blends the result in two steps later at equal weight, and matched standard training.

The numbers that matter

WhatNumberWhy it matters
The hero’s eight cells8, 2, 6, 1, 7, 3, 5, 4; average 4.5; spread 2.29One example used in Chapters 4, 5, 7 and 9
A straggler 4× slower120 vs 435 steps in a minuteWaiting for the slowest wastes most of the work
Links, 8 cellsstar 8 (hub 8), all-to-all 28 (each 7), ring 8 (each 2), butterfly 12 (each 3)The busiest node sets the pace
Parameter server, 8 workers, 1 GB, 25 Gbps2.56 s link vs 2.0 s compute; 16 shards: 1.28 sSharding widens the door (illustrative)
Dean et al. (2012)10 shards hold 1/10 each; 20 and 200 replicasDownpour SGD tolerates slow and failed replicas
Stale-gradient limit on the bowlη < 2 sin(π/(4τ+2)): 2.000, 1.000, 0.445, 0.209 for τ = 0, 1, 3, 7Eight workers cut the safe step by about 10×
Lian et al. (2017)up to one order of magnitude faster; 112 GPUs; ring weight 1/3Decentralized wins on low bandwidth or high latency
Random pairs, ρ4 cells 1/3; 8 cells 6/14 = 0.43; 32 cells 0.48About one half whatever the size
Ring λ2n = 8: 0.805; n = 32: 0.987; n = 64: 0.997A small spectral gap means slow mixing
Rounds to 1% spreadring 19, 70, 251, 896 for 8, 16, 32, 64 cells; random pairs 11 to 13; butterfly 3 to 6Rings grow with n squared
Butterfly vs ring all-reduce, 8 cells3 hops, 3 copies vs 14 hops, 1.75 copiesFewer hops win when latency is high
Failed exchange, 8 cellsspread 0.75 (stage 1 cut), 0.125 (stage 3 cut), 0.65 (cell lost); average stays 4.50Faults weaken mixing, they do not change the mean
The post’s eight-learner run64 GB300 as eight 8-GPU cells; ~32B parameters; 6 exchanges per 50 steps; blend 0.5/0.5 after 2 stepsPairwise exchange matched standard training
The post’s two-site run160 B300 + 160 GB300, ~9,000 miles, 25 Gbps; ~0.2525 vs 0.2549 bits per byteDifferent clusters, one model

The words, in plain terms

TermPlain meaningWhere
replica, cell, learnerOne full copy of the model that trains by itselfCh 0
all-reduceEvery cell sends and receives until all hold the averageCh 0, 7
bandwidth, Gbps, latencyBits per second a link carries; a billion of them; the time one tiny message needsCh 0
stragglerA cell much slower than the restCh 0
topology, link, degree, busiest nodeWho talks to whom; one line between two cells; links at one cell; the cell with the mostCh 1
parameter server, shardThe machine that holds the model; one slice of it on its own machineCh 2
asynchronous, synchronousNobody waits; everybody finishes the step togetherCh 3
stalenessHow many updates passed while a gradient was being computedCh 3
mixing matrix, doubly stochasticThe table of averaging weights; rows and columns each add to 1Ch 4
spreadHow far the cells sit from their average (root mean square)Ch 1
gossip, matchingRandom pairs average their values; every cell in exactly one pairCh 5
contraction factor ρHow much one round shrinks the expected squared spreadCh 5
spectral gap, mixing time1 minus the slowest shrink factor; rounds needed to nearly agreeCh 6
butterfly mixing, XORPair cell i with i ⊕ 2s; ⊕ flips the binary digits where the other number has a 1Ch 7
fragment, candidate, live weightsA slice of the model; the cell’s offer at an exchange; the numbers it trains nowCh 8
local SGD, pseudo-gradient, outer optimizerMany steps between exchanges; the change in the weights over those steps, treated as a gradient; the optimizer that applies itOwn lesson in this series
neocloud, stranded compute, compute islandA newer company that rents GPUs; GPUs that exist but cannot be used well (the post’s word); a fast pool of GPUs joined to others by slow linksPost; Ch 0

The core, as code

Two functions carry most of the lesson. The first is the butterfly average on an array of cells. The second is one cell’s loop from Chapter 8. Both are sketches: send, arrived, candidate and pair_result stand for your transport layer.

pythonimport numpy as np

def butterfly_average(x):                       # x: [n_cells, P], n_cells a power of two
    n = x.shape[0]
    for s in range(int(np.log2(n))):                # log2(n) stages
        partner = np.arange(n) ^ (1 << s)         # i XOR 2**s: a different partner each stage
        x = 0.5 * (x + x[partner])                # each pair replaces both rows by their mean
    return x                                    # every row now equals x.mean(axis=0)

def gossip_round(x, rng):                       # random matching, rho = (M-2) / (2(M-1))
    idx = rng.permutation(x.shape[0])
    for a, b in idx.reshape(-1, 2):
        x[[a, b]] = x[[a, b]].mean(axis=0)           # both keep the pair mean; the total never changes
    return x

def cell_loop(live, frag, steps, E=8, delay=2):    # the post's exchange, from one cell's view
    pending = []
    for t in range(steps):
        live = train_step(live)                   # never waits for the network
        if t % E == 0:
            send(partner(frag, t // E), candidate(live, frag))   # step t: build and send
            pending.append(t + delay)
        if pending and pending[0] == t and arrived(frag):  # step t+2: fold the result in
            live[frag] = 0.5 * live[frag] + 0.5 * pair_result(frag)
            pending.pop(0)                      # if it has not arrived, skip: weaker mixing, no stall

Read it line by line. The training step is never inside a network call. The partner changes by fragment and by exchange number. A missing result is a skipped blend, not a stalled run. Each of these is a choice from this lesson.

A checklist for any decentralized scheme

  1. Who is the busiest node, and how many bytes does it handle each round?
  2. What is the mixing time? Rounds to 1% for the plan, not just the degree.
  3. How stale can a number be, and what learning rate does that allow?
  4. Does the mean survive? Check that every mixing step is doubly stochastic.
  5. What happens when an exchange fails? Weaker mixing is fine. A stall or an abort is not.
  6. What does the plan do with a wrong value? Gossip hides a faulty cell. Add a check.
  7. Hops or bytes? Compare hops × latency + bytes / bandwidth on the real links.

Where this sits

The post places this lesson’s tools in a longer line. Zinkevich and co-authors averaged models once at the end in 2010. Dean and co-authors built the sharded, asynchronous Downpour SGD in 2012. Elastic Averaging SGD tied workers loosely to a central copy in 2015. Lian and co-authors gave decentralized SGD its theory in 2017. Moshpit SGD in 2021 built dynamic averaging groups for unreliable, mixed peers. Decoupled DiLoCo in April 2026 uses asynchronous learners and quorum-based aggregation. Factored Gossip DiLoCo in June 2026 swaps part of DiLoCo’s global averaging for pairwise gossip to cut blocking communication, and the post’s own butterfly run takes the pairwise idea to a 32B model. Each step in the line removes one more thing the earlier design needed.

Keep going

Credit and sources

This lesson was built for the Core Automation post The Hitchhiker’s Guide to Training on Compute Islands by Rohan Anil (2 November 2026). Its schedule, quotations and run details are the post’s. All devices, toy numbers and worked examples are ours and are labelled as illustrative where they are. Primary sources opened for this lesson:

The takeaway. Agreement does not need a boss or a global stop. A pattern of pairs, three rounds for eight cells, gives the exact average. Random pairs give about a halving of the squared spread per round. Add a small delay and a gentle blend, and a missed exchange costs you mixing, not the run. That is what lets compute islands train as one.
You must choose how 64 cells on slow, high-latency links agree. Which plan fits the lesson’s evidence?

Now press Teach and explain one idea from memory: why the average survives every pairing, how a butterfly reaches the exact average in three rounds, or why a cut link weakens mixing without changing the mean. Then go back to the eight cells and mix them with each method again.

Decentralized and Gossip Training, prerequisite 08 of Training on Compute Islands
The Core Automation post · Factored Gossip DiLoCo · Decentralized PSGD · Back to Gleams