AnyLearn
All lessons
AIadvanced

Client Drift: The Heterogeneity Problem

Why local training on non-identical data pulls clients apart, how averaging their updates produces a model that suits nobody, and the control-variate fix that corrects the drift.

Updated · AI-authored, review-gated · how lessons are made

Not signed in: your progress and quiz score won't be saved.
Progress1 / 8

The assumption FedAvg quietly makes

FedAvg works well in one condition and degrades outside it. Naming the condition precisely is the whole of this lesson.

Write the global objective as the average of client objectives, each being the loss on that client's own data. Under IID data, every client's local objective is an unbiased estimate of the global one. So a step that improves a client's local loss improves the global loss in expectation, every client is pulling in roughly the same direction, and averaging their endpoints is sound.

Under non-IID data this fails at the root. Each client's local objective has a different minimiser from the global objective. Local training does not approximate global training with noise; it optimises a genuinely different function.

The consequence has a name: client drift. As a client takes more local steps, it moves further toward its own optimum and further from where the global model should go. The very mechanism that made FedAvg communication-efficient, many local steps, is what causes it.

Full lesson text

All 8 steps on one page, for reading, reference, and search.

Show

1. The assumption FedAvg quietly makes

FedAvg works well in one condition and degrades outside it. Naming the condition precisely is the whole of this lesson.

Write the global objective as the average of client objectives, each being the loss on that client's own data. Under IID data, every client's local objective is an unbiased estimate of the global one. So a step that improves a client's local loss improves the global loss in expectation, every client is pulling in roughly the same direction, and averaging their endpoints is sound.

Under non-IID data this fails at the root. Each client's local objective has a different minimiser from the global objective. Local training does not approximate global training with noise; it optimises a genuinely different function.

The consequence has a name: client drift. As a client takes more local steps, it moves further toward its own optimum and further from where the global model should go. The very mechanism that made FedAvg communication-efficient, many local steps, is what causes it.

2. How data actually differs

Heterogeneity is not one phenomenon, and the flavours have different consequences.

Label skew is the most studied. Each client holds a different mix of classes. A phone belonging to a cat owner has cat photographs; a hospital specialising in oncology sees cancers at a rate unlike a general practice.

Feature skew means the same class looks different across clients. Handwriting differs by writer. Imaging equipment differs by manufacturer, so the same pathology has a different appearance at each site.

Concept drift means the same input maps to different labels. What counts as spam depends on the recipient. A borderline diagnosis depends on local clinical convention.

Quantity skew means dataset sizes span orders of magnitude, which interacts with weighting.

A clean way to see the extreme case: give each client exactly one class. Local training then drives each client's model to predict its own class always, since that is optimal for its local loss. Averaging models that each predict a different constant produces something that predicts nothing well.

Real heterogeneity is milder, but the mechanism is identical.

3. Why the average misses

The failure is geometric. Each client walks toward its own minimum, so the further they walk the more their endpoints spread. Averaging spread-out endpoints lands somewhere that is not the global optimum, and the error grows with the number of local steps.

flowchart TD
  A["All clients start from the global model"] --> B["Client 1 descends toward its own optimum"]
  A --> C["Client 2 descends toward a different optimum"]
  A --> D["Client 3 descends toward another one"]
  B --> E["Endpoints spread further with more local steps"]
  C --> E
  D --> E
  E --> F["Server averages the endpoints"]
  F --> G["Average is not the global optimum"]
  G --> H["More local steps means cheaper rounds but worse target"]

4. The tension, stated as a trade-off

Client drift creates a genuine dilemma rather than a bug to be patched.

Many local steps per round
  + far fewer communication rounds
  + cheap: local compute is nearly free
  - clients drift far from each other
  - averaged model can be poor or unstable

Few local steps per round
  + updates stay close, averaging is sound
  + behaves like centralised SGD
  - communication cost per unit of progress explodes

So the local-epoch count is not a free efficiency knob. It trades communication against solution quality, and in strongly heterogeneous settings the useful range can be uncomfortably narrow.

The symptoms in practice are recognisable. Training loss oscillates between rounds rather than descending smoothly. Accuracy plateaus below what centralised training on the pooled data achieves. Increasing local epochs, which should help throughput, makes results worse. Individual clients perform well on their own data and poorly on everyone else's.

The research question that follows is whether you can keep many local steps and correct the drift. That turns out to be possible.

5. SCAFFOLD and control variates

The influential fix is SCAFFOLD, from Sai Praneeth Karimireddy, Satyen Kale, Mehryar Mohri, Sashank Reddi, Sebastian Stich, and Ananda Theertha Suresh, published at ICML 2020 as "SCAFFOLD: Stochastic Controlled Averaging for Federated Learning".

The insight is that drift is a bias with predictable direction, not random noise. A client's local gradient consistently differs from the global gradient in a way that reflects that client's data. If the difference is consistent, it can be estimated and subtracted.

SCAFFOLD applies control variates, a classical variance-reduction technique. Each client maintains a control variate estimating its own gradient bias, and the server maintains one for the global direction. During local training, the client corrects each step:

local step:  w -= lr * ( grad_local(w) - c_client + c_server )

Read the correction. Subtract what this client's gradient habitually over-contributes; add back the global direction it habitually under-represents. The corrected step estimates the global gradient rather than the local one, so the client can take many steps without wandering toward its own optimum.

The paper's result is that SCAFFOLD requires significantly fewer communication rounds and is not affected by data heterogeneity or client sampling.

6. The cost SCAFFOLD pays

The correction is not free, and its costs determine where it can be deployed.

Communication doubles. Clients now send both a model update and a control variate update, so each round moves roughly twice the data. Since communication was the binding constraint, this is a real price.

