TL;DR
Federated learning trains one model across many devices or hospitals while the data stays where it was collected. The standard method, FedAvg, lets each participating device take several local gradient steps before the server averages the results. When the devices hold very different data, their local steps pull in different directions, an effect the paper calls client drift, and convergence becomes slow and unstable. SCAFFOLD adds a control variate to every local step, so each device corrects its direction toward the global gradient. It needs fewer communication rounds on heterogeneous data and is relatively unaffected by which clients are sampled.
Builds on: Communication-Efficient Learning of Deep Networks from Decentralized Data, Federated Learning, Stochastic Gradient Descent, Control Variate, Client Drift · Leads to: Adaptive Federated Optimization, Advances and Open Problems in Federated Learning
Why it mattered
The paper gives a rigorous account of when federated averaging is slow and a method that avoids the slowdown without sending more data. Its analysis allows clients whose data are arbitrarily different, with no assumption on how similar they are. The authors also show that for quadratic losses, taking several local steps can help rather than hurt when the clients are similar. The abstract calls this the first result to quantify the usefulness of local steps in distributed optimization.
The paper is also a clear example of a general idea: if you know a per-client bias, you can estimate it and subtract it. The same move appears in variance reduction for single-machine stochastic optimization, and SCAFFOLD makes that link explicit by describing its correction as client-variance reduction.
Federated averaging, described in Communication-Efficient Learning of Deep Networks from Decentralized Data, is in the paper's words the algorithm of choice for federated learning. Zhao and colleagues (2018) first observed that performance drops on non-identical client data. Earlier analyses bounded the resulting drift with strong assumptions about gradients or client optima. This paper proves rates for FedAvg without such assumptions and then removes the drift with control variates.
The problem
Federated learning has three hard constraints. Communication between server and clients is slow and unreliable. Only a small subset of clients is available in a given round. And the data on different clients is heterogeneous, so each client's loss has its own minimum. The most popular method, FedAvg, reduces communication by running several local steps per round. The heterogeneity is where it breaks.
Each client moves toward its own minimum during its local steps. The server then averages those moves, and the average points toward the mean of the client minima, which is not the minimum of the global loss. The gap between the two is the drift. To stop the drift from overwhelming the progress, FedAvg must use smaller step sizes, and smaller steps mean more rounds.
The paper makes this precise. Its Theorem I gives FedAvg convergence rates that depend on a gradient-dissimilarity constant . Its Theorem II gives a lower bound: for some strongly convex problems, FedAvg's error after rounds is at least of order , even with no noise and no client sampling. The paper also notes that plain SGD can be faster than FedAvg on such problems. The question is whether the drift can be removed without losing the savings from local steps.
How it works
SCAFFOLD keeps one extra vector per client and one for the server, and uses their difference to correct every local step. Here is one tiny instance, with two clients and one number as the model.
Client 1 has loss , so its minimum is at 0. Client 2 has loss , with its minimum at 4. The global loss is the average , whose minimum is at 2. The plot shows the three curves.
- client 1 loss f_1
- client 2 loss f_2
- global loss f
- Start. The server model is . Suppose the control variates already hold the clients' gradients at the global optimum: client 1 holds (its gradient ), client 2 holds (its gradient ), and the server holds , their average. Check: is the average of the .
- Compute the corrected direction. Each local step uses the raw gradient minus the client's control variate plus the server's: . At the first local point , client 1's raw gradient is , and its corrected direction is . Client 2's raw gradient is , and its corrected direction is . Check: both corrected directions equal , the average raw gradient .
- Take the local step. With local step size , each client moves by times its corrected direction. Both move from 0 to . Check: both clients are now at the same point, 1.
- Repeat for the second local step. At , client 1's corrected direction is , and client 2's is . Both step to . Check: both clients agree again.
- Update the control variate. Each client refreshes from the steps it just took (the paper's option II), so the next round starts from a better estimate of its own gradient. The server then averages the changes.
- Aggregate. The server model moves by the average client change, , with global step size . Check: the server moved toward the global minimum at 2.
The pattern is what matters. Without the correction, the two clients would walk toward their own minima and end at different points, one at 0 and one at 3 in this run. The correction makes the two local paths identical, so every local step follows the average gradient. In this run the FedAvg average also lands at 1.5, but only because the two drifts are symmetric and cancel. The paper's point is that FedAvg's average is biased in general, while the corrected steps are not.
flowchart LR S["Server sends model x and control variate c"] --> C["Sampled clients take K corrected local steps"] C --> U["Each client refreshes its own c_i"] U --> A["Server averages the changes in x and c"] A --> S
Second round
Start round 2 from the server model reached at the end of round 1. Option II has refreshed the variates: client 1 holds , client 2 holds , and the server holds , which is their average. Each variate was computed as from round 1, for example for client 1.
- At , client 1's raw gradient is . Its corrected direction is .
- Client 2's raw gradient is . Its corrected direction is .
- Both match the global gradient , and both move by to .
- At , the two corrected directions are each. Both move to .
- The server moves by the average client change, .
Interpretation: the error to the optimum at 2 went from 0.5 after round 1 to 0.125 after round 2, shrinking by a factor of 4 per round. The clients stayed in lockstep, and the corrected direction matched the global gradient at every step.
The math
Definition: the SCAFFOLD round. There are clients, of them are sampled each round, and each sampled client takes local steps with step size . The server has model and control variate . Each client has its own control variate , and is its stochastic gradient. The global loss is .
Step 1 in symbols: the corrected local step
For a sampled client starting from , each of the steps is
The term is the correction. In the worked example it was for client 1 and for client 2, which turned both raw gradients into the same direction.
Step 2 in symbols: updating the client control variate
After its local steps, client computes a new control variate . The paper gives two options:
Option I takes one extra pass over the local data to compute the gradient at the server model. Option II reuses the gradients from the local steps: since is the sum of the local steps, option II works out to the average of the gradients computed along the local path. The paper says option II is cheaper and usually enough, and all its experiments use it.
Step 3 in symbols: aggregation
The server averages the client changes over the sampled set and updates both variates:
The server control variate moves by the average change of the client variates, scaled by rather than , so it stays the average of all clients even when only some are sampled. Setting every to zero turns the algorithm back into FedAvg.
The convergence rate in symbols
For -smooth functions with no assumption on how different the clients are, the paper's Theorem III gives, for strongly convex with no sampling (), a number of rounds of order
where bounds the gradient noise, is the strong-convexity constant, and is the target error. The heterogeneity constant is absent. Compare this with FedAvg's rate in Theorem I, which has the extra term and a term that grows with the heterogeneity.
Results
Simulated quadratics. The paper uses two clients with full-batch gradients and no noise. FedAvg slows as the number of local steps grows and as the gradient dissimilarity grows. SCAFFOLD is unaffected by , and with it is about 5 times faster than SGD, while is twice as fast. The gain from more local steps is sublinear because the clients differ in their Hessians, which Theorem IV says limits the benefit.
EMNIST logistic regression. The paper splits EMNIST across 100 clients. Each client gets of i.i.d. data and the rest sorted by label, so 0% similarity means fully sorted data. Table 4 gives communication rounds to reach 0.45 test accuracy with 5 epochs per round.
| Method | Sampled clients | 0% similarity | 10% similarity |
|---|---|---|---|
| SCAFFOLD | 20% | 143 | 9 |
| SCAFFOLD | 5% | 290 | 13 |
| SCAFFOLD | 1% | 790 | 28 |
| FedAvg | 20% | 179 | 12 |
| FedAvg | 5% | 334 | 17 |
| FedAvg | 1% | 1k+ | 35 |
The paper's reading is that SCAFFOLD is consistently faster than FedAvg, and that its slowdown under sampling is sublinear, better still for more similar clients.
EMNIST two-layer network. Table 5 gives the best test accuracy after 1,000 rounds, with 20% of clients sampled and 5 epochs per round.
| Method | 0% similarity | 10% similarity |
|---|---|---|
| SGD | 0.766 | 0.764 |
| FedAvg | 0.787 | 0.828 |
| SCAFFOLD | 0.801 | 0.842 |
The paper's reading is that SCAFFOLD gives the best accuracy in both settings, and that SGD does not improve with similarity while the local methods do.
- Compare FedAvg and SCAFFOLD at 20% sampling with 0% similarity: , so FedAvg needs about a quarter more rounds on this run.
- Drop to 1% sampling, so one round touches one client in a hundred. SCAFFOLD now needs 790 rounds, while FedAvg does not reach 0.45 within 1,000 rounds.
- Repeat with 10% similarity, where clients hold more mixed data. SCAFFOLD needs 9 rounds at 20% sampling and 28 at 1%. FedAvg needs 12 and 35.
- Interpretation: sampling fewer clients slows both methods by a similar factor, and SCAFFOLD needs fewer rounds at every sampling level. The control variates are meant to let the sampled clients stand in for the whole population. Try it: from the 20% and 1% rows with 0% similarity, how many times more rounds does SCAFFOLD need at 1% than at 20%? Answer: , which matches the 5.5 times in the table.
Common mistakes and tradeoffs
It is tempting to think SCAFFOLD removes heterogeneity from the problem. In fact it removes the effect of heterogeneity on the local steps, but each client still has its own minimum. The control variates let the local steps follow the global gradient. They do not make the data more similar.
It is tempting to think SCAFFOLD is free because it uses the same number of rounds. In fact each client sends both its model change and its control variate change in every round, so each message carries two vectors instead of one. The paper compares methods by rounds, not bytes. The saving is real only if fewer rounds outweigh the larger messages.
It is tempting to think more local steps always help. In fact on heterogeneous data FedAvg gets worse as grows, while SCAFFOLD benefits. For identical clients, the paper's Theorem IV gives a complexity whose second term falls as , so local steps help in proportion to . For clients that are similar but not identical, the bound's second term is , so extra local steps help less and less once the floor dominates. This is why the experiments show sublinear gains from .
It is tempting to think the server must hold every client's state. In fact the server holds one vector , but each client must store its own across rounds, because the paper's clients are stateful.
When to use SCAFFOLD. Use it when the clients' data differ a lot, when only a fraction of clients are sampled per round, and when a client can keep a vector of state between rounds. When not to. If the clients are nearly identical, FedAvg is simpler and nearly as good. If clients cannot store state, or if message size rather than round count is the bottleneck, the tradeoff changes. An alternative is FedProx, which adds a penalty that keeps each client near the global model, described in Federated Optimization in Heterogeneous Networks.
Limits
The experiments are small: a logistic regression model, a two-layer network, and one dataset. The authors say larger experiments are beyond the scope of the paper. The analysis assumes smooth losses and bounded noise, and the local-steps result covers only quadratic functions, which the paper names as an open problem for general functions. The rounds comparison also hides the doubled message size noted above.
Reading guide
The chain of ideas the paper builds, in order: FedAvg's rates under heterogeneity, then the lower bound that shows the drift is real, then the control-variate correction, then its rates without the heterogeneity term, then the advantage from local steps on similar quadratics, then experiments.
- Abstract and Section 1 (Introduction). Needs Federated Learning and Communication-Efficient Learning of Deep Networks from Decentralized Data. The three challenges are slow links, partial participation and heterogeneous data.
- Section 2 (Setup). Needs Stochastic Gradient Descent and Smooth Function. The sum over clients and the bounded-variance noise assumption come from there. The dissimilarity assumptions (A1) and (A2) are defined here and are the paper's vocabulary for heterogeneity.
- Section 3 (Convergence of FedAvg). Needs Convex Function and Strong Convexity for the rate statements, and Gradient Descent for the local step. Read Theorem I as a benchmark, not as the paper's method.
- Section 3.2 (Lower bound). Needs Client Drift. Theorem II explains the drift as a gap between the average of client minima and the global minimum.
- Section 4 (Algorithm). Needs Control Variate. Algorithm 1 and Figure 2 are the core. Re-derive the corrected step from the ideal update in equation (6), as in How it works.
- Section 5 (Convergence of SCAFFOLD). Theorem III is the main result. Its rate has no heterogeneity term.
- Section 6 (Local steps). Needs only the second derivative (the Hessian) and Smooth Function. Theorem IV and the Hessian argument are the paper's novel contribution for quadratics.
- Section 7 (Experiments). Tables 4 and 5 are the main evidence for the claims above.
- Appendices. Appendix E holds the full convergence proofs; Appendix F covers the quadratic case.
Read next: Communication-Efficient Learning of Deep Networks from Decentralized Data for the baseline the paper improves on, and Federated Optimization in Heterogeneous Networks for another answer to the same heterogeneity problem. Adaptive Federated Optimization takes the server side of federated learning further.
Check yourself
QuestionIn one sentence, what is client drift, and why does it force FedAvg to use smaller step sizes?Show answer
Client drift is the movement of each client's local model toward its own minimum during local steps, so the average of the client updates points toward the mean of the client minima instead of the global minimum. To keep the drift from overwhelming progress, FedAvg must shrink the step size, and smaller steps need more rounds.
QuestionIn the tiny example, client 1 has control variate 2 and client 2 has control variate -2, and both raw gradients at 0 are 0 and -4. What is client 2's corrected direction at 0, and why does it match client 1's?Show answer
The corrected direction is . Client 1's corrected direction is . They match because the correction turns each raw gradient into its deviation from its own control variate plus the server value, and here both come out to the average raw gradient .
QuestionWhy does the server update the control variate c with a factor of 1/N rather than 1/|S|?Show answer
The control variate c is supposed to equal the average of all client variates. A client that is not sampled keeps its old , so the sum over sampled clients must be divided by to keep as the average over all clients, even when only some of them changed.
QuestionIn the EMNIST 0% similarity runs, SCAFFOLD needs 143 rounds with 20% of clients sampled and 790 rounds with 1%. What is the ratio, and what does it say about sampling?Show answer
The ratio is . Sampling 1% of clients rather than 20% makes SCAFFOLD about 5.5 times slower in rounds. Participation fell by a factor of 20, but rounds rose only about 5.5 times, so the slowdown is sublinear.
QuestionSuppose you run SCAFFOLD on clients whose data are all identical. Would you expect the control variates to matter much? Explain using the paper's Theorem IV reasoning.Show answer
Probably not much. If the clients are identical, the gradients are the same, so the control variates are nearly equal and the correction is close to zero. The paper's Theorem IV says that for identical functions the complexity's second term falls as , so local steps help SCAFFOLD on identical clients. The control variates contribute little there, because the correction they supply is already near zero.
Sources
- Karimireddy, Kale, Mohri, Reddi, Stich, Suresh (2019), SCAFFOLD: Stochastic Controlled Averaging for Federated Learning, arXiv:1910.06378. https://arxiv.org/abs/1910.06378
- Federated learning, Wikipedia. https://en.wikipedia.org/wiki/Federated_learning