Large Scale Distributed Deep Networks

A network too big for one machine can still learn if hundreds of copies share one set of weights and never wait for each other. Each copy is called a replica. Race them and see what breaks.

Learn how Google trained a network with 1.7 billion parameters on thousands of ordinary machines in 2012, and why the same trick still matters when machines are slow, far apart or unreliable.

Pick a setup and watch the loss fall. Then switch to 200 replicas without Adagrad and watch the run explode. Then we build, piece by piece, the parameter server, the asynchronous update, the stale gradient that breaks it, and the per-parameter rate that saves it.

You need a rough idea of a neural network (a stack of layers that turns an input into a prediction) and what a slope is. We build the rest from zero, including every term in the title.

Based on Jeffrey Dean, Greg Corrado, Rajat Monga, Kai Chen, Matthieu Devin, Quoc Le, Mark Mao, Marc’Aurelio Ranzato, Andrew Senior, Paul Tucker, Ke Yang and Andrew Ng, Large Scale Distributed Deep Networks, NeurIPS 2012 (Google). Read here as a classic cited by the Core Automation post The Hitchhiker’s Guide to Training on Compute Islands by Rohan Anil. The background lesson is Decentralized and gossip training. Every idea is re-taught in our own words and devices.

Race the replicas

A toy you run live: eight weights with different curvature, a made-up loss that is a bowl, noisy slopes, and replicas of uneven speed (one in seven is up to four times slower). One tick is one mini-batch on one replica. The counts 1, 20 and 200 are the paper’s Figure 4 setups; the curves are not its data. Fixed rates were tuned by hand: 0.05 for one replica, 0.01 for 20 and for 200; Adagrad uses its scale constant 0.15.

Chapter 0

The Network That Did Not Fit

See why one GPU and one machine ran out of room, and what 2012 researchers did instead

Picture a recipe card with 1.7 billion numbers on it. Each number is a knob. To teach a program to name the objects in a photo, you must tune every knob until the answers come out right. Now try to keep that card on your desk.

That was the problem Google faced in 2012. This chapter defines the words you need, shows why one machine was not enough, and says what the paper did instead.

Training, in four words

A neural network is a stack of layers that turns an input, such as a photo, into a prediction, such as “cat”. Each layer multiplies its input by numbers it keeps. Those kept numbers are the parameters, the knobs of the network. A small network has thousands. The paper’s largest has 1.7 billion.

Training means turning the knobs until the predictions are good. You need a score for “how wrong are we”. That score is the loss: low is good. For each knob you also need a gradient, which is the slope of the loss along that knob. It says which way to turn the knob, and how hard, to make the loss fall.

One training step is short. Show the network a few examples. Measure the loss. Compute the gradient of every parameter. Nudge each parameter a little against its gradient. Repeat millions of times. This recipe is stochastic gradient descent, or SGD. “Stochastic” means each step uses a small random handful of examples, called a mini-batch, not the whole data set.

w
The list of all parameters. For the paper’s biggest network it holds 1.7 billion numbers.
w (right side)
The same list before the step. The arrow means “replace the list with the result”.
η
The learning rate: the size of the nudge. Too small and training crawls. Too large and it overshoots and blows up.
g
The gradient on one mini-batch: one slope for each parameter, so a list as long as w.

Worked example with two knobs. Say w = (3, −1), the gradient is g = (2, 4), and the learning rate is η = 0.1. The nudge is 0.1 × (2, 4) = (0.2, 0.4). The new w is (3 − 0.2, −1 − 0.4) = (2.8, −1.4). One step, done. Real training does this billions of times.

Why one machine ran out of room

By 2012 people trained networks on a GPU, a graphics chip that does huge amounts of arithmetic at once. A GPU is fast, but it has its own small memory. The paper puts it at typically under 6 gigabytes. The authors write that the GPU speed-up is small when the model does not fit in that memory.

Researchers worked around this by shrinking the data or the model. That is fine for small jobs. It is a poor answer for photos at high resolution, where you want both many examples and many knobs.

Check the size. A parameter is usually stored as a 32-bit number, which takes 4 bytes. This is a common choice, not a fact the paper states. At 4 bytes, 1.7 billion parameters need 1.7 × 109 × 4 = 6.8 billion bytes, or 6.8 gigabytes. That is already more than the 6 GB card, before we store a single gradient. Try the four networks of the paper.

Does it fit on one GPU?

Each bar is the memory to hold the parameters alone. The dashed line is the paper’s 6 GB GPU. Pick a network, then change how many bytes one parameter takes.

4

The four parameter counts are the paper’s (Figure 3: speech 42M, images 80M, 330M and 1.7B) and so is the GPU limit of about 6 GB. Bytes per parameter is a knob of ours: 4 is the common 32-bit number. The bars count parameters only. Training also keeps gradients and other values, so real needs are higher.

Only the largest network fails the 6 GB test at 4 bytes. But the 330 million network, at 1.3 GB, is already tight once gradients and the working data sit beside it. And the data is big too: the speech set holds 1.1 billion examples, and the image set holds 16 million photos in 21 thousand categories.

The time problem

Even a model that fits can train too slowly. Suppose, as an illustration, that one machine handles 1,000 examples a second. One pass over 1.1 billion examples takes 1.1 × 106 seconds. That is 12.7 days. Two hundred machines working side by side would cut it to about 5,500 seconds, a little over an hour and a half.

Plain SGD cannot use all those machines. Each step needs the weights the last step produced, so the steps form a single line. The paper says it directly: the traditional formulation of SGD is inherently sequential.

Three words for the rest of the lesson

