Inferensys

Glossary

SCAFFOLD

SCAFFOLD is a federated optimization algorithm that corrects for client drift caused by data heterogeneity by introducing control variates that estimate the update direction of the global model, significantly reducing communication rounds.
ML engineer managing model versions on laptop, version history visible, technical Git-like workflow.
STOCHASTIC CONTROLLED AVERAGING FOR FEDERATED LEARNING

What is SCAFFOLD?

SCAFFOLD is a federated optimization algorithm that corrects for client drift in heterogeneous data environments by introducing control variates to estimate the global update direction, significantly reducing communication rounds.

SCAFFOLD (Stochastic Controlled Averaging for Federated Learning) is a communication-efficient algorithm that mitigates the client drift caused by non-IID data distributions across clients. Unlike FedAvg, where local updates diverge from the global optimum due to statistical heterogeneity, SCAFFOLD introduces control variates—stateful correction terms maintained by both the server and each client—that estimate the true global gradient direction. These variates are updated iteratively using the difference between the global and local model gradients, effectively steering local training toward the global solution.

By subtracting the local control variate and adding the global one during local updates, SCAFFOLD neutralizes the variance introduced by heterogeneous data, allowing clients to perform more local steps without diverging. This correction mechanism enables the algorithm to converge in significantly fewer communication rounds than FedAvg, especially under high data heterogeneity. The trade-off is doubled state storage per client and slightly increased local computation, but the reduction in bandwidth overhead makes SCAFFOLD a foundational protocol for communication-efficient federated learning in healthcare and other privacy-sensitive domains.

ALGORITHM DEEP DIVE

Key Features of SCAFFOLD

SCAFFOLD (Stochastic Controlled Averaging for Federated Learning) introduces control variates to correct for client drift, the primary obstacle to convergence in heterogeneous data environments. By estimating the global update direction locally, it dramatically reduces communication rounds.

01

Control Variate Correction

The core innovation of SCAFFOLD is the maintenance of control variates (c and c_i) for the server and each client. These variates estimate the global model's update direction. During local training, the client corrects its stochastic gradient by subtracting the drift between its local variate and the server's variate: g_i = ∇F_i(x) - c_i + c. This correction prevents the local model from straying too far toward its local optimum, directly addressing the client drift problem that plagues standard FedAvg on non-IID data.

02

Eliminating Client Drift

In standard Federated Averaging, when client data distributions are heterogeneous (non-IID), local models drift toward their individual local minima. SCAFFOLD's control variates mathematically bound this drift. The correction term c - c_i acts as a force pulling the local update back toward the global optimum. This allows clients to perform many more local steps without diverging, which is the key mechanism enabling a significant reduction in total communication rounds compared to FedAvg.

03

Communication Efficiency

SCAFFOLD achieves communication efficiency not by compressing gradients, but by reducing the total number of communication rounds required to reach a target accuracy. Because the control variates prevent divergence, the algorithm converges in significantly fewer rounds than FedAvg, especially under high data heterogeneity. The trade-off is that each round transmits both the model update and the updated local control variate, doubling the payload size per round. However, the reduction in total rounds typically yields a net decrease in overall communication.

04

Convergence Guarantees

SCAFFOLD provides strong theoretical convergence guarantees under non-IID data distributions. It provably converges to a stationary point at a rate comparable to SGD on a single machine, even with arbitrarily heterogeneous client data. This is a significant theoretical advantage over FedAvg, which can converge to a suboptimal point or require a carefully tuned learning rate decay when data is non-IID. SCAFFOLD's convergence is robust to both statistical heterogeneity and partial client participation.

05

Option I vs. Option II

SCAFFOLD defines two algorithmic variants:

  • Option I: The server maintains a single global control variate c. Clients update their local variate c_i and transmit the difference Δc_i back to the server, which aggregates them to update c.
  • Option II: Clients transmit their updated local variate c_i directly, and the server averages them to form the new c. Option II is simpler but requires clients to maintain state across rounds, making it suitable for cross-silo settings with stateful clients.
06

Stateful Client Requirement

A practical limitation of SCAFFOLD is that it requires clients to be stateful—each client must store and update its local control variate c_i across rounds. This is feasible in cross-silo federated learning (e.g., hospitals training collaboratively) where clients are persistent and reliable. However, in cross-device settings with millions of ephemeral mobile devices, maintaining per-client state is impractical. Variants like FedDyn and Mime have been proposed to address this limitation.

SCAFFOLD ALGORITHM

Frequently Asked Questions

Clear, technically precise answers to the most common questions about the SCAFFOLD federated optimization algorithm, its mechanisms for correcting client drift, and its advantages over standard Federated Averaging in heterogeneous data environments.

SCAFFOLD (Stochastic Controlled Averaging for Federated Learning) is a federated optimization algorithm that corrects for client drift caused by heterogeneous (non-IID) data distributions by introducing control variates (variance reduction terms) that estimate the update direction of the global model. Unlike Federated Averaging (FedAvg), which suffers from divergence when local client data distributions differ significantly, SCAFFOLD maintains a server-side control variate c and client-side control variates c_i that track the difference between the global and local update directions. During local training, each client corrects its stochastic gradient by subtracting its local control variate and adding the server control variate: g_i = ∇f_i(x; ξ) - c_i + c. This correction anchors local updates to the global optimum, dramatically reducing the number of communication rounds required for convergence—often by an order of magnitude compared to FedAvg under severe data heterogeneity. The algorithm was introduced by Karimireddy et al. in the 2020 paper 'SCAFFOLD: Stochastic Controlled Averaging for Federated Learning' and remains a foundational method for communication-efficient, statistically robust federated optimization.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.