Clients become stateful. Each client must remember its control variate between rounds. That is natural in cross-silo federation, where the same ten hospitals participate every round. It is a serious problem in cross-device federation, where a phone may be selected once and never again, leaving its control variate stale or undefined.

This is why the taxonomy from the previous lesson matters operationally rather than academically.

Other approaches trade differently. FedProx adds a proximal term penalising distance from the global model, which is stateless and cheap but conservative, slowing progress rather than correcting direction. Momentum-based methods offer another route, with work showing momentum benefits non-IID federated learning both simply and provably, and attractively for cross-device because the state can live on the server.

No method dominates. The choice depends on which resource, communication or client state, you can afford to spend.

7. When one global model is the wrong goal

There is a deeper response worth considering: if clients have genuinely different data distributions, perhaps forcing them to share a single model is the mistake.

Ask what the objective should be. If clients differ because of sampling noise around a shared truth, one global model is right and heterogeneity is an obstacle to overcome. If they differ because their situations genuinely differ, a single model is a compromise nobody wanted.

Personalised federated learning takes the second view: use collaboration to learn what is shared, then adapt locally to what is not. Common structures include training a global model then fine-tuning per client, sharing a representation while keeping per-client heads, or learning which clients should collaborate with which.

The last idea has a natural formulation as a bilevel optimisation problem, where the outer level decides collaboration structure and the inner level trains, an approach explored in work from Jaggi's lab among others.

The practical question to ask before choosing: would a single model, trained on all the pooled data, actually serve every client well? If yes, fight the drift. If no, personalisation is not a compromise, it is the correct objective.

8. Choosing a method

A summary of the options against the constraints that decide between them.

MethodCorrects driftExtra communicationClient stateBest setting
FedAvgNoNoneNoneNear-IID data
FedProxPartly, by restraintNoneNoneMild heterogeneity, cross-device
SCAFFOLDYes, by correctionAbout doubleRequiredCross-silo, strong heterogeneity
Server momentumPartlyNoneServer-side onlyCross-device at scale
PersonalisationSidesteps itVariesUsually requiredGenuinely different clients

Two gotchas that cause real confusion. First, more local epochs can make things worse, which inverts the usual intuition that more local work is free progress; if accuracy drops when you raise local epochs, you are seeing drift, not a bug. Second, evaluation must be per-client as well as global. A global average can look acceptable while hiding that the model fails badly on a subset of clients, and in a hospital consortium that subset is a real population.

Everything so far assumes a central server that aggregates. The next lesson removes it.

Check your understanding

The lesson ends with a 5-question quiz. Take it in the player above to see your score.

  1. What causes client drift in federated averaging?
    • Network latency variation between clients and the server
    • Each client's local objective has a different minimiser, so local steps move toward local rather than global optima
    • Floating point precision differences across client hardware
    • Clients using different random seeds for initialisation
  2. Why does increasing local epochs sometimes make federated training worse?
    • It causes overfitting on the global validation set
    • It exceeds the memory available on client devices
    • More local steps let clients drift further apart, so their averaged endpoints land further from the global optimum
    • It increases the variance of the aggregation weights
  3. How does SCAFFOLD correct client drift?
    • By discarding updates from clients whose data is too unusual
    • By reducing the number of local epochs adaptively per client
    • By encrypting updates so the server cannot bias aggregation
    • By using control variates to subtract each client's consistent gradient bias and add back the global direction
  4. Why is SCAFFOLD impractical in cross-device federated learning?
    • It requires clients to maintain state between rounds, but a phone may be sampled only once
    • It cannot handle label skew, only feature skew
    • It requires the server to access raw client data
    • It only converges when all clients have equal dataset sizes
  5. When is personalised federated learning the right objective rather than a compromise?
    • When communication bandwidth is severely constrained
    • When clients differ because their situations genuinely differ, so no single model would serve all of them well
    • Whenever the number of clients exceeds one thousand
    • When the server cannot be trusted to aggregate honestly

Related lessons

AI
intermediate

Streams, Actions, Rewards, and Thinking That Is Not Ours

The paper is concrete about what an experiential agent would differ on, and names four: it lives in a continuous stream rather than episodes, acts in the world rather than emitting text, takes rewards from grounded signals rather than human judgement, and plans in terms it worked out rather than imitating human chain of thought. This lesson works through each.

8 steps·~12 min
AI
intermediate

The Argument: Why Learning From Us Runs Out

David Silver and Richard Sutton argue that the current approach has a ceiling built into it, because a system trained to predict what humans wrote is aiming at human performance by construction. This lesson works through their three eras, the claim about data exhaustion, why they think superhuman performance needs a different learning signal, and the honest counter-arguments.

8 steps·~12 min
AI
advanced

Throughput, Failures, and Making a Long Run Finish

A configuration that fits is not a run that finishes. Llama 3 405B training saw 419 unexpected interruptions in 54 days on 16,384 GPUs, one every three hours, and still kept over 90 percent effective training time. This lesson covers model FLOPs utilisation, the optimal checkpoint interval and where it comes from, loss-spike triage, silent data corruption, and the habits that finish runs.

10 steps·~15 min
AI
advanced

Splitting the Model Itself: Tensor and Pipeline Parallelism

Sharding distributes copies; tensor and pipeline parallelism split the computation. This lesson covers the column-then-row trick that lets a transformer block communicate only twice per layer, sequence parallelism for the parts tensor parallelism cannot reach, the pipeline bubble and why it is (p-1)/m, what 1F1B and interleaving actually fix, and how the three axes compose into a 3D layout.

10 steps·~15 min