Search

Search papers and lessons

Adaptive Federated Optimization

Sashank Reddi, Zachary Charles, Manzil Zaheer et al. · 2020

Reddi and colleagues treat the averaged change from federated clients as a gradient for the server, then apply Adagrad, Adam or Yogi on the server, adding adaptivity without extra client cost.

On this page

  • Colour = topic mix
  • Probability
  • Discrete math
  • Optimizers
  • Calculus
  • Linear algebra
  • Neural network basics
  • ReadReady to readNot yet

TL;DR

Federated learning trains one model across many devices whose data never leaves them. The standard method, FedAvg, lets each device take several local steps and then averages the results, but it is hard to tune and converges poorly on some tasks. This paper proposes a framework, FedOpt, in which the server treats the averaged change from the devices as a gradient and applies an optimiser to it. Using Adagrad, Adam or Yogi on the server adds adaptivity without extra cost on the devices. The authors prove convergence for nonconvex losses with heterogeneous data, and on seven tasks the adaptive servers match or beat FedAvg while being easier to tune.

Builds on: Communication-Efficient Learning of Deep Networks from Decentralized Data, Adam Optimizer, AdaGrad · Leads to: Federated Optimization in Heterogeneous Networks (a related fix for the same client-drift problem)

Why it mattered

Federated learning trains a model without collecting the training data in one place. The paper's main concern is the cross-device setting, where a small fraction of devices such as phones join each round and none can keep state between rounds. Several strong methods, including SCAFFOLD, need clients to remember state across rounds. That is workable between institutions such as hospitals, but not between phones. This paper gave a clean recipe for the harder cross-device setting: the server carries all the adaptive state, and each device still sends one model update per round. The authors also released a benchmark of seven federated tasks across five datasets, with open-source code, so that later methods could be compared on the same ground. By their own account these are the first methods for federated learning to use adaptive server optimisation.

The problem

FedAvg has three practical difficulties, and the paper names two of them directly:

  1. Client drift. After several local steps on its own data, a device's model moves toward the minimum of its local loss, which may differ from the global minimum. Averaging drifted models gives a worse update than the true global gradient would.
  2. Lack of adaptivity. FedAvg is essentially stochastic gradient descent with a fixed server step. Text models in particular produce heavy-tailed gradient noise and sparse gradients, where rare words update rarely, and per-parameter step sizes help.

The known fix for drift, SCAFFOLD, uses control variates that each client must store and update across rounds. That is impossible when clients are sampled rarely and keep no state. Adaptive methods, meanwhile, need an accumulator for each parameter. Doing that on each device, as in earlier adaptive federated methods, means the accumulators must be communicated and averaged across clients. The paper notes that keeping the adaptive state on the server means at most half the communication and client memory per round of those designs. The question is whether adaptivity can live on the server alone.

How it works

Take a tiny example with two parameters, x=(x1,x2)x = (x_1, x_2), starting at (0,0)(0, 0), two sampled clients, and a server step η=0.1\eta = 0.1. Assume the adaptivity constant τ\tau is negligible for the arithmetic.