Machines that cooperate can keep step with one another or not. Synchronous means everyone waits at a line until the last machine arrives, and then all move on together. Think of a school trip where the bus leaves when the last child is aboard. Asynchronous means each machine goes at its own pace and never waits.

A straggler is a machine that runs slower than the rest, because it is busy, old or broken. In a synchronous job one straggler slows everybody. In an asynchronous job it hurts nobody, but its news arrives late. That trade is the heart of the paper, and of the Core Automation post.

What the paper does

The authors built a software framework called DistBelief. It uses a cluster, which is a room full of ordinary machines wired together. They write about tens of thousands of CPU cores (the general-purpose processors inside those machines) and models with billions of parameters. It does two jobs.

  1. Cut one network across several machines so a model too big for one machine fits (Chapters 1 and 2).
  2. Run many copies of the network at once and let them share what they learn, with two methods: Downpour SGD (Chapters 3 to 5) and Sandblaster L-BFGS (Chapter 6).

The result: a network 30 times larger than any reported before, and a speech model trained in under a tenth of the GPU’s time. The same ideas sit under every large training job today, including the compute-island setting of the Core Automation post, where machines are far apart and some are slow or lost.

The road

  1. Two ways to split the work: cut the network, or copy it.
  2. Model parallelism: one network over many machines, and when it stops paying.
  3. Downpour SGD: replicas, a parameter server, and no waiting.
  4. Stale gradients: why old slopes shrink the safe step size.
  5. Adagrad and the warmstart: the two fixes that made it work.
  6. Sandblaster L-BFGS: a coordinator, small portions and backup copies.
  7. The experiments: speech, ImageNet and the race between methods.
  8. Field guide: numbers, code, and the line to compute islands.
Why can plain SGD not simply be run on 200 machines to go 200 times faster?

Chapter 1

Two Ways to Split the Work

Cut a network across machines, or copy it onto many, and see what each choice costs

You own a library with one giant book, and a thousand letters arrive each hour. Each letter asks a question the book can answer. One reader cannot cope. You have two ways to add readers, and they solve different problems.

The first way is to tear the book into volumes and give each reader one volume. To answer one letter, the readers pass notes about what they found. The book never has to sit in one place. The second way is to photocopy the whole book for every reader. Each reader answers different letters, and the readers swap tips about corrections.

These are the two ways to spread a neural network over machines. The paper uses both at once.

Two names to remember

Model parallelism splits one network across machines. Each machine holds part of the network and computes part of every answer. This is the torn book. It lets you run a network too big for one machine.

Data parallelism copies the whole network onto many machines. Each copy is a replica. Each replica works on different training examples. This is the photocopied book. It lets you get through the data faster, but only if the replicas can share what they learn. Chapters 3 to 6 are all about that sharing.

The paper calls the second level of parallelism “an intelligent version of data parallelism”: many instances of the model solve one optimisation problem together, and periodically combine their results.

What a network looks like to a machine

Draw the network as columns of dots. A column is a layer. Each dot is a node: one small unit that adds up what it receives and passes on a result. A line between two nodes is a connection, and every connection carries a parameter.

Two shapes of network matter here. In a fully connected layer, every node connects to every node in the next layer. In a locally connected layer, each node connects only to a few neighbours, as an image filter does when it looks at a small patch. The paper’s image network is locally connected. Its speech network is fully connected.

A network runs in two phases. In the upward phase (also called the forward pass, or “feedforward” in the paper’s footnote), each layer computes its outputs from the layer below. In the downward phase (backpropagation) the error flows back and each node learns its gradient. DistBelief lets the user define what each node computes and what messages it sends in both phases. Our optimization and backprop lesson builds both phases from zero.

Cutting the network: what must be sent

Suppose we give each machine a vertical stripe of every layer. Inside a stripe, nodes talk freely, at memory speed. A connection that crosses from one stripe to another is a message over the network, which is far slower. The paper’s Figure 1 makes the rule exact: only nodes with connections that cross a boundary must send their state, and a node sends its state to the machine on the other side once, even if several connections cross.

So we can count messages exactly. Take 5 layers of 12 nodes. There are 4 gaps between layers. Cut each layer into k equal stripes, so there are k − 1 boundaries. In a locally connected network where each node links to its left, own and right neighbour, only the two nodes beside a boundary are involved: one on each side. That is 2 messages per boundary per gap. In a fully connected network, every node needs to be seen by every other stripe, so each of the 12 nodes sends to k − 1 other machines.

Cut the network

Each column is a layer of 12 nodes. Colours mark which machine owns a node. Yellow lines are connections that cross between machines and must travel over the network. Pick the shape of the network, then the number of machines.

3

A toy network of ours: 5 layers of 12 nodes, 4 gaps. Local nodes connect to the node straight across and its two neighbours; the machine counts 1, 2, 3, 4, 6 and 12 divide 12 evenly. The counting rule (one message per node per other machine) is the paper’s Figure 1 caption. The paper does not give these numbers.

Read the two ratios. With 4 machines, the local network sends 24 messages for 136 connections, so each message pays for about 5.7 connections of arithmetic. The fully connected network sends 144 messages for 576 connections: only 4 connections per message. At 12 machines the gap widens: the local net still does 1.5 connections per message, the full net just 1.09. Work per message is the number to watch.

Work it by hand for k = 3 and a locally connected network. Each stripe holds 12 ÷ 3 = 4 nodes per layer. The boundaries sit between nodes 3 and 4, and between nodes 7 and 8. At the first boundary, node 3 sends its state right and node 4 sends its state left: 2 messages. The second boundary adds 2 more. So each gap costs 4 messages, and the 4 gaps cost 16. The fully connected network instead has 12 nodes, each sending to 2 other machines, so 24 messages per gap and 96 in all. Compare 16 with 96 on the slider.

