Sending every gradient to every GPU costs 636.9 MB per step at 300M parameters. DeMo sends 7.49 MB, 85 times less, by moving only the fast part of each worker’s momentum.
Learn how a GPU can share a small, well-chosen slice of its momentum instead of a full gradient, and why the slice has to be cut in a cosine view, not in raw numbers.
Choose Raw values or DCT, then drag how many numbers you keep out of 64. Watch the rebuilt chunk and its error. Then we build, piece by piece, the momentum, the cosine transform, the top-k pick and the memory trick that make it work.
You need the idea of a gradient (the direction that makes the loss smaller) and a little Python. We build momentum, all-reduce and cosines from zero.
Based on “DeMo: Decoupled Momentum Optimization” by Bowen Peng, Lizhang Chen, Baiyu Su, Jeffrey Quesnelle, Diederik P. Kingma and Qiang Liu (Nous Research and UT Austin), arXiv 2411.19870. It is one of the papers linked from Rohan Anil’s post The Hitchhiker’s Guide to Training on Compute Islands (Core Automation, 2 November 2026). Background lesson: Communication Compression. Every idea is re-taught here in our own words and devices.
Toy chunk: 64 numbers built from four cosines plus small noise and one spike, seeded so it is the same on every visit. The paper’s chunks are 64 × 64 matrices; this one is a single row so you can see it. The error is computed live as the size of what is lost divided by the size of the chunk. The megabytes are the paper’s Table 1 for OLMo-300M (k = 1, 2, 4, 8, 16, 32) and do not depend on the view; only the quality of the rebuild does.
Chapter 0
Count the bytes that one GPU must send every training step, and see why a slow cable turns that count into idle time
Picture two warehouses, each full of workers packing the same product. Every few seconds, each worker must tell every other worker what they just learned. Inside one warehouse, the workers shout across a room. Between the warehouses, they pass notes down a single thin pipe.
That is distributed training across data centers. Rohan Anil’s post on compute islands describes a real case: two clusters “nearly halfway around the world from each other, over a bidirectional link of 25 Gbps”. This lesson teaches one paper that attacks the note-passing problem head on. First we need the words.
A GPU is the chip that does the arithmetic. A training step is one round of learning: show the model some text, measure how wrong it was, and nudge its numbers. The nudge for each number is its gradient: a small signed value that says “go up” or “go down”. A model with 320 million numbers has 320 million gradient values per step.
In data parallel training, every GPU holds a full copy of the model. Each GPU reads different text, so each computes a different gradient. Before anyone updates, the GPUs must agree on one shared gradient, the average. If they did not, the copies would drift apart. The averaging operation is called an all-reduce: every GPU contributes a gradient, and every GPU ends with the average. Our data parallel and all-reduce lesson builds it in detail.
The cost of an all-reduce is bytes on a wire. Bandwidth is how many bits a wire can carry each second. It is written in Gbps, gigabits per second. A bit is one 0 or 1, and 8 bits make a byte. Careful: a megabyte (MB) is 8 megabits. So 636.9 MB is 5,095 megabits, about 5.1 gigabits. Our bandwidth arithmetic lesson practises these conversions.
The paper trains a model it calls OLMo-300M, with 320 million non-embedding parameters (the weights that are not the word lookup table). It trains on 64 H100 GPUs (H100 is a recent NVIDIA data center GPU model). The standard recipe, called AdamW with DDP (DDP is PyTorch’s name for data parallel training), moves 636.9 MB per GPU per step of dense gradient, meaning every value is sent and none is left out. That is Table 1 of the paper.
A quick check shows where the number comes from. 320 million values at 2 bytes each (the 16-bit format called bfloat16) is 640 MB. The table says 636.9. So the all-reduce moves about one full gradient per step. (The 2 bytes is our reading of the arithmetic, not a statement in the paper.)
For the 1 billion parameter model, the same table says 2,416.6 MB. The paper's introduction says the cost “reach[es] terabytes per step for state-of-the-art models”. Inside a data center, special cables such as NVLink and InfiniBand carry hundreds of gigabits per second, so this is fine. Across the internet, it is not.
Now try it. The device below sends the paper’s two payloads over a link you choose. Slide the link speed down toward an ordinary internet connection and watch the wait grow.
Each bar is one training step: warm is computing, yellow is waiting for the link. Drag the link speed, then the compute time. The two payloads are the paper’s numbers for OLMo-300M.
The payloads (636.9 MB and 7.49 MB per GPU per step) are Table 1 of the paper, AdamW-DDP and DeMo with k = 8. The link speeds and the compute time are illustrative: the paper does not report step times. We also assume no overlap of sending and computing, and count only the bytes one GPU sends once. Real all-reduce moves a bit more than one copy of the gradient.
At 1 Gbps with half a second of compute, the dense step is mostly waiting. The compressed step barely notices the link. This is the whole motivation: the wire, not the chip, sets the speed once the chips sit in different places.
Earlier ideas split into two families. One sends the same bytes less often (the family of local SGD and DiLoCo). The other sends fewer bytes each time (the family of compression, our background lesson). DeMo belongs to the second family, with three moves that this lesson builds one at a time.
First, each GPU keeps its own momentum (a running memory of past gradients) and never averages raw gradients. Second, each GPU changes that momentum into a cosine view, and keeps only the few largest values in each small block. Third, whatever it did not send stays in its momentum and gets another chance next step. The hero at the top of this page is move two. Keep the paper’s own claim in mind: “the gradient information exchanged during distributed training is highly redundant”.
Chapter 1
Smooth a noisy stream of gradients into one buffer, and see why the buffer, not the raw gradient, is the thing DeMo shares
You are walking down a foggy hillside to reach the valley. Every few steps you check a cheap compass. The compass wobbles: it points downhill on average, but each reading is off by a random amount. If you obey each reading, you zigzag. If you average the last few readings, you walk straight.
A training step has the same problem. The gradient from one small batch of text is a noisy reading of the true downhill direction. Momentum is the averaging fix: the optimizer keeps a running memory of past gradients and steps along the memory, not along the latest reading. The memory lives in a buffer, a tensor with the same shape as the model’s weights. Our optimizers and momentum lesson covers the idea in full.
At each step t, the buffer forgets a fraction of its old content and adds the new gradient. The paper’s Algorithm 1 writes this on each worker i.
A worked case shows the effect. Suppose the gradient is a steady 1 for one weight, and β = 0.9. The buffer reads 1, then 0.9 × 1 + 1 = 1.9, then 2.71, then 3.439, then 4.095. It climbs toward 1 ÷ (1 − 0.9) = 10. A buffer with memory β adds up about 1 ÷ (1 − β) recent gradients.
1 → 1.9 → 2.71 → 3.439 → 4.095 → … → 10 (β = 0.9, gradient always 1)
In code, the buffer for a weight matrix of shape [1024, 1024] is a second tensor of shape [1024, 1024]. One multiply and one add update it each step, so it costs the same memory as the weights. It starts at zero, so the first steps move the weights only a little. That warm-up is a feature of every momentum method, not a bug.
One honest note on the paper. Its text equation (2) writes the update as βM + (1 − β)G, while its Algorithm 1 uses βM + G. The two buffers differ only by the constant factor 1 ÷ (1 − β). We follow the algorithm. The device below plots the buffer multiplied by (1 − β), so both forms look the same.
The device feeds a noisy gradient into the buffer. The true signal is 1.0 for 40 steps, then it drops to 0.3. Drag β up and watch two things change: the buffer gets smoother, and it follows the drop more slowly.
Grey dots are noisy gradients. The warm line is the buffer, scaled by (1 − β). The dashed line is the true signal. Drag β from 0 to 0.95.
Illustrative: the gradient is the true signal plus Gaussian noise of size 0.8, seeded so it is the same on every visit; the buffer starts empty and is not corrected for that. The paper trains with β = 0.999, a far longer memory than this device can show in 80 steps.
The smoothing is not free. A long memory averages away noise, but it reacts late when the true direction changes. Training with a very large β therefore works well only when the direction changes slowly. The paper later finds that DeMo likes a large β (0.995 to 0.999). Chapter 6 explains why.
The paper makes one claim here, and it is a claim, not a proof: the momentum is “a compressible, information-rich surrogate for raw gradients”. A buffer that sums many steps carries more than one noisy reading. It also has structure, because nearby weights in a matrix often move together. Structure is what a compressor can use.
DeMo’s default optimizer is the simplest member of the family. Signum steps along only the sign of the buffer: plus one for positive, minus one for negative. AdamW, the usual choice, keeps two buffers per weight (a momentum and a second one for each weight’s typical size). The paper also lists Lion and Muon as compatible. The paper’s conclusion says the sign variant needs less memory than AdamW, because it keeps one buffer, not two.
Chapter 2
Send only the biggest numbers, watch the small ones vanish, and see how error feedback brings them back at a price
You run a small post office with room for one letter a day. Eight people want to write to you, and some write more urgent letters than others. Each day you take the most urgent one. The people with quiet letters never get through, however long you wait.
That is top-k sparsification. A worker has a long list of numbers to share, say a gradient. It keeps only the k numbers with the largest size, called the top-k, and sends those with their positions. Everything else is dropped. The idea is old: Aji and Heafield proposed it in 2017, and Lin and colleagues made it work for real networks in Deep Gradient Compression (2018).
Sparsification is one of four ways to cut the bill from Chapter 0. Quantization sends each number in fewer bits, as in QSGD. Low rank sends two thin matrices that multiply into a close copy of the big one, as in PowerSGD. Local steps send less often: each site trains alone for many steps, then they average, as in local SGD and DiLoCo. Our communication compression lesson compares all of them.
DeMo sits in the first family with a twist. To see the twist, we first see why the plain version breaks.
A dropped number is not small in every sense. It is small this step. If the same weight gets a small gradient every step, it gets dropped every step, and its total push is lost. The compressor is biased: it systematically favours some weights.
The standard fix is error feedback. Seide and colleagues used it for 1-bit gradients in 2014, and Stich and colleagues and Karimireddy and colleagues analysed it later. Each worker keeps a second tensor, the error memory, that holds everything it did not send. Next step, it adds the memory to the new gradient before it picks the top-k.
Work a tiny case. Four weights get a steady gradient of 0.9, 0.5, 0.2 and 0.1 each step, and the worker sends one entry per step. At step 1 the memory plus gradient is [0.9, 0.5, 0.2, 0.1]. It sends 0.9, so the memory becomes [0, 0.5, 0.2, 0.1]. At step 2 the sum is [0.9, 1.0, 0.4, 0.2]. Now weight 2 wins, with 1.0.
step 3: send 1.8 (weight 1) · step 4: send 1.0 (weight 2) · step 5: send 1.8 · step 6: send 1.2 (weight 3) (weights numbered from 1)
By step 6 the third-biggest gradient finally gets its turn, carrying everything it had saved. Without the memory, it would never have been sent. Try the same effect on eight weights.
Eight weights get steady gradients of different sizes. Each step the worker sends only one entry. The outline is what the weights produced; the fill is what arrived. Switch the mode, then drag the steps.
Toy numbers: the eight gradients are 0.9, 0.5, 0.2, 0.1, 0.06, 0.04, 0.03 and 0.02 on every step, one entry is sent per step, and ties go to the lower number. Nothing here comes from the paper; it shows the mechanism the paper builds on.
With the memory on, every weight eventually delivers most of what it produced. With it off, the eight weights split into the few that always win and the rest that never speak.
Error feedback works, but the paper points at its cost. The error memory has one number per weight, so it adds one more copy of the model’s size to GPU memory. The paper’s introduction says such mechanisms “introduce substantial GPU memory overhead”. For a model that already strains memory, a full extra copy hurts.
The paper also names a second weakness, in the sparse picks themselves. Choosing the top-k raw gradient entries gives an update that touches only a few weights, and the paper says such sparse update patterns “often harm performance”. Chapter 4 shows the paper’s answer to that. Chapter 6 shows its answer to the memory bill: it reuses a buffer that already exists, the momentum.
Chapter 3
Remove the gradient all-reduce, let each worker’s buffer evolve alone, and check that sharing buffers later loses nothing
Four chefs taste the same soup, each from a different spoon. The usual kitchen rule says: after every sip, all four meet, agree on one verdict, and only then does each chef write a note. The meeting is the slow part. A better rule lets each chef keep private notes and share a short summary when it matters.
Standard data parallel training is the meeting after every sip. Every GPU computes a gradient, all GPUs run the all-reduce, and every GPU receives the same averaged gradient. Because they all feed the same gradient into the same momentum rule, every GPU holds an identical momentum buffer. Nothing differs between them.
DeMo deletes the meeting. The paper says it removes “the global all reduce synchronization of micro-batch gradients”, so each worker’s momentum buffer evolves from its own gradients only. This is what decoupled means: the momentum is no longer tied to a shared gradient. In PyTorch terms, the implementation turns off DDP’s built-in gradient synchronization and puts the DeMo optimizer in charge of communication.
Now worker i has its own buffer, built from its own stream of gradients.
This line is the heart of the argument, and it is only algebra. The momentum rule is linear: it multiplies and adds, nothing else. So averaging the buffers gives the same result as feeding the averaged gradient into one buffer. The paper puts it in one sentence: aggregating gradients or momenta is “theoretically equivalent due to linearity”.
The device checks this with numbers. Four workers each get their own random gradients (seeded) for six weights. It compares the average of their four buffers with one buffer fed the averaged gradient.
Warm bars: the average of four workers’ buffers as received. Blue marks: one buffer fed the averaged gradient. Choose what each worker sends, then drag the step count.
Toy numbers: four workers, six weights, β = 0.9, random gradients from a fixed seed. Nothing here is from the paper’s experiments. The sparse mode keeps each worker’s two biggest buffer entries and averages them with zeros elsewhere, with no error memory yet; Chapter 6 adds it.
With the full buffer, the two agree to rounding error. The all-reduce was never needed for the maths of momentum, only for sending the information. With the sparse buffer, the average no longer matches. That gap is the price of compression, and the rest of the lesson is about paying as little of it as possible.
Here is the failure to watch for. Suppose you add DeMo on top of a standard DDP setup but leave DDP’s own gradient synchronization on. The symptom is a bandwidth meter that still shows the full gradient on the wire. You measure about 636.9 MB per step at 300M, not 7.49 MB. The fix is the one the paper describes: switch off the default synchronization and let the optimizer own all communication.
The weights must stay identical, or the copies would drift apart into different models. After the exchange, every worker rebuilds the same aggregated momentum, and applies the same update to its weights. So the weights match everywhere, step after step.
The buffers do not match, and they should not. Each worker’s buffer still holds the part it chose not to send, plus its own recent gradients. In Chapter 6 we see that this leftover is the error memory, so it must stay private. The data flow per step, per worker, is: a local gradient (same shape as the weights), a local buffer update (same shape), a small sparse payload sent out, and a shared update received.
The paper writes the exchange as an all-gather (equation 5): every worker sends its small payload to everyone, so every worker receives all N payloads and averages them itself. Its Algorithm 1 draws a parameter server instead (one central machine that collects every payload and sends back the result), but both give the same result, and the paper calls the method topology agnostic: it does not care how the workers are wired together.
Chapter 4
Rewrite a list of numbers as a mix of waves, and see why keeping the biggest waves works better than keeping the biggest raw values
Look at a photo of a clear sky. Nearby pixels are almost the same shade. To describe the sky, you do not need to list a million pixels. You can say “mostly this blue, a little brighter toward the left”. A few words carry the picture, because neighbours agree.
The paper bets that blocks of momentum behave like that sky. Neighbouring entries in a weight matrix tend to move together, so the block is smooth, not random. The tool that turns “smooth” into “few numbers” is the Discrete Cosine Transform, or DCT. It is the same transform that JPEG images use.
Take a list of N numbers. The DCT writes it as a sum of N cosine waves. Wave number u = 0 is flat, u = 1 makes one slow dip across the list, u = 2 wiggles twice, and so on, faster and faster. The transform output is N numbers: how much of each wave is in your list. These are the coefficients.
Orthonormal has two practical meanings. The inverse transform is just the transpose of the matrix, so going back is cheap: the paper notes P−1 = P⊤. And the sum of squares is unchanged, so the energy of the list equals the energy of its coefficients. If you drop some coefficients, the error is exactly the energy you dropped.
Take N = 4 and the flat list [1, 1, 1, 1]. Only wave 0 is present: X0 = √(1/4) × 4 = 2, and the other three coefficients are 0. One number, exact.
Now take a ramp, [3, 1, −1, −3]. The calculation gives X = [0, 4.461, 0, 0.317]. The energy of the list is 9 + 1 + 1 + 9 = 20. The coefficients give 4.4612 + 0.3172 = 19.90 + 0.10 = 20.0, as promised. Keep only X1 and the rebuilt list has error √(0.10 / 20) = 7.1%. One number out of four carries 99.5% of the energy.
[3, 1, −1, −3] → DCT → [0, 4.461, 0, 0.317] | keep 1 of 4 → error 7.1%
In raw form the same ramp has four entries of similar size. Keep the two biggest raw entries, [3, 0, 0, −3], and the error is √(2/20) = 31.6%. That gap is why DeMo ranks coefficients, not entries. The paper tests it directly: “the DCT-based transformation clearly improves performance over the identity mapping” (its Figure 3, at k = 8, 16 and 32).
Top: the 16 raw numbers. Bottom: the same list as DCT coefficients. Teal outlines mark the 3 biggest in each view. Set the three waves, then press Add a spike to break the smoothness.
Toy list of 16 numbers built from waves 1, 2 and 4 with the amounts you set (a wave of amount A shows up as a coefficient of about 2.8 times A, the square root of 16 ÷ 2, because of the orthonormal scale). The spike adds 3 to entry 5. The error is the size of what is lost divided by the size of the list, computed live with the orthonormal DCT above. Real momentum is not guaranteed to be this smooth; the paper tests that with training runs, not with this device.
Without the spike, three coefficients rebuild the list exactly while the raw view needs all sixteen. With the spike, the DCT view needs more numbers, because a sharp spike is built from many waves. The DCT is a bet on smoothness, and the bet is the paper’s empirical finding, not a law.
For a 64 × 64 chunk the idea is the same in two directions. Coefficient (0, 0) measures the average of the whole block. Coefficients far from the corner are fast jitter from one entry to the next. A random block, with no smooth part, has energy spread over all 4,096 coefficients. The symptom is a large error at small k. You measure it as in the device above, and the fix is a larger k. The paper’s results suggest real momentum blocks are closer to the smooth case than to the random one.
The paper also tried random orthonormal matrices, fresh every step and shared by all workers. They did slightly better, but the DCT is the default. The DCT has a fast algorithm built on the FFT (fast Fourier transform), and its matrix is computed once before training. The paper says the choice avoids “the need to recompute the basis at each step” while performing comparably.
Chapter 5
Cut each tensor into 64 by 64 tiles, keep k cosine coefficients per tile, and recompute the paper’s megabytes from scratch
Imagine mailing a huge mural. Mailing the whole thing is slow. So you cut it into postcard-sized tiles, summarise each tile with a handful of numbers, and mail only the summaries. The receiver pastes the tiles back together. DeMo does this to the momentum of every weight tensor.
A tensor is a grid of numbers with any number of dimensions. A weight matrix is a tensor with two. The paper splits each dimension into equal pieces, so a tensor of size n becomes c pieces of size s, with n = c × s. Each resulting block is a chunk. Its default is s = 64: a 64 × 64 tile for a matrix, and a run of 64 entries for a vector such as a layer norm’s weights.
Why not transform the whole matrix at once? Cost. The paper’s complexity note counts it. A full N × N projection needs O(N3) work and O(N2) memory. Cutting the matrix into C × C chunks lowers the work to O(N3/C) and the memory to O(N2/C2). And every chunk uses the same small 64 × 64 DCT matrix, so the extra memory is a constant.
For a 2-D chunk B, the transform multiplies a DCT matrix on each side. This is the paper’s equation (3), with d = 2.
Then comes top-k: among the 4,096 coefficients, keep the k with the largest magnitude and zero the rest (equation 4). With the default chunk size, the upload shrinks by about 4,096 ÷ k in numbers sent. Here is the data flow for one 1,024 × 1,024 weight matrix at k = 8.
Each worker sends this payload to all the others (an all-gather). Receivers must combine N payloads where the workers kept different indices. The paper’s Algorithm 3 does it entry by entry: add up what arrived for each index, then divide by how many workers sent that index, with 0 ÷ 0 = 0. Equation 5 calls the result an average over workers. We follow Algorithm 3; the text is loose here.
The paper’s Table 1 reports 7.49 MB per GPU per step for OLMo-300M at k = 8. We can rebuild that number. The model has 320 million non-embedding parameters. Divide by 4,096 to get 78,125 chunks. At k = 8 that is 625,000 entries. Each entry is a value plus the index that says which of the 4,096 positions it came from.
The table fits 12 bytes per entry exactly: 625,000 × 12 = 7.5 MB. A 4-byte value plus an 8-byte index makes 12. The paper does not state this, so treat it as our reading of the arithmetic. The dense side fits too: 320 million × 2 bytes = 640 MB, against the table’s 636.9.
That also explains a gap. The text says the upload shrinks “roughly 4096/k”, which is 512 at k = 8. The table shows 85. The difference is bytes: each sent entry costs 12 bytes while each dense value costs 2, so the real ratio is (4,096 × 2) ÷ (12 × k) ≈ 683 ÷ k, which is 85 at k = 8. Try your own k.
Bars use a log scale: each gridline is ten times the last. Pick a model, then drag k. The arithmetic below the bars shows every step.
The table values and parameter counts (320 million and 1.18 billion non-embedding parameters) are the paper’s (Table 1 and Section 3.1). The bytes per entry (12 for DeMo, 2 for the dense gradient) are our reading, chosen because they reproduce every row of the table to within rounding.
The ratio does not depend on the model size, only on k: 85 at 300M and 88 at 1B for k = 8 (2,416.6 ÷ 27.58). The paper’s headline “up to 85 times” is the k = 8 row at 300M. Smaller k saves more: the table implies 685 times at k = 1 for 300M and 702 times for 1B, with a small accuracy cost (Chapter 8).
The saving is on the upload. Each worker still receives N payloads, one per peer, so the download grows with the number of workers. The paper says so in its limits: this is “intrinsic to all top-k sparsification-based approaches”. In its DiLoCo comparison with eight workers, k = 32 cuts uploads by 128 and downloads by 16 (counted in numbers, so the byte ratio is smaller).
Chapter 6
Take out what you sent, keep what you did not, and see why that leftover needs no extra tensor
You keep an outbox tray on your desk. Each morning you pick the most important letters and mail them. A careful clerk would take those letters out of the tray, so the tray holds only what still needs to go. A careless clerk mails the same top letters every day.
Chapter 2 gave the clerk a separate tray: the error memory, a full extra copy of the model’s size. DeMo notices that it already has a tray. The momentum buffer holds every gradient seen so far, decayed. If we remove what we sent from it, the buffer holds exactly the part not yet communicated. One tensor does both jobs.
After a worker picks its top-k coefficients and builds the sparse message Q, it rebuilds those coefficients back into momentum space with the inverse DCT, and subtracts the result from its own buffer. This is line 8 of Algorithm 1, and the paper’s equation (8) adds a strength knob.
Compare it with Chapter 2. There the memory was e + g − q. Here the buffer is βM + G − αq. It is the same idea, with a forgetting factor and a strength knob. The related-work section of the paper counts the saving: the method “reduces one copy of memory for the accumulator”.
Two honest notes. First, Algorithm 1 subtracts the part this worker itself sent, while the printed equation (8) writes the aggregated message. We follow the algorithm, because the leftover must be private to the worker, as Chapter 3 argued. Second, Algorithm 1 has no α; it behaves as α = 1. The knob appears in equation (8) and in the ablations.
Unsent information waits in the buffer. If β is small, the buffer forgets quickly, and the waiting information fades before its turn comes. So subtraction pairs with a large β. The paper says: “setting a larger coefficient of β = 0.999 significantly helps convergence” once subtraction is on. In its extra sweep over β = 0.95, 0.98, 0.99, 0.995 and 0.999, all work, larger is better, and 0.995 is best.
Here is the failure in practice. Suppose β is small, say 0.9, and the worker subtracts what it sent. The symptom is a loss curve that trails the best run. The cause is that unsent information fades in about 10 steps, before its coefficient grows big enough to win. The paper measures the remedy: β between 0.95 and 0.999 all train, larger values do better, and 0.995 is best. So raise β when you turn subtraction on.
An ablation removes or changes one part of a method to see what that part does. The paper varies α over 0, 0.1, 0.2, 0.5 and 1 (Figure 4, middle). Its findings, in its words:
The device reproduces the first finding in miniature. It is a toy with sixteen coefficients, not the paper’s experiment. A steady gradient feeds the buffer, and each step the worker sends its top 2. Watch how many different coefficients ever get picked.
Each bar counts how many steps picked that coefficient (a low index means a bigger, steadier gradient). The warm tick is what is still waiting in the buffer. Choose α, then drag the steps.
Toy model: β = 0.99, the gradient of coefficient u is 1 ÷ (1 + u) with 10% seeded noise, k = 2, and the buffer lives directly in the cosine view. The paper uses β = 0.999 and a real network; it reports the α ablation as training-loss curves, not as a count of picks.
With α = 0 the buffer only grows, the same two coefficients stay on top forever, and the rest never speak: the message is the same every step. With α = 1 the sent coefficients drop to zero and others take their place. In between, the sent coefficients decay slowly. That gradual rotation is what the paper credits for its best result. The toy shows rotation only; it cannot tell you whether 0.2 trains better than 1. The paper’s loss curves do.
Chapter 7
Follow one training step of the whole algorithm, from local gradient to updated weights, with real numbers
You now have every part. A relay race has runners, a baton and a handover, and the clearest way to understand it is to watch one lap. This chapter runs one lap of DeMo: two workers, one chunk of eight numbers, every intermediate value on screen.
The paper’s Algorithm 1 runs on every worker i at every step t. We list it with the shape of each tensor and where each line has appeared.
One detail matters for the sign variant. The sign keeps the direction of each entry and throws away its size. Every weight then moves by exactly η, plus decay, whatever its size in M*. That is robust to the odd scale of averaged sparse messages, and it is why the paper can call its sign variant memory efficient: there is no second buffer for per-weight sizes.
It helps to list what each worker stores. It keeps the weights, one momentum buffer for the sign variant, and the small 64 × 64 DCT matrix shared by all tensors. AdamW stores the weights plus two buffers. The extra compute is a pair of 64 × 64 matrix products per chunk each way, plus a top-k. The paper calls that overhead negligible for small precomputed DCT matrices, but it reports no timing for it.
The device below runs lines 1 to 8 on two workers, A and B, with one chunk of eight numbers. Real chunks have 4,096 numbers and a top-k of 1 to 32. Here k = 2 so you can see it all. Press Next to move one stage, or Play to run them in order.
Warm is momentum space, purple is cosine space, teal is what gets sent. Use Next and Back to move through the nine stages.
Toy numbers from a fixed seed: β = 0.9, k = 2, α = 1, η = 0.05, λ = 0.1, sign variant, aggregation by the paper’s Algorithm 3 (divide each index by the number of senders). With only 8 numbers per chunk the sparse message is not smaller than the dense one; the saving appears at 4,096 numbers per chunk.
Watch stage 5 closely. An index that both workers picked is averaged over two. An index that only one worker picked is divided by one, so it keeps its full size. After the inverse DCT in stage 6, those two sparse messages have become a full, dense update again, which is the point of the cosine view.
The paper proves a convergence result (Theorem 1). It assumes three standard things: bounded gradient noise, a smooth loss, and bounded gradients. With a learning rate near 1 ÷ √T, the average gradient size then shrinks like 1 ÷ √T + 1 ÷ √N. Here T is the number of steps and N is the number of workers. One term in the bound depends on the kept fraction k ÷ M of each chunk and gets worse as that fraction shrinks.
Read this as a safety guarantee, not a speed prediction. It says DeMo does not diverge in principle. It does not say how much accuracy k = 2 costs. Also note the theorem asks for β of order 1 ÷ √T, while the experiments use β near 1. The theory and the recipe do not line up, which the paper does not discuss.
Chapter 8
Read Table 1 and the ablations like a reviewer, then list the claims the evidence supports and the ones it leaves open
A paper claims its method is nearly free: 85 times fewer bytes and no loss in quality. You are the reviewer. Where would you look first? You would ask what was trained, against what baseline, on how much data, and how the quality was measured. This chapter answers those questions from the paper.
All runs use OLMo, an open framework for training language models, on the Dolma v1.5 text corpus. The two models are OLMo-300M (320 million non-embedding parameters) and OLMo-1B (1.18 billion). The main runs train on 100 billion tokens, well beyond the 20 tokens per parameter that the Chinchilla rule of thumb recommends (it says to train on about 20 tokens per weight). Every run uses 64 NVIDIA H100 GPUs, a global batch of 2,048 sequences of 2,048 tokens, and chunk size 64. The baseline is AdamW with DDP at the OLMo recommended settings. DeMo uses β = 0.999. Ablations use only the 300M model at 20 tokens per parameter, about 6 billion tokens (20 per parameter).
Figure 2 plots training loss for DeMo at k = 1, 2, 4, 8, 16, 32 against AdamW, for both models. The text says “a sparsification of just k = 2 is sufficient to achieve better training performance than AdamW”, and larger k gives “marginal gains at a greater communication cost”. We cannot check the curves here, but the claim is clear and testable. Figure 4 (left) then plots final validation perplexity against megabytes per step on a log scale, which is the cost-quality frontier.
Table 1 scores the 100B-token checkpoints on three zero-shot benchmarks: HellaSwag (finish a sentence sensibly), ARC-Easy (grade-school science questions) and PIQA (physical common sense). Zero-shot means the model gets no examples, only the question. Try the device. It holds every row of the table.
Blue bars are AdamW-DDP, teal bars are DeMo at your k. Pick a model and drag k from 1 to 32. The axis starts at 0.30 so small gaps are visible.
Every number is from Table 1 of the paper (accuracy to two decimals; HellaSwag and PIQA normalized accuracy, ARC-Easy plain accuracy; megabytes per GPU per step after 100B tokens). The paper reports one value per cell, with no error bars in the text we read.
Read the grid as the paper does: DeMo mostly matches or beats AdamW. At 1B with k = 16, all three scores are higher (0.47, 0.53, 0.70 against 0.43, 0.51, 0.68) while sending 55.16 MB against 2,416.6 MB, 44 times less. But slide k down to 1. At 300M, ARC-Easy is 0.45 against 0.46. At 1B, HellaSwag is 0.41 against 0.43. The abstract’s “comparable” holds; the conclusion’s “equivalent or better” is too strong for the smallest k.
Also keep the scale in mind. Neighbouring rows differ by 0.01 to 0.02, scores come from one run per cell, and these small models score far below frontier models. The table supports “no obvious loss at moderate k”. It does not support a claim of 0.01 improvements.
Section 3.5 tunes the baselines hard. It sweeps learning rates and β2 for AdamW-DDP, and learning rates for Muon-DDP. Muon comes out better than AdamW. The paper then says plainly that “DeMo underperforms AdamW at equal update counts but provides substantially lower communication cost”. That is a different message from Figure 2, and it is the honest one: DeMo trades some progress per step for far fewer bytes.
Against DiLoCo with eight workers and a tuned outer learning rate, DeMo reaches lower final perplexity (a score of how surprised the model is by held-out text; lower is better) at comparable compression (Figure 6). For example, 64 × 64 chunks at k = 32 give 128 times less upload and 16 times less download, counted in numbers, not bytes. Against PowerSGD at rank 32 (about 26 times smaller), with 1,000 warm-up steps, DeMo is slightly ahead and PowerSGD is close to DiLoCo. Note that PowerSGD needed an Adam-style update added, so it is not the pure published method.
Rohan Anil’s post lists DeMo with DisTrO in a separate line from DiLoCo: “compresses optimizer momentum in a transformed representation”. The paper itself suggests the two combine: inside each data center use ordinary DDP, and treat the whole center as one large worker for DeMo.
Chapter 9
Keep the numbers, the terms, the checklist and the core code on one page, then pick where to go next
DeMo makes a bet that the information a data parallel worker needs to share is small and structured. Each worker keeps its own momentum. It cuts the momentum into 64 by 64 tiles and moves each tile into a cosine view, where a few coefficients carry most of the energy. It sends the top k of them. It subtracts what it sent, so the buffer doubles as the error memory. Every worker rebuilds the same sparse average and takes the same sign step. At k = 8 on a 300M model, that is 7.49 MB per GPU per step, not 636.9 MB.
| What | Number | Where from |
|---|---|---|
| Dense AdamW-DDP, OLMo-300M | 636.9 MB per GPU per step | Table 1; about 2 bytes × 320M parameters |
| DeMo k = 8, OLMo-300M | 7.49 MB, 85 times less | Table 1; the abstract’s “up to 85×” |
| DeMo k = 16, OLMo-1B | 55.16 MB against 2,416.6 MB, 44 times less | Table 1 and Section 3.3 |
| Smallest payload | 0.93 MB (300M), 3.44 MB (1B) at k = 1 | Table 1 |
| Chunk | 64 × 64 = 4,096 values | Section 3.1 |
| Bytes per sent entry | 12 (our reading), against 2 for a dense value | Fits every Table 1 row |
| Upload and download at k = 32, 8 workers | 128 times and 16 times less, counted in numbers | Section 3.5, DiLoCo comparison |
| Best settings | β = 0.999 default, 0.995 best; α = 0.2 | Sections 3.1, 3.4, 3.5 |
| Training | 100B tokens of Dolma v1.5, 64 H100 GPUs, batch 2,048 × 2,048 tokens | Section 3.1 |
| PowerSGD baseline | rank 32, about 26 times, 1,000 warm-up steps | Section 3.5 |
| Term | Plain meaning |
|---|---|
| All-reduce | Every GPU contributes a value; every GPU gets the average. |
| Bandwidth, Gbps | Bits a wire carries each second. 8 bits make a byte. |
| Momentum buffer | A running memory of past gradients, one number per weight. |
| Decoupled | Each worker’s buffer grows from its own gradients, with no shared average. |
| DCT | Rewrites a list as a mix of cosine waves; smooth lists need few waves. |
| Chunk | A 64 × 64 tile of a tensor, transformed on its own. |
| Top-k | Keep the k biggest coefficients of each chunk, zero the rest. |
| Error feedback | Keep what you did not send and offer it again later. |
| Momentum subtraction | DeMo’s error feedback: subtract the sent part from the buffer. |
| Signum | Step along only the sign of the momentum. |
This sketch is ours, written to match the paper’s Algorithm 1 for one weight tensor. It is not the authors’ code; their implementation is at github.com/bloc97/DeMo. The chunking helpers are left out, and the shapes are in the comments.
python (sketch of Algorithm 1) import torch, torch.distributed as dist def dct_matrix(s): # orthonormal DCT-II, shape [s, s] n = torch.arange(s) P = torch.cos(torch.pi * (2 * n[None, :] + 1) * n[:, None] / (2 * s)) * (2 / s) ** 0.5 P[0] *= 0.5 ** 0.5 # now P @ P.T == I, so the inverse is P.T return P @torch.no_grad() def demo_step(p, m, P, lr, beta=0.999, wd=0.0, k=8, alpha=1.0): # p.grad is the LOCAL gradient: DDP's all-reduce is switched off m.mul_(beta).add_(p.grad) # line 5: m = beta*m + g [same shape as p] B = to_chunks(m) # [C, 64, 64] Q = P @ B @ P.T # [C, 64, 64] DCT of every chunk flat = Q.flatten(1) # [C, 4096] idx = flat.abs().topk(k, dim=1).indices # [C, k] the k biggest per chunk val = flat.gather(1, idx) # [C, k] signed values sent = torch.zeros_like(flat).scatter_(1, idx, val) # sparse Q, dense layout m.sub_(alpha * from_chunks(P.T @ sent.view_as(Q) @ P)) # line 8: subtract what we sent V = [torch.empty_like(val) for _ in range(dist.get_world_size())] I = [torch.empty_like(idx) for _ in range(dist.get_world_size())] dist.all_gather(V, val); dist.all_gather(I, idx) # the only communication: 2 x [C, k] per worker tot = torch.zeros_like(flat); cnt = torch.zeros_like(flat) for v, i in zip(V, I): # Algorithm 3: sum, then divide by senders tot.scatter_add_(1, i, v); cnt.scatter_add_(1, i, torch.ones_like(v)) agg = tot / cnt.clamp(min=1) # 0/0 = 0 M_star = from_chunks(P.T @ agg.view_as(Q) @ P) # inverse DCT, back to p's shape p.mul_(1 - lr * wd).sub_(lr * M_star.sign()) # line 15: x -= lr * (sign(M*) + wd * x)
DeMo is a data parallel method that sends fewer bytes each step. DiLoCo and OpenDiLoCo send full information much less often. They can be combined in principle, since the paper treats each data center as one large worker, but the paper does not test it. Our DiLoCo lesson and the compute islands capstone show how the pieces fit.
“DeMo: Decoupled Momentum Optimization” is by Bowen Peng and Jeffrey Quesnelle (Nous Research), Lizhang Chen, Baiyu Su and Qiang Liu (University of Texas at Austin), and Diederik P. Kingma, whose work was done before joining Anthropic. Read it at arXiv 2411.19870; the code is at github.com/bloc97/DeMo. This lesson re-teaches the paper in our own words. The numbers marked “our reading” are our arithmetic, not the authors’ claims.
Now press Teach and explain the paper out loud, from memory: the 636.9 MB bill, why momentum, why the cosine view, how k becomes bytes, and what the subtraction does. Then go back to the chunk at the top, switch between raw values and DCT, and say why the error differs.