Strangers with mixed GPUs and home internet can train one model together. DeDLOC splits the averaging work by bandwidth, and finished sahajBERT in 8 days, 1.8 times faster than 8 V100 GPUs.
Learn how a swarm of unequal computers can behave like one big, fair training cluster, from the first gradient to the last volunteer.
Pick a team of computers. Watch three ways of averaging gradients race on it. Then we build, piece by piece, the idea that lets the purple bar win: who sends what to whom, and why the slowest link no longer sets the pace.
You need no distributed-training background. A gradient is the list of nudges that tells a model how to improve. We explain everything else from zero.
Based on Distributed Deep Learning in Open Collaborations by Michael Diskin, Alexey Bukhtiyarov, Max Ryabinin and colleagues at Yandex, Hugging Face, HSE University, MIPT and the University of Toronto (NeurIPS 2021). Read after Heterogeneous and Unreliable Compute and the Core Automation guide to training on compute islands.
The seconds are Table 1 of the paper: averaging the gradients of a ResNet-50 (an image model), mean of 100 rounds, standard deviation under 1%. Circle area shows each computer’s network speed. “Gb/s” means gigabits per second, so 1 Gb/s moves 125 megabytes each second.
Chapter 0
See why one big model needs more compute than most people have, and why a crowd of home computers cannot simply share it
Picture someone who wants a language model that reads Bengali well. More than 230 million people speak Bengali as a first language, the paper says, yet few pretrained models exist for it. A pretrained model is a network that someone else already trained on a huge pile of text, so you can start from it. Our someone owns one laptop.
Training such a model from scratch is out of reach for one laptop. The paper says it often takes hundreds of high-end GPUs (graphics chips, the machines that do the heavy arithmetic of training), and years on a single device. Big companies and a few universities can pay for that. Most people cannot.
The usual fix is a model hub, a public shelf of models that others trained. Hubs help, but they hold what their makers cared about. The authors note that it is hard to find up-to-date models for more than a handful of languages. Vision hubs rarely hold models for drawings, satellite photos or microscope images. Researchers end up working on the problems that have models, not the problems that need solving.
The paper proposes a different shelf-stocking method: train the model together. This is volunteer computing (also called grid computing). Many independent people donate the idle time of their computers to one big job, a bit like neighbours lending tools for a barn raising.
It works at huge scale in other sciences. The paper reports that over 700,000 volunteers gave Folding@home 2.43 exaFLOPs of compute for COVID-19 research in April 2020. A FLOP is one arithmetic step on decimal numbers, and “exa” means a billion billion. BOINC, another project, brought together 41.548 petaFLOPs from over 790,000 computers in March 2020. The authors say the raw power of such crowds can beat the fastest supercomputers.
So why is the crowd not already training our Bengali model? The paper names three troubles. First, the devices differ: gaming PCs, workstations, even phones. Second, most use a household internet link, which has limited bandwidth (how many bits per second a link can carry) and is not reliable. Third, volunteers come and go as they like.
Folding a protein is easy to split. Each computer works alone and reports back. Training one network is not. The paper contrasts it with MLC@Home, a project that trains many small independent models and needs no talking between volunteers. Training a single model needs a lot of communication, and a failed job cannot just be restarted somewhere else.
Here is the communication, made concrete. A model has parameters, the numbers it learns. After each batch of examples, every computer works out a gradient: one nudge for every parameter. All the nudges from all the computers must be averaged before anyone can take the next step.
So each round, a computer has to push about one full copy of the gradient over its link. In 32-bit numbers, each nudge is 4 bytes. The link speed then decides the wait. The device below sets four links side by side: a 50 Mb/s home link, 200 Mb/s, 1 Gb/s, and the 25 Gb/s of the paper’s high-bandwidth cloud setup.
Each bar is the time to send one full copy of the gradient in one direction. The scale is logarithmic: each gridline is ten times longer. Drag the model size, or press a preset.
Model sizes are the paper’s (17 M, 72.5 M, 560 M parameters). The 4 bytes per parameter and the one-way, no-overhead send are my simplifications, so real rounds differ. The link speeds are the paper’s setups.
Look at the gap between the top and bottom bars. The same gradient takes 500 times longer on the home link, whatever the model. A bigger model stretches every bar by the same factor, but the home bar is the one that hurts, because it climbs into minutes.
Computers on the home link could do their sums just as fast as the datacenter ones. They would simply sit idle, waiting for bytes. That waiting is the real enemy of the whole paper.
Three standard recipes exist, and each fails on a crowd. Ring All-Reduce lets computers pass gradient pieces around and average them. It works well for identical servers, but loses a lot when latency or bandwidth varies. A parameter server is one machine that collects everyone’s gradients. It copes with mixed devices, but the whole system is capped by that one server’s network. Elastic training lets workers join and leave, but the paper found it tied to global state sync, so one low-bandwidth newcomer can slow it by orders of magnitude. Chapter 1 builds each of these from zero.
The paper also lists plain network obstacles: home routers that block incoming connections (NAT, which Chapter 6 explains), regional access limits, and uneven speeds.
DeDLOC (Distributed Deep Learning in Open Collaborations) keeps the training recipe fixed and changes who does the work. Every device collects gradients at its own pace until the group reaches a set batch size. Then the group averages and takes one step. An algorithm re-assigns roles to match each peer’s speed and bandwidth, so a slow link stops being everyone’s speed limit. The authors used it with 40 volunteers to train sahajBERT, a Bengali model.
This lesson reads the paper as the real-world test of the background in Heterogeneous and Unreliable Compute. The Core Automation post on training on compute islands lists the paper in its history of the field, with the note “Collaborative pretraining with volunteers, demonstrated on a Bengali ALBERT model.”
The hero’s purple bar is the finished product. Each chapter builds one part of it.
Chapter 1
Learn what data-parallel training sends over the network, and why a parameter server and a ring each break in a different way
Four friends each mark a different quarter of a stack of exam papers. Each writes down the same kind of note: “this question was too hard, that one too easy.” To get one fair verdict, they must combine their four notes. Who collects them, and how do the notes travel? That small question is the whole of distributed training.
The paper focuses on data-parallel training, the most popular way to split the work. Every computer keeps a full copy of the model. Each computer reads its own slice of the training examples and works out a gradient from that slice. The group then averages the gradients, and every copy takes the same step. (The lessons on distributed training and parallelism, pipelines and FSDP show the other ways to split a model. The paper notes that even those use data parallelism at the top level.)
A gradient g is a list with one number per parameter. It says how much to push each parameter to lower the error on the examples just seen. A tiny model with three parameters has a gradient with three numbers. The step takes the average gradient and moves the parameters against it.
Work it with four peers. Start at θt = (1, 1, 1) and η = 0.1. The gradients are g1 = (2, 0, 4), g2 = (0, 2, 4), g3 = (4, 2, 0) and g4 = (2, 4, 0). Add them: (8, 8, 8). Divide by 4: (2, 2, 2). Multiply by η: (0.2, 0.2, 0.2). Subtract: θt+1 = (0.8, 0.8, 0.8). Every peer must reach exactly this answer, or the copies drift apart.
(2,0,4) + (0,2,4) + (4,2,0) + (2,4,0) = (8,8,8) → ÷ 4 = (2,2,2) → (1,1,1) − 0.1 · (2,2,2) = (0.8,0.8,0.8)
The only hard part is the sum. It needs a gradient from each peer, so bytes must cross the network. For a model with P parameters, each gradient is a vector of shape [P], and a peer must move on the order of P numbers per round. Chapter 0 showed what that costs on a slow link.
A parameter server (PS) is one machine that keeps the official parameters. Workers download them, compute a gradient, and send it back. The server averages and takes the step. It is easy to build. The paper also names its flaw: the whole system is limited by the network speed of that single server.
Count the traffic. With n workers, the server receives n gradients and sends out n copies of the parameters. That is n times P in each direction. Add workers, and the server’s load grows in step. If the server link has speed bs, one round takes about n · P / bs.
All-Reduce removes the server. It is a family of operations where every peer ends up holding the average. The trick is to split the gradient into n chunks. Peer j becomes the keeper of chunk j. Everyone sends chunk j to peer j. Peer j averages the n copies it received, and sends the averaged chunk back to everybody. A ring passes the chunks around a circle, and a butterfly sends them straight to their keepers. The traffic per peer is the same.
Count it. A peer sends n − 1 chunks of size P/n in the first phase, and n − 1 more in the second. So each peer sends about 2P(n − 1)/n, which is just under 2P however large n is. The load per peer stays flat as the group grows. That is why All-Reduce scales to many identical servers.
Now the catch. Every peer must finish its sends before the round ends. A round takes 2P(n − 1)/n divided by the slowest peer’s speed. One home link in a room of fast servers sets the pace for all.
Drag the number of workers. Then press the button to swap one worker for a slow home link, and see which method suffers.
Illustrative: a gradient of 600 megabits, every link at 1 Gb/s both ways, the slow worker at 0.1 Gb/s, no latency or overhead. The formulas are the traffic counts above.
Two different failures appear. The server’s round time grows with every added worker, until the server link is saturated. All-Reduce stays flat when links are equal, but one slow peer drags everyone down. Neither recipe was built for a crowd where links differ and peers change.
This is the whole All-Reduce data-parallel step as a program. The gradient is flattened into one vector so the network call is a single operation.
python# one data-parallel step on peer `rank` of n (sketch) x, y = batches[rank] # this peer's slice of the examples loss = loss_fn(model(x), y) loss.backward() # local gradients, one per parameter g = flatten(p.grad for p in params) # shape [P], float32 all_reduce(g) # every peer now holds the SUM of the n vectors g /= n # the average opt.step(g) # identical step on every peer
Chapter 2
Fix one big batch, let every peer fill it at its own pace, and see why the result matches an ordinary cluster
A baker follows a recipe: 4,096 cookies per oven batch, no matter who is in the kitchen. Some days four helpers show up, some days two. A fast helper rolls more dough than a slow one. The recipe never changes, so the cookies always taste the same. Only the time to fill the tray changes.
That is the first design choice of the paper. Many top models, such as GANs and Transformers, need a strict training regimen: a fixed batch size, and no gradients computed from out-of-date parameters. The authors warn that straying from the recommended batch size, or using stale gradients (gradients computed from parameters that have since changed), can change the final accuracy a lot. In a crowd you cannot control who joins, so without a rule, two runs could produce two different models.
DeDLOC uses synchronous data-parallel training with fixed hyperparameters whatever the number of collaborators. The key word is target batch size, written B or m. It is the number of training examples that must be seen before one optimizer step. Every peer works on its own pace until the group has jointly processed B examples. Only then do they exchange gradients and take one step.
This also helps with slow links. A large batch means a step needs a lot of compute, so peers talk less often. The paper calls this adopting “extremely large batches” to make up for slow communication. In the real sahajBERT run the group accumulated 4,096 samples per step.
Peers differ in speed, but that no longer matters for correctness. A fast peer simply processes more of the 4,096 examples, a slow one fewer. Each peer keeps a running total of the gradients of the examples it has seen (this is gradient accumulation) and reports its count of samples. The shared count is kept in the swarm’s shared dictionary (Chapter 6). When the counts add up to B, everyone stops computing and averages.
Each lane is one peer, filling at its own speed. Press Run a round. Then switch peers off to mimic them leaving, and run again.
Illustrative speeds: 200, 120, 80 and 40 samples per second. The target batch of 4,096 is the sahajBERT value (Appendix I.6). The paper does not give per-peer speeds here.
Notice what stays constant. The total is always 4,096. Peers leaving only stretch the time. What changes is who contributed which share.
Appendix G of the paper makes this exact. Peers may overshoot: network delay lets some peers add a few more gradients between the moment 4,096 samples are reached and the moment everyone stops. So at step k the group averages mk samples, with mk at least m. Treat each example’s gradient as a random draw whose variance is σ02. The mean of mk independent draws has variance σ02/mk.
Work it with a toy. Say σ02 = 8 and m = 4,096. The bound is 8/4,096, about 0.00195. If delay lets 4,200 samples in, the variance is 8/4,200, about 0.00190. A little better, never worse. So the standard convergence bounds for SGD (stochastic gradient descent, the basic training algorithm) with batch m still hold. The paper plugs this into Theorem 5 of a known SGD analysis to say so.
8 / 4,096 = 0.00195 → 8 / 4,200 = 0.00190 (toy σ02 = 8, illustrative)
The paper checked the claim on a real run. Figure 10 compares sahajBERT’s loss per optimizer step against a regular 8-V100 run. The two curves are nearly identical, with a slight gap the authors attribute to chance or to the slightly larger batches.
The symptom: two runs of the same code, started on different days with different volunteers, end at different accuracy. The measurement: look at the batch each step really used. If it followed the crew, the runs were not the same experiment. The fix is the rule of this chapter: one target batch, filled by whoever is present, with identical hyperparameters. Then the crew changes the speed and not the answer.
Peers count global steps. If a peer was offline and misses steps, it sees that others are ahead. It downloads the latest parameters and the optimizer statistics (momentum and similar running numbers) from an up-to-date peer, and then resumes. That is how a laptop that slept for an hour rejoins without poisoning the run. Figure 1 of the paper draws this: five peers, microbatches, state averaging, and a failure.
Chapter 3
Write training speed as the slower of two clocks, computing and averaging, and find which one is yours
A small factory has two stations. At station one, workers make parts. At station two, a truck carries finished parts to the shop. The factory ships one batch as fast as the slower station allows. Hire more workers if the trucks are idle. Buy bigger trucks if the workers are idle.
Training in a swarm has the same two stations. Computing turns examples into gradients. Averaging (also called aggregation) turns n gradients into one. The paper’s goal is to find a way of sharing both jobs that makes the most steps per hour with the target batch size B. This chapter writes that goal as a formula. Chapter 4 solves it.
The paper describes every peer i with four kinds of facts:
All peers with ci = 1 work at once, so their speeds add up. The group makes ∑ sici samples per second. A step needs B samples. So compute can finish Fcompute steps per second.
Averaging needs the whole gradient, all P numbers, to reach every computing peer. Peer i receives the averaged gradient from several keepers j at rates gji. Its total rate is the sum over j. The round ends when the slowest peer holds all P numbers. So the averaging clock is the worst peer’s total receive rate divided by P.
The two stations can run in parallel. The paper uses delayed parameter updates (DPU) for this. While the swarm averages the gradients of step k, the peers already compute the gradients of step k + 1. The price is exactly one round of staleness: step k + 1’s gradients were computed with parameters that lack step k’s update. The paper cites that this works for a wide range of models, including Transformers. The speed becomes the slower clock, not the sum of the two.
Try it. Fourteen peers at 50 samples per second fill a 4,096 batch in 5.9 seconds. That is the compute clock. Now give them 200 Mb/s links and a 600-megabit gradient, with plain All-Reduce. Averaging takes about 5.6 seconds. The clocks are close, so the plan is balanced. Add peers, and compute gets faster while averaging does not.
Orange blocks are computing a batch. Purple blocks are averaging. Drag the peers, pick a link speed, and toggle delayed updates.
Illustrative: 50 samples per second per peer, B = 4,096, a gradient of 600 megabits, plain All-Reduce at equal link speeds. The formulas are the paper’s clocks; the numbers are not from the paper.
Two lessons come out. First, adding peers cannot lift the step rate past the averaging clock. Second, on slow links the clocks cross early, which is why the next chapter works on the averaging side.
The plan is the set of rates aij (peer i sends gradients to keeper j) and gji (keeper j sends the average back to i), plus the switches ci. Four rules fence it in.
Chapter 4
Turn the speed problem into a linear program, and watch All-Reduce, a parameter server and hybrids fall out of one answer
Twenty-four people must carry a pile of mail sacks across a river. Eight own trucks and a wide bridge. Sixteen walk. If every person carries an equal share, the walkers set the pace and the trucks wait. A smarter plan hands the sacks that must be received, sorted and returned to the people with the best roads. That is the heart of DeDLOC.
Chapter 1 showed two fixed plans. In All-Reduce every peer keeps an equal chunk of the gradient. In a parameter server one machine keeps all of it. The paper’s claim is that both are special cases of one question: what fraction of the averaging work should each peer keep?
Split the gradient (P numbers) into pieces. Peer i is the keeper of a fraction fi of the pieces, and the fractions add to 1. Every computing peer sends piece-owner j the part of its own gradient that j keeps. Keeper j averages what arrives and returns the result to every computing peer. Equal fi gives All-Reduce. One peer with f = 1 gives a parameter server.
Let us count the traffic of one peer when all n peers compute. It sends the pieces it does not keep, a share (1 − fi) of P. It also returns its averaged piece to the other n − 1 peers, which is (n − 1) fi P. Receiving is the same by symmetry. So the traffic each way is:
Peer i has link speed bi, so it needs ti = Vi/bi seconds. The round lasts as long as the slowest peer. We want the fi that make the largest ti as small as possible. The best plan makes all the times equal, T. Then each peer’s fraction is fi = (T bi/P − 1)/(n − 2). The fractions add to 1, which pins T down:
Check it on equal links. Then ∑ bi = n b, so the second term is 2P(n − 1)/(n b). That is exactly All-Reduce from Chapter 1. With unequal links, the plan gives more work to fat links. Work an example with the hero’s team C: 8 peers at 1,000 Mb/s, 16 at 200 Mb/s, and a 600-megabit gradient.
Table 1 measured 5.69 s, 14.1 s and 2.96 s for these three on team C. The toy lands within 5 percent, which tells us the traffic counts are right. The message size of 600 megabits is my pick, tuned so the toy sits near Table 1. The paper does not state it.
Pick a team. Purple bars are the share each peer keeps under DeDLOC's plan; grey bars are the equal split of All-Reduce. Then add CPU-only helpers.
The solver is my simplified model (symmetric links, equal fractions solved by the formula above, bisection when helpers join), not the paper's full linear program. Gradient of 600 megabits, chosen so the toy lands near Table 1. Helpers have c = 0: they average but compute nothing.
Add the helpers to team D or B. The helpers have no GPU, but they own wide links. They take a large share of the keeping, and the slow peers send their gradients once and rest. That is the role split the paper describes: peers without accelerators “dedicate all their bandwidth to gradient aggregation.”
The real problem is larger than my toy. It has different upload and download speeds, pair limits tij, and the choice of who computes. The paper maximizes the step rate from Chapter 3 over all rates a, g and switches c. The max of a min is not a linear program yet. Two reductions fix that.
Reduction one: lift the min. Add a new variable ξ and ask it to be at most each term. Maximizing ξ then equals maximizing the minimum:
Reduction two: relax the switch. The switch ci is 0 or 1, which makes the problem hard (a mixed-integer program). The paper rewrites the rule “a keeper can return no faster than the slowest computing sender” so that c can take any value between 0 and 1:
The result is a plain linear program with continuous variables. Each peer solves it itself, using a deterministic interior-point solver with the same settings everywhere, so all peers reach the same plan without talking. In the paper’s runs the solver converged in under 50 ms and ran about twice a minute. Finally, peer i keeps a fraction proportional to its effective throughput, minj gij. A peer with ci not equal to 1 ignores its own local gradients.
Because the plan adapts to the hardware, the paper lists what you get. Reliable, equal peers give Butterfly All-Reduce. Add one peer with huge bandwidth and little compute, and it becomes a parameter server. Peers with equal links but no accelerators act as the extra summation services of BytePS. A swarm with a high failure rate shrinks its groups to pairs, which resembles decentralized SGD (Chapter 5). Real volunteer teams usually get a hybrid that matches none of these (the paper’s Figure 2).
Chapter 5
Average in small groups that take turns, so one dead laptop spoils a group and not the whole swarm
Imagine a relay race with 1,000 runners where the baton must be handed over by every runner in the same second. If any one of them trips, the whole handover is void and everyone starts again. With a thousand runners, someone trips almost every time. The race never finishes.
The paper hit exactly this problem. With several hundred active volunteers, most training iterations had at least one participant with a network problem. A single global averaging round, in which every peer must succeed, then fails more often than it works. The authors say this directly: without precautions, the entire averaging round fails more often than it succeeds.
The fix is to replace one global average with several small ones. This idea goes by the names Group All-Reduce and Moshpit All-Reduce in the papers the authors cite. Peers form groups of m. Each group averages inside itself. Then the groups are reshuffled so that new groups mix peers from different old groups. After enough rounds, every peer holds the exact global average.
The cleanest picture is a grid. Put nine peers on a 3 by 3 board, so m = 3. In round one, each row averages. In round two, each column averages. Every column now holds one number from each row. Since each row mean already covers its whole row, the column mean covers all nine values. Try it below with the values 1 to 9, whose global mean is 5.
Each cell is a peer holding one number. Press Average rows, then Average columns. Switch on the failure to see the middle row retry.
Toy values 1 to 9. The retry rule (a failed group runs again) follows the paper’s remark that a failure only affects the peer’s immediate group; the board and numbers are mine.
Two rounds were enough for nine peers because 3 × 3 = 9. In general, with n peers and groups of m, the groups need ⌈logm n⌉ rounds to cover everyone. A thousand peers in groups of 10 need three rounds, since 103 = 1,000.
The symptom: averaging rounds keep aborting, and training barely moves even though many peers are online. The measurement: suppose each peer drops out of a round with chance 0.5 percent, and 1,000 peers must all succeed. The chance of a clean global round is 0.9951000, about 0.0067. Only about one round in 150 would finish. The fix is the grouping above, where each group is small enough to succeed most of the time.
Groups trade two costs. A bigger m means fewer rounds. A bigger m also means a higher chance that someone in the group trips. If each peer fails with chance p in a round, a group of m survives with chance (1 − p)m. We retry a failed group until it works, so the expected number of tries is 1/(1 − p)m. A rough cost is the number of rounds times that.
Work it for n = 1,000 and p = 1 percent. A single global group (m = 1,000) survives with chance 0.991000, about 0.00004. That needs about 23,000 tries. Groups of 10 need three rounds at about 1.11 tries each, around 3.3 in all. Groups of 32 need two rounds at about 1.38 tries each, around 2.8 in all. That is the idea behind the paper’s choice: the best m depends on n and p.
m = 1,000: 1 × 1/0.991000 ≈ 23,000 m = 10: 3 × 1/0.9910 ≈ 3.3 m = 32: 2 × 1/0.9932 ≈ 2.8 (toy cost)
The curve shows toy cost against group size. The ring marks the cheapest group size. Choose a swarm size, then drag the failure rate.
My toy cost: rounds times the expected tries of one group, ignoring the wait for the slowest of many parallel groups. It is not the formula in Appendix C. The axis range for failure (0 to 2.5%) follows the paper’s Figure 8.
Slide the failure rate to zero: the best group size jumps to n, a single global group, since there is nothing to protect against. Push it to 2.5 percent on a large swarm and groups of a few dozen win. In the paper’s own runs, which had a small number of participants and rare serious network failures, the optimal group size was m = n. So the sahajBERT run used plain global averaging. The group machinery is insurance for bigger crowds.
At the other end sits m = 2: peers pair up, average, and mix on. The paper notes that a very high failure rate pushes the choice towards m = 2, which resembles decentralized SGD. The lesson on decentralized and gossip training covers that style.
Chapter 6
Connect computers that hide behind home routers, keep the roster without a server, and feed data to peers that just joined
You join a video call from home. You can see everyone, but nobody can phone you directly: your router only lets connections start from inside the house. That router rule is the biggest obstacle for volunteers, and it is the reason the algorithm of the last chapters needs a system around it.
The paper builds that system as a swarm, in the spirit of BitTorrent. There is no central boss. Peers find each other, share a roster, and keep going when some of them vanish. This chapter covers the four pieces: the shared dictionary, the router problem, the data feed, and the few stable peers that hold it together.
Peers form a distributed hash table (DHT). It is a key-value dictionary whose entries are spread across all the peers, so no single machine holds it. Each peer stores a slice, and any peer can look up any key by asking around. If a peer disappears, the others still hold the rest of the dictionary.
DeDLOC uses the dictionary for three jobs, all named in the paper: counting the gradient samples accumulated so far (Chapter 2), finding peers to form averaging groups (Chapter 5), and tracking each peer’s global step so a laggard knows it has fallen behind.
A few backbone peers keep the dictionary alive. They greet new collaborators and do helper jobs such as storing checkpoints and tracking learning curves. The only rule is that at least one backbone peer is up at all times. They need no GPU, so they can run on cheap servers. The cost analysis in Chapter 8 prices them.
NAT (network address translation) lets many devices in a home share one public internet address. The router remembers which inside device started each outgoing connection and forwards the replies. It drops anything that nobody inside asked for. The paper notes that most household and office computers sit behind one or more layers of NAT.
Appendix D sorts NATs into two kinds. A cone NAT gives your computer the same public address and port whoever you talk to. A symmetric NAT gives a different one for each destination. The kind decides which trick works.
Classic systems like WebRTC and BitTorrent use dedicated servers for this introduction work. The paper prefers fully decentralized traversal, where ordinary public peers act as the helper and the relay. It builds on libp2p, which needs at least four publicly reachable peers to learn newcomers’ public addresses.
Pick the kind of address each peer has. Then switch the public helper on or off. Watch which of the three tricks the pair needs.
The decision rules summarise Section 3.3 and Appendix D. A peer with a public address accepts connections, so a NAT peer connects to it directly. Real networks have more NAT variants than the two the paper names.
Big datasets take hours to download, and a volunteer may stay for one evening. So DeDLOC streams. The dataset is cut into shards (files of consecutive examples). A new peer starts downloading shards one by one and begins training as soon as the first examples are in, while the rest arrive in the background.
Training needs examples in random order, but a stream arrives in file order. So each peer loads the shards in its own random order and keeps a shuffle buffer. It fills the buffer with the first S = 10,000 examples. Then it repeats: pick a random example out of the buffer to train on, and put the next streamed example into the vacated slot. The result is a random-looking stream, even though the input was ordered. The paper’s runs streamed from a dedicated storage service. A peer-to-peer version (Appendix H) is described as future work and was not used.
Six shards, each its own colour, arrive one after another. The strip is the order in which the peer trains on examples. Drag the buffer size.
Scaled down: 6 shards of 100 examples and buffers up to 300, with a fixed random seed. The paper uses a buffer of S = 10,000. Shard colours only tell the shards apart.
With a buffer of 1 you train on the stream exactly as stored, one shard at a time, and the model would see a lopsided diet. A bigger buffer mixes neighbouring shards. For the data to be truly independent and identically distributed, each peer also starts at a different random shard, which mixes the peers against each other.
The run needs to credit contributors and block bad actors. The paper used an allowlist: only listed Hugging Face usernames could join, and each request between peers carried a signed token, a one-time number (a nonce) and a signature, so an eavesdropper could not replay or alter it (Appendix I.5). Every volunteer also got a live dashboard of their own contribution, and a leaderboard at the end.
Chapter 7
Read Table 1 and Figures 3 to 5 line by line, and see what each one proves and what it leaves open
A claim in a paper is only a sentence until someone measures it. The authors set up three kinds of tests. First, they timed the averaging step alone on four fixed teams (Table 1). Second, they trained two real models under controlled hardware (Figures 3 to 5). Third, they ran a true volunteer experiment (Chapter 8). This chapter reads the first two kinds.
The test model is ResNet-50, an image network. The authors time one averaging round of its gradients, as the mean of 100 rounds with a standard deviation under 1 percent. They try three methods on four teams. You met this table in the hero. Here it is as numbers, with the speed-up of DeDLOC over the better baseline.
| Team | All-Reduce | Parameter server | DeDLOC | Reading |
|---|---|---|---|---|
| A: 8 × 1 Gb/s | 1.19 s | 4.73 s | 1.20 s | Equal peers: no cost for being adaptive. |
| B: 16 × 0.2 Gb/s | 5.3 s | 39.6 s | 5.3 s | Slow but equal: All-Reduce is already right. |
| C: A and B | 5.69 s | 14.1 s | 2.96 s | Mixed: 1.9 times faster than All-Reduce. |
| D: B + one 2.5 Gb/s peer | 5.3 s | 3.22 s | 3.18 s | One fast peer: matches the server. |
Read it row by row. In A and B the peers are equal, so All-Reduce is the right plan, and DeDLOC finds it: 1.20 against 1.19, and 5.3 against 5.3. Nothing is lost. In D, one fast peer turns the best plan into a server, and DeDLOC matches the server. In C the peers are mixed, and neither pure plan fits. DeDLOC’s hybrid gets 2.96 seconds, against 5.69 and 14.1. This is the table that shows why a single fixed recipe cannot do the job.
One honest note: the table times only the averaging, and only on a model of the paper’s choosing. It says nothing yet about end-to-end training speed or how a messy real network behaves.
The next test trains SwAV, a method that learns image features from unlabeled photos, on ImageNet with a ResNet-50 and 32,768 samples per batch. Three teams train it. SERVER: 8 workers, each with one V100 GPU and 1 Gb/s links. WORKSTATION: 16 older 1080 Ti machines at 200 Mb/s each. HYBRID: both together, 24 machines. Workstation GPUs train in full 32-bit precision, because they lack fast 16-bit arithmetic.
The curves of loss against hours show HYBRID converging fastest. It beats SERVER by 40 percent and WORKSTATION by 52 percent. A model from that run gets 72.2 percent accuracy when tested in the supervised setting. The point is that old, cheap workstations on slow links, working alone, still make good progress. Adding them to servers helps more than it hurts.
The third test is a language model. The authors pretrain ALBERT-large on WikiText-103, using T4 GPUs on a cloud platform with controlled conditions. They chose ALBERT because it is very sensitive to batch size, so a wrong recipe would show. They also note that ALBERT shares weights, which makes it need less communication than BERT. Keep that in mind: it is kinder to slow links than most models.
Five setups form a ladder. Each rung adds one realistic mess or one fix.
Press a rung. The bar shows its training speed as a share of the 25 Gb/s setup. Each rung adds a fix or a mess to the one before.
Speeds are derived from the text of Section 4.2: 100% for the reference, 1/2.5 = 40% for naive heterogeneous, 40% × 1.47 = 59%, at least 40% × 1.6 = 64%, and 74% as stated. The days column is a toy: it assumes a job that takes 7 days on the reference.
Every number tells one story. The mess costs a lot: 60 percent of the speed gone to slow links. The plan wins back much of it. Cheap helpers with no GPUs win back more. And a crowd that is away half the time still brings the swarm to three quarters of a datacenter-grade setup. That last number is why volunteer training is not a joke.
The same ALBERT experiment run with 8, 16, 32 and 64 nodes. The authors measure the time between gradient steps and report that DeDLOC scales well. The paper gives the plot, not a table, so we do not quote numbers. Notice what it can and cannot show: it scales cloud nodes with good links, a friendlier case than 64 homes.
Chapter 8
Follow 40 volunteers who trained a Bengali language model, and compare what that cost with renting a cluster
On launch day the organizers sent one chat message. It said: you need your Hugging Face username on the allowlist, then open this Colab notebook or this Kaggle notebook, which gives you a P100 GPU. Please do not run more than one GPU instance on the same service. That was the whole onboarding. Forty people did it, in their own time, and a Bengali language model came out.
The task was to pretrain a masked language model for Bengali, the language of over 230 million native speakers. A masked language model hides some words in a sentence and learns to guess them. The authors recruited 30 Bengali-speaking volunteers and 10 outside collaborators. Nobody was told what hardware to use or how long to stay. A poll among the participants named the model sahajBERT.
The model was ALBERT-large, trained on Bengali Wikipedia and the Bengali part of the multilingual OSCAR text collection. To account for the uneven size and quality of the two sources, the authors sampled Wikipedia twice as often, giving mixing probabilities of 0.23 for Wikipedia and 0.77 for OSCAR. Every other setting was copied from the controlled ALBERT test of Chapter 7.
Here is what happened, in the paper’s numbers.
The step-by-step learning curves of the swarm and the 8-GPU baseline were nearly the same (Chapter 2). Per step, the swarm learned just as much. Per hour, it learned more, because it had more machines.
The authors tested sahajBERT on two Bengali tasks. WikiANN is named-entity recognition, finding names of people, places and groups in text. The score is an F1 value, a mix of precision and recall. NCC is news category classification, scored by accuracy. They compared it with three existing models.
| Model | WikiANN F1 | NCC accuracy | Note |
|---|---|---|---|
| bnRoBERTa | 82.32 ± 0.67 | 80.94 ± 0.45 | Bengali-only RoBERTa |
| IndicBERT | 92.52 ± 0.45 | 74.46 ± 1.91 | ALBERT, 12 languages |
| XLM-R Large | 96.48 ± 0.22 | 90.05 ± 0.38 | 560 M parameters, about 500 data center GPUs |
| sahajBERT | 95.45 ± 0.53 | 91.97 ± 0.47 | 17 M parameters, tens of low-cost GPUs |
| sahajBERT-XL | 96.59 ± 0.26 | 92.91 ± 0.43 | 72.5 M parameters, 14 volunteers, 22 days |
Read it. sahajBERT beats bnRoBERTa and IndicBERT on both tasks. Against the big XLM-R Large it is a little behind on WikiANN (95.45 against 96.48) and ahead on NCC (91.97 against 90.05). That is strong for a model with 17 million parameters against 560 million. The authors link this to ALBERT’s weight sharing, which also keeps communication small enough for slow links. sahajBERT-XL, with 72.5 million parameters, was the best on both. It was trained from the first model’s checkpoint by 14 volunteers, using GPUs and free-tier TPUs for 22 days. The authors say it would have taken over 3 months on 8 V100s. Training it also hit a snag: 16-bit numbers on GPUs and bfloat16 on TPUs made it diverge, so they ran the TPUs in 32-bit.
Appendix F prices the same training on six kinds of fleet, sized to give about the same speed. Each is a monthly rental cost, so every number below is dollars per month.
Bars are monthly costs from Table 3. Press the switch to rent the helper peers from a provider that charges for network traffic, and see how fragile the cheap row is.
Costs are the paper’s Table 3. The switch adds the networking bill of $5,000 to $6,000 per month that Appendix F estimates for premium non-GPU instances; I use $5,500 for the bar and assume it adds to the volunteer row. Volunteers also carry costs: $9 to $30 per volunteer per month for electricity and internet, by the paper’s estimate.
The cheapest row costs $257 a month for four CPU helpers. The most expensive costs $16,898 for one on-demand 8-V100 node. That is 66 times as much, which the paper rounds to two orders of magnitude. Moving to many cheaper machines saves about 3 times, and accepting preemptible machines saves about 3 times again.
Then read the switch. The paper warns that putting GPUs in several cloud regions can add over $3,000 a month in network charges on a $2,074 hardware bill. And helpers on premium cloud instances would add $5,000 to $6,000. The fix is a provider that does not charge for traffic. Such providers offer less reliable machines with lower bandwidth, which DeDLOC can live with. Part of the saving also moves to the volunteers themselves. Be honest about that when you compare.
The authors end with two open points. How to recruit and motivate a crowd is an open question. And they argue that using old and low-end devices could prolong the useful life of existing computers.
Chapter 9
Keep the numbers, the terms, the checklist and the core code on one page, and see where DeDLOC leads
DeDLOC trains one model on computers that nobody controls. It keeps the recipe fixed by filling a target batch at each peer’s own pace. It solves a small linear program so each peer keeps a share of the averaging work that matches its bandwidth, which turns All-Reduce, parameter servers and hybrids into one family. It averages in groups when failures are common. It wraps this in a swarm that crosses NAT, streams data and welcomes newcomers. The proof is sahajBERT: 40 volunteers, 8 days, 1.8 times faster than 8 V100 GPUs.
| Number | What it is | Where |
|---|---|---|
| 2.43 exaFLOPs | Compute from over 700,000 Folding@home volunteers, April 2020 | Section 2.2 |
| 1.19 / 4.73 / 1.20 s | Team A averaging: All-Reduce / server / DeDLOC | Table 1 |
| 5.69 / 14.1 / 2.96 s | Team C averaging: DeDLOC is 1.9 times faster than All-Reduce | Table 1 |
| < 50 ms, about 2 per minute | Linear-program solve time and call rate | Footnote 3 |
| 40% and 52% | How much HYBRID beats SERVER and WORKSTATION in SwAV | Figure 3 |
| 2.5×, +47%, 60%+, 74% | ALBERT: naive slowdown, then each fix, then final speed share | Figure 4 |
| 4,096 | Samples per step in sahajBERT | Appendix I.6 |
| 40 people, 91 devices, 8 days | The volunteer run; 1.8 times faster than 8 V100 GPUs | Section 4.3 |
| 6.95 GB per hour | Network traffic of an average volunteer device | Section 4.3 |
| $16,898 vs $257 | Monthly cost: on-demand 8 V100 vs volunteer fleet with CPU helpers | Table 3 |
| Term | Plain meaning |
|---|---|
| Peer | One computer in the swarm. It may compute, average, or both. |
| Gradient | The list of nudges, one per parameter, that says how to improve the model. |
| Bandwidth (Gb/s) | How many bits a link carries each second. 1 Gb/s is 125 megabytes per second. |
| All-Reduce | Every peer ends with the average, each keeping an equal chunk. |
| Parameter server | One machine collects the gradients and holds the parameters. |
| Target batch size | The number of samples the swarm must process before one step. |
| Delayed parameter update | Compute step k + 1 while averaging step k, at the price of one stale step. |
| Keeper fraction | The share of the gradient a peer averages. Set by its bandwidth. |
| Auxiliary peer | A peer with c = 0: no GPU work, only averaging. |
| Group All-Reduce | Average in small groups that take turns, so a failure hits only one group. |
| DHT | A shared dictionary spread over all peers. No central server. |
| NAT | A home router that blocks connections started from outside. |
| Hole punching, relay, client mode | Direct link by introduction; link via a third peer; send-only. |
| Backbone peer | A stable server that greets newcomers and stores checkpoints. |
| Shuffle buffer | A pool of S examples to draw from at random, refilled from the stream. |
This sketch follows the paper’s description. It is not the API of the Hivemind library that the authors used.
pythondef collaborative_step(peer, dht, B, P): # 1. compute: every peer fills the shared batch at its own pace while dht.get("samples") < B: x, y = next(peer.stream) # from the shuffle buffer peer.accumulate(grad(peer.model, x, y)) dht.add("samples", len(x)) # 2. plan: every peer solves the same LP (< 50 ms) and gets the same answer plan = solve_lp(dht.roster(), B=B, P=P) # a_ij, g_ij, c_i if plan.c[peer.id] < 1: peer.drop_local_gradients() # helper: average only # 3. average in groups of size m; keep fraction f_i ~ min_j g_ij for group in dht.make_groups(m=plan.group_size): peer.avg_chunks(group, keep=plan.fraction[peer.id]) # 4. every peer takes the same optimizer step, then bumps its step counter peer.optimizer.step(peer.averaged_gradient()) dht.set(peer.id, "step", peer.step + 1)
DeDLOC sits between two worlds. Federated learning also faces unreliable devices, but it puts privacy first and often leaves most compute idle. Datacenter methods assume equal machines and fast links. DeDLOC wants every device to work, on public data.
The paper is honest about its limits. Each peer must hold the whole model and run its whole forward and backward pass, so a phone cannot join a model that does not fit in its memory. Peers with ci not equal to 1 throw away their local gradients, and sharing partial gradients is left for later. Peer-to-peer data sharing was described but not built. Recruiting volunteers is called an open question. And the tests use two models.
The Core Automation guide to training on compute islands lists DeDLOC as an early step on the road to training across clusters of different sizes. The islands in that story are whole clusters rather than single laptops, but the arithmetic of this lesson, bandwidth, the slowest link, who averages what, carries over. The post is the place to see how those ideas grew.
Credit. This lesson teaches Distributed Deep Learning in Open Collaborations by Michael Diskin, Alexey Bukhtiyarov, Max Ryabinin, Lucile Saulnier, Quentin Lhoest, Anton Sinitsin, Dmitry Popov, Dmitry Pyrkin, Maxim Kashirin, Alexander Borzunov, Albert Villanova del Moral, Denis Mazur, Ilia Kobelev, Yacine Jernite, Thomas Wolf and Gennady Pekhimenko (NeurIPS 2021). Read it at arxiv.org/abs/2106.10207; the code is at github.com/yandex-research/DeDLOC. The toy solvers on this page are simplified models written for teaching, and they say so beside each device.
Now press Teach and explain the hero’s purple bar from memory: why the plain ring waits on the slowest link, what the keeper fractions are, and why the batch stays fixed. Or go back to the race and try each team again.