Failure mode: more machines, slower training

The symptom: you double the machines and each step takes longer. The measurement: compute time per machine falls, but time spent waiting on messages rises, and the messages per useful multiplication climb. The fix: use fewer partitions for a network with dense connections, or choose a network whose connections are local. The paper says exactly this. Models with local connectivity are “more amenable to extensive distribution than fully-connected structures, given their lower communication requirements”.

Chapter 2 puts real numbers on this. For the data-parallel half, Chapter 3 shows how replicas share. For a longer treatment of how modern systems combine the same two ideas with pipeline and tensor splits, see the parallelism lesson from CS336 and our distributed training lesson.

A team cuts a fully connected speech network over more and more machines. Training gets slower past a point. What is the best explanation?

Chapter 2

Model Parallelism: One Network, Many Machines

Spread a single network over machines and find the point where adding more makes it slower

Think of an assembly line with a few dozen workers who build one car together. Add workers and the cars come faster, up to a point. Then workers trip over one another, hand-offs pile up, and everybody waits for the slowest hand. The line gets slower with more people on it.

A network cut over machines behaves the same way. This chapter shows what DistBelief handles for you, the three costs that fight each other, and what the paper measured.

What DistBelief takes off your hands

The user of DistBelief writes two things. First, what each node computes. Second, what messages it sends during the upward phase (prediction) and the downward phase (learning). The user then says how to partition the model across machines. The framework does the rest. It runs the nodes of one partition in parallel on every core of its machine (a core is one independent processing unit inside a CPU). It also manages communication, synchronisation and data transfer between machines, in both training and inference.

The authors ran large models with up to 144 partitions and saw significant speed-ups. Modest models showed “decent speedups for up to 8 or 16 partitions”. For their largest model, they used 32 machines at an average of 16 busy cores each, so 32 × 16 = 512 cores training one network.

Three costs on one step

Time a single mini-batch on one machine as T1. Cut the network over N machines. Three things change the time.

  1. Useful arithmetic gets shared. Most of the work divides cleanly, so each machine does about 1/N of it.
  2. Some work does not divide. Loading the batch, bookkeeping and the serial parts stay at a fixed share, call it α.
  3. Talking costs more as you cut more. Each new boundary adds messages (Chapter 1) and each message adds waiting. The paper also names a fourth effect: variance in processing times, which leaves “many machines waiting for the single slowest machine”.

We fold the talking and waiting into one slowly growing term. This is our own model for building intuition, not the paper’s. It is simple enough to fit to the two speed-ups the paper states.

T(N)
Time for one mini-batch when the network is cut over N machines. T1 is the same on one machine.
α
The share of the work that never divides. It sets a ceiling: the speed-up can never pass 1/α.
(1 − α) / N
The divisible work, shared equally by N machines. It shrinks as N grows.
δ ln N
Talking and waiting. It grows with the number of boundaries. δ is bigger for a fully connected network.
speed-up
How many times faster than one machine. The paper plots exactly this in its Figure 3.

The sum has a lowest point. The divisible term falls like 1/N and the talking term rises like ln N, so they cross. Setting the slope to zero, −(1 − α)/N2 + δ/N = 0, gives the best size N* = (1 − α)/δ. Past N*, more machines cost more than they save.

Fit it to the paper’s two numbers

The paper says the speech model (42 million parameters, fully connected) runs fastest on 8 machines, at 2.2 times the single-machine speed, and slows past 8. So N* = 8 and T(8)/T1 = 1/2.2 = 0.4545. Put δ = (1 − α)/8 into the formula and solve for α. The answer is α = 0.113 and δ = 0.111. Check: 0.113 + 0.887/8 + 0.111 × ln 8 = 0.113 + 0.111 + 0.231 = 0.455. It matches.

The 1.7 billion image network (locally connected) reaches more than 12 times at 81 machines. Take α = 0.04, a guess of ours, and solve δ: it comes out near 0.0069, so T(81)/T1 = 0.04 + 0.0119 + 0.0069 × ln 81 = 0.082. The speed-up is 12.2. Its δ is sixteen times smaller than the speech network’s because local connections talk so much less. Move the slider and find where each curve peaks.

Find the useful number of machines

The curve is the speed-up over one machine. The ringed dots are the two values the paper states. The bar below splits one step into useful work, work that never divides, and talking and waiting.

8

The curves come from our simple model, fitted to the paper’s Figure 3 statements: speech peaks at 8 machines with 2.2 times, and the 1.7B image model passes 12 times at 81 machines (we use 12.2, with α = 0.04 as our guess). They are not the figure’s data.

Try the speech curve. At 8 machines about half of each step goes to talking and waiting. At 32 machines it is nearly three quarters, and the model runs slower than at 8. Switch to the image network and push to 128: the curve still rises, with “diminishing returns”, just as the paper reports.

Failure mode: the straggler

The symptom: a run on 64 machines is barely faster than one on 32. The measurement: log the time each machine spends in each phase. Most machines finish early and then idle at the end of the phase, while one or two finish late. The slow machine sets the pace of the whole step. The paper names this as the typical cause of less-than-ideal speedups. The fix, in this chapter’s world, is to use fewer, better-balanced partitions. The fix for data parallelism, in Chapters 3 and 6, is to stop waiting.

In the paper, the 42M-parameter speech model trained fastest on 8 machines per model and slower on more. What explains the slow-down?

Chapter 3

Downpour SGD: Replicas and a Parameter Server

Watch replicas fetch weights, send gradients and never wait for one another

