Eight PCs on slow home links must train one network together. In a chain, every batch waits for every link, and one dead PC stops all. Learning@home gives each layer many experts and averages whoever answers: 300.8 samples per second against 7.23 over real cloud links.
Learn how a network of ordinary PCs, with slow links and nodes that drop out, can still train one big model, and why a mixture-of-experts layer is the trick that makes it work.
Pick a method, then drag the network delay up to 200 ms and switch on a node failure. Watch which method keeps working. Then we build, piece by piece, the expert layer, the grid that finds experts, the address book that tracks them, and the training loop around them.
You need a rough idea of a neural network layer (a function with weights that turns an input vector into an output vector). We build the rest from zero, including every network term.
Based on “Towards Crowdsourced Training of Large Neural Networks using Decentralized Mixture-of-Experts” by Max Ryabinin (Yandex, HSE University) and Anton Gusev, NeurIPS 2020, arXiv 2002.04013. Re-taught in our own words and devices. It is the volunteer-computing ancestor of the ideas in Rohan Anil’s post The Hitchhiker’s Guide to Training on Compute Islands; the background lesson is Heterogeneous and Unreliable Compute.
Illustrative toy, not the paper’s plot: 8 layers in a row, 20 ms of compute per layer, 8 batches in flight for the chain and 256 for Learning@home (the paper says a trainer handles hundreds of concurrent batches), at most 50 batches per second of compute. The paper’s measured numbers are in Chapter 8: 300.8 against 7.23 samples per second for feed-forward blocks on three cloud GPUs with 92.49 ms average latency (Table 2).
Chapter 0
See why a pile of cheap computers beats a supercomputer on paper, and why ordinary training cannot use it
Picture a street with a hundred thousand houses. Every house has a gaming PC with a decent graphics card. At night each PC sits idle. Together they hold more raw arithmetic power than a supercomputer that costs hundreds of millions of dollars.
The authors of this paper ran the numbers. A popular $2,500 desktop has a graphics card (a GPU, a chip built for the matrix arithmetic of neural networks) that is 50 to 80% as fast as a server-grade Tesla V100. So 10,000 desktops give 8 to 15 times the throughput of a pod of 512 V100 GPUs. The paper's Appendix A makes this estimate, and calls it rough.
The idea has a name: volunteer computing. People donate spare computer time to a science project. Folding@home did this for protein simulation, and in January 2019 it reported 146,091 teraflops (a teraflop is a trillion arithmetic operations per second, so this is a measure of raw speed), close to the 148,600 of the top supercomputer in the world that November. So why does nobody train a big language model this way?
The first number is bandwidth: how many bytes per second a link can carry. A node is any one computer in the network. The paper assumes each volunteer node has a home connection of 100 megabits per second in each direction. A megabit is a million bits, and 8 bits make one byte, so that is 12.5 megabytes per second. Inside a data center, links are hundreds of times faster. The paper says the Internet is two to three orders of magnitude slower than typical supercomputer connections.
The second number is latency: how long one message takes to arrive, however small it is. The paper assumes 20 to 250 ms. It also assumes 0.33% packet loss. Think of bandwidth as the width of a pipe and latency as its length. A wide pipe does not make the water arrive sooner.
The third problem is people. The paper expects 5 to 20% of home computers to fail at least once a day. A volunteer closes a laptop lid, a power cut hits, a game starts. Server hardware is built to avoid this. Home hardware is not.
Training a network means repeating one loop: run a batch of examples forward through the layers, measure the error, and compute a gradient (a number for every weight that says which way to nudge it). Then update the weights.
The usual way to use many GPUs is data parallel training. Every GPU keeps a full copy of the model. Each one computes the gradient on its own slice of the batch. Then all GPUs average their gradients, so every copy makes the same update. That average needs every GPU to send a gradient as large as the whole model, every step.
Take GPT-3, with 175 billion weights. In half precision, each weight takes 2 bytes. So one gradient is 175 billion times 2 bytes, which is 350 gigabytes, or 350,000 megabytes. At 12.5 megabytes per second, one send takes 350,000 divided by 12.5, which is 28,000 seconds. That is about 7.8 hours, for one step. A fast data-center link moves the same gradient in seconds. Try the sizes below.
Each bar is the time to send a gradient the size of the model, on a log scale. Pick a model size and compare the two links.
The home link is the paper's assumption: 100 Mbit/s each way, which is 12.5 MB/s. The data-center link is illustrative: 400 Gbit/s, which is 50 GB/s. The gradient is 2 bytes per weight (half precision), sent once, with no compression and no overlap with compute. The model sizes are round figures, and 175 billion is GPT-3 as the paper cites it.
Now the gap is clear. Over the home link, sending one gradient takes longer than the work that made it. The GPU spends nearly all its time waiting. The paper says gradient communication needs a connection often faster than hundreds of megabytes per second, "which is unrealistic" for a household.
Learning@home does not try to fix the network. It changes the model so that it needs very little from the network. Three ideas make that work. The model's layers are mixtures of experts (Chapter 2): many small sub-networks, of which each input uses only a few. A distributed hash table (Chapter 4) is a shared address book that tells everyone where each expert lives. And training is asynchronous (Chapter 5): nobody waits for anybody.
The paper's own concession is worth stating now. Each single batch may take longer. The system gives up latency (time to finish one batch) to keep throughput (batches finished per second) high. Training time mostly depends on throughput, so the trade is a good one.
Chapter 1
Score four existing training schemes against what a volunteer network needs, and see where each one breaks
Suppose you run a bakery chain and want every shop to sell the same bread. You could have every baker phone every other baker after each loaf. You could have one head office that all shops call. You could split one recipe across shops, so shop one mixes, shop two bakes, shop three ices. Or you could let each shop keep its own flour and mail only the changes. Each plan has a failure on a bad phone line. Distributed training has the same four plans.
The paper first states the setting it wants to serve. There are 103 to 106 weak, mixed PCs, each with 2 to 8 CPU cores, 4 to 16 GB of RAM, and one consumer GPU with 2 to 12 GB of memory. The links are home internet: 20 to 250 ms latency and 100 Mbit/s. And 5 to 20% of the computers fail at least once a day.
Synchronous data parallel is the plan from Chapter 0. Every worker holds the whole model, so each worker needs enough memory for all of it. Every worker also needs a fast link, because the gradient average is the size of the model.
Asynchronous training uses a parameter server: one computer that holds the latest weights. Workers fetch the weights, compute on a batch, and send an update back without waiting for anyone. Throughput rises. But the server is a single point of failure, and the updates arrive in any order. That brings a new problem, described below.
Model parallel training cuts the model by layers. Node 1 holds the first layers, node 2 the next, and so on. A batch passes through the nodes in order. Splitting the batch into micro-batches that flow like cars on an assembly line keeps all nodes busy. This is the only scheme here that can train a model bigger than any one node can hold. Its weakness: if one node in the chain stops, the whole run stops.
Federated learning keeps data on each device. Each device trains a local copy and sends only parameter updates, which the server can read only as an average over several devices. The cost is performance. Secure aggregation needs many workers to talk to each other, and its cost grows with the square of their number.
In asynchronous training, a stale gradient is a gradient computed on weights that have since changed. The worker looked at an old version of the model, and the answer no longer matches the model it will update.
A tiny example shows the harm. Let the loss be f(w) = w²/2, so the gradient at w is w. Use a step size (learning rate) of 1.5. Start at w = 5. Two workers both read w = 5 and both compute the gradient 5.
Worker A applies first: w = 5 − 1.5 × 5 = −2.5.
Worker B applies its stale gradient 5: w = −2.5 − 1.5 × 5 = −10.
A fresh gradient at −2.5 would give w = −2.5 + 3.75 = 1.25.
One step with a fresh gradient moves toward 0. The stale step lands at −10, twice as far from the target as the start. Repeat this and the weights blow up. Real losses are less simple, but the effect is real and the paper names stale gradients as what can hinder convergence.
The paper's Table 1 rates each scheme on seven properties, plus a row for the wished-for scheme. Two columns need a note. "Network bandwidth: High" means the scheme demands a fast link, which is bad here. "Latency: Low" means it demands short delays. "Any" means it tolerates all delays. Pick a scheme and see how many properties it misses.
Left column: the scheme you pick. Right column: what a volunteer network needs. Red cells are the mismatches.
The cell values are the paper’s Table 1, copied as printed. A match means the same word as the “Desired” row. “Only workers” means the system has central parts that are not fault-tolerant.
No row matches the wish list. The wish list asks for a model limit set by the whole system, high throughput, full fault tolerance, hot-join (a node can arrive mid-run), low bandwidth and any latency. The paper's conclusion: general large networks do not fit volunteer computing, but a subclass of architectures does. That subclass is mixture-of-experts.
The paper also lists three earlier volunteer-training projects, and none of them solve this. One trains many small models, one per device, to compare architectures. One uses standard asynchronous training with a central parameter server, so each model must fit on a consumer GPU. Leela Chess Zero uses volunteers only to generate chess games, while the model trains on one server.
Chapter 2
Build a mixture-of-experts layer by hand: score the experts, keep the best few, and blend their answers
A hospital has a hundred specialists. A patient walks in with a sore knee. Nobody asks all hundred doctors. A receptionist reads the complaint, picks the two best fits, and the hospital combines their opinions. The other ninety-eight doctors do nothing, and the patient still gets a good answer.
That is a mixture of experts (MoE) layer. An expert is a small neural network, such as a feed-forward block. The receptionist is the gating function: a small network that reads the input and gives each expert a score. The layer picks the top-k experts, meaning the k with the highest scores, runs only those, and blends the results.
The idea is old. The paper says it was first proposed almost three decades ago, and later work used it as one layer inside a larger network trained end to end. Shazeer and colleagues pushed it to "outrageously large" layers with thousands of experts, with better translation and language modeling. Our Mixture-of-Experts lesson shows the transformer version. Here we need only the layer itself.
Let the input be a vector x ∈ R1024, as in the paper's feed-forward experiment, where each block maps 1024 → 4096 → 4096 → 1024. Each expert f maps a 1024-vector to a 1024-vector. The gate gives one score per expert, g(x, f). With N experts there are N scores. Keep the k best. Turn their scores into weights that add to 1. Add up the k outputs, each multiplied by its weight.
This is the paper's Equation 1. The sum in the denominator runs over the chosen experts only, not over all N. That detail matters in Chapter 6, because it lets the layer renormalise when an expert is missing.
Use six experts and a two-dimensional input, to keep the numbers small. Say the gate scores expert j as 3 × cos(θ − αj), where θ is the input’s angle and the experts sit at α = 0°, 60°, 120°, 180°, 240° and 300°. These are illustrative toy scores, not the paper’s. For an input at θ = 20°:
scores = 2.82, 2.30, −0.52, −2.82, −2.30, 0.52
top-2 = experts 0 and 1, with scores 2.82 and 2.30
exp(2.82) = 16.8, exp(2.30) = 10.0, sum = 26.8 → weights 0.63 and 0.37
The layer's output is 0.63 times expert 0's answer plus 0.37 times expert 1's answer. Four of six experts did no work. Now try it. Drag the input angle and change k.
Left: the gate’s score for each of six experts, with the chosen ones filled. Right: each chosen expert’s answer as an arrow, and the blend in teal.
Toy layer, not the paper’s model: six fixed random 2-by-2 experts followed by tanh, and the gate score 3 × cos(angle − expert angle). The softmax over the chosen scores is Equation 1, computed exactly in your browser.
Sweep the angle slowly. Different experts win at different angles, so the layer behaves as if it had a different function in each region of the input space. That is why people say each expert specializes: it handles the part of the input it is best at.
Two facts about MoE drive the whole paper. First, a layer can have a huge number of experts, yet each input touches only k of them. Compute per input stays small while total capacity grows. Second, different inputs touch different experts. So experts can live on different machines, and one input needs to talk to only k machines.
There is one known trap. Left alone, the gate learns to favour a few experts for every input, and the rest go unused. Shazeer and colleagues fixed this with a load-balancing regularizer: an extra loss term that rewards using all experts at an even rate. In this paper it earns a second job. Even use of experts means even use of the volunteers' machines.
Chapter 3
Lay the experts on a grid, score each row and column once, and add the two scores to rank a million experts
Imagine a library of one million books, and you must find the five best matches for your question. You cannot read all one million blurbs. But suppose each book has a shelf number and a slot number on its shelf. You rate each of the 1,024 shelves, and each of the 1,024 slots. A book's score is its shelf rating plus its slot rating. Now you have done 2,048 ratings, not a million.
This is the paper's structured gating function. With N experts, the plain gate of Chapter 2 would output N scores. For N near a million that is too much to compute, and far too much to send over a home network. The paper borrows a trick from product key layers (Lample and colleagues), which organized over a million keys in a 1,024 by 1,024 grid.
Give every expert a unique address, its uid: a tuple of d whole numbers (u0, u1, …, ud−1), each between 0 and M − 1. For d = 2 and M = 1,024 that is a 1,024 by 1,024 grid. Pick d and M so the grid has room for all experts and some spare cells. Spare cells let new volunteers add experts mid-training.
The gate has d small linear layers g0 to gd−1. A linear layer is a matrix multiply. Each takes the input x and returns a vector of M scores, one per index along its axis. The score of expert f adds the entries its address points to.
Look at the cost. The gate outputs d vectors of M numbers. For d = 2 and M = 1,024 that is 2,048 numbers, about 8 KB at 4 bytes each. Scoring a million experts one by one would give 1,048,576 numbers, about 4.2 MB. The structured gate is 512 times smaller, and it is the thing a trainer must send around.
Let d = 2 and M = 4, so there are 16 cells. Suppose the gate gave these two vectors for some input. They are toy numbers.
g0(x) = [1.0, 0.2, −0.5, 0.8] g1(x) = [0.3, 1.2, 0.1, −0.4]
score(0,1) = 1.0 + 1.2 = 2.2 score(3,1) = 0.8 + 1.2 = 2.0 score(1,1) = 0.2 + 1.2 = 1.4
score(0,0) = 1.0 + 0.3 = 1.3 (the fourth best)
The top 3 are cells (0,1), (3,1) and (1,1). Their softmax weights are e2.2 = 9.03, e2.0 = 7.39 and e1.4 = 4.06, which sum to 20.47. The weights are 0.44, 0.36 and 0.20.
With a full grid, you could find the top-k cheaply by taking the best entries of each vector and combining them. But the grid is not full. Volunteers come and go, so many cells are empty. If cell (0,1) held no expert, the winners would be (3,1), (1,1) and (0,0). The device below lets you retire experts and watch the ranking move.
Rows are g0, columns are g1. Filled cells are live experts; faint cells are empty. Gold rings mark the top 3. Pick an input, then press Retire the winner a few times.
Toy values: the two score vectors for each input are seeded random numbers, and 44 of the 64 cells hold an expert, chosen by a seeded draw. The addition and the top-3 search are exact. The paper’s own grids are larger, and it notes typical sizes of 100 or 256 indices per dimension.
Brute force over the live cells works in this toy. In the real system the live experts are spread over thousands of machines, so we cannot even list them. Finding the top-k among live experts needs a search that asks "which cells under this prefix exist?". That search is Chapter 4.
Chapter 4
Find which volunteer hosts which expert with no central server, using a distributed hash table and a beam search
You want to call the person who runs expert (2,2). Who knows their phone number? In a company, the front desk does. In a volunteer network there is no front desk. A hundred thousand people come and go, and any one of them can leave tonight. Whatever keeps the address book must survive that.
The paper says even holding the full list of active experts would be infeasible for any single participant. The answer is a distributed hash table (DHT): a dictionary of key and value pairs that is stored across all the participants, with no coordinator.
A hash function turns any text, such as "ffn.2.2", into a fixed-size number that looks random. Here is the scheme from the paper's Appendix B.
The paper uses Kademlia, the DHT behind BitTorrent. It measures "closest" with the XOR distance: write both IDs in binary, compare bit by bit, and read the result as a number. A bit that differs gives 1, a bit that matches gives 0. Take four-bit IDs. Five peers have IDs 0001, 0100, 0111, 1010 and 1101, and the key hashes to 0110.
0001 ⊕ 0110 = 0111 = 7
0100 ⊕ 0110 = 0010 = 2
0111 ⊕ 0110 = 0001 = 1
1010 ⊕ 0110 = 1100 = 12
1101 ⊕ 0110 = 1011 = 11
The two closest peers are 0111 (distance 1) and 0100 (distance 2). They store the pair. Each peer knows only about log N others, and any lookup takes at most O(k + log2 N) requests. The table keeps working when peers leave, because the pair lives on several peers.
Each runtime announces every expert it hosts, again and again, with the current timestamp. Two kinds of key go in the DHT. The first maps an expert uid to the server address. The second maps each prefix of a uid to the list of indices that are active under it. The paper's example uses six experts: ffn.1.3, ffn.2.1, ffn.2.2, ffn.2.6, ffn.3.2 and ffn.3.5.
ffn.1.* → [3] ffn.2.* → [1, 2, 6] ffn.3.* → [2, 5]
ffn.2.2 → address of the server that hosts it
The timestamps do a quiet but vital job. A key older than t seconds counts as dead, so when a volunteer vanishes its experts fade out of the book on their own. Runtimes also save the latest expert weights into the DHT, so another volunteer can pick them up.
Now combine the grid gate and the book. The paper's Algorithm 1, SelectExperts, is a beam search: a search that keeps only the k best partial answers at each step. It starts from the first grid dimension and adds one dimension per round.
Take k = 2 with toy scores g0 = [0.1, 0.9, 1.4, 0.7, …] for the first dimension. Prefixes 2 (1.4) and 1 (0.9) win. The DHT says prefix 2 has [1, 2, 6] and prefix 1 has [3]. With g1 = [0.2, 0.8, 1.1, 0.5, 0, 0.3, 0.6], the candidates score 2.2, 2.5, 2.0 and 1.4. The top two are ffn.2.2 and ffn.2.1. That took two DHT queries, not six.
In general the search makes O(dk) DHT lookups, each O(log N), so O(dk log N) in the worst case. Finding the top experts therefore grows slowly with the number of experts. The paper then needs only k direct calls to run them. Step through it below, and try input B.
Press Next step. Purple rings are the beam. Dashed gold marks the true best experts by brute force. Change k and the input, and look for a case where the beam misses.
The six experts and the DHT keys are the paper’s Appendix C example. The scores for g0 and g1 are toy numbers. Prefix 0 and indices 4 to 6 of g0 have no active experts; the algorithm counts DHT queries per beam entry.
Input B shows the price of the shortcut. With k = 1, the beam commits to prefix 3 after the first round and never looks under prefix 2, where the true best expert lives. A wider beam fixes it. Beam search is fast because it is greedy, and greedy can miss. The paper accepts that, since the gate and the experts are trained together and the layer adapts to whichever experts the search returns.
Chapter 5
Follow one training batch from the trainer, through the address book, to the experts and back, with every tensor shape
A volunteer runs three programs on one PC. Think of a restaurant. The trainer is the waiter: it takes orders (batches), decides which kitchens to send them to, and collects the plates. The runtime is the kitchen: it owns the stove (the GPU) and cooks. The DHT node is the phone book: it knows which kitchen makes what. Every volunteer can be all three.
The paper's Section 3.3 names them exactly: Trainer forms batches and trains; Runtime does expert inference and updates; DHT Node does bookkeeping and routing. The runtime is the only process that touches the GPU.
The runtime answers two kinds of request, and no more.
Because trainers live behind slow links, requests arrive at random times. The runtime does not answer each one at once. It collects requests into a larger batch, so the GPU works on a full batch at a time.
Backpropagation needs the activations of the forward pass: the values computed inside the expert. The usual way is to store them until the backward pass. That is a problem here. The batch may wait on the network for a long time, and in the meantime the GPU holds the stored activations of every batch in flight. Memory fills after a few batches, and the GPU must wait.
The paper uses gradient checkpointing: store nothing during the forward pass. When the backward request arrives with the inputs, run the expert forward again, then backpropagate. This costs about one third more compute per batch. In return, memory stays small. For Transformer layers at 100 ms latency, the paper reports roughly 9 times less throughput without it (Appendix D). That is why the backward request must include the inputs.
Now put it together, for one layer. The trainer holds a batch of b inputs, each a vector of length 1024, so a tensor of shape (b, 1024). In the paper's feed-forward test, b is 2048.
Count the bytes. A (2048, 1024) tensor in 32-bit floats is 2048 × 1024 × 4 bytes, which is 8.4 MB. At the paper's 100 Mbit/s (12.5 MB/s) one such tensor needs about 0.67 s. That is our own arithmetic, not a number from the paper. The paper does say its throughput tests saturate at 100 to 200 Mbit/s, and its Appendix E suggests sending 8-bit tensors to cut the load. Latency is not the only limit. Bandwidth still matters, and the design moves it from "every weight, every step" to "a few activations".
Press Next message to send the next message between the trainer, the DHT and a runtime. Change the batch size to see how the bytes change.
The message order follows the paper’s Figure 2 and Section 3.3. Sizes are our arithmetic for one expert and one layer: 32-bit floats, hidden width 1024 as in the paper’s feed-forward blocks, and a 100 Mbit/s link (12.5 MB/s). The two gate vectors use M = 1,024 for illustration.
Notice what never moves: the expert's weights. They stay on the runtime and change in place at step 8. Only activations and gradients cross the network. The weights reach the DHT only as occasional saved copies, so a replacement volunteer can restart an expert.
The trainer does not sit idle while step 3 flies across the Internet. It starts the next batch at once, and the paper says a trainer can process hundreds of concurrent batches. Chapter 7 explains the cost of that choice, stale gradients, and why mixtures pay it cheaply.
Chapter 6
Treat a silent expert like a dropped one: leave it out, renormalise the weights, and keep training
A relay race has eight runners in a fixed order. If one runner trips, the baton stops and the team is out. Now picture a different race: at each stage, four runners start with the baton at once, and the team takes the average of whichever runners finish. One runner can trip and the team still gets through. This is the difference between a chain of layers and a mixture of experts.
Remember Equation 1 from Chapter 2. The trainer picks k experts and weights their answers. Some of the k may not reply: the volunteer's laptop went to sleep, the link dropped, or the reply is too slow. The paper's rule is plain. Exclude the silent experts from the average, and renormalise the remaining weights so that they add up to 1 again.
Here is the arithmetic. Four experts were chosen with weights 0.40, 0.30, 0.20 and 0.10 (toy numbers). Expert 1, with weight 0.40, never replies. The remaining weights sum to 0.60. Divide each by 0.60: they become 0.50, 0.33 and 0.17. The output is a proper average of the three that answered. The softmax makes this natural: dropping a score and recomputing the softmax gives the same result.
The paper compares the effect to dropout, the training trick of randomly switching off parts of a network so that it cannot lean on any one part. Training with failures means the experts learn overlapping specializations. If one expert is lost, a neighbour can partly cover for it. The paper adds that training on a faulty network automatically adapts the mixture to the failure points of that network.
Suppose each node fails during a batch with probability p = 0.1. This matches the paper's experiments, where each expert does not reply with probability 0.1. A model-parallel chain of 16 layers (as in the paper's language model) needs every layer. The batch survives only if all 16 nodes survive.
chain: 0.916 = 0.185
one mixture layer with k = 4: fails only if all 4 fail, 0.14 = 0.0001, so survives 0.9999
16 mixture layers: 0.999916 = 0.998
So 18.5% of batches finish in the chain, against 99.8% in the mixture. This is a simple model that assumes failures are independent and every expert chosen is a distinct machine. The paper does not give this calculation; it shows the effect in experiments (Chapter 8). But it explains why the experiments look the way they do.
Top: four chosen experts. Tap one to make it fail and watch the others take its share. Bottom: the share of batches that finish through 16 layers, for a chain and for a mixture, at the failure rate you set.
The four weights are toy numbers. Survival uses independent failures, a chain of 16 layers (the paper’s Transformer-XL has 16) and k = 4 chosen experts per mixture layer, as in the paper’s language model. The formula bars are exact; the simulation draws 2,000 random batches in your browser.
Slide the failure chance to 20%. The chain drops to under 3%, since 0.816 is 0.028. The mixture still completes 97.5% of batches, because 1 − 0.24 = 0.9984 per layer and 0.998416 = 0.975. The wider the mixture, the safer it is.
The same design handles more than crashes. A slow expert that misses the timeout is dropped just like a dead one, so slow machines do not hold up a batch. Volunteers can host different numbers of experts to match their hardware. If a node leaves, another can take its place by fetching the saved expert weights from the DHT. New volunteers can join mid-training in the spare grid cells. And the load-balancing term from Chapter 2 spreads work evenly across machines.
The paper is honest about what this does not cover. A faulty expert that returns garbage values (not-a-number results) instead of staying silent could poison the network through backpropagation. Because each expert sees only a small share of the inputs, the damage is limited, but the paper only sketches defences, such as ignoring outlier gradients.
Chapter 7
Count how many other batches change the experts your batch uses, and see why a bigger mixture means fewer stale gradients
Sixty-four cooks share one recipe book. Each cook reads the page, goes away to cook, and comes back to write a correction. If everyone edits the same page, then by the time you return, sixty-three others have changed it, and your correction was written for a page that no longer exists. Now give the kitchen four thousand separate recipe cards. A cook uses four cards. Most of the time nobody else touched yours.
That is the staleness story of this chapter. In Chapter 1 we met the stale gradient: a gradient computed on weights that have changed since. Asynchronous training makes staleness common, because each worker starts the next batch without waiting. Learning@home fully embraces asynchrony, with hundreds of batches in flight per trainer. So how does it avoid the damage?
Follow one batch. It reads an expert's weights at its forward pass. Later, at its backward pass, it updates that expert. In between lies a staleness window. Every other batch that updates the same expert inside this window makes the gradient staler by one update. Because the network is slow, the window is long: all the time spent crossing the Internet and queuing.
In a plain network, every batch updates every weight. So if B batches are in flight, each gradient is stale by about B − 1 updates. With B = 64 that is 63.
In a mixture, a batch updates only the k experts it chose. The paper states it directly: two individual inputs are likely to affect completely different experts, so updating expert weights for the first input introduces no staleness for the second one. Let us count it.
Assume, as a simplification, that each batch picks its k experts uniformly at random from N. This is roughly what the load-balancing term (Chapter 2) pushes the gate toward. Then any other batch picks a given expert with probability k/N. Among B − 1 other batches, the expected number that update the expert you use is:
B = 64, k = 4:
N = 4 (every expert every time, like a plain layer): 63 × 4/4 = 63
N = 64: 63 × 4/64 = 3.9 N = 256: 63 × 4/256 = 0.98 N = 4,096: 63 × 4/4096 = 0.061
With 4,096 experts, only about six in a hundred of your experts have been touched by anyone else. The gradient is almost fresh. This is a model for intuition, not a measurement from the paper. It predicts the ordering the paper's Figure 5 shows: bigger mixtures suffer less.
Each bar is the expected number of other batches that update an expert you use. Drag the number of batches in flight. Press Simulate to draw random expert choices and see the measured average as a teal tick.
Model, not the paper’s data: every batch picks k = 4 distinct experts uniformly at random, and each other batch updates each expert it picked once during your window. The sizes 64, 256 and 4,096 are the mixture sizes in the paper’s Figure 5; 4 stands for a plain layer where every batch hits every expert. The paper uses 64 workers in its high-latency test.
Real gates do not pick uniformly. Popular experts get hit more often, and that is exactly what the load-balancing term fights. The estimate is best read as the case where balancing works.
The claim is about how fast staleness accumulates. It does not say a mixture is immune. It says the cost per in-flight batch is smaller, so a trainer can run many more batches at once before convergence suffers. That is exactly what you need when latency is high: more batches in flight keep the GPUs busy while messages travel.
Also notice the link to Chapter 1's stale-gradient example. There, a step size of 1.5 turned one stale step into a blow-up. Reducing the number of stale updates a weight sees is the same as reducing that danger.
Chapter 8
Read each table and figure for what it measures, make your own prediction first, and see what the paper found
The authors test two bets, and say so: first, that mixture-of-experts architectures keep high throughput under latency, and second, that they converge despite stale gradients. They also say they chose small experiments on purpose, so the general properties are easy to see. This is a prototype paper, and the tests are small.
Throughput here means training batches processed per second. The setup is one large model built from 224 identical blocks, spread over 4 NVIDIA GTX 1080 GPUs. The authors add an artificial delay after each block. The delays follow an exponential distribution (many short waits and a few very long ones), which the paper cites as a good model of network latency. Two block types are tested: a feed-forward block (1024 → 4096 → 4096 → 1024, batch size 2048) and a BERT-like Transformer block (hidden size 1024, sequences of length 512, batch size 4).
Learning@home uses 64 trainer processes. The only mainstream rival that fits a model this large is model parallel training, so that is the baseline. As an upper bound, the authors also run model parallel with pipelining and no delay at all.
Figure 4 plots samples per second against network delay from 0 to 200 ms. The finding: Learning@home keeps nearly the same throughput even with delays approaching 200 ms, while model-parallel throughput falls fast. The paper shows this as a plot, and we do not read values from it.
Table 2 repeats the test with real machines: three cloud instances with Tesla K80 GPUs in West US, East US and West Europe, with average latency of 92.49 ± 32.42 ms. Samples per second:
| Approach | Feed-forward | Transformer encoder |
|---|---|---|
| Model parallel | 7.23 ± 0.06 | 0.01 ± 0.001 |
| Learning@home | 300.8 ± 15.9 | 0.68 ± 0.01 |
Worked ratios: 300.8 / 7.23 = 41.6 times for feed-forward blocks. For Transformer blocks, 0.68 / 0.01 = 68 times, but the model-parallel number is rounded to one significant digit, so read it as roughly 60 to 75. The paper also measured the beam search of Chapter 4 on DHT nodes deployed in the same cloud regions (batch size 64, finding the top 4 experts): 317 ± 58 ms with 100 nodes, 528 ± 127 ms with 1,000 and 764 ± 106 ms with 10,000. Each tenfold increase in nodes adds a few hundred milliseconds, which fits the logarithmic cost of Chapter 4.
Make your own guess below before you look. The device holds the paper's three results.
Pick a result, set your guess with the slider, then press Reveal. Your guess is the dashed ghost.
All revealed numbers are from the paper: Table 2 (3 cloud K80 GPUs, 92.49 ± 32.42 ms latency, mean ± standard deviation over 5 repeats) and Section 4.1 (DHT beam search, batch 64, top-4 experts). Error ticks show one standard deviation for the DHT test.
Does the model still learn when updates are late? The authors use MNIST digit recognition, a task any modern model solves, so the effect of staleness is easy to isolate. They compare a feed-forward network (FFN, 4 stacked blocks) with three DMoE models with 4 layers each and 64, 256 or 4,096 experts in total. Each DMoE layer picks 4 experts, so compute equals the FFN baseline.
Figure 5 has three panels of validation accuracy against training batches. Panel one: 16 workers, 100 ms average delay. Panel two: 64 workers, 1,000 ms average delay (about 125 ms per forward or backward pass through a DMoE). Panel three: the same 1,000 ms plus a 10% chance that each expert does not answer. The result in the authors' words: high latency is harder for all models, but it affects the mixtures much less, especially the largest. That matches the count in Chapter 7.
Last, Transformer-XL on WikiText-2. The base model has 16 layers with hidden size 400 and feed-forward size 900. A small baseline halves both (200 and 450). The DMoE Transformer has 256 experts spread over 16 layers, each expert a Transformer layer the size of the small model's, with top-4 routing, so its compute per sample matches the base. It trains with 32 trainers (batch size 1 each), 1,000 ms average latency and a 10% failure rate.
Figure 6 plots validation perplexity (how surprised the model is by text it has not trained on; lower is better) against training samples, out to about 3 million. The authors report a pattern like the feed-forward case, and note that in this setting the 10% failures helped, which they put down to dropout-like regularization on limited data.
Chapter 9
Keep the numbers, the checklist and the core code, then see the limits and where the idea went next
Learning@home trains a huge network on unreliable volunteer PCs by changing the model, not the network. Each layer is a mixture of experts. A grid gate scores millions of experts with a few small vectors. A DHT beam search finds the live ones. Trainers send activations, not weights, and skip any expert that stays silent. Asynchrony keeps GPUs busy, and the size of the mixture keeps staleness low.
| Item | Value | Where |
|---|---|---|
| Volunteer PC, assumed link | 20 to 250 ms latency, 100 Mbit/s each way, 0.33% packet loss | Section 2.1, footnote 6 |
| Failure rate expected | 5 to 20% of computers fail at least once a day | Section 2.1 |
| 10,000 desktops against a pod | 8 to 15 times the throughput of 512 V100 GPUs (rough) | Appendix A |
| Expert address | uid = (u0, …, ud−1), each in [0, M) | Section 3.2 |
| Gate | g(x, f) = ∑ gi(x)[ui]; d vectors of size M | Section 3.2 |
| Layer output | weighted average of top-k; drop silent experts and renormalise | Equation 1 |
| Expert lookup cost | O(dk log N) DHT queries; then k direct calls | Appendix C |
| Gradient checkpointing | about 1/3 more compute; about 9 times more throughput for Transformer layers at 100 ms | Appendix D |
| Throughput, 3 cloud K80s | 300.8 against 7.23 samples/s (feed-forward); 0.68 against 0.01 (Transformer) | Table 2 |
| Beam search time, top-4 | 317, 528, 764 ms at 100, 1,000, 10,000 DHT nodes | Section 4.1 |
| Convergence tests | MNIST at 1,000 ms with 10% failures; Transformer-XL on WikiText-2 | Figures 5 and 6 |
python# Our sketch of the paper's Algorithm 1 and Equation 1, not the authors' code. def select_experts(x, k, gates, dht): scores = [g(x) for g in gates] # d vectors, each shape (M,) top0 = sorted(range(len(scores[0])), key=lambda i: -scores[0][i])[:k] beam = [((i,), scores[0][i]) for i in top0] for dim in range(1, len(gates)): cand = [] for prefix, s in beam: for j in dht.active_suffixes(prefix): # one DHT query per beam entry cand.append((prefix + (j,), s + scores[dim][j])) beam = sorted(cand, key=lambda c: -c[1])[:k] return beam # [(uid, score), ...] def dmoe_forward(x, k, gates, dht, timeout): replies = [] for uid, score in select_experts(x, k, gates, dht): try: y = rpc_forward(dht.address(uid), x, timeout) # (b, 1024) in, (b, 1024) out replies.append((y, score)) except (TimeoutError, ConnectionError): pass # silent expert: leave it out if not replies: raise LayerFailed w = softmax([s for _, s in replies]) # renormalised over the survivors return sum(wi * y for wi, (y, _) in zip(w, replies))
The paper calls itself a prototype with limited direct consequences. Its experiments are small. Its security section lists known peer-to-peer attacks (denial of service, which floods a node with junk; Sybil, where one attacker poses as many peers; and eclipse, where an attacker surrounds a victim with fake neighbours), and a risk specific to training: one expert that returns not-a-number values could poison neighbours through backpropagation. It notes that hacked machines could be used without the owner knowing, as botnets mine cryptocurrency. It warns that experiments saturate 100 to 200 Mbit/s, so many volunteers on one local network could congest it, and lists cuts such as 8-bit tensors. It also notes a bias: volunteers favour exciting or socially relevant projects.
Rohan Anil's post The Hitchhiker’s Guide to Training on Compute Islands lists Learning@home in 2020 as "decentralized mixture-of-experts training on volunteer hardware", among the foundations of low-communication training. It follows with Moshpit SGD and DeDLOC in 2021. The post's islands are a few big clusters with fast links inside each, a different setting from a hundred thousand home PCs. The shared lesson is the paper's: when the network is the bottleneck, change what must cross it, and let nobody wait. Our lesson Heterogeneous and Unreliable Compute teaches that background.
Keep going: Mixture-of-Experts for the transformer version of the layer; Distributed Training and CS336 Parallelism, Pipeline and FSDP for the usual schemes this paper escapes; TinyML Distributed Training for the federated flavour; Optimization and Backprop for the gradient steps. The authors' code is at github.com/mryab/learning-at-home.
Press Teach and explain, from memory, how a batch finds its experts and what happens when one stays silent. Then go back to the instrument at the top, set the delay to 200 ms, switch on the node failure, and say why the chain stalls while the mixture does not.