Training machines swap gradients every step, and on a slow wire the swap takes longer than the work. This paper sends 0.1% of each gradient and keeps the accuracy: 270 to 600 times fewer bytes.
Learn why a slow network starves expensive GPUs, how to send only the largest gradient values, and the four small fixes that stop that shortcut from hurting accuracy.
Pick a method and a wire speed. Watch how long the GPUs sit idle in each step. Then we build, piece by piece, every idea underneath, with a toy you can play at each stop.
You need a rough idea of a neural network that learns by small steps (the weights move a little each step). We build the rest from zero.
Paper: Yujun Lin, Song Han, Huizi Mao, Yu Wang and William J. Dally, “Deep Gradient Compression: Reducing the Communication Bandwidth for Distributed Training”, ICLR 2018. Read here as a source for Core Automation’s Hitchhiker’s Guide to Training on Compute Islands (Rohan Anil, 2 November 2026). Background lesson: Communication compression.
AlexNet gradient sizes are the paper’s Table 3: 232.56 MB, 29.18 MB (TernGrad), 0.39 MB (DGC). The 0.30 s of compute per step is illustrative. Wire time is size × 8 ÷ link speed, ignoring protocol overhead and the extra traffic of an all-reduce.
Chapter 0
See why a group of machines training one network spends more time talking than thinking, and why that is a problem you can fix by talking less
Picture four friends building one huge jigsaw puzzle. Each friend works on a different pile of pieces. After every few minutes, they stop and tell each other what they learned, so that all four boards stay the same. If they talk by shouting across a room, the talking is quick. If they have to post letters to each other, the talking takes longer than the puzzle.
Training a neural network on many machines works the same way. Each machine is a node: a computer with one or more GPUs (chips built for fast arithmetic). Each node reads its own pile of training examples and works out how the network’s numbers should change. Those numbers are the weights. The suggested change to the weights is the gradient: one number per weight that says which way to nudge it, and by how much.
In the common setup, called synchronous training, every node must add up everyone’s gradients before any node takes its next step. Each node sends its whole gradient to the others. For ResNet-50, an image network, that gradient is 97.49 MB. For DeepSpeech, a speech network, it is 488.08 MB. Both figures come from this paper’s tables. Every node sends that much, every step, thousands of times.
A network link is the wire between nodes. Its speed is its bandwidth: how many bits it carries per second. We write it in Gbps, gigabits per second, where one gigabit is a billion bits. Eight bits make one byte. So a 1 Gbps link carries at most 125 MB each second.
Now do the sum for the paper’s AlexNet. Its gradient is 232.56 MB. That is 1,860 megabits. On a 1 Gbps link the bits need about 1.86 s to cross. A GPU can finish the arithmetic of one step in a fraction of that time. For the whole 1.86 s, the expensive chips sit and wait. The hero at the top of this page shows exactly this: the blue blocks are work, the hatched yellow blocks are waiting.
The paper states the problem in one sentence. Gradient exchange is costly and “dwarfs the savings of computation time”, especially for recurrent networks, which do little arithmetic for each weight they own. So adding more nodes stops helping. The network becomes the limit on how far training scales.
The authors make a bold claim in their abstract: 99.9% of the gradient exchange in distributed SGD is redundant. SGD means stochastic gradient descent, the step rule from Chapter 1. “Redundant” means you can leave it out and training still reaches the same accuracy. Their method, Deep Gradient Compression (DGC), sends about one value in a thousand. It cuts ResNet-50’s gradient from 97 MB to 0.35 MB, and DeepSpeech’s from 488 MB to 0.74 MB, with no loss in accuracy.
That sounds like cheating, so the rest of this lesson earns it. First we learn what a node really sends. Then we see why earlier tricks lost accuracy. Then we build DGC one mechanism per chapter: send the biggest values and save the rest, fix the momentum, clip the spikes, kill stale pushes, and ease in gently at the start.
Why does a lesson about a 2017 paper sit in a path about compute islands? Core Automation’s post The Hitchhiker’s Guide to Training on Compute Islands describes clusters of GPUs that sit far apart and talk over slow links. One run in the post used 160 GPUs in the US and 160 in Asia, joined by a 25 Gbps link, roughly 9,000 miles long. The post lists DGC in its table of older ideas: it “sends only a small fraction of gradient values, with momentum correction”. The wire between islands is the same problem, only larger.
Look at one gradient as a field of numbers. In most trained networks a few values are large and most are small. Below, one thousand gradient values are drawn as a grid. The brighter the square, the larger the value. Drag the slider to choose how many of the largest values to send.
Each square is one gradient value. Orange squares are sent. Grey squares stay home. Drag the slider and see how much of the total size the sent squares carry.
Illustrative: 1,000 values drawn from a heavy-tailed distribution (log-normal sizes, random signs, fixed seed), not a real gradient. The paper’s own evidence is accuracy: Section 4 shows ResNet-50 matching its baseline while sending 0.1% of the values.
In the toy, the few largest squares carry a big share of the total size. But notice what the grey squares are not: they are not zero. They are small, and there are many. If we simply threw them away, we would lose information every step. The whole paper is about a way to hold them back without losing them.
Here is the plan in one line. Do not delete the small values. Keep them on the node, add them up over many steps, and send each one once it has grown big enough. Chapter 3 builds that. Chapters 4 to 7 then fix the side effects it causes.
Chapter 1
Follow one training step across four machines and count the bytes that must cross the network before anyone can move on
You run four machines, and you want them to train one network faster than one machine can. The simplest plan is data parallelism: every machine holds a full copy of the network, and every machine reads different training examples. Nobody splits the network. They split the data.
A step is one round of learning. In a step, each node takes a small group of examples, called a minibatch of size b. It runs the network on them (the forward pass) and then works backwards to find the gradient (the backward pass). Now each node holds a gradient that reflects only what it saw. If each node moved its weights by its own gradient, the copies would drift apart. So the nodes first pool their gradients, then all take the same move.
Here is the rule the paper calls synchronous distributed SGD (Equation 1). Stochastic gradient descent, SGD, moves the weights a little way against the average gradient of a random minibatch.
A worked case with one weight, four nodes and two examples each (N = 4, b = 2). The eight per-example gradients are 0.2, 0.4 | −0.1, 0.3 | 0.0, 0.2 | 0.5, 0.1. They add to 1.6. Divide by N b = 8 and the average gradient is 0.2. With wt = 1.0 and η = 0.5, the next weight is 1.0 − 0.5 × 0.2 = 0.9. Every node lands on 0.9.
Real training rarely uses the plain rule. It adds momentum, which works like a heavy ball rolling downhill: it keeps some of its old speed. The ball’s speed is the velocity u. The paper writes it as Equation 3.
We will break and then repair this equation in Chapter 4. For now, keep one fact: the weight does not move by the new gradient alone. It moves by a running blend of past gradients. The lesson on optimizers and momentum builds this idea from zero, and optimization and backprop covers the gradient itself.
The sum over nodes is where the network gets used. The paper names two ways to do it (Appendix A). With a parameter server, every node pushes its gradient to a central machine, which updates the weights and hands them back. With all-reduce, the nodes pass pieces of the gradient around among themselves until each one holds the total. The paper uses all-reduce by default, and so do we.
The usual all-reduce arranges the nodes in a ring. Each node cuts its gradient into N pieces and passes pieces to its neighbour in two sweeps. Standard ring arithmetic (it is background here, not a result of this paper) says each node sends about 2(N−1)/N times the gradient size S. For large N that is close to 2 S, whatever N is. The lesson on data parallelism and all-reduce derives it. Try it below.
Orange dots are gradient pieces moving round the ring. Pick a network and drag the number of nodes. Watch what happens to the bytes each node must send.
Gradient sizes are the paper’s Tables 3 and 4. The 2(N−1)/N factor is standard ring all-reduce arithmetic, not from the paper. Time assumes a 1 Gbps link and ignores latency and protocol overhead.
Notice the trap. Add nodes, and each node gets fewer examples to chew on in the same time, so the arithmetic per node shrinks. But the bytes each node sends do not shrink. They creep up toward 2 S. That is Figure 1 of the paper: more training nodes make the computation bar short and leave the communication bar as long as ever. At some N the wire is the whole step.
There is one more detail that matters later. If every node sends only a few chosen values, the all-reduce must add sparse lists. The paper warns in Section 5 that, in the worst case, the density of the summed list doubles at every aggregation step, because different nodes pick different positions. Its speed-up estimates take this into account.
Here is how the trap shows up in a real run. The symptom: you double the nodes from 8 to 16 and the run barely speeds up. The measurement: log the time spent in compute and the time spent in the all-reduce, for every step. On a 1 Gbps link, ResNet-50’s all-reduce takes 1.75 × 97.49 MB × 8 ÷ 1,000 = 1.37 s at 8 nodes, and 1.875 × 97.49 MB × 8 ÷ 1,000 = 1.46 s at 16 nodes. Say compute per node falls from 0.40 s to 0.20 s (an illustrative figure). The step goes from 1.77 s to 1.66 s: about 6% faster for twice the machines. The fix is not more nodes. The fix is fewer bytes, which is the whole aim of the paper.
Chapter 2
Compare the two ways to shrink a gradient and see why each one hit a ceiling before this paper
You have to mail a heavy parcel, and postage is by weight. You have two ideas. You can wrap each item in lighter paper. Or you can mail fewer items. The first idea shrinks each item, the second shrinks the count. Researchers tried both on gradients years before Deep Gradient Compression.
A gradient is a list of M numbers. Normally each number is a 32-bit float: 32 bits (four bytes) to store one decimal-like value. Both ideas attack the total, which is M × 32 bits.
Gradient quantization stores each value with fewer bits. The paper’s related-work section lists the main steps. 1-bit SGD (Seide et al., 2014) keeps only the sign of each value and reached a 10× speed-up in speech training. QSGD (Alistarh et al., 2016; its own lesson) lets you choose how coarse the values are and balances precision against bandwidth. TernGrad (Wen et al., 2017) uses just three levels, so each value is one of three symbols. DoReFa-Net (Zhou et al., 2016) goes further and quantizes the weights too.
These work, but they share a hard ceiling. Even if you cut each 32-bit value to a single bit, you send M bits instead of 32 M. That is 32 times smaller, and no more. The paper’s Table 3 shows the real figure for TernGrad on AlexNet: a gradient of 29.18 MB instead of 232.56 MB, which is 8× smaller. A footnote explains part of the gap: the last fully connected layer of AlexNet stays in 32-bit floats in that work.
Gradient sparsification sends only some of the M values. A sparse list is one where most entries are zero and we do not send the zeros. The question is which values to send. The paper traces the answer through four earlier works.
The pattern is clear. Sparsity of 99% or a little more was the safe zone. The paper warns that without care, extreme sparsity greatly harms convergence. It gives its own number in Section 3.2: plain sparsification as in Algorithm 1 “incurred more than 1.0% loss of accuracy on the Cifar10 dataset” at very high sparsity. So the field stopped near two orders of magnitude.
DGC keeps the sparsification of Gradient Dropping and the local accumulation, then adds four techniques. The paper’s Table 1 lists every technique and the job it does. The right-hand columns say whether it fights staleness (Chapter 6 explains the word).
| Technique | Gradient Dropping | DGC | Job it does |
|---|---|---|---|
| Gradient sparsification | yes | yes | Reduces bandwidth |
| Local gradient accumulation | yes | yes | Ensures convergence |
| Momentum correction | no | yes | Improves accuracy |
| Local gradient clipping | no | yes | Ensures convergence, keeps iteration count |
| Momentum factor masking | no | yes | Improves accuracy, keeps iteration count |
| Warm-up training | no | yes | Improves accuracy, keeps iteration count |
Table 1 of the paper, rewritten. “Keeps iteration count” means training needs no extra steps to reach the same accuracy. We build the second row in Chapter 3, and one new row in each chapter after.
Let us compare the two ideas with arithmetic. Quantization to q bits gives a ratio of 32/q. Sparsification must also say where each kept value sits. The paper’s encode() function (Section 3.1) packs each kept 32-bit value together with a 16-bit run length, the count of zeros that came before it. So each kept value costs 48 bits. If you keep a fraction f of the values, the ratio is 32 ÷ (48 f) = 0.667 ÷ f. At f = 0.1% that is 667×. Try the two knobs.
The top bar is quantization: fewer bits for every value. The bottom bar is sparsification: fewer values, 48 bits each. The scale is logarithmic. Drag both sliders and see which bar can reach 500×.
Ratios are computed from the encoding the paper describes (32-bit values, 16-bit run lengths). The paper’s measured ratios are the markers: TernGrad 8× and DGC 597× on AlexNet (Table 3). Quantization here ignores any extra scale numbers a real scheme sends.
The sliders tell the story. The best a bit-width can do is 32× at one bit. To reach hundreds of times, you must send fewer values. That is the road DGC takes. The catch is accuracy: dropping 99.9% of the values is a big change to the training signal. The next chapters show how to keep that change safe.
Why did the older sparsifiers stall near 99%? Take a fixed threshold, such as Strom’s. Suppose a position sends whenever its value passes 0.01. Early on, typical gradient values are near 0.1, so many positions pass. Later they shrink to near 0.001, and almost nothing passes. This is our own illustration of why a fixed cut-off is awkward, and the paper only says it is “hard to choose in practice”. Dryden et al. fixed the proportion instead of the size. DGC does the same: it fixes the share to send (0.1%), and finds the size cut-off each step from the data.
Chapter 3
Build the core of DGC: pick the largest gradient values, hold back the others in a local drawer, and see why holding back loses nothing
A small post office has one van a day. Heavy parcels go in the van at once. Light letters wait in a drawer. Each day the drawer grows, because new light letters arrive. Sooner or later a letter in the drawer has gathered enough others on top of it to count as heavy, and then it ships. No letter is lost. Some arrive late.
That is gradient sparsification with local accumulation, the first building block of DGC. Each node follows one rule in every step: look at the size of each value, send the largest few, and keep the rest.
The paper’s Algorithm 1 runs on every node k. Here it is as a numbered list, with the node’s drawer called the accumulator, written Gk. It holds one number per weight, and it starts at zero.
The paper uses the size of a value as its guide to importance: “a simple heuristics”, its own words. It sets the same sparsity for all layers of the network.
The worry is plain. If a position is not sent now, is its information gone? The paper answers with a short calculation (Equation 2). Look at one weight, position i, and suppose the node sends it only every T steps. During those T steps its value in the accumulator is the sum of its T gradients. So after T steps the weight has moved like this:
Read it as a batch-size statement. Waiting T steps for position i is the same as training that position with a minibatch T times bigger, N b T examples. The paper adds that learning-rate scaling for large minibatches (Goyal et al., 2017) is the usual way to handle a bigger batch. Here it comes for free. The T in the learning rate η T and the T in the batch size N b T cancel. So a delayed position is just a position trained with a larger batch. That is a respected thing to do. The gradients are not lost. They are bundled.
Take a network with M = 1,000,000 weights. A dense gradient is 4,000,000 bytes. At 99.9% sparsity a node sends 1,000 values. The encode() function stores each as a 32-bit value plus a 16-bit run length of zeros, so 48 bits, or 6 bytes. The message is 6,000 bytes. That is a ratio of 4,000,000 ÷ 6,000 = 667×.
The paper’s measured ratios on whole models are lower: 277× for ResNet-50, 462× for the language model, 597× for AlexNet. The paper does not explain the gap between the 667× of the encoding and these measured figures. It also reports that at 99.9% a typical position is sent only every 600 to 1,000 iterations. Keep that number in mind. It is why the rest of the paper exists.
Now run Algorithm 1 yourself on a toy node. Each press of Step adds a fresh gradient to the accumulator and sends the largest values.
Each bar is one position in the accumulator. Purple bars are waiting. Orange bars were just sent, then reset to zero. Press Step a few times, or Play. Choose how many values go each step.
Toy: 24 positions, each with its own random gradient size (fixed seed, heavy-tailed). The paper picks a threshold so the top 0.1% pass; here a fixed count passes so the effect is visible. The totals are exact sums, so produced always equals sent plus waiting.
Watch the ledger in the read-out. Everything the node has produced is either already sent or still waiting in the drawer. The two always add to the total. That is the guarantee behind the paper’s phrase “eventually send all of the gradients over time”.
It is not a free lunch. A position that waits 800 steps is sent with a gradient that was measured 800 steps ago, against weights that have since moved. Chapters 4 to 7 deal with that cost.
Here is one position traced by hand. Use a threshold of 0.06 (a made-up figure). The gradients on four steps are 0.02, 0.03, −0.01 and 0.04. The accumulator reads 0.02, then 0.05, then 0.04, and then 0.08. Only the last passes the threshold, so the node sends 0.08 on step 4 and resets the position to zero. The four gradients sum to 0.02 + 0.03 − 0.01 + 0.04 = 0.08. The message equals the sum, so nothing was lost. Also notice the small dip on step 3: a negative gradient cancelled part of the pile, as it would in a larger batch.
Chapter 4
Find the push that delayed gradients lose, and repair it by saving the velocity instead of the raw gradient
Imagine pushing a heavy shopping cart. Your first shove sets it rolling. Your second shove, a moment later, adds to a cart that is already moving, so it matters more than the first. A good pusher feels the cart’s speed build. Now imagine a helper who writes down each shove on paper and applies them all at once at the end. The total of the shoves is right, but the cart never built up speed. The result is a weaker push.
That is the trouble Algorithm 1 has with momentum. The paper says so directly: “Algorithm 1 doesn’t directly apply to SGD with the momentum term, since it ignores the discounting factor between the sparse update intervals.”
Recall the velocity rule from Chapter 1: ut = m ut−1 + gradient. Suppose one position gets the gradient 1 on three steps in a row, and m = 0.9. The velocity grows: u = 1, then 0.9 × 1 + 1 = 1.9, then 0.9 × 1.9 + 1 = 2.71. The weight moves by η times each velocity, so the three steps together move it η × (1 + 1.9 + 2.71) = 5.61 η.
Equation 4 of the paper writes the same thing by gradient. The first gradient is counted 1 + m + m2 = 2.71 times, the second 1 + m = 1.9 times, the last once. Early gradients get a longer echo. Their echo is the accumulated discounting factor, the sum of powers of m.
Now hold that position back for T = 3 steps with the plain rule of Chapter 3. The accumulator keeps the raw gradients: v = 1 + 1 + 1 = 3. The node sends 3 and then the server applies its momentum on top. The three echoes (2.71, 1.9, 1) have collapsed into three plain ones. The weight moves 3 η instead of 5.61 η. That is Equation 6, where the discount sums are gone. In Figure 2(a) of the paper, dense momentum drives the optimization from point A to point B, but local accumulation lands at point C, short of the goal.
At 99.9% sparsity a position waits hundreds of steps, so T is large and the lost push grows with it. This is the cause of the accuracy drop the paper reports for plain sparsification.
The repair is small. If momentum is a rule that turns gradients into velocity, then velocity plays the role of the “gradient” for the final update. So the node should keep its own momentum buffer, and accumulate the velocity, not the raw gradient. The paper calls this momentum correction (Equation 7).
Check it on the example. The velocities are 1, 1.9 and 2.71. The accumulator adds them: v = 5.61. The node sends 5.61, and the weight moves 5.61 η, exactly like dense momentum. The echoes are back, because the node kept applying momentum locally while it waited.
The paper stresses the cost: “It is a tweak to the update equation, it doesn’t incur any hyper parameter.” It extends to Nesterov momentum (Appendix B, Equation 10), where the accumulator adds m · u + gradient instead. In memory, each node now holds two buffers the size of the gradient: u and v.
One position gets a gradient of 1 every step. The lines show the total push after T steps. Blue is dense momentum. Red is plain accumulation. The dashed green line is momentum correction. Drag m and T.
Toy: a constant gradient of 1 on one position. Dense total = sum over i from 1 to T of (1 − mi)/(1 − m), from Equation 4. Plain accumulation sends T. Momentum correction equals the dense total. The formulas are the paper’s; the unit gradient is illustrative.
Drag T upward at m = 0.9. At T = 40 dense momentum has pushed about 311 units, and plain accumulation only 40. Plain accumulation delivers only 13% of the push, and that share falls toward 10% as T grows. At m = 0 (no momentum) the lines coincide, and plain accumulation is already right. Momentum correction matters exactly when momentum is on.
On the paper’s AN4 speech task, momentum correction together with local gradient clipping (Chapter 5) improved the word error rate from 14.1% to 12.9%, and the training curves followed momentum SGD more closely.
How would you catch this bug in practice? The symptom: sparse training reaches a lower accuracy than dense training with the same settings. The paper’s measurement for plain sparsification (Algorithm 1) is a loss of more than 1.0% accuracy on Cifar10, as its Figure 3(a) shows. You can confirm the cause by logging how far one weight moves between sends and comparing it with a dense momentum run. If the sparse weight moves much less, by up to 1/(1 − m) times (ten times at m = 0.9) when waits are long, momentum is leaking. The fix costs one extra buffer and no new setting.
Chapter 5
Cap each node’s gradient before it goes into the drawer, and learn why the cap must shrink with the square root of the node count
Back to the post office. The drawer holds light letters until they pile up. One day a huge parcel lands in the drawer by mistake, ten times heavier than anything else. In a normal office it would ship the same day and someone would notice. In this office it sits in the drawer, buried among small letters. Then it ships with the rest, long after anyone could stop it. Meanwhile it has crowded out the right letters.
Gradients can behave the same way. A gradient explosion is a step where the gradient is far larger than usual. It happens in recurrent networks, the kind used for language and speech, because a long chain of multiplications can blow a number up. A network that applies such a gradient can throw its weights far off course in one step.
The usual cure is gradient clipping (Pascanu et al., 2013). First measure the gradient’s L2 norm: square every value, add the squares, take the square root. It is the length of the gradient as an arrow in M dimensions. If that length is above a limit, shrink the whole arrow to the limit. The direction stays the same. Only the length changes.
In normal distributed training this happens after aggregation. The nodes pool their gradients with an all-reduce, and then the pooled gradient is clipped. The paper notes this is “conventionally executed after gradient aggregation from all nodes”.
With DGC the order has to change. Each node keeps adding gradients into its own accumulator for many steps, and nothing is pooled in between. If a spike enters the accumulator, it stays there until it is sent. Clipping the message when it goes out would come too late, because the spike is by then mixed in with many other steps. So DGC clips locally: on each node, to each new gradient, before it is added into the accumulator. In the algorithm this is a step between “compute” and “accumulate”.
That raises a question. What limit should a node use? The global limit was chosen for the sum of N gradients. A single node’s gradient is smaller. The paper gives a short argument in Appendix C.
Suppose all N nodes see gradients from the same kind of data, with the same spread. The paper assumes this: “independent identical gradient distributions with the variance σ2”. Variance measures how widely a number varies, and a standard deviation σ is its square root. When you add N independent numbers, their variances add. So the sum has variance N σ2 and a typical size of √N σ. In the paper’s Equations 11 and 12:
A worked case. Take N = 16 nodes and a global limit of 5.0 (a number we choose to illustrate). Then √16 = 4, so each node clips at 5.0 ÷ 4 = 1.25. With N = 64 the local limit falls to 5.0 ÷ 8 = 0.625. The more nodes, the tighter each one clips, because each one is a smaller part of the total.
The assumption is simple, and real gradients are not always identical across nodes. The paper checks it only by outcome: “in practice, we find that the local gradient clipping behaves very similarly to the vanilla gradient clipping in training, which suggests that our assumption might be valid”. We take that as evidence, not proof.
First test the square-root rule on made-up gradients. Then watch a spike enter an accumulator with and without local clipping.
Top bars: the measured length of one node’s gradient and of the sum of N nodes, from 200 random trials. Bottom: the accumulator’s length over 12 steps when step 5 has a spike. Drag N and toggle the local clip.
Toy: gradients are 100 random Gaussian numbers per node, identical in distribution, which is exactly the paper’s assumption. The spike is a step 6 times too large; the local limit is 1.5 times the typical local length. The √N rule is the paper’s Equation 12. Real gradients may not match the assumption.
In the toy, the measured ratio of the summed length to one node’s length sits close to √N for every N. Turn the clip off and the spike enters the accumulator at step 5 and never leaves. Turn it on and the spike is cut to the limit, so the accumulator keeps its smooth growth.
A last point. Clipping happens before the accumulator, but it does not change the sparsification. After clipping, the node still adds to u and v and still picks the largest. Clipping only controls what goes into the drawer. It costs no bandwidth.
The failure looks like this. The symptom: a recurrent network trains well for a while, and then the loss jumps, or the numbers overflow and training breaks, soon after a send. The measurement: log the length of the accumulator on each node. A spike shows as a sudden rise that does not fade, since nothing leaves the accumulator until it is sent. The fix: clip each gradient at N−1/2 of the global limit before adding it. The cost is one norm and one multiplication per step. The paper applies clipping to its recurrent models, the language model and the speech models.
Chapter 6
See why a late gradient can push the wrong way, and why zeroing the momentum buffer after a send calms the overshoot
You tell a friend the way to a shop: “turn left at the bakery.” The message takes three weeks to arrive by slow post. In the meantime the bakery has closed and the road is one-way. Your friend follows your old directions with full confidence and ends up in the wrong street. The directions were right when you wrote them. They were stale when they arrived.
Staleness is the age of an update: how many steps passed between measuring the gradient and applying it. In plain synchronous training the age is zero. Sparsification changes that. The paper measures the new age: “most of the parameters are updated every 600 to 1000 iterations when gradient sparsity is 99.9%”. Take the Cifar10 setting of Table 2 with 128 images per iteration across 4 GPUs. One epoch, a full pass over the 50,000 training images, is about 391 iterations. By our arithmetic a typical weight waits one and a half to two and a half epochs between sends. The paper says this is “quite long” and that staleness “can slow down convergence and degrade model performance”.
Chapter 4 gave each node a momentum buffer u. It records a running blend of recent gradients for each position. When a position is finally sent, the message carries the velocity that built up while it waited. But u itself does not go away. After the send, it still holds that old history. On the next steps the node adds u into the accumulator v again.
In dense training, this coasting is fine. The weight moves a little each step, the gradient answers each move, and the buffer fades out as the gradient turns round. In sparse training the weight moved in one jump of many steps’ worth. The gradient that fed the buffer was measured at the old weights and may now point the other way. The buffer keeps pushing along a direction the loss has already left. The paper calls this the stale momentum “carrying the weights in the wrong direction”.
The paper cites Mitliagkas et al. (2016), who showed that delay in asynchronous training acts like extra, hidden momentum, which they call implicit momentum. They suggest searching for a new momentum factor to compensate. DGC takes the cheaper route.
The fix is one line. When a position is sent, clear it from the accumulator, as before. Also clear it from the momentum buffer. Both use the same mask. The paper writes (Section 3.3):
The symbol ⊙ means multiply position by position, and ¬Mask flips true and false, so the product zeroes exactly the sent positions. In code, u[mask] = 0 next to v[mask] = 0. The paper’s own description: “This mask stops the momentum for delayed gradients.”
With the mask, a sent position starts over. Its next message is built only from gradients measured after the send, against the weights as they are now. There is a price. The position loses momentum it would otherwise have kept. The paper argues the trade is good, and Figure 3 backs it up (Chapter 8).
To feel the effect, use the smallest possible case: one weight w, a loss of ½(w − 1)2, so the gradient is w − 1, and the best value is w = 1. We start at w = 0 with a learning rate of 0.1 and m = 0.9. Dense momentum comes in with some overshoot and settles. Then we make the weight “sparse”: it moves only when its accumulator passes the threshold. We compare no mask with the mask.
The weight wants to reach 1.0 (dashed line). Blue: dense momentum. Red: sparse updates with stale momentum left alone. Green: sparse updates with the mask. Drag the threshold. A higher threshold means longer waits.
Illustrative one-weight toy, not an experiment from the paper: loss ½(w−1)², learning rate 0.1, m = 0.9, 120 steps. The sparse runs add the velocity to an accumulator and apply it only when its size passes the threshold; the green run also zeroes the velocity buffer at each send. Real networks have millions of weights and different results can follow.
At the default threshold the dense run overshoots to 1.60 before settling. The unmasked sparse run overshoots just as far and ends 0.062 from the target after 120 steps, still ringing. The masked run peaks at only 1.04 and ends 0.013 away. Raise the threshold to 2 or 3 and the order flips on the final error. The masked run is still creeping up (0.129 and 0.199 away) because it forgets momentum at each send. The unmasked run is close (0.026 and 0.032), but it has overshot to 1.59 and 1.63. So the mask buys a calm path at the price of speed. The toy shows the shape of the argument and not its size.
The mask adds no tunable number. The paper pairs it with a second remedy for staleness, which Chapter 7 covers.
How do you tell that staleness, and not something else, hurts you? The symptom: your run has sparsification, local accumulation and momentum correction, and it still trails the dense baseline. The measurement: this is the middle curve of the paper’s Figure 3. Gradient Dropping (red) trails the baseline, momentum correction (yellow) is slightly better, and only adding the mask and warm-up (blue) closes the gap. Because the later techniques fix the curve, staleness was the cause. The fix is the mask here and the warm-up of the next chapter.
Chapter 7
Ease into 99.9% sparsity instead of jumping to it, then see how the node finds the cut-off without sorting millions of numbers
A new dam fills slowly. Engineers open the gates a little at a time, because a fresh structure under full load can crack. Early training is a fresh structure. The weights start random. The network changes fast, and the first gradients are large and unlike each other. This is the worst time to hold most of them back.
The paper explains the risk in a few sentences. Sparsifying early “limits the range of variation of the model, and thus prolongs the period when the network changes dramatically”. Worse, the aggressive early gradients pile up in the accumulator. When they are finally sent, “they may outweigh the latest gradients and misguide the optimization direction”. That is staleness again, at its most harmful.
The remedy borrows a known trick. Goyal et al. (2017) trained with very large minibatches and found that the learning rate should start low and rise over the first few epochs. This is warm-up: a gentle start. DGC keeps that idea and adds a second dial. During warm-up it uses “a less aggressive learning rate” and also “less aggressive gradient sparsity”, so fewer extreme gradients get delayed.
The paper does not ramp the sparsity in a straight line. It raises it exponentially. Every experiment uses the same five values (Section 4.1): 75%, 93.75%, 98.4375%, 99.6% and 99.9%. Look at the share that is sent at each: 25%, 6.25%, 1.5625%, and then about 0.4% and 0.1%. Each stage sends a quarter of what the stage before sent. The last two values are rounded in print: a quarter of 1.5625% is 0.39%, and a quarter of that is 0.098%.
This is the only new hyper-parameter DGC adds. How long does the warm-up last? The paper gives the length in epochs for each task:
The warm-up is a few per cent of training. The paper does not say how the five values map onto those epochs, so the device below simply lets you step through all five.
Take the ResNet-50 gradient of 97.49 MB. A node sends a fraction f of its values at 48 bits each, which is 1.5 times the 32-bit size of those values. So it sends 97.49 × f × 1.5 MB. At stage 3, f = 1.5625%, that is 2.29 MB. At stage 5, f = 0.1%, it is 0.146 MB. Move through the stages below.
Each bar is the size of one message from a ResNet-50 node, on a logarithmic scale. Drag the stage from 1 to 5. The dense gradient is the long grey bar.
The five sparsity values are the paper’s (Section 4.1). Message sizes are computed here as 97.49 MB × share sent × 1.5 (the 48-bit encoding), not read from the paper. The paper’s measured final size for ResNet-50 is 0.35 MB, larger than the 0.146 MB computed at stage 5; the paper does not explain the gap.
Each step the node must find the top 0.1% of millions of values. Sorting everything costs time that GPUs would rather spend on arithmetic. Even a smart selection pass is of order n, where n is the number of gradient values. The paper’s remedy (Section 5) is hierarchical threshold selection, in plain steps:
The paper says the total extra computation is “negligible compared to network communication time which is usually from hundreds of milliseconds to several seconds”. It gives no timing table, so we cannot quote a number for the saving. Try the idea on 100,000 made-up values below.
The grey bars count 100,000 gradient sizes. The teal line is the exact cut-off for the top 100. The orange line is the cut-off guessed from a small sample. Pick a sample size, then press Resample to try different random samples.
Toy: 100,000 log-normal sizes (fixed seed) and a target of the top 0.1%, which is 100 values. A sample of 100 values gives a very rough cut-off, which is why the paper samples 0.1% to 1% and refines when too many pass.
Small samples are noisy. A sample of 100 values has only one value in its top 0.1%, so that value is the sample’s maximum, and the cut-off swings from run to run. Larger samples are steadier. When the guess lets too many values through, the refine step trims them. The check and the refine step make a rough guess safe.
One thing to check about the sample: how many values does it really use? ResNet-50’s 97.49 MB gradient holds about 24.4 million 32-bit values (97.49 million bytes divided by 4, our arithmetic). A 0.1% sample is about 24,000 values, and 24 of them lie in the top 0.1%. A 1% sample is about 244,000 values, with about 244 in the top 0.1%. So on a real network the estimate rests on tens to hundreds of values, not on one. The toy above uses only 100,000 values, so its samples are much smaller and its estimates much noisier than the paper’s.
Chapter 8
Read the paper’s evidence line by line: what was trained, what was compared, what held up, and what is only modelled
A claim of 600 times less traffic with no loss of accuracy needs a close look. Before we read the numbers, ask three questions. What was trained? Against which baseline? And how was each number measured? The paper (Section 4) gives clear answers to the first two, and a more careful answer to the third.
The paper tests three kinds of task. Image classification: ResNet-110 on Cifar10 (50,000 training images, 10 classes), and AlexNet and ResNet-50 on ImageNet (over a million images, 1,000 classes). Language modelling: a 2-layer LSTM with 1,500 hidden units per layer on the Penn Treebank text set. Speech recognition: a 5-layer LSTM on the small AN4 set, and a 7-layer GRU of 1,200 units per layer on the 960 hours of LibriSpeech. The tables run on 4 nodes, except Table 2, which varies from 4 to 32 GPUs. The sparsity is 99.9% for every curve.
This table puts DGC next to Gradient Dropping, the closest earlier method, at four cluster sizes. Each cell is the top-1 accuracy of ResNet-110, with the change from the baseline.
| GPUs (batch) | Baseline | Gradient Dropping | DGC |
|---|---|---|---|
| 4 (128) | 93.75% | 92.75% (−1.00) | 93.87% (+0.12) |
| 8 (256) | 92.92% | 93.02% (+0.10) | 93.28% (+0.37) |
| 16 (512) | 93.14% | 92.93% (−0.21) | 93.20% (+0.06) |
| 32 (1024) | 93.10% | 92.10% (−1.00) | 93.18% (+0.08) |
Gradient Dropping loses a full point in two rows. DGC is at or above the baseline in all four. Notice the sizes, though: DGC gains of 0.06 to 0.37 points are small, and the paper reports one number for each cell, with no spread across random seeds. We read the table as “DGC matches the baseline”, not as “DGC beats it”.
Figure 3 is the paper’s ablation. It trains ResNet-110 on 4 nodes and ResNet-50 on ImageNet, and plots accuracy and training loss. For Cifar10 it adds the techniques one by one. Gradient Dropping (red) is worse than the baseline “due to gradient staleness”. Add momentum correction (yellow), and training “converges slightly faster” and the accuracy is much closer. Add momentum factor masking and warm-up (blue), and “gradient staleness is eliminated” and the curve closely follows the baseline. That is the story of Chapters 4 to 7, in one picture. On ImageNet, the paper notes that sparse training’s top-1 error falls faster than the baseline’s at the same training loss, an observation it does not explain.
Table 3 reports ImageNet. For AlexNet, the gradient shrinks from 232.56 MB to 0.39 MB, a 597× ratio, with top-1 accuracy at 58.20% against a 58.17% baseline. TernGrad gets 8×, and loses 0.89 points. The paper says DGC gives “75× better compression than TernGrad” (597 ÷ 8 ≈ 75). For ResNet-50, 97.49 MB falls to 0.35 MB, which is 277×, and top-1 rises from 75.96% to 76.15%.
Table 4 covers language and speech. The language model goes from 194.68 MB to 0.42 MB (462×) with perplexity 72.30 against 72.24. Perplexity measures how surprised the model is by new text, and lower is better. DeepSpeech on LibriSpeech goes from 488.08 MB to 0.74 MB, and the word error rate on clean test speech falls from 9.45% to 9.06%, on noisy speech from 27.07% to 27.04%.
A check of the arithmetic, because it is cheap. 232.56 ÷ 0.39 = 596, 97.49 ÷ 0.35 = 279 and 194.68 ÷ 0.42 = 464. Those sit within a few units of the printed 597, 277 and 462, which is fair for sizes rounded to two decimals. But 488.08 ÷ 0.74 = 660, while the paper prints 608. The abstract says “270× to 600×” and gives the same 488 MB and 0.74 MB. Either 0.74 or 608 is a typo or a rounding of a different quantity. We quote both as printed and flag the mismatch. Try each task below.
Choose a task. The two bars are the gradient size per node, baseline against DGC, on a logarithmic scale. The read-out gives the quality number and the time on a 1 Gbps wire.
All sizes, ratios and quality numbers are the paper’s Tables 3 and 4 (4 nodes, 99.9% sparsity). Wire times are size × 8 ÷ 1 Gbps, ignoring protocol overhead. For DeepSpeech the printed 0.74 MB and 608× do not agree (488.08 ÷ 0.74 = 660); both are shown as printed.
Figure 6 is where the story turns to speed. It plots speed-up against the number of nodes, from 1 to 64, for AlexNet and DeepSpeech, on a 1 Gbps and a 10 Gbps Ethernet cluster. Each node has 4 NVIDIA Titan XP GPUs. Read the caveat in the text: these curves come from “the performance model proposed in Wen et al. (2017)”, which “combin[es] the lightweight profiling on single training node with the analytical communication modeling”. So Figure 6 is a model fed with measured single-node numbers, not a 64-node run. It includes the worst case where sparse lists get denser at every all-reduce step.
What it shows is the paper’s main systems claim. Conventional training does much worse at 1 Gbps than at 10 Gbps. DGC lets the 1 Gbps cluster compete with conventional training at 10 Gbps. For AlexNet on 64 nodes, conventional training reaches about 30× at 10 Gbps, while DGC reaches more than 40× at 1 Gbps. The gain grows when the model has a high communication-to-computation ratio and the network is slow, which is exactly the compute-island case.
Chapter 9
Keep the numbers, the checklist and the core code on one page, and see where this 2017 paper sits in the story of training across slow links
Here is the whole paper in one paragraph. Synchronous training makes every node send a full gradient every step, and on a slow wire that wait starves the GPUs. Deep Gradient Compression sends only the largest 0.1% of values, and keeps the rest in a local accumulator so nothing is lost. Four fixes make that safe. Momentum correction accumulates velocity so delayed gradients keep their echo. Local clipping caps spikes before they enter the accumulator, with a limit of N−1/2 times the global one. Momentum factor masking clears stale momentum at each send. Warm-up eases from 75% to 99.9% sparsity. The result is 270 to 600 times fewer bytes at the baseline’s accuracy.
| What | Value | Where in the paper |
|---|---|---|
| Sparsity used | 99.9% (0.1% non-zero) | Section 4.2 |
| Warm-up sparsity ladder | 75%, 93.75%, 98.4375%, 99.6%, 99.9% | Section 4.1 |
| Warm-up length | 4 of 164 epochs (Cifar10), 1 of 40 (PTB), 1 of 80 (speech) | Section 4.1 |
| Message format | 32-bit value plus 16-bit run length of zeros | Section 3.1 |
| Wait between sends at 99.9% | most weights every 600 to 1,000 iterations | Section 3.3 |
| Local clip limit | global limit × N−1/2 | Equation 12 |
| Threshold sample | 0.1% to 1% of the gradient values | Section 5 |
| AlexNet (ImageNet) | 232.56 MB to 0.39 MB, 597×, top-1 58.17% to 58.20% | Table 3 |
| ResNet-50 (ImageNet) | 97.49 MB to 0.35 MB, 277×, top-1 75.96% to 76.15% | Table 3 |
| LSTM language model (PTB) | 194.68 MB to 0.42 MB, 462×, perplexity 72.30 to 72.24 | Table 4 |
| DeepSpeech (LibriSpeech) | 488.08 MB to 0.74 MB, printed 608× (arithmetic gives 660), WER 9.45% to 9.06% | Table 4 |
| Plain sparsification on Cifar10 | more than 1.0% accuracy loss | Section 3.2 |
| AN4 word error rate | 14.1% to 12.9% with momentum correction and local clipping | Section 3.2 |
| AlexNet at 64 nodes (modelled) | about 30× at 10 Gbps conventional, more than 40× with DGC at 1 Gbps | Figure 6 |
| Term | In plain words |
|---|---|
| Node | One machine with its own GPUs and its own copy of the network. |
| Gradient | One number per weight, saying which way to nudge it. |
| All-reduce | Every node ends up with the sum of every node’s values. |
| Bandwidth (Gbps) | How many billions of bits a link carries each second. |
| Sparsity | The share of values left out of a message. 99.9% means 1 in 1,000 is sent. |
| Accumulator (v) | The local drawer that holds values until they are big enough to send. |
| Momentum correction | Accumulate the velocity u, not the raw gradient. |
| Local gradient clipping | Cap each node’s gradient at N−1/2 of the global limit before accumulating. |
| Staleness | How many steps old an update is when it is applied. |
| Momentum factor masking | Zero the momentum buffer wherever a value was just sent. |
| Warm-up | Start with little sparsity and raise it in five stages. |
| Compression ratio | Size of the encoded message divided into the size of the dense gradient, as a multiple. |
This sketch follows the paper’s Algorithm 3 for vanilla momentum. It is pseudo-code in the style of PyTorch, not the authors’ released code (that is at github.com/synxlin/deep-gradient-compression). The gradient is already averaged over the node’s minibatch and divided by N, so a sum over nodes gives the average.
# shapes: grads, u, v are float32 tensors of shape [M], M = number of weights
SPARSITY = [0.75, 0.9375, 0.984375, 0.996, 0.999] # warm-up ladder, final stage held
def dgc_step(grads, u, v, w, m, lr, global_clip, N, stage):
# 1. local gradient clipping (Chapter 5)
limit = global_clip / N ** 0.5
norm = grads.norm()
if norm > limit:
grads = grads * (limit / norm)
# 2. momentum correction (Chapter 4)
u = m * u + grads # local velocity, updated every step
v = v + u # accumulate velocity, not the raw gradient
# 3. threshold from a small sample (Chapter 7)
keep = 1.0 - SPARSITY[min(stage, 4)]
idx = torch.randint(len(v), (len(v) // 100,)) # 1% sample
k = max(1, int(len(idx) * keep))
thr = v.abs()[idx].topk(k).values[-1]
mask = v.abs() > thr
# (if mask.sum() is far above keep * M, run an exact topk on v[mask])
# 4. build the message: positions and 32-bit values, about keep * M entries
pos = mask.nonzero().squeeze(1)
msg = (pos, v[pos])
# 5. clear what was sent, in BOTH buffers (Chapter 6)
v[mask] = 0
u[mask] = 0
# 6. sparse all-reduce, then a plain step: no momentum on the server side
total = sparse_all_reduce(msg, M) # shape [M], sum over N nodes
w = w - lr * total
return w, u, vThe Core Automation post names four old lines of work behind today’s methods: local updates, compression, gossip, and fault-tolerant averaging. DGC belongs to the second line. The post’s timeline lists it as the 2017 method that “sends only a small fraction of gradient values, with momentum correction”, next to QSGD (quantization), and later PowerSGD (2019), which uses low-rank compression that is compatible with all-reduce.
Later literature calls the accumulator trick error feedback: keep what compression left out, and add it to the next message. The post uses the same words about its long-distance run, where compressed updates carry error feedback and “may land late”. DGC’s chapters on staleness are an early account of why late arrival needs care.
What DGC does not do is reduce how often nodes talk. It still exchanges every step, just with smaller messages. The other path, taking many local steps between exchanges, is the subject of local SGD and model averaging and DiLoCo (with its own paper lesson, DiLoCo). Modern low-communication training often combines both.
This lesson teaches “Deep Gradient Compression: Reducing the Communication Bandwidth for Distributed Training” by Yujun Lin, Song Han, Huizi Mao, Yu Wang and William J. Dally (Tsinghua University, Stanford University, NVIDIA), ICLR 2018. All results quoted are theirs. Toy numbers are labelled in each device. It was written as a companion to Core Automation’s The Hitchhiker’s Guide to Training on Compute Islands by Rohan Anil (2 November 2026).
Go back to the wire at the top and run the three methods again. Now you can say what each one sends, and what it keeps at home.