A newsroom has one master copy of tomorrow’s paper on a wall. Twenty reporters each hold a photocopy. A reporter reads the wall, goes off to fix a story, and returns with a correction. The editor writes the correction on the wall straight away. Nobody waits for the others. A reporter may even fix a story using a wall that has changed since they last looked.

This is Downpour SGD. The wall is the parameter server. The reporters are the replicas. This chapter builds the loop piece by piece, then runs it next to a version where everyone waits.

The loop, one step at a time

A parameter server is a group of machines whose only job is to hold the current weights and apply updates to them. It is “sharded”: the parameters are cut into pieces, one piece per machine. With 10 shards, each holds one tenth of the model. For the 1.7 billion parameter network that is 170 million parameters per shard.

Each replica runs a copy of the model on its own slice of the training data. It repeats five steps.

  1. Fetch. Ask the shards for the current weights, w.
  2. Compute. Run one mini-batch through the model. Get the gradient Δw, one slope per parameter.
  3. Push. Send Δw to the shards.
  4. Apply. Each shard updates its own piece at once: w ← w − η Δw. This is the formula the paper prints in Figure 2.
  5. Repeat with the next mini-batch. Do not wait for any other replica.

Because each replica is itself spread over several machines (Chapter 2), a machine talks only to the shards that hold the parameters for its own part of the network.

Asynchronous in two ways

The paper says Downpour is asynchronous “in two distinct aspects”. First, the replicas run independently of each other. Second, the parameter server shards run independently of each other. One shard may have applied 1,000 updates while its neighbour has applied 998, and there is no promise that they applied them in the same order.

This brings real disorder. The paper lists it plainly. A replica almost certainly computes its gradient from weights that are slightly out of date, because someone else updated the server in the meantime. A gradient computed from old weights is a stale gradient. The staleness of an update is the number of server updates that landed between the replica’s fetch and its push. The authors write that 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.” (A nonconvex problem is one whose loss surface has many hills and valleys, like every deep network.)

Fewer, bigger trips: nfetch and npush

Look at the data that moves. A replica of the 42 million parameter speech model pulls 42 × 106 numbers and pushes the same number back. At 4 bytes each that is 168 MB each way, per mini-batch. These sizes are our arithmetic, not the paper’s. They show why the paper says Downpour needs relatively high frequency, high bandwidth contact with the server.

The paper offers a cheaper schedule. A replica asks for new weights only every nfetch steps, and sends gradients only every npush steps. With nfetch = npush = 5, a replica makes one trip in five. Traffic falls to a fifth, and each gradient is a bit older when it lands. In fact fetching, pushing and computing run in three weakly synchronised threads. The experiments in the paper fix nfetch = npush = 1 for a clean comparison with ordinary SGD.

Watch it against a version that waits

The simplest alternative is synchronous SGD. All replicas fetch, all compute, and the server waits at a barrier until every gradient has arrived. Then it applies them and everybody starts again. The device below runs both on the same toy cluster. One replica is a straggler, about two and a half times slower than the rest.

Wait, or do not wait

Each row is a replica. Teal blocks are mini-batches. Yellow shading is a replica sitting idle. The bottom row is the server: a warm tick for every time it applies gradients. Change the mode, add replicas, then break one.

5

A toy schedule of ours: a mini-batch takes about 2 ticks, the 4th replica about 5.5, and each duration varies by 20% on a fixed seed. In the synchronous run a failed replica is not replaced, so the barrier never opens; the paper says a single failure delays the whole synchronous process. Staleness counts the server updates between a replica’s fetch and its push.

In asynchronous mode the server applies a gradient about every 0.5 tick with 5 replicas, and no row ever idles. The cost shows up as the average staleness, three or four updates with 5 replicas. In synchronous mode the same cluster waits on the straggler every round, so rows idle nearly half the time. Now press the fail toggle. Synchronous training stops. Downpour loses one replica’s share and carries on.

That last point is why the paper reports Downpour as “more robust to machines failures than standard (synchronous) SGD”. It is also why the Core Automation post cares: when machines are rented, far apart and sometimes lost, a design that never waits is the one that survives.

One machine in a Downpour run crashes. What happens, according to the paper?

Chapter 4

Stale Gradients: Why Fixed Rates Break

Derive how old weights shrink the safe step size, and why 200 replicas blow up

You are steering a ship by a map. The map is a minute old. If the ship moves slowly, a minute makes no difference. If the ship moves fast, you steer toward where the harbour was, over-correct, and swing from side to side with wider and wider swings.

A stale gradient is that old map. This chapter turns the picture into one short formula, and the formula explains why the 200-replica run in the hero blew up.

The smallest model of staleness

Take one parameter w and a loss shaped like a bowl: loss = ½ λ w2. The number λ is the curvature: how steeply the bowl rises. A large λ is a narrow, steep bowl. The gradient is g = λ w. The minimum is at w = 0.

Ordinary SGD updates with the fresh weight: wt+1 = wt − η λ wt. A Downpour replica uses a weight that is τ updates old. Call τ the delay. The update becomes the equation below.

wt+1
The weight on the server after the update lands.
wt
The weight on the server now.
a
The step strength. It is the learning rate times the curvature.
wt−τ
The old weight the replica saw when it fetched. Its slope is a = ηλ times this value.
a = η λ
One number that mixes the learning rate with the steepness of the bowl.

With τ = 0 this is plain SGD. It settles whenever a is below 2. With τ > 0 the update pushes against a value that has already moved on. That pushing sets up a swing, and the swing may grow.

Deriving the safe limit

Look for solutions that grow or shrink by a fixed factor z at every step: wt = zt. Put this into the update and divide by zt−τ. You get zτ+1 = zτ − a. The run settles if every solution has |z| below 1. It blows up if any has |z| above 1. The edge is |z| = 1.

