Each client runs several local SGD steps; the server computes a weighted average of all updates proportional to each client's dataset size.
Before FedAvg, the naive FL approach was FedSGD: each client computes one gradient step and sends it; the server accumulates gradients. This requires one round of communication per gradient — enormously expensive at scale. FedAvg's insight: let each client run multiple local SGD steps before communicating. The resulting weight deltas are then averaged. More local compute per round = fewer rounds = drastically less communication.
Why does weight averaging work? Neural network loss surfaces are approximately convex in the region of convergence. If two clients both start from the same global weights and move towards local minima via SGD, the midpoint of their weights is typically also a lower-loss point than the global start — so weighted averaging produces a globally better model. This breaks down with very non-IID data or too many local steps.
FedAvg has two levels: the server loop and the client update. The server samples a fraction C of clients each round, sends them the global model, waits for their updated weights, then computes a weighted average. The weight given to client k is proportional to its local dataset size n_k divided by the total data n.
For each round t = 1 to T:
S_t ← random sample of C·K clients
For each client k in S_t (in parallel):
w_k ← ClientUpdate(k, w_t)
w_{t+1} ← Σ_k (n_k / n) · w_k
Split local data into batches of size B
For epoch e = 1 to E:
For each batch b:
w ← w − η · ∇L(w; b)
Return w
FedAvg converges to a good solution under IID data — clients effectively pool their data through the average. Under non-IID data, convergence degrades because clients diverge towards their local optima during the E local epochs before re-synchronising. This is called client drift. The remedy is either reducing E, reducing C (more clients per round), or using FedProx which adds a proximal term penalising deviation from the global model.
FedAvg spawned an entire research field. Key extensions: FedProx adds a proximal term to each client's loss to limit divergence from the global model. SCAFFOLD uses variance reduction to correct for client drift. FedNova normalises local updates by the number of steps taken to avoid biasing towards clients with more compute. FedMA uses neuron-level matching to average dissimilar network architectures.
Say the answer out loud before revealing — recalling is what makes it stick.
What is the key difference between FedSGD and FedAvg?
How does FedAvg weight each client's contribution?
What is client drift in FL?
How does FedProx address client drift?