Inferensys

Glossary

SCAFFOLD

SCAFFOLD (Stochastic Controlled Averaging for Federated Learning) is an algorithm that uses control variates to correct for client drift, enabling faster, more stable convergence under Non-IID data conditions.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
FEDERATED LEARNING ALGORITHM

What is SCAFFOLD?

SCAFFOLD (Stochastic Controlled Averaging for Federated Learning) is a foundational algorithm designed to correct client drift and accelerate convergence in federated learning, particularly under Non-IID data conditions.

SCAFFOLD is a federated optimization algorithm that introduces control variates—client-specific and server-side correction terms—to reduce the variance between local stochastic gradients and the true global gradient. By maintaining these stateful variables, it directly counteracts client drift, the divergence of local models caused by statistical heterogeneity, leading to more stable and significantly faster convergence than standard Federated Averaging (FedAvg).

The algorithm operates by having each client compute the difference between its local update and a global reference direction, storing this as a local control variate. The server aggregates these differences to update a global control variate, which is then used to correct the next round of client updates. This variance reduction mechanism makes SCAFFOLD robust to high levels of data heterogeneity, as quantified by bounded gradient dissimilarity, and is a key reference in the field of federated optimization techniques.

SCAFFOLD

Core Algorithmic Mechanisms

SCAFFOLD (Stochastic Controlled Averaging for Federated Learning) is an algorithm that uses control variates to correct for client drift, enabling faster and more stable convergence under Non-IID data conditions.

01

Core Definition & Purpose

SCAFFOLD (Stochastic Controlled Averaging for Federated Learning) is a federated optimization algorithm designed to correct for client drift—the divergence of local client models from the global objective due to Non-IID data. It introduces control variates (corrective terms) on both the server and clients to reduce the variance between local updates, leading to faster and more stable convergence compared to standard Federated Averaging (FedAvg).

02

The Control Variate Mechanism

The algorithm's key innovation is the use of two control variates:

  • Client control variate (c_i): Tracks the drift of client i's local updates from the server's direction.
  • Server control variate (c): Represents the global update direction.

During local training, clients adjust their gradient steps using the difference between their control variate and the server's. This correction reduces the bias introduced by local data skew. After aggregation, both control variates are updated to reflect the new global state, creating a feedback loop that continuously corrects for drift.

03

Algorithm Steps

A single round of SCAFFOLD involves:

  1. Server Broadcast: The server sends the global model x and global control variate c to a subset of clients.
  2. Local Correction & Training: Each client i computes local updates using a corrected stochastic gradient: gradient - c_i + c. This aligns the local step with the global direction.
  3. Update Transmission: Clients send back their model update delta_i and their updated local control variate c_i_new.
  4. Server Aggregation: The server averages the model updates to form a new global model x. It also updates the global control variate c by averaging the changes in client control variates.
04

Advantages Over FedAvg

SCAFFOLD provides significant improvements in heterogeneous settings:

  • Faster Convergence: Achieves the same accuracy as FedAvg in fewer communication rounds, often by a factor of 3-10x under high heterogeneity.
  • Stability: The control variates smooth the optimization path, reducing oscillation and improving final test accuracy.
  • Theoretical Guarantees: Provides convergence guarantees under standard assumptions (bounded gradient dissimilarity) without requiring data to be IID.
  • Robustness: Less sensitive to hyperparameter choices like client learning rate and number of local epochs compared to FedAvg.
05

Limitations & Practical Considerations

While powerful, SCAFFOLD introduces trade-offs:

  • Communication Overhead: Clients must transmit both model updates and control variates, doubling the per-client communication cost compared to FedAvg (though still fewer rounds are needed).
  • Client State: Requires clients to maintain persistent local control variates c_i across rounds, adding memory overhead and complexity for dropping/rejoining clients.
  • Computation: The local correction step adds minimal but non-zero computational overhead.
  • Initialization Sensitivity: Performance can depend on the initial values of the control variates, though they are typically initialized to zero.
06

Related & Contrasting Algorithms

SCAFFOLD exists within a spectrum of algorithms tackling Non-IID data:

  • FedAvg: The baseline; suffers from client drift without correction mechanisms.
  • FedProx: Adds a proximal term to the local loss to penalize deviation from the global model; simpler but less adaptive than SCAFFOLD's control variates.
  • FedOpt: Applies adaptive server optimizers (e.g., Adam) to aggregated updates; can be combined with SCAFFOLD's client-side correction.
  • Personalized FL (e.g., Ditto): Aims for distinct local models, whereas SCAFFOLD seeks a single, improved global model. SCAFFOLD is particularly effective when the primary goal is a high-performance global model in a statistically heterogeneous environment.
ALGORITHM MECHANISM

How SCAFFOLD Works: Step-by-Step

SCAFFOLD (Stochastic Controlled Averaging for Federated Learning) is an advanced federated optimization algorithm that uses control variates to correct for client drift, enabling faster and more stable convergence on Non-IID data.

The algorithm introduces two key control variates: a server control variate c and local client variates c_i. At each round, selected clients receive the global model and c. They perform local Stochastic Gradient Descent (SGD), but their update is corrected by the difference between their local variate c_i and the global c. This correction directly counteracts the bias introduced by local data heterogeneity, reducing the variance between client updates.

After local training, clients send their model delta and an updated local control variate to the server. The server aggregates the model updates via federated averaging and similarly updates the global control variate c by averaging the client variate changes. This iterative refinement of control variates progressively aligns client optimization directions, mitigating client drift and accelerating convergence to a superior global optimum under statistical heterogeneity.

ALGORITHM COMPARISON

SCAFFOLD vs. FedAvg: Key Differences

This table contrasts the core mechanisms, convergence properties, and practical implications of the SCAFFOLD and FedAvg algorithms for federated learning under Non-IID data conditions.