Write z = eiθ, a point on the unit circle. Then z − 1 has length 2 sin(θ/2). At the edge the equation says this length equals a, so a = 2 sin(θ/2). The direction of z − 1 is θ/2 + π/2. The equation also needs the whole expression to point opposite to the positive axis, so τθ + θ/2 + π/2 = π. Solve: θ = π / (2τ + 1). Put it back.

amax(τ) = 2 sin( π / (2(2τ + 1)) )   ≈   π / (2τ + 1)

Check the ends. For τ = 0, amax = 2 sin(π/2) = 2. This matches ordinary SGD. For τ = 1, amax = 2 sin(π/6) = 1. Direct algebra on wt+1 = wt − a wt−1 gives the same 1. Now the replica counts. With 20 replicas the delay is about 19 updates, so amax = 0.081. With 200 replicas it is about 199, so amax = 0.0079. The safe step shrinks roughly like 1 over the delay.

Find the edge of stability

Top: the safe limit on a, against the delay. Below the curve is safe, above is unsafe. Bottom: the weight over 300 updates, on a log scale. Pick a delay, then slide the step strength across the curve.

0.039

Exact maths for one weight in a bowl-shaped loss with no noise: the limit 2 sin(π/(2(2τ+1))) is derived above and the trace is computed live. The hero uses eight weights; its steepest has λ = 4, so a = 4η. The paper does not give this formula.

Set the delay to 19 and a near 0.04. That is the hero’s 20-replica run: η = 0.01 on the steepest weight, a = 0.04. The limit is 0.081, so the weight settles. Move to delay 199 with the same a. The limit is 0.0079, so a = 0.04 is five times too big and the weight swells. That is the hero’s red line.

What this costs, and why it matters

Only the steepest direction matters. A flat direction has a small λ and stays inside the limit, but the steep one decides whether the whole run lives. So the learning rate has to follow the steepest bowl in the network, divided by the delay.

Now count the progress. Each replica pushes at about the same speed, so N replicas make N updates per tick. If every step must shrink in proportion to 1/N, the total movement per tick stays about the same. A fixed rate can therefore stop adding speed once the replicas pile up. The rest of the story, in Chapter 5, is how the paper found a way past this wall.

Failure mode, in order. The symptom: the loss rises or oscillates after you add replicas. The measurement: compare the delay (about the number of replicas) with the limit; if your a is above it, you are over the edge. The fix: lower the learning rate, or let the rate adapt per parameter.

You change from 20 to 200 replicas and keep the same fixed learning rate. What does the delay model predict?

Chapter 5

Adagrad and the Warmstart

Give every parameter its own rate and start with one replica so that 200 can follow

Two hikers cross the same hill in fog. One takes steps of one fixed length, however steep the ground. The other watches how violently the ground has been tilting underfoot, and shortens the stride wherever it has lurched most. After an hour the first has fallen twice. The second is still on the path.

The second hiker is Adagrad. The paper found that Adagrad and asynchronous SGD, two methods never meant to be used together, “work so well together”. This chapter derives the rule and runs it.

One rate per parameter

Up to now the learning rate η was one number for every parameter. Adagrad gives each parameter i its own rate, set by the history of that parameter’s own gradients. The paper writes it like this.

ηi,K
The learning rate of parameter i at update K. Each parameter has its own, and it changes over time.
γ
One constant that scales all the rates. The paper says it is usually larger, by perhaps a factor of ten, than the best fixed rate you would use without Adagrad.
∑ Δwi,j2
The running total of the squared gradients that parameter i has received so far, from update 1 to update K.

Read the formula in words. A parameter that has seen big gradients has a big total, so it gets a small rate. A parameter that has seen small gradients gets a large rate. The server never needs any other machine to compute this: the total for parameter i lives on the shard that holds parameter i, so “Adagrad is easily implemented locally within each parameter server shard”.

Work one parameter through three gradients with γ = 0.15. First gradient 2: total 4, root 2, rate 0.075, step 0.075 × 2 = 0.15. Second gradient 4: total 20, root 4.47, rate 0.0335, step 0.134. Third gradient 1: total 21, root 4.58, rate 0.0327, step 0.033. The first step is exactly γ. Later steps never exceed it.

Why a bounded step helps

The step on update K is ηi,K Δwi,K = γ Δwi,K / √(∑Δwi,j2). The top is one term of the bottom, so the ratio is at most 1 in size. Every single step is at most γ in length, however wild the gradient.

That is a safety rail. A stale gradient can be large and wrong, as Chapter 4 showed. A fixed rate multiplies it by η and lets the weight lurch. Adagrad can never move a weight by more than γ per update, and as the total grows the rate keeps falling until the total stops growing. This is our reading. The authors say only that they “conjecture that Adagrad automatically stabilizes volatile parameters in the face of the flurry of asynchronous updates, and naturally adjusts learning rates to the demands of different layers.”

The warmstart

The second fix is a habit. Train with a single replica for a while, then release the others. The paper calls this warmstarting. In its speech experiments, Downpour and Sandblaster runs all start from the same warmstart of about 10 hours of simple SGD.

Why? At the start the weights are random and far from any good answer. Gradients are large and the weights change fast. If 200 replicas fetch the same random weights and all push large gradients at once, the server takes a hit from 200 updates that each assumed the others did nothing. After a single replica has pulled the weights into calmer ground, the same crowd does little harm. Together with Adagrad, the authors say, warmstarting “has virtually eliminated stability concerns”.

Let each weight set its own rate