flowchart LR
  A["Server sends model x_t"] --> B["Clients run local SGD for K steps"]
  B --> C["Each client sends its change Delta_i"]
  C --> D["Server averages to Delta_t"]
  D --> E["Treat minus Delta_t as a gradient"]
  E --> F["Server optimiser: Adagrad, Adam or Yogi"]
  F --> G["New server model x_t+1"]
  G --> A
  1. Broadcast. The server sends x0=(0,0)x_0 = (0, 0) to the sampled clients.
  2. Local training. Each client runs several steps of ordinary SGD on its own data. Client 1 ends at (0.4,0.1)(0.4, 0.1), and client 2 ends at (0.2,0.3)(0.2, 0.3). Their changes are Δ1=(0.4,0.1)\Delta_1 = (0.4, 0.1) and Δ2=(0.2,0.3)\Delta_2 = (0.2, 0.3). Check: the clients only send these changes, not their optimiser state.
  3. Average the changes. Δt=12(Δ1+Δ2)=(0.3,0.2)\Delta_t = \tfrac{1}{2}(\Delta_1 + \Delta_2) = (0.3, 0.2). The server reads −Δt=(−0.3,−0.2)-\Delta_t = (-0.3, -0.2) as a gradient, which the paper calls the pseudo-gradient.
  4. The FedAvg step, for comparison. Plain averaging is equivalent to applying gradient descent with step 1 to this pseudo-gradient, so the new model is x1=(0.3,0.2)x_1 = (0.3, 0.2). Check: each coordinate moves by the averaged change.
  5. The FedAdagrad step. Adagrad keeps a running sum of squared pseudo-gradients, v0=Δt2=(0.09,0.04)v_0 = \Delta_t^2 = (0.09, 0.04). Check: the sum starts from the first round's squared changes, taking the paper's initial value v−1v_{-1} as zero.
  6. Scale each coordinate. The update is x1=x0+η Δt/v0x_1 = x_0 + \eta\, \Delta_t / \sqrt{v_0}. Coordinate 1 becomes 0+0.1×0.3/0.3=0.10 + 0.1 \times 0.3 / 0.3 = 0.1, and coordinate 2 becomes 0+0.1×0.2/0.2=0.10 + 0.1 \times 0.2 / 0.2 = 0.1. So x1=(0.1,0.1)x_1 = (0.1, 0.1).
  7. Interpretation. Averaging moved coordinate 1 by 0.30.3 and coordinate 2 by 0.20.2. Adagrad moved both by 0.10.1, because each coordinate is divided by its own history. A coordinate with large past updates takes smaller steps; one with small past updates takes larger ones. The client cost is unchanged, because clients still send one change per round.

The math

Let FiF_i be the loss of client ii out of mm clients, and let f=1m∑iFif = \tfrac{1}{m}\sum_i F_i be the global objective the server wants to minimise. FedAvg with KK local steps on each client produces, for a sampled set S\mathcal{S} of clients, the average change

Δt=1∣S∣∑i∈S(xit−xt).\Delta_t = \frac{1}{|\mathcal{S}|}\sum_{i \in \mathcal{S}} \left(x_i^{t} - x_t\right).

Step 4 in symbols: FedAvg as server gradient descent

Treat −Δt-\Delta_t as a gradient. A gradient-descent step with server rate η\eta on it is xt+1=xt−η(−Δt)=xt+ηΔtx_{t+1} = x_t - \eta(-\Delta_t) = x_t + \eta\Delta_t. Setting η=1\eta = 1 recovers FedAvg exactly. This is the observation that makes the framework possible: any other gradient-based optimiser can be run on the server in place of this step.

Step 5 in symbols: the adaptive server updates

The paper's Algorithm 2 writes FedAdagrad, FedYogi and FedAdam with a server state mtm_t (a momentum of the pseudo-gradient) and vtv_t (a per-coordinate second moment):

mt=β1mt−1+(1−β1)Δt,m_t = \beta_1 m_{t-1} + (1 - \beta_1)\Delta_t,

and then, depending on the method,

vt=vt−1+Δt2(Adagrad),vt=vt−1−(1−β2)Δt2 sign⁡(vt−1−Δt2)(Yogi),vt=β2vt−1+(1−β2)Δt2(Adam).v_t = v_{t-1} + \Delta_t^2 \quad (\text{Adagrad}), \qquad v_t = v_{t-1} - (1-\beta_2)\Delta_t^2\,\operatorname{sign}(v_{t-1} - \Delta_t^2) \quad (\text{Yogi}), \qquad v_t = \beta_2 v_{t-1} + (1-\beta_2)\Delta_t^2 \quad (\text{Adam}).

The server model is then

xt+1=xt+η mtvt+τ.x_{t+1} = x_t + \eta\,\frac{m_t}{\sqrt{v_t} + \tau}.

The adaptivity constant τ\tau controls how adaptive the method is: a smaller τ\tau means larger coordinate-wise differences in step size. In the walkthrough, β1=0\beta_1 = 0, so mt=Δtm_t = \Delta_t, and v0=Δ02v_0 = \Delta_0^2, which is the step 6 arithmetic. The client side is ordinary SGD with client rate ηl\eta_l.