Feature / MetricSCAFFOLD (Stochastic Controlled Averaging)FedAvg (Federated Averaging)

Core Mechanism

Uses control variates (c_i, c) to correct for client drift

Averages local model parameters (weights) directly

Primary Objective

Reduce variance between local and global update directions

Minimize aggregate loss via simple parameter averaging

Convergence Speed (Non-IID)

Faster, more stable; provably linear convergence

Slower, unstable; can diverge or oscillate

Communication Rounds to Target Accuracy

30-50% fewer rounds

Baseline (100%)

Local Computation per Client

Slightly higher (maintains & updates control variate)

Standard (local SGD steps only)

Client Memory Overhead

Higher (stores local control variate c_i)

Lower (stores only model parameters)

Robustness to High Data Heterogeneity

High (explicitly corrects for drift)

Low (suffers from client drift)

Theoretical Guarantee for Non-IID Data

Yes (under bounded dissimilarity)

No (requires IID or very low heterogeneity)

Server-Side Computation

Higher (maintains & broadcasts global control variate c)

Lower (simple weighted average)

Typical Use Case

Mission-critical applications with severe statistical heterogeneity

Homogeneous data or applications tolerant of slower convergence

SCAFFOLD

Implementation and Practical Considerations

SCAFFOLD's practical implementation involves managing additional state variables, tuning hyperparameters, and ensuring compatibility with system heterogeneity. These cards detail the key engineering decisions required to deploy it effectively.

01

Control Variate Mechanics

The core of SCAFFOLD is the maintenance of two sets of control variates: client-specific (c_i) and server (c). These are stateful variables updated each round.

  • Client Update: c_i = c_i - c + (x - y_i) / (η_l K), where x is the global model, y_i is the local model after training, η_l is the client learning rate, and K is the number of local steps.
  • Server Update: c = c + (1/N) * Σ (c_i^{new} - c_i^{old}). These variates correct the local update direction, reducing the variance introduced by Non-IID data.
02

Hyperparameter Sensitivity

SCAFFOLD introduces critical hyperparameters beyond the standard learning rate.

  • Client Learning Rate (η_l): Controls the aggressiveness of local updates. Must be balanced to allow correction by the control variate.
  • Server Learning Rate (η_g): Applied to the aggregated model update. Often set to 1.0 for FedAvg-style aggregation.
  • Local Epochs/Steps (K): A higher K increases client drift; SCAFFOLD's correction is most beneficial here. Tuning is essential for stability.
03

Communication Overhead

SCAFFOLD doubles the per-client communication cost compared to Federated Averaging (FedAvg).

  • What's Transmitted: Each client sends both its updated model parameters and its updated client control variate c_i to the server.
  • Bandwidth Impact: For a model with M parameters, communication per client is 2M floats per round. This is a key trade-off for improved convergence under heterogeneity.
  • Mitigation: Can be combined with compression techniques (e.g., sparse updates, quantization) applied separately to the model and control variate tensors.
04

Partial Client Participation

SCAFFOLD remains effective when only a subset of clients participates each round, a practical necessity.

  • Server Control Variate (c): Acts as a stable, global anchor. Participating clients use c to correct their updates.
  • Non-Participating Clients: Their client control variates c_i remain unchanged until their next participation. The algorithm does not require synchronous updates from all clients.
  • Bias Correction: The server update for c uses only the changes from participating clients, but this is unbiased in expectation, preserving convergence guarantees.
05

Integration with Secure Aggregation

SCAFFOLD is compatible with cryptographic Secure Aggregation (SecAgg) protocols to protect individual client updates.

  • Challenge: SecAgg typically sums model updates. SCAFFOLD requires the server to also compute the sum of changes to c_i.
  • Solution: Both the model delta (y_i - x) and the control variate delta (c_i^{new} - c_i^{old}) can be masked and aggregated securely within the same protocol. The server learns only the aggregated sums, not individual values.
  • Privacy: This maintains client privacy while enabling the variance reduction benefits of SCAFFOLD.
06

Comparison to FedProx

FedProx and SCAFFOLD are both solutions for Non-IID data, but with different mechanisms.

  • FedProx: Adds a proximal term (μ/2 * ||w - w^t||^2) to the local loss, penalizing deviation from the global model w^t. It's a regularization-based approach.
  • SCAFFOLD: Uses control variates to correct the update direction itself. It's a variance reduction technique.
  • Practical Choice: FedProx is simpler to implement (one extra hyperparameter μ). SCAFFOLD often achieves faster convergence but with higher communication and memory (state) costs. The choice depends on system constraints.
SCAFFOLD

Frequently Asked Questions

SCAFFOLD (Stochastic Controlled Averaging for Federated Learning) is a foundational algorithm for tackling Non-IID data in decentralized training. These questions address its core mechanics, advantages, and practical implementation.

SCAFFOLD (Stochastic Controlled Averaging for Federated Learning) is a federated optimization algorithm that introduces control variates—client-specific and server-side correction terms—to explicitly counteract client drift caused by statistical heterogeneity (Non-IID data). It modifies the local stochastic gradient descent (SGD) update on each client to reduce the variance between local updates and the global objective, enabling faster and more stable convergence than standard Federated Averaging (FedAvg). The algorithm's core innovation is maintaining two states: the global model parameters and a set of control variables that track and correct for the bias in client updates.

Key Components:

  • Client Control Variate (c_i): A vector stored locally by each client i that estimates the bias between its local updates and the global direction.
  • Server Control Variate (c): A global average of the client control variates, representing the aggregate correction.
  • Corrected Local Update: Clients compute gradients and adjust them using the difference between their local c_i and the global c, effectively 'de-biasing' their step.
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.