Top: loss against time for the replicas you pick, with Adagrad in warm colour and a fixed rate shown in grey. Bottom: the rate each of the eight weights ended with. A steeper weight (higher curvature) ends with a smaller rate. Try the warmstart.

0.15

The same toy as the hero, computed live: eight weights with curvature 0.2, 0.3, 0.5, 0.8, 1, 2, 3 and 4 (shown in that order, left to right), noisy slopes, uneven replicas. The grey line is a fixed rate of 0.01. The warmstart runs one replica for 12 ticks first. The paper’s own warmstart was about 10 hours of plain SGD on a real network.

Choose 200 replicas and press nothing else. The loss first climbs to about 39, then falls below 0.001. Turn on the warmstart and the peak drops to about 20. Slide γ up and the peak climbs sharply. Slide it down to 0.05 and the spike disappears. A fixed rate of 0.01 on the same 200 replicas never comes back. Now look at the bars: the steepest weight ends with a rate more than ten times smaller than the flattest. No one set that by hand.

Failure mode. The symptom: a large spike in the first few ticks, sometimes to a loss far above where training began. The measurement: the peak loss, which this device prints. The fix: warm up with one replica, and lower γ. The paper reports that with both in place, Downpour with Adagrad ran with 200 replicas, and was the clearly dominant method for budgets up to 2,000 cores.

Why can an Adagrad step never be larger than γ?

Chapter 6

Sandblaster L-BFGS: A Coordinator and Small Portions

Run a batch method on a crowd of machines without waiting for the slowest one

A teacher marks 96 exam papers with eight helpers. She hands each helper 12 papers and waits. Seven helpers finish in about 12 minutes. The eighth is slow today and needs 40. Seven people sit idle for 28 minutes, and nobody can report grades until the last paper is in.

Now the teacher tries again. She hands out two papers at a time, and anyone who finishes gets two more. At the very end, if one paper is still out, she gives a spare copy to someone who is free and takes whichever mark comes back first. That is the load balancing of Sandblaster.

A different kind of method: batch

Downpour is an online method: it updates the weights after every mini-batch. A batch method works the other way. It computes the gradient over a large set of examples, then makes one careful update. The paper notes that batch methods “work well in training small deep networks” and builds a framework called Sandblaster to apply them to big ones.

The batch method it implements is L-BFGS. In plain words, L-BFGS remembers the last few steps and how the gradient changed on each. From that short history it guesses the shape of the bowl, then jumps toward the bottom instead of rolling down it. It needs only simple vector operations on its memory and on the gradient: dot products, scaling and adding vectors. That fact is what Sandblaster uses.

Move the commands, not the numbers

A network with 1.7 billion parameters is a vector with 1.7 billion entries, about 6.8 GB at 4 bytes (our figure). Sending that to one computer to take a dot product is absurd. The paper’s key idea is “distributed parameter storage and manipulation”. The vector stays where it lives, spread across the parameter server shards. A small coordinator process holds the logic of L-BFGS but never sees the parameters. It sends short commands: dot product, scale, add, multiply coefficient by coefficient. Each shard runs the command on its own slice and keeps the result there. L-BFGS’s memory of past steps is stored on the shard that computed it.

A worked example with three shards. Take u = (1, 2 | 3, 4 | 5, 6) and v = (6, 5 | 4, 3 | 2, 1), each cut into three slices of two. The coordinator says “dot(u, v)”. Shard 1 returns 1×6 + 2×5 = 16. Shard 2 returns 3×4 + 4×3 = 24. Shard 3 returns 5×2 + 6×1 = 16. The coordinator adds three numbers: 56. That equals the dot product of the full vectors. Three numbers crossed the network instead of twelve. For the real model, a handful of numbers cross instead of 1.7 billion.

Do not wait for the slowest

The data side needs care too. In a typical parallel L-BFGS, each machine computes the gradient on its share of the examples and sends it to a central server, and everything waits for the last one. On a big shared cluster there is always a slow machine, so this scales badly.

The paper's cure has three parts. First, the coordinator hands each replica a small portion of the batch, “much smaller than 1/Nth of the total”, and gives out a new portion whenever a replica is free. Fast replicas do more portions. Second, near the end of the batch, it schedules extra copies of the portions still outstanding and keeps whichever copy finishes first. These are backup tasks, an idea borrowed from MapReduce. Third, it prefetches data and gives sequential portions to the same worker, so reading data is never the bottleneck.

Share the batch

Eight replicas must finish 96 units of work. Replica 7 runs at under a third of normal speed. Each row is a replica in time. Warm hatched blocks are backup copies. Choose how the work is handed out, then change the portion size.

3

A toy schedule of ours. One unit of work takes one tick at speed 1. Speeds are 1, 1.1, 0.95, 1, 0.9, 1.05, 0.3 and 1, so the ideal finish if nobody ever waits is 96 / 7.3 = 13.2 ticks. A backup may start only when a replica is free and a portion is still running, and the slower copy is cancelled when the faster one finishes. The paper gives the scheme, not these numbers.

With the equal split, the slow replica needs 12 ÷ 0.3 = 40 ticks, three times the ideal. With portions of 3 units, the batch ends at 20: the slow replica took a 3-unit portion near the end, needed 10 ticks for it, and everyone waited. Add backups and it ends at 15.0, 14% over ideal, at the price of 6.1 units of duplicated work, about 6% extra. Portions of 1 unit end at 13.7 with no backups, but then the coordinator hands out 96 portions instead of 32. Set portions to 12 and small-portion mode ends at 40, the same as the equal split. Portions must be small.

Where it differs from Downpour

