Train one model across devices that each hold different data and accuracy collapses. Add momentum on the server and the worst case climbs from 30.1% to 76.9%.
Drag How alike the clients are from identical to one class each, then change how many clients report per round. Watch the accuracy bar fall. Then we build, piece by piece, the recipe that makes clients differ, the cause of the fall, and the fix.
You need a rough idea of training a neural network by gradient descent (nudging weights downhill on a loss). We build the rest from zero.
Based on Measuring the Effects of Non-Identical Data Distribution for Federated Visual Classification by Tzu-Ming Harry Hsu, Hang Qi and Matthew Brown (MIT CSAIL and Google Research, 2019), read through The Hitchhiker’s Guide to Training on Compute Islands by Rohan Anil (Core Automation, 2 November 2026). Background lesson: Local SGD and model averaging.
Accuracies are Figure 2 of the paper (FedAvg, CIFAR-10, 100 clients, learning rate tuned for each cell, 10,000 rounds). The client bars are our own seeded sample from the paper’s recipe, 30 of 100 clients, so they illustrate the populations but are not the paper’s exact draws.
Chapter 0
See why a model trained across many separate places learns badly when each place holds a different slice of the world
Picture one hundred phones. Each phone holds the photos its owner took. One owner photographs only dogs. Another photographs cars. A third has mostly pictures of lunch. You want one model that recognizes all of these things, and you may not copy the photos off the phones.
So you do something different. You send the same model to every phone. Each phone trains it a little on its own photos. Then each phone sends back only what changed. You combine the changes into one better model, and you repeat. This recipe is federated learning: many separate places, called clients, each train on their own data, and one coordinator, called the server, combines the results. The data never leaves the client. Only the model changes travel.
Phones are the classic case. They are not the only one. A recent post from Core Automation, The Hitchhiker’s Guide to Training on Compute Islands, asks how to train one large model on many separate pools of chips with slow links between them. Its history section says the idea of synchronizing parallel workers less often “keeps being rediscovered, most visibly in federated learning.” Its timeline lists this paper as FedAvgM (Hsu et al.), the version of federated training with “server-side momentum.”
You do not need the post to follow this lesson. Treat each pool of chips, or each phone, as a client. The same question appears in both worlds: what happens to a shared model when the clients do not see the same data?
Inside a data center, engineers shuffle the training data before they split it. Every machine then sees a fair sample of everything. Statisticians call this IID, short for independent and identically distributed. Think of a deck of cards shuffled and dealt: every hand looks like a small copy of the whole deck.
On phones, nobody shuffles. Each client keeps what its owner produced. The hands are non-IID, or non-identical: one hand is all hearts. The paper studies one kind of difference, called label skew. Each client has images from the same ten kinds of thing, but in different proportions. A label (or class) is the answer a classifier must give, such as “dog” or “truck”.
Two hundred cards, twenty from each of ten classes, are dealt to five clients. Each column shows what one client holds, split by class. Choose how the deck was ordered before the deal.
Illustrative toy: 200 cards, not CIFAR-10. The shuffle uses a fresh random order each time you press Deal again. Sorting by class and cutting the deck into five equal piles is the “sort and partition” split that earlier papers used.
When the deck is shuffled, every client holds almost every class. Their local views agree with each other and with the whole. When the deck is sorted first, each client holds just two classes. A model that trains only on client 1 never meets a class 8 picture. It learns that class 8 does not exist.
The server asks each client to improve the model on its own data. Each client improves the model in a direction that suits its data. A dog-only client pushes the model toward saying “dog” for everything. A car-only client pushes toward “car”. The server averages these pushes. If the pushes point in opposite directions, the average is small and noisy, and the model barely learns. The rest of this lesson measures how bad this gets, and then fixes it.
Earlier papers tested only extreme splits, such as the sorted deal above, with ten clients. That setting is unrealistic: a real system has many clients, and their differences come in degrees. Hsu, Qi and Brown do three things. First, they invent a dial for how different the clients are, from identical to one class each. Second, they measure how a standard federated method loses accuracy along the dial. Third, they show that a small change on the server, adding momentum, wins most of the accuracy back. In the most skewed settings the abstract reports a rise from 30.1% to 76.9% on the CIFAR-10 image set.
Look back at the instrument at the top. The slider is that dial. You will meet its exact definition in Chapter 2.
Chapter 1
Follow the model out to the clients and back, and see exactly what the server averages
A teacher hands the same worksheet to four students. Each student works on it alone for ten minutes and writes corrections in the margin. The teacher then collects the four sheets and writes one final version that blends the corrections. That is one round of federated learning. The next round starts from the blended sheet.
The method has a name, federated averaging, written FedAvg. McMahan and colleagues introduced it in 2017, and the Hsu paper uses it as the baseline. If you want the full story of why it saves communication, read Local SGD and model averaging and the FedAvg paper lesson. Here we need only the mechanics.
The weights w are all the numbers inside the model. They form one long list, and every client and the server keep a list of the same length. The population has K = 100 clients. In each round the server picks a fraction C of them, the reporting fraction. With C = 0.4 that is 40 clients. Client k holds nk training images, and n is the total over the clients chosen that round. The paper gives every client 500 images.
Each chosen client then runs SGD, stochastic gradient descent, on its own images. SGD shows the model a small batch of images, measures the error, and nudges every weight a little downhill. The batch size is B = 64. One pass over all 500 images is one local epoch, and the number of passes is E, which is 1 or 5 in the paper. The nudge size is the learning rate η.
Count the steps. Five hundred images in batches of 64 make 8 batches per epoch (seven full batches and one of 52). So E = 1 means 8 nudges per round, and E = 5 means 40.
A worked case with one weight. Three clients hold 100, 300 and 600 images, so their shares are 0.1, 0.3 and 0.6. They report changes of +0.2, −0.1 and +0.05. The average is 0.1×0.2 + 0.3×(−0.1) + 0.6×0.05 = 0.02 − 0.03 + 0.03 = 0.02. If the server’s weight was 1.00, it becomes 0.98.
Why is this called an average of weights? Because with a server rate of 1, w − ∑(nk/n)(w − wk) = ∑(nk/n) wk, since the shares add to 1. The new weights are the share-weighted mean of the clients’ final weights. The server could also treat Δw as a gradient and hand it to any optimizer. The Core Automation post calls this change a pseudo-gradient: a stand-in for a gradient that the server can feed to an outer optimizer. Chapter 6 uses exactly that idea.
The model here has just two weights, so one point on the plane is one model. Blue diamonds are the best model for each client’s data, sized by its image count. The green star is the best shared model. Press the button to run the next step of the round.
Illustrative toy, not from the paper. Each client’s loss is a round bowl around its own best point, and each local step moves 30% of the way to it. The client sizes (200, 500, 800, 500 images) are made up.
After a few rounds the server point lands on the star. Here the clients differ, but their bowls have the same shape, so the weighted average is exact. Chapter 3 breaks that comfort.
To judge the final model, the paper feeds it the 10,000 CIFAR-10 test images, which are balanced across the ten classes, and reports the share it labels correctly. The clients never see these images. The chosen training setup is a small convolutional network from the 2017 paper, with a weight decay of 0.004 and no learning-rate schedule. It is not a state-of-the-art model. The authors say it is enough to compare conditions with each other.
Count the work in the paper’s setup. With C = 0.40 and E = 1, a round trains 40 clients on 500 images each, so 20,000 image visits. Over 10,000 rounds that is 200 million visits, or 4,000 passes over the 50,000-image training set. With E = 5 the same rounds cost five times more: 20,000 passes. With C = 0.05 and E = 1 it is only 25 million visits, 500 passes.
Now count the messages instead. A data-center job that syncs after every batch exchanges weights once per step. A FedAvg client exchanges once per 8·E steps. At E = 5 that is one exchange per 40 steps, forty times fewer than syncing every step. This is why the method fits slow links, and it is the same trade the Core Automation post studies: fewer, larger exchanges. The price is that the 40 steps run apart, which is the subject of Chapter 3.
Chapter 2
Build clients whose data differ by exactly as much as you choose, using a recipe card for each one
To measure a problem you need to control it. A researcher cannot ask a million phones to hold a little less dog. So the paper builds fake clients out of a real image set, CIFAR-10, and gives itself a dial. At one end of the dial every client looks alike. At the other end every client holds a single class. Every stop in between is a population you can build again and test.
Give each client a recipe card: ten numbers, one per class, that say what share of its images comes from that class. A card for a client that likes dogs might read: dog 0.6, cat 0.2, truck 0.1, everything else 0.1 in total. The shares are never negative and always add up to 1. The paper calls this list q. Once the card exists, the client fills its 500 slots by picking a class from q for each slot, independently, and taking an image of that class.
The remaining question is how to write the cards at random, with a knob for how lopsided they are. The tool is the Dirichlet distribution, a machine that produces random lists of non-negative numbers that add up to 1. The paper writes the draw as
You can build a Dirichlet draw from simpler parts. Draw ten positive numbers g1 to g10. Each one comes from a Gamma distribution (a generator of positive numbers) with shape α·pi, which here is α/10. Then divide each by their total: qi = gi / (g1 + … + g10). The division forces the shares to add to 1.
The shape number decides the behaviour. When the shape is large, every g lands near its typical value, so all ten are similar, and each share is near 0.1. When the shape is below 1, most draws are tiny and a rare one is large. One g then dominates the total, and one class takes most of the share.
A worked case, with illustrative numbers. Take α = 1, so each shape is 0.1. Suppose the ten draws come out as 0, 0.62, 0, 0.03, 0, 0, 0.11, 0, 0, 0.01, with total 0.77. The shares are 0.805 for class 2, 0.143 for class 7, 0.039 for class 4 and 0.013 for class 10, and nearly 0 for the rest. One class holds four-fifths of this client.
Two facts pin the dial down. The average share of any class is its pi = 0.1 for every α, so the whole population still averages to the uniform mix. The spread is Var(qi) = pi(1 − pi) / (α + 1) = 0.09 / (α + 1). At α = 100 the standard deviation of a share is 0.03, so cards stay within about 0.07 to 0.13. At α = 1 it is 0.21, twice the mean, which means most classes are near 0 and a few are large. As α falls to 0, each client holds one class chosen at random.
Each row is one client; its colours show the share of its 500 images in each of the ten classes. Drag the dial, then press New clients to draw a fresh population at the same setting.
The stops are the paper’s eight values of α (100, 10, 1, 0.5, 0.2, 0.1, 0.05, 0). Our sampler draws each client’s 500 labels independently from its card, so it is a faithful sketch of the recipe, not the authors’ exact code. Statistics are over 100 clients.
Compare the picture with Figure 1 of the paper. The sort-and-partition split gives ten clients with exactly two classes. The Dirichlet populations at α = 100, 1 and near 0 look like a smooth walk from the first picture of this lesson to the last. This dial is the paper’s first contribution: it lets the authors ask not just “does FedAvg break?” but “how fast does it break as the clients drift apart?” An earlier paper by Yurochkin and colleagues used the Dirichlet at one setting, α = 0.5. This paper sweeps eight.
The paper builds balanced populations of 100 clients with 500 images each, so 50,000 images, the size of the CIFAR-10 training set. For each client it samples q and hands out images of the matching classes. For every setting of α the authors build several populations. Each learning-rate result in the next chapters is an average over 5 runs on different populations drawn with the same α.
Here is what our seeded sample of 100 clients shows, using the sampler in the device above. The average client puts this share of its 500 images into its biggest class: 16% at α = 100, 30% at 10, 64% at 1, 75% at 0.5, 88% at 0.2, 92% at 0.1, 96% at 0.05, and 100% at 0. Count the classes that hold at least 5% of a client’s images (25 or more). It falls from 9.6 of 10 at α = 100 to 6.4 at 10, 2.8 at 1, 1.3 at 0.1 and exactly 1 at 0.
Read those numbers as a guide to the later results. α = 1 is already a hard world: the typical client has nearly two thirds of its data in one class. Most of the interesting action in the paper’s grid happens at or below that point. Different seeds shift each number by a point or two, but the pattern holds.
Chapter 3
Watch two clients that care about different things pull a shared model off course, and see why more local work makes it worse
Two friends plan a holiday. One cares only about the beach, the other only about the museum. Each is allowed to plan alone for a week, then they average their plans. Each friend’s plan is excellent for one interest and ignores the other. The average may suit neither. If they instead met every day and adjusted a little, the plan would balance both interests. The longer they work apart, the further the average drifts from that balance.
This is client drift. It is the reason non-identical data hurts FedAvg. The paper does not prove it. Its experiments measure the damage and its related-work section points to proofs by Sahu and colleagues and by Li and colleagues. To see the cause, we use a toy small enough to compute by hand.
A client’s loss is a number that is low when its model fits its data. Plot the loss against two weights and you get a landscape. For a simple model the landscape is a bowl, and the bottom of the bowl is the best weights for that client. A client holding only dogs has a bowl that is steep in the weights that decide “dog” and nearly flat in the weights that decide “truck”, because it never sees a truck and nothing it does depends on them. A truck-only client has the opposite bowl.
The best shared model is the bottom of the bowl you get by adding the two losses together. It leans toward whichever client has the steeper bowl in each direction. In the toy below, client 1 is steep in weight 1 and flat in weight 2, and client 2 is the reverse. Client 1 prefers weights (−1.0, 0.8), client 2 prefers (0.8, −1.0). Adding the bowls puts the best shared model at (−0.84, −0.84). The plain mean of the two preferred points is (−0.10, −0.10).
Now run FedAvg. Each round, both clients start at the server’s point and take L local gradient steps downhill on their own bowl. The server averages the two end points. When L = 1, one small step on each bowl, then averaging, equals one step on the summed bowl. FedAvg then walks to the true best shared model. When L is large, each client slides all the way to the bottom of its own bowl before the average, and the average of the two bottoms is the plain mean of the preferred points. The server settles at the mean, far from the best shared model.
Warm line: the server’s path over 300 rounds from the start point. Blue ellipses: the two clients’ bowls. Green star: the best shared model. Raise the local steps and watch where the path ends.
Illustrative toy, computed exactly in your browser; the paper reports no such experiment. Bowl steepness is 2.0 in the weight a client cares about and 0.2 in the other, the step size is 0.1, both clients hold equal data, and both report every round.
Take weight 1 alone. Client 1 has steepness 2.0 and prefers −1.0. Client 2 has steepness 0.2 and prefers 0.8. The best shared value minimises 2.0(w+1.0)2/2 + 0.2(w−0.8)2/2. The answer weights each preference by its steepness: (2.0×(−1.0) + 0.2×0.8) / (2.0 + 0.2) = −1.84/2.2 = −0.84. The plain mean ignores steepness: (−1.0 + 0.8)/2 = −0.10. Local steps let each client slide to its own preference, and the average gives each client an equal vote regardless of steepness. The fixed point drifts from the weighted answer to the equal-vote answer as L grows.
With identical data the bowls coincide, steepness and preferences match, and the two answers agree. Non-identical data pulls them apart. This also explains the shape of the paper’s results. More local epochs mean more drift. More clients per round means more bowls in each average, so each round’s average is closer to the whole population.
A real network has millions of weights and bumpy landscapes, and a paper can only measure the damage by training. Still, the toy captures two real levers, local work and client difference, and the paper turns both into experiments: E in Chapter 4 and α in Chapter 2.
A real network has no picture you can draw. One way to see drift is to compare the clients’ updates in a round. Treat each Δwk as an arrow in a space with millions of dimensions, and measure the angle between pairs of arrows with their cosine similarity (1 means the same direction, 0 means unrelated, −1 means opposite). With identical clients the arrows point roughly together, apart from noise. With one-class clients they point in very different directions, and the average arrow is short. This measurement is our suggestion, not an experiment from the paper.
It also explains why a short average is bad twice. The server moves a short distance, so learning slows. And what remains of the arrow is mostly the part the clients happened to share, which is not what any one client needed. In Chapter 6 you will see how momentum on the server uses many such short arrows from successive rounds.
Chapter 4
Read the paper’s Figure 2 cell by cell and find the three patterns hidden in its sixty-four numbers
You have the dial (Chapter 2) and the suspect (Chapter 3). Now the experiment. The authors run vanilla FedAvg on every combination of three things and write the best accuracy of each combination into a table. Reading it well is a skill: the table is the paper’s main result, and a few of its patterns are not obvious.
Each cell in Figure 2 answers: with this dial setting α, this many clients per round (C) and this many local epochs (E), what test accuracy does FedAvg reach after 10,000 rounds? The rows are C = 0.05, 0.10, 0.20 and 0.40, which is 5, 10, 20 and 40 clients out of 100. The two panels are E = 1 and E = 5. The eight columns are the eight values of α. That makes 4 × 8 = 32 cells per panel and 64 in all.
One more fact matters: each cell is optimised over learning rates. The authors try eight client learning rates, 10−4, 3×10−4, 10−3 and so on up to 3×10−1, and keep the best. Each rate is averaged over 5 runs on different random populations with the same α. If every cell used the full grid, that is 8 rates × 8 values of α × 4 values of C × 2 values of E × 5 runs = 2,560 training runs of 10,000 rounds. A cell is therefore the method at its best, not at a careless setting. That makes the low numbers more serious.
Each cell is a test accuracy in percent. Columns run from identical clients on the left to one class each on the right. Tap any cell to compare it with the same row at α = 100.
All numbers are Figure 2 of Hsu, Qi and Brown (2019): FedAvg, CIFAR-10, 100 clients with 500 images, 10,000 rounds, best learning rate per cell. Green is 60% or more, yellow 40% to 60%, red under 40%. Centralized training reaches 86.0%.
Look along the top row of the E = 1 panel (C = 0.40). Accuracy goes 83.9, 83.3, 78.9, 77.0, 74.6, 73.2, 70.3, 65.9. From α = 100 down to α = 1 it loses 5.0 points. From α = 1 to α = 0.1 it loses 5.7 more. From α = 0.1 to α = 0 it loses 7.3. The paper puts it this way: significant changes in test accuracy occur around low α, when the clients come close to one class. Most of the slide happens where clients become nearly single-class.
Read down a column. At α = 100 with E = 1, going from 5 to 40 clients per round lifts accuracy from 82.9 to 83.9, a single point. At α = 0.1 the same change lifts it from 57.9 to 73.2, over fifteen points. At α = 0 with E = 5 it lifts it from 26.8 to 48.1. When all clients look alike, any few of them represent the whole population. When they differ, a round needs many of them to cover the classes. Chapter 5 measures that directly.
Rounds are the scarce resource: all cells use the same 10,000. With E = 5 each round does five times more local work than with E = 1. You might expect that fewer local steps, meaning more frequent syncing, is always safer. The paper says it “does not always improve the accuracy on non-identical data.” Compare the two panels at C = 0.40. At α = 100, E = 5 wins narrowly (84.7 against 83.9), because the extra local work is useful when the data are alike. At α = 0, E = 1 wins by a large margin (65.9 against 48.1), because the extra local work is drift. At the middle α the two nearly tie: at α = 0.1 with C = 0.05 they read 57.9 and 58.0.
The grid shows the end of training. Figure 3 shows the whole path for a few settings. For the identical case the curve climbs smoothly toward the centralized line. For the skewed case it climbs more slowly and jumps up and down. With a small reporting fraction, runs “struggle to converge within 10,000 communication rounds.” The next chapter explains why the curves wobble.
First, the scale. A guesser on ten balanced classes scores 10%. The worst cell, E = 5, C = 0.05, α = 0, scores 26.8%. That is only 16.8 points above chance, and 59.2 below centralized training. The best cell, E = 5, C = 0.40, α = 100, scores 84.7%. The whole grid spans 57.9 points between its best and worst cells.
Second, the cells are not independent experiments. Every cell in a column shares its client populations, and every cell reports a maximum over learning rates. A small gap between two neighbouring cells, such as 83.9 against 84.1, is within what a different draw of populations could change. The paper averages 5 runs per learning rate for this reason, but it does not print error bars. Treat gaps of a point or less as ties, and trust the larger pattern.
Chapter 5
Measure how much each round’s data mix wanders when only a few clients report, and see why tuning then gets harder
A pollster wants to know what a town of 100 people thinks about ten topics. Each person talks about one topic only. If she asks 40 people, she hears about every topic in roughly the right proportions. If she asks 5, she hears about three topics and none of the other seven. Ask again tomorrow and she hears about a different three. Her picture of the town keeps jumping around.
A federated round is that poll. The server hears from only m = C·100 clients, and the averaged update reflects only what those clients hold. A different handful reports next round, so the update points a different way. The training curve wobbles and the model may never settle.
The data behind one round is the mix of the chosen clients’ recipe cards (Chapter 2) averaged together. Averaging m cards shrinks the spread of any class’s share by the square root of m. From Chapter 2, one card’s share has standard deviation √(0.09/(α+1)). So a round’s share has roughly √(0.09/(α+1)) / √m. This ignores a small correction for sampling without replacement.
A worked case at α = 1: one card has spread 0.212. With 5 clients it is 0.212/√5 = 0.095. With 40 clients it is 0.212/√40 = 0.034. The balanced share of any class is 0.1, so with 5 clients a class’s share in a round typically swings by almost as much as its own size. With 40 it swings by about a third of it. At α = 0.1 the single-card spread is 0.286, giving 0.128 with 5 clients and 0.045 with 40. At α = 100 the single-card spread is 0.030 and even 5 clients give 0.013, a small wobble.
One number summarises the wobble: the total variation distance between a round’s class mix and the balanced mix. It is half the sum of the absolute gaps, TV = ½ ∑|sharei − 0.1|. It is 0 for a perfectly balanced round and 0.9 if the round holds one class. The device draws rounds from a population of 100 clients and shows how far they land from balance.
Top: the class mix of the clients that reported in one round; the dashed line is the balanced 10%. Bottom: how far 300 such rounds land from balanced. Press Draw a round a few times, then change the dial or the clients per round.
Our own simulation of the paper’s recipe (100 clients, 500 images each, clients chosen without replacement), not an experiment from the paper. It measures the data mix of a round, not the accuracy.
Figure 3 of the paper shows the result as learning curves. Runs with few clients and skewed data have large swings in test accuracy and, in the lowest cases, fail to converge in 10,000 rounds. Figure 4 plots test accuracy against the client learning rate (the size of each local nudge). With near-identical clients and many of them, about two orders of magnitude of learning rate (a hundredfold range) give good accuracy. With few clients and skewed data, the paper says, “careful tuning of the learning rate is required.”
A reasonable reading of why: a high learning rate lets each client run far down its own slope, which amplifies the drift of Chapter 3 and the round-to-round jumps of this chapter. A low learning rate is stable but moves the model too little in 10,000 rounds. When rounds are noisy and clients differ, the usable window between “too wild” and “too slow” narrows from both sides. This is our interpretation of the pattern the figure shows, not a statement from the paper.
The practical cost is large. A tuning grid that is cheap on a data-center cluster means thousands of federated runs, and each round needs real devices to be online. A method that widens the window is worth a lot. That is the job of the next chapter.
The square-root rule assumes each reporting client is drawn independently. In a round the server picks m different clients from a fixed population of 100. A pollster who asks 40 of 100 people learns more than the rule says, because she has covered 40% of the town. The textbook fix multiplies the spread by √((100 − m)/99). For m = 5 the factor is 0.98, so the spread of 0.095 barely changes. For m = 40 it is 0.78, so 0.034 becomes about 0.026. At m = 100 the factor is 0 and there is no wobble at all, because everyone reports. The device uses real draws without replacement, so it already includes this effect.
Figure 3 plots test accuracy against communication round for a handful of settings, with centralized training as a dashed line. Its legend names the cases: α = 100 with 40 clients, α = 0.5 with 40 clients, α = 0 with 40 clients, α = 0 with 5 clients and E = 1, and α = 0 with 5 clients and E = 5. The paper’s text reads these curves as follows: training error is “more volatile” as the data become more non-identical, and runs with a small reporting fraction struggle to converge within 10,000 rounds. Figure 4 plots final accuracy against learning rate, one curve per α, with a dashed line at chance. Its text reports that near-identical populations give good accuracy over about two orders of magnitude of learning rate, while small C and small α need careful tuning. We read the curves from the paper’s words, not from pixel values.
Chapter 6
Let the server remember the direction of earlier rounds, so steady progress adds up and zigzags fade
Push an empty shopping cart across a car park. A single shove moves it a little. Keep pushing in the same direction and it speeds up, because the cart remembers your earlier shoves. Now push left, right, left, right in turn. The cart barely moves forward, because each shove undoes the last.
That memory is momentum. It is a standard trick from ordinary training, where it has helped for decades by adding up the history of gradients. The paper’s idea is to put it on the server. Each round gives the server one update Δw. Rounds that agree about a direction should add up. Rounds that disagree, because different clients reported, should partly cancel.
Vanilla FedAvg is w ← w − Δw. FedAvgM, FedAvg with server momentum, keeps one extra list v, the same length as the weights, which starts at zero:
Unroll the rule. After round t the velocity is vt = Δwt + βΔwt−1 + β2Δwt−2 + …. It is a sum over all past rounds, each weighted by β to the power of its age. At β = 0.9, an update from 10 rounds ago still counts 0.35, and one from 22 rounds ago still counts 0.1. The server carries a long memory.
A steady push. Let every round report the same update, Δ = 0.01, and take β = 0.9. Then v is 0.01, then 0.9×0.01 + 0.01 = 0.019, then 0.0271, and it climbs toward 0.01/(1 − 0.9) = 0.1. The server ends up stepping 10 times as far per round. A steady signal gains a factor of 1/(1 − β).
A zigzag. Now let the updates alternate: +0.01, −0.01, +0.01, and so on. The velocity settles into swinging between about +0.0053 and −0.0053, since the steady-state size is Δ/(1 + β) = 0.01/1.9. The server moves about half as far as one raw update, in alternating directions. The steady part gained a factor of 10. The zigzag part did not grow. So the steady part, where the clients agree, now dominates what the server does.
The server walks down a long, narrow valley, with a small random error added to each round’s update. Grey: no momentum. Purple: the momentum you pick. Same random errors for both. Pick a momentum and watch the purple path.
Illustrative toy, not the paper’s experiment: loss = 0.025x² + 0.5y², each round’s update is 0.3 times the gradient plus a random error of size 0.02, 80 rounds, start at (2, 1.2). Averages use 6 seeded error draws; the paths show one of them.
Try the four settings. Small momentum speeds the slow direction and settles. Very large momentum overshoots and keeps swinging. The toy hints at a lesson the next chapter makes exact: momentum also scales the step, so it must be paired with a smaller learning rate.
The paper actually uses Nesterov accelerated gradient (Nesterov, 2007), a variant that evaluates the step with a small look-ahead: the common implementation steps by Δw + βv after updating v. Our equation is the plain form in the paper’s text. Both share the idea above.
The cost is small. The server stores one extra list the size of the model, so its memory doubles. No extra bytes cross the network, and the clients run the same code as before. This is why the idea transfers so cleanly: the Core Automation post names it as the “inner/outer optimizer formulation”, where the clients’ local SGD is the inner optimizer and the server’s momentum rule is the outer optimizer. Later large-model methods keep that split. See Optimizers and momentum and DiLoCo and low-communication pretraining.
Take one weight that starts at 1.00 and β = 0.9. Five rounds report the updates 0.04, 0.05, −0.02, 0.05 and 0.04. The third is a bad round: a different set of clients pulled the other way.
Without momentum the weight would be 1.00 − (0.04 + 0.05 − 0.02 + 0.05 + 0.04) = 0.84. With momentum it is 0.58. The server moved 0.42 instead of 0.16, about 2.6 times as far, and it moved forward in the round where the raw update pointed back. That is the whole benefit in miniature: the server trusts the trend over one round.
Chapter 7
Combine the client’s step size and the server’s momentum into one number, and use it to tune the method
A car has a gas pedal and a gear. Press the pedal halfway in first gear and you creep. Press it a quarter in third gear and you may move just as fast. Two controls, one speed. The speed is what matters, not the pair.
FedAvgM has two such controls. The client learning rate η sets how big each local nudge is, so it sets how big each client’s update Δwk is. The momentum β sets how much the server multiplies those updates. The paper asks: which combination of the two gives the best accuracy? The answer is that mostly only their combined speed matters.
From Chapter 6, if every round gave the same update Δ, the velocity would settle at v = Δ/(1 − β). The update Δ itself is proportional to η: twice the nudge size means about twice the change. So the server’s steady step is proportional to η/(1 − β). The paper, following Shallue and colleagues (2018), names this the effective learning rate:
Worked case. Take η = 0.01 and β = 0.9. Then ηeff = 0.01/(1 − 0.9) = 0.1. Now take η = 0.1 and β = 0. That is also 0.1. And η = 0.001 with β = 0.99 gives 0.001/0.01 = 0.1 as well. Three different pairs, one speed. The search grid has 8 learning rates and 6 momenta, which is 48 pairs, yet many of them land on the same speed.
Each dot is one of the 48 pairs the paper searches. Its place on the line is its effective rate. Rows are momentum values. Pick a pair and see which others share its speed.
The 48 pairs and the formula are the paper’s. The brackets show the viable-window widths from the paper’s text (about two orders of magnitude with many clients, as little as one with few). Their position follows your pick, so they show the slack you have, not where the best value lies.
Figure 6 plots test accuracy against ηeff at α = 1, one dot per pair, with dot size set by η. Dots from different pairs fall on one curve with a single peak, so each setting of the world has an optimal ηeff. Three things stand out.
One more rule of thumb in the paper: to stop client updates diverging, use a low absolute learning rate with a high momentum. Both give the same ηeff, but the small η keeps each client’s own walk short and stable, and the server’s momentum supplies the speed. That is the gear idea again: let the server do the scaling, and keep the clients gentle.
The paper’s grid spans six orders of magnitude of speed. The smallest pair, η = 10−4 with β = 0, has ηeff = 10−4. The largest, η = 0.3 with β = 0.997, has ηeff = 0.3/0.003 = 100. A viable window of two decades covers a third of that range, and one decade covers a sixth.
Now count grid points. At a fixed β, the eight learning rates sit about 0.48 decades apart (a factor of 3 or 3.3 each), roughly two per decade. A two-decade window therefore contains about four or five grid points, and a one-decade window only about two. Miss by one grid step on the wrong side and a run diverges or crawls. This is what the paper means by tuning being easier with many clients: the target is wide enough to hit with a coarse grid.
The practical gain of the formula is a cheaper search. Of the 48 pairs on the grid, the speeds fall on only about 13 half-decade steps, because many pairs land close together (the grid values are 3 or 3.3 apart, so the match is approximate). A sensible plan is to fix a high β, sweep η to find the best speed, and check the neighbouring speeds with the other β values only if you have budget left. The paper does not claim this plan. It follows from the shared curve in Figure 6.
Chapter 8
Check what the paper shows with server momentum, which knobs it varies, and what it leaves open
You now hold every part. Clients differ by a dial (Chapter 2). Averaging drifts (Chapter 3). The damage is measured on a grid (Chapter 4) and made worse by few clients (Chapter 5). The server keeps momentum (Chapter 6) and the right combined speed is tuned (Chapter 7). This chapter puts the headline back together and asks how far to trust it.
The abstract states that classification accuracy on CIFAR-10 “improved from 30.1% to 76.9% in the most skewed settings.” Centralized training with the same kind of model reaches 86.0%, taken from a TensorFlow tutorial. The gap between plain FedAvg and the centralized baseline is 86.0 − 30.1 = 55.9 points. Momentum closes 76.9 − 30.1 = 46.8 of them, which is 46.8/55.9 = 83.7%.
The body text gives a second pair of numbers. With E = 1 and C = 0.05, FedAvgM “stays relatively constant and above 75%” while FedAvg “falls rapidly to around 35%” as the data become more skewed. Figure 5 plots both methods across the whole dial for C = 0.05, 0.10 and 0.40 and both values of E. FedAvgM is better throughout, and “close to the centralized learning baseline (86.0%) in many cases.”
Choose which of the paper’s two quoted comparisons to look at. The bars are test accuracy on CIFAR-10. The share of the gap that momentum wins back is worked out under the chart.
The abstract numbers (30.1, 76.9) and the centralized 86.0 are quoted exactly. The text numbers are the paper’s own rounded words (“around 35%”, “above 75%”), so the second gap share is approximate. The paper does not say which table cell the abstract’s 30.1% comes from, and its tuned FedAvg result for the same corner in Figure 2 is 40.7%, so the two are not directly comparable.
Every claim rests on a sweep. There are five knobs. The dial α has 8 values. The reporting fraction C has 4. The local epochs E has 2. The server momentum β has 6. The client learning rate η has 8. Everything else is fixed: a small convolutional network from the 2017 FedAvg paper, a batch size of 64, a weight decay of 0.004, no learning-rate schedule, 100 clients with 500 images each, 10,000 rounds, and a server learning rate held at 1.0.
Two sweeps are the real ablations. Sweeping α shows the damage grows as the data differ. Sweeping β and η together shows that the gain depends on ηeff (Chapter 7). The comparison FedAvg against FedAvgM at the same α, C and E is the test of the fix itself.
Check yourself against three anchors. With α = 100, E = 1 and C = 0.40, you should land near 84%. With one-class clients you should land far lower, in the 40s to 60s for C = 0.40 or lower for few clients. And centralized training of the same network should give about 86%. If your identical-clients run is far below the centralized figure, the fault is in your pipeline and not in the non-identical data.
Three places deserve a test before you rely on this result. A larger network may have different curvature, so the best ηeff window may move. A different kind of skew, such as clients with different image styles, may not respond to server momentum the same way. And tuning on the test set, if that is what happened, could inflate the gains by a point or two. None of these is shown to break the finding. They are open, and the paper leaves them open.
Chapter 9
Keep the numbers, the terms, the checklist and the core code on one page, and find where to read next
The paper in one paragraph. Federated clients usually hold different data. The authors build 100 clients from CIFAR-10 with a Dirichlet recipe whose concentration α runs from identical (100) to one class each (0). They run FedAvg over 8 values of α, 4 reporting fractions and 2 local-epoch settings. Accuracy falls as α falls, most sharply near one class per client, and falls further when few clients report. They add momentum on the server, FedAvgM, and tune it through the effective learning rate η/(1 − β). In the most skewed settings the abstract reports a rise from 30.1% to 76.9%.
| Quantity | Value | Where in the paper |
|---|---|---|
| Clients, images each | 100, 500 | Section 3 |
| Values of α | 100, 10, 1, 0.5, 0.2, 0.1, 0.05, 0 | Figure 2 |
| Reporting fraction C | 0.05, 0.1, 0.2, 0.4 (5, 10, 20, 40 clients) | Section 4 |
| Batch size, local epochs | B = 64, E = 1 or 5 | Section 4 |
| Rounds | 10,000 | Section 4 |
| Client learning rates | 10−4 to 3×10−1, 8 values | Section 4 |
| FedAvg at α = 100, E = 1, C = 0.40 | 83.9% | Figure 2a |
| FedAvg at α = 0, E = 1, C = 0.40 | 65.9% | Figure 2a |
| FedAvg at α = 0, E = 5, C = 0.05 | 26.8% | Figure 2b |
| Momentum values β | 0, 0.7, 0.9, 0.97, 0.99, 0.997 | Section 4.2 |
| Server learning rate | 1.0 (held constant) | Section 4.2 |
| Centralized baseline | 86.0% | Section 4.2 |
| Headline gain | 30.1% to 76.9% | Abstract |
| Term | Plain meaning |
|---|---|
| Client | A device or site that trains on its own data and never shares it. |
| Server | The coordinator that sends the model out and averages the changes. |
| Round | One trip: send the model, train locally, send changes back, average. |
| IID, non-IID | Clients that hold fair samples of the whole, or clients that do not. |
| Label skew | Clients share the same classes but in different proportions. |
| Dirichlet, α | A generator of random class-share recipes; α sets how lopsided they are. |
| Client drift | Local training pulls each client toward its own best point, away from the shared one. |
| Reporting fraction C | The share of clients that take part in each round. |
| Pseudo-gradient | The averaged client change, which the server treats as a gradient. |
| Inner, outer optimizer | The clients’ local SGD, and the server’s rule for using the average. |
| FedAvgM | FedAvg with momentum on the server. |
| Effective learning rate | η/(1 − β): the speed the server really moves at. |
pythonimport numpy as np def dirichlet_clients(labels, n_clients=100, per_client=500, alpha=1.0, n_classes=10, seed=0): # one recipe card q per client: q ~ Dir(alpha * p), p uniform (Chapter 2) rng = np.random.default_rng(seed) p = np.full(n_classes, 1.0 / n_classes) by_class = [np.where(labels == c)[0] for c in range(n_classes)] clients = [] for _ in range(n_clients): q = rng.dirichlet(alpha * p) if alpha > 0 else np.eye(n_classes)[rng.integers(n_classes)] counts = rng.multinomial(per_client, q) # images per class, sums to 500 idx = np.concatenate([rng.choice(by_class[c], size=k) for c, k in enumerate(counts)]) clients.append(idx) # sketch: samples with replacement return clients def server_round(w, v, clients, picked, local_train, beta=0.9): # w, v: flat float arrays, one entry per model weight (same shape) n = sum(len(clients[k]) for k in picked) delta = np.zeros_like(w) for k in picked: w_k = local_train(w.copy(), clients[k]) # E epochs of SGD, batch 64, client rate eta delta += len(clients[k]) / n * (w - w_k) # share-weighted change (Chapter 1) v = beta * v + delta # velocity (Chapter 6); beta = 0 is plain FedAvg w = w - v # server learning rate 1.0 return w, v # Nesterov form: w - (delta + beta * v) eta_eff = lambda eta, beta: eta / (1 - beta) # Chapter 7
Now press Present or Teach and explain the whole paper from memory: how clients are made different, why averaging drifts, what the grid shows, and how server momentum and the effective learning rate fix it. Then go back to the instrument at the top, set the dial to one class each with 5 clients, and say what each part of the picture now means.