Step 6 in symbols: the convergence rate

The paper assumes Lipschitz gradients, bounded per-coordinate gradients GG, and bounded variance. It measures heterogeneity with σg2\sigma_g^2, the variance of the client gradients around the global gradient; σg=0\sigma_g = 0 means all clients are identical in distribution. For FedAdagrad and FedAdam with full participation, the paper's Corollaries 1 and 2 give, for suitable learning rates and τ=G/L\tau = G/L,

min⁡0≤t≤T−1E∥∇f(xt)∥2=O ⁣(f(x0)−f(x∗)mKT+2σl2LG2mKT+σ2GKT+σ2LmG2K T3/2),\min_{0 \le t \le T-1} \mathbb{E}\|\nabla f(x_t)\|^2 = \mathcal{O}\!\left(\frac{f(x_0) - f(x^*)}{\sqrt{mKT}} + \frac{2\sigma_l^2 L}{G^2\sqrt{mKT}} + \frac{\sigma^2}{GKT} + \frac{\sigma^2 L\sqrt{m}}{G^2\sqrt{K}\,T^{3/2}}\right),

where σ2=σl2+6Kσg2\sigma^2 = \sigma_l^2 + 6K\sigma_g^2 and σl\sigma_l is the variance within a client. The leading term decays as 1/mKT1/\sqrt{mKT}, which the authors note matches the best known rate for this nonconvex setting. Heterogeneity enters through σ2\sigma^2, which appears only in the later terms. The paper's Remark 1 says the effect of heterogeneity can be reduced by choosing the client and server rates well, but not removed.

Results

All numbers are from the paper's Table 1, which gives validation performance averaged over the last 100 rounds. Higher is better, except for EMNIST AE, which reports mean squared error times 1000.

TaskFedAdagradFedAdamFedYogiFedAvgMFedAvg
CIFAR-1072.177.478.077.472.8
CIFAR-10047.952.552.452.444.7
EMNIST CR85.185.685.585.284.9
Shakespeare57.557.057.257.356.9
Stack Overflow NWP23.825.225.223.819.5
Stack Overflow LR (Recall@5)67.165.865.936.930.0
EMNIST AE (MSE ×1000, lower is better)4.201.010.981.656.47

Where adaptivity helps most. The largest gaps are on the sparse-gradient text tasks and the image tasks where the baseline is weakest. On Stack Overflow next-word prediction, FedAdam and FedYogi reach 25.2 against 19.5 for FedAvg. On Stack Overflow tag prediction, FedAdagrad reaches 67.1 against 30.0. On CIFAR-100, FedAdam reaches 52.5 against 44.7. The paper's explanation for the text tasks is that words absent from a client's data give near-zero updates, so their accumulators stay small and rare words can take large steps when they do appear.

Where the gaps are small. On Shakespeare and EMNIST CR, all methods are within a point or so of each other, and the paper's own bolding treats anything within 0.5 points of the best as tied. Adaptivity does not hurt there, but it is not what makes the difference.

Comparison with SCAFFOLD. On every task SCAFFOLD performed comparably to or worse than FedAvg and the adaptive methods. On Stack Overflow it was nearly identical to FedAvg, because the 342,477 clients make it unlikely any client is sampled twice, so its control variates never get used. The authors suggest that rarely sampled clients make control variates stale.

Ease of tuning. For FedAvgM, only a few client learning rates work for each server rate. For FedAdam and FedYogi, many pairs work. The adaptivity constant τ\tau mattered little: τ=10−3\tau = 10^{-3} worked almost as well as the alternatives on nearly all tasks.

Limits. The authors tuned hyperparameters by minimising average training loss over the last 100 rounds, because validation data is often unavailable in federated settings, so the numbers are not the usual held-out comparison. Each experiment is a simulation with uniform client sampling in TensorFlow Federated, not a deployment. The theorems assume full participation, and extending them to partial participation adds a term that depends on the sampled fraction. The analysis also assumes bounded gradients, which is a strong assumption for deep networks. And the paper does not claim that adaptivity removes client heterogeneity, only that it works well for the moderate heterogeneity found in these tasks.