Downpour needs “relatively high frequency, high bandwidth parameter synchronization with the parameter server”. Sandblaster workers fetch the parameters only at the start of each batch, when the coordinator has updated them, and send gradients only every few finished portions. That is far less traffic. The price: the weights are updated once per batch, not once per mini-batch, so each update is slower in wall-clock terms but sits on a better-informed direction.

The symptom of getting this wrong is idle machines at the end of every batch. The measurement is the finish-time gap between the first and last replica. The fix is smaller portions, backup copies, and more work handed out only when a replica asks.

Why does the Sandblaster coordinator hand out portions much smaller than 1/N of the batch?

Chapter 7

What the Experiments Show

Read the speech and ImageNet results, and predict which method wins

You have built the parts. Now the question is the one every systems paper must answer: did it work, compared with what, and at what cost? The authors ran two jobs, one modest and one huge. We read what each one shows.

The two jobs

The speech job asks a network to label a short snippet of audio. The input is 11 overlapping frames of 25 milliseconds each, and each frame is described by 40 numbers, the log-energy (how loud the sound is, on a log scale) in 40 frequency bands. That makes 11 × 40 = 440 numbers. The output is one of 8,192 acoustic states, the small sound units a speech recogniser reasons about.

Follow the shapes for a mini-batch of B snippets. The input is [B, 440]. Each of four hidden layers has 2,560 nodes with a sigmoid (a smooth squash of each sum into the range 0 to 1), so the tensors are [B, 2560] four times in a row. A softmax layer (it turns 8,192 raw scores into 8,192 shares that add up to 1) ends at [B, 8192]. The weights are 440×2560 + 3×2560×2560 + 2560×8192 = 1.13 million + 19.66 million + 20.97 million, about 41.8 million. This agrees with the paper’s “approximately 42 million”; we ignore biases. The training set had 1.1 billion weakly labelled examples.

The image job uses 16 million ImageNet photos, each scaled to 100×100 pixels, and 21 thousand categories. The network has three stages. Each stage filters, pools and normalises local contrast. Each filtering node looks at a 10×10 patch of the layer below. The output layer holds 21 thousand “one-vs-all” logistic classifiers: one yes-or-no detector per category. The authors varied how many identically connected nodes sat on each patch, from 8 to 36, and the largest net reached 1.7 billion parameters.

JobParametersWiringData
Speech42 million5 layers, fully connected1.1 billion audio snippets
ImageNet80 million to 1.7 billion3 stages, locally connected16 million images, 21,000 categories

What each figure shows

Figure 3 is the model-parallel speed-up, covered in Chapter 2. Small models stop gaining early. The 1.7 billion network gains more than 12 times on 81 machines.

Figure 4 compares optimisation methods on the speech model. Its horizontal axis is training time in hours, from 0 to about 120. Its vertical axis is frame accuracy, the share of audio frames labelled correctly. Left is the training set, right is held-out test data. Every Downpour and Sandblaster run starts from the same warmstart of about 10 hours of plain SGD. The paper’s goal here is “the maximum test set accuracy in the minimum amount of training time, regardless of resource requirements”. In order from slowest to fastest, the text reports: single-replica SGD, then Downpour with 20 replicas (a significant improvement), then Downpour with 20 replicas and Adagrad (modestly faster), then Sandblaster L-BFGS with 2,000 replicas (considerably faster), and fastest, Downpour with Adagrad on 200 replicas. Both Sandblaster and Downpour with Adagrad beat a GPU running the identical model, and the paper says it took under a tenth of the GPU’s time to reach the same accuracy.

Figure 5 asks about cost. Fix a target of 16% test accuracy, and plot how long each method needs against the machines or cores it used (four configurations per method). Points near the origin are good: quick and cheap. Downpour with Adagrad is the best trade. For any fixed budget it reaches the target sooner than the other two. For any deadline it uses fewer resources than Sandblaster, and the fixed-rate Downpour often misses the deadline entirely. Sandblaster scales well with extra cores and may be fastest at an extremely large budget such as 30,000 cores.

Now the result that gave the paper its fame. Downpour trained the 1.7 billion image network on the 21k-category ImageNet task and reached a cross-validated accuracy of over 15%, a relative improvement of over 60% on the best result the authors knew. Work it backwards: 15 ÷ 1.6 = 9.4, so the earlier best was below about 9.4%. The abstract also says the network is 30 times larger than any reported before.

Predict the order

Before you trust the order above, test your own intuition. Rank the five setups by how fast they reach the target accuracy in Figure 4. One catch: the winner is not the one with the most machines.

Rank the methods

Tap the setups from fastest to slowest. Your order builds up below. When all five are placed, press Check to see the paper’s order and how many replicas each one used.

The order and the replica counts (1, 20, 20, 2000, 200) come from the text around the paper’s Figure 4, which names the single-replica SGD as slowest and Downpour with Adagrad on 200 replicas as fastest. The paper’s curves are not reproduced here and the bars show resources used, not time.

If you ranked Sandblaster first because it used 2,000 replicas, you met the lesson of Figure 5. Resources and speed are different axes. L-BFGS used ten times the replicas of the winner and finished later.

Limits to keep in mind

The paper tests one speech model and one image model. It admits there is “little theoretical grounding” for asynchronous updates on nonconvex problems, and that the pairing with Adagrad is surprising. The numbers come from a Google data centre with fast, uniform links. Downpour needs frequent, high-bandwidth contact with the server. That fits a data centre well. It is a poor fit for machines separated by slow links, which is why Chapter 8 follows the idea to compute islands.

In Figure 5, why is Downpour with Adagrad called the best trade-off?

Chapter 8

Field Guide: Numbers, Code and Where It Led

Keep the numbers, the checklist and the code, then follow the idea to compute islands

You can now say it in one paragraph. A network too big or too slow for one machine can be cut over machines (model parallelism) and copied onto many (data parallelism). In Downpour SGD the copies, called replicas, fetch weights from a sharded parameter server, push gradients back, and never wait for each other. The cost is stale gradients, which shrink the safe step like 1 over the delay. Adagrad and a single-replica warmstart tame them. Sandblaster does the same for a batch method by moving commands, not parameters, and by handing out small portions with backup copies.

The numbers and terms to keep

ItemValueWhat it means
GPU memory limitabout 6 GBModels bigger than this get little GPU speed-up (Introduction).
Largest partitioning144 partitionsLarge models still gained speed at this many machines per model (Section 3).
Largest single model run32 machines × 16 cores = 512 coresOne network on 512 cores; replicas multiply this to tens of thousands.
Speech network42M parameters, 1.1B examplesFully connected, 5 layers; fastest at 8 machines, 2.2× (Figure 3).
Image network1.7B parameters, 16M imagesLocally connected; over 12× at 81 machines (Figure 3).
Replica counts compared20, 200, 2000Downpour 20, Downpour + Adagrad 20 and 200, Sandblaster 2000 (Figure 4).
Warmstartabout 10 hoursPlain SGD before the crowd joins (Figure 4 caption).
Accuracy target16%The fixed test accuracy used for time-to-accuracy (Figure 5).
ImageNet 21k resultover 15%, over 60% relative gain1.7B parameters, 30× larger than any network reported before.
Speech vs GPUunder 1/10 the timeSame accuracy as the GPU run, on a cluster (Introduction).

Terms: replica (a copy of the model), parameter server (sharded home of the weights), stale gradient (computed from older weights), Adagrad (a rate per parameter from past squared gradients), warmstart (one replica first), coordinator (issues commands, never sees the parameters), portion and backup task (small pieces of work and spare copies of late ones).

A checklist you can reuse

  1. Does the model fit on one device? If not, cut it, and prefer local connections. Count messages per unit of arithmetic.
  2. How many machines per model? Measure the speed-up. Stop where it peaks.
  3. How many replicas? Expect the delay to be about one less than the replica count. Check the learning rate against the stability limit.
  4. Is the rate adaptive? If not, expect to shrink it as replicas grow.
  5. Did you warm up? Run one replica first. Watch the peak loss.
  6. What if a machine dies or lags? Prefer designs that never wait. Hand out small work and cover the tail with backups.
  7. How much traffic per step? Weights are fetched and gradients pushed: twice the model size, unless nfetch and npush are above 1.

The core as code

Here is the heart of Downpour with Adagrad on the shards, and one Sandblaster command. It is our sketch of the ideas in the paper, not the paper’s code. The shapes are in the comments: P is the number of parameters and S the number of shards.

python
import numpy as np

class Shard:                                   # holds P / S of the parameters
    def __init__(self, w, gamma):
        self.w, self.gamma = w, gamma             # w: [P/S]
        self.G = np.full_like(w, 1e-8)          # sum of squared gradients, per parameter
    def fetch(self): return self.w.copy()          # replica reads: [P/S]
    def push(self, dw):                          # replica sends a gradient piece: [P/S]
        self.G += dw * dw
        self.w -= self.gamma / np.sqrt(self.G) * dw   # eta_i = gamma / sqrt(G_i)
    def dot(self, u, v): return float(u @ v)      # Sandblaster command: S scalars cross the network

def replica(shards, batches, grad_fn, n_fetch=1, n_push=1):
    acc = 0
    for step, batch in enumerate(batches):
        if step % n_fetch == 0:
            w = np.concatenate([s.fetch() for s in shards])   # [P], may be stale by push time
        acc = acc + grad_fn(w, batch)             # [P] gradient of one mini-batch
        if (step + 1) % n_push == 0:
            for s, piece in zip(shards, np.split(acc, len(shards))):
                s.push(piece)                     # applied at once, no barrier
            acc = 0

Where it sits in the field

The paper stands at a turning point. Before it, deep learning ran on one machine or one GPU. After it, large-scale training meant clusters, parameter servers and asynchronous updates. Later systems moved the gradient exchange onto fast collective operations such as all-reduce, and moved to GPUs, but the questions stayed: what do you do about slow machines, old information and heavy traffic?

Those are exactly the questions of the Core Automation post The Hitchhiker’s Guide to Training on Compute Islands by Rohan Anil. Its timeline lists Downpour SGD (Dean et al., 2012) as “the classic asynchronous design: training continues when individual machines are slow or fail”, and its list of methods names Downpour as one way to cope with unreliable peers. Our reading of the link: a replica that pushes every npush steps sends several gradients at once, close in spirit to the change over many local steps that later work calls a pseudo-gradient. And the server’s own rule, Adagrad here, plays the role of a separate outer optimiser. On islands, links are slow, so the exchange must be rarer and bigger. Decentralized and gossip training teaches that background.

Keep going

The takeaway. Do not make a crowd wait. Give the crowd one shared set of weights, let every worker read and write it when it can, and pay for that freedom with old information. Then spend your effort on the old information: shrink the step with the delay, give each parameter its own rate, start with one worker, and cover the slow ones with spare copies.
A run with 200 replicas and a fixed rate blows up in its first minutes. Which pair of changes does the paper's recipe suggest?

Now press Present or Teach and explain from memory why 200 replicas can break a fixed learning rate and what Adagrad and the warmstart change. Then go back to the race at the top, switch between the four setups, and say what each curve is telling you.

Large Scale Distributed Deep Networks (Dean et al., NeurIPS 2012)
Read the paper · The Core Automation post · Back to Gleams