Reading guide

  1. Abstract and Section 1, Introduction. The problem (client drift and lack of adaptivity) and the claimed contributions. Read with Federated Learning and Stochastic Gradient Descent in mind.
  2. Section 2, Federated learning and FedAvg. The FedAvg update rewritten as a pseudo-gradient step, and Algorithm 1, the general FedOpt framework. The key idea of the paper is that FedAvg is the special case where clients and server both run SGD and the server learning rate is 1. Prerequisites: Gradient Descent, and Momentum for the server-momentum variant FedAvgM.
  3. Section 3, Adaptive federated optimization. Algorithm 2 and the theorems. Read the algorithm box closely, then the corollaries; skip the constants in Theorems 1 and 2 on a first pass. Prerequisites: AdaGrad, Adam Optimizer, and Learning Rate for the step-size roles.
  4. Section 4, Datasets, models and tasks. The seven tasks and the models: ResNet-18 with group normalisation in place of ResNet's batch normalisation (see Group Normalization), a recurrent network for Shakespeare, Bag of Words logistic regression for tag prediction, and a Recurrent Neural Network language model for next-word prediction.
  5. Section 5, Results. Table 1 carries the headline claims. Figures 2 and 3 give the tuning results, which matter as much as accuracy for practitioners.
  6. Appendix A. The proof strategy. The main difficulty, as the appendix puts it, is that client updates are pseudo-gradients, biased and high-variance, not gradients.

Check yourself

QuestionRecall: which choice of server optimiser and server learning rate makes FedOpt equal to FedAvg?Show answer

Plain stochastic gradient descent on the server, with server learning rate η=1\eta = 1. Applied to the pseudo-gradient −Δt-\Delta_t, one such step adds the averaged client change to the server model, which is exactly the FedAvg update.

QuestionComputation: a server starts at x0=(0,0)x_0 = (0, 0). In the first round the averaged change is Δt=(0.5,−0.2)\Delta_t = (0.5, -0.2). With FedAdagrad, server rate η=0.1\eta = 0.1 and τ\tau negligible, what is x1x_1?Show answer

Here v0=Δt2=(0.25,0.04)v_0 = \Delta_t^2 = (0.25, 0.04), so v0=(0.5,0.2)\sqrt{v_0} = (0.5, 0.2). Coordinate 1 becomes 0+0.1×0.5/0.5=0.10 + 0.1 \times 0.5 / 0.5 = 0.1, and coordinate 2 becomes 0+0.1×(−0.2)/0.2=−0.10 + 0.1 \times (-0.2) / 0.2 = -0.1. So x1=(0.1,−0.1)x_1 = (0.1, -0.1). Each coordinate moved by the same size, although their averaged changes were different.

QuestionWhy: why does the paper say that adaptive server optimisation avoids the extra cost that client-side adaptive methods pay?Show answer

Client-side adaptive methods keep per-parameter accumulators on each device, so those accumulators must be sent and averaged across clients each round, which the paper estimates costs up to twice the communication and client memory per round. In the server-side design the accumulators live only on the server, and each client still sends one model change and receives one model. The server is the only place the adaptive state is kept, so the cost on the devices is unchanged.

QuestionApplied: you deploy federated training on phones, where each round samples a small fraction of devices and no device keeps any state between rounds. Which method from the paper is ruled out, and which is compatible? What would you expect from each?Show answer

SCAFFOLD is ruled out, because its control variates must be stored and updated by each client across rounds, which devices sampled rarely cannot do. FedAdam or FedYogi is compatible, because the adaptive state lives on the server and devices only run ordinary SGD. The paper's experiments suggest FedAdam or FedYogi would beat FedAvg on text tasks and on some image tasks, while SCAFFOLD would perform no better than FedAvg. Verify on your own task, since the paper's numbers come from simulations.

Sources

Read the full paper

Sashank Reddi, Zachary Charles, Manzil Zaheer et al., 2020. arXiv:2003.00295