Search

Search papers and lessons

Federated Optimization in Heterogeneous Networks

Tian Li, Anit Kumar Sahu, Manzil Zaheer et al. · 2018

Li et al. (2018) propose FedProx, which lets devices do uneven amounts of work and adds a penalty that keeps each device's update near the global model, stabilising training on non-identical data.

On this page

  • Colour = topic mix
  • Probability
  • Calculus
  • Discrete math
  • Linear algebra
  • Learning basics
  • Optimization
  • ReadReady to readNot yet

TL;DR

Federated learning trains one model across many devices (phones, sensors, wearables) while the data stays on each device. Real devices differ in two ways: their data is not drawn from the same distribution, and they have different amounts of time and power to spare. FedProx (Li and colleagues, 2018) handles both. It lets each device do however much local work it can finish, and it adds a penalty that keeps each device's update close to the current global model. The penalty is what keeps training stable when the data differs from device to device. The authors also prove convergence guarantees under an explicit assumption about how different the devices are.

Builds on: Federated Learning, L2 Regularization, Proximal Point Method · Leads to: none listed yet

Why it mattered

Before this paper, the standard federated method, FedAvg, had become the default in practice, but it had little theory behind it for non-identical data, and it had a practical habit that wastes work: it throws away slow devices. FedProx showed two things at once. First, a small change to the local objective, a proximal term, makes training more stable on heterogeneous data. Second, keeping the partial work of slow devices, instead of dropping them, helps convergence. The paper's experiments report a 22% average improvement in test accuracy over FedAvg in its most heterogeneous settings (90% stragglers). The authors released their code publicly, and they note that FedProx can be integrated into existing federated systems such as TensorFlow Federated and LEAF.

The problem

Federated training has a central server and many devices. Each device holds its own examples, and the server wants one model that fits all of them. A round of training works like this: the server picks a few devices, sends them the current model, each device trains on its own data, and the server averages what comes back.

Two things go wrong.

Statistical heterogeneity. Each device's data comes from its own distribution. A phone's keyboard data reflects its owner's habits; one device's data may contain only two classes. When each device runs many local steps, its model drifts toward its own data, and the average of drifted models can be worse than any step the server would have taken with all the data. The paper notes that earlier experiments found FedAvg diverging on such data.

Systems heterogeneity. Devices differ in processor speed, memory, network connection and battery. A device that cannot finish its planned local work by the round deadline is a straggler. FedAvg handles a straggler by dropping its update. If many devices are stragglers, most of the work is thrown away, and the devices that are dropped are often the ones with the least powerful hardware, so the data they hold is left out of training.

The paper's key observation is that these two problems interact. Dropping stragglers (FedAvg) and naively keeping their partial work (FedProx with no penalty) both push the global model toward whichever devices are not dropped, which increases statistical heterogeneity. The fix has to handle both at once.

How it works

Here is the procedure in plain steps. The running example uses one number per device, so the arithmetic stays visible.

  1. The server holds a global model w. Suppose it is a single number, w = 0.
  2. The server picks devices. Each round it selects a subset of K devices. The paper uses K = 10 in its experiments.
  3. Each chosen device gets the same starting point. Every device receives w^t = 0.
  4. Each device minimises a local objective with a penalty. Instead of minimising only its own loss F_k, device k minimises F_k(w) plus mu/2 times the squared distance from w^t. The penalty pulls the answer back toward the start. Take a device whose loss is F_k(w) = (w - 4)^2 / 2, which is lowest at w = 4, and set mu = 1. Its penalised objective is lowest at w = 2. The penalty stopped it halfway.
  5. Devices do uneven work. A device does not have to finish the subproblem. It stops after however many local steps fit its budget, and the paper measures how close it got with a number gamma (smaller is more accurate). If a device stops early, its answer is gamma-inexact, and it still goes into the average.
  6. Devices send their results back. Each device returns its local model.
  7. The server averages. It computes w^{t+1} as the plain average of the K returned models.

With the penalty turned off (mu = 0), step 4 reduces to plain local training, and the procedure is FedAvg with the stragglers kept. With mu greater than zero, the local answers move less far from the start, which is the stabilising effect.

A concrete trace with two devices, both starting at w^t = 0 and mu = 1. Device A has local optimum 4 and device B has local optimum -2, so their penalised answers are A: (4 + 1 times 0) / (1 + 1) = 2 and B: (-2 + 1 times 0) / (1 + 1) = -1. The server averages them: (2 + (-1)) / 2 = 0.5. Without the penalty the same two devices would return 4 and -2, and the average would be 1. The penalty pulled the global step back toward the start.

−10123450246810wpenalised loss
  • mu = 0
  • mu = 1
  • mu = 3
Illustrative one-device example with start w^t = 0. The minimiser moves from 4 (no penalty) to 2 (mu = 1) to 1 (mu = 3): a larger mu keeps the local answer closer to the start.
flowchart LR
  S[Server holds w^t] --> P[Select K devices]
  P --> L1[Device 1: approximate min of F_1 + mu/2 ‖w - w^t‖²]
  P --> L2[Device 2: approximate min of F_2 + mu/2 ‖w - w^t‖²]
  P --> LK[Device K: approximate min of F_K + mu/2 ‖w - w^t‖²]
  L1 --> A[Server averages the K returned models]
  L2 --> A
  LK --> A
  A --> S

Worked examples

Example
1. One device, hand-computable
  1. Device loss is F(w) = (w - 4)^2 / 2. Its lowest point is w = 4.
  2. Start at w^t = 0. Choose mu = 0. The subproblem is just F, so the answer is w = 4.
  3. Choose mu = 1. The objective becomes (w - 4)^2 / 2 + w^2 / 2. Its derivative is (w - 4) + w, which is zero at w = 2.
  4. Choose mu = 3. The objective is (w - 4)^2 / 2 + 3 w^2 / 2. Its derivative (w - 4) + 3 w is zero at w = 1.
  5. Interpretation: the answer moves from 4 to 2 to 1 as mu grows. The penalty keeps the local model near the global start; in this case the answer is 4 / (1 + mu).
Example
2. Two devices, averaging
  1. Two devices start at w^t = 0 with mu = 1. Device A has F_A(w) = (w - 4)^2 / 2, so its answer is w_A = 4 / 2 = 2.
  2. Device B has F_B(w) = (w + 2)^2 / 2, whose lowest point is w = -2. Its answer is w_B = -2 / 2 = -1.
  3. Both devices have equal weight p = 1/2, and the server takes a plain average: w^1 = (2 + (-1)) / 2 = 0.5.
  4. Without the penalty (mu = 0), the answers are 4 and -2, and the average is (4 - 2) / 2 = 1.
  5. Interpretation: with mu = 1 the global step is half the size it would be without the penalty. Each device's pull toward its own optimum is weakened, so the round is less dominated by one device's data. This is the stabilising effect the paper describes.
Example
3. The paper's systems-heterogeneity setting

The paper's simulation selects K = 10 devices per round. At the 90% setting, it assigns a random number of epochs between 1 and E to 90% of the selected devices, and the remaining 10% complete all E epochs. Take E = 20.

  1. In a round at the 90% setting, the number of stragglers is 0.9 times 10 = 9.
  2. FedAvg drops those 9 stragglers and averages only the one device that finished. Its global update is the average of one model.
  3. FedProx keeps all 10 returned models, including the 9 partial ones, and averages all of them. The update is the average of 10 models, each of which moved less far from the start because of the penalty.
  4. The paper reports that in this highly heterogeneous setting FedProx improves absolute test accuracy over FedAvg by 22% on average.
  5. Try it: how many of the 10 selected devices contribute to the FedAvg average at the 50% setting, and how many to FedProx? Answer: 5 stragglers are dropped, so FedAvg averages the 5 devices that complete. FedProx averages all 10.

The math

The global goal is to minimise a weighted average of local losses. Each device k has n_k examples out of n in total, and the weights are p_k = n_k / n:

min⁡wf(w)=∑k=1NpkFk(w)=Ek[Fk(w)],∑k=1Npk=1.\min_{w} f(w) = \sum_{k=1}^{N} p_k F_k(w) = \mathbb{E}_k\big[F_k(w)\big], \qquad \sum_{k=1}^{N} p_k = 1.

Here N is the number of devices, and F_k(w) is the average loss of model w on device k's own data. The paper allows each F_k to be non-convex.

The local subproblem (step 4 in symbols)

Device k in round t solves, approximately,

hk(w;wt)=Fk(w)+μ2 ∥w−wt∥2.h_k(w; w^t) = F_k(w) + \frac{\mu}{2}\,\lVert w - w^t \rVert^2 .

The first term is the device's own loss. The second is the proximal term: mu is its strength, and w^t is the global model the device started from. Its gradient is

∇hk(w;wt)=∇Fk(w)+μ (w−wt).\nabla h_k(w; w^t) = \nabla F_k(w) + \mu\,(w - w^t).

For the one-number example, F_k(w) = (w - 4)^2 / 2 has gradient w - 4, so setting (w - 4) + mu (w - 0) = 0 gives w = 4 / (1 + mu). For mu = 1 this is 2, as in the walkthrough.

How much work counts as enough (step 5 in symbols)

Definition 2 in the paper says a point w* is a gamma-inexact solution of the subproblem when

∥∇hk(w∗;wt)∥≤γkt ∥∇hk(wt;wt)∥,\lVert \nabla h_k(w^*; w^t) \rVert \le \gamma_k^t \, \lVert \nabla h_k(w^t; w^t) \rVert,

with gamma in the interval from 0 to 1. Read it as: the gradient at the answer must be at most a fraction gamma of the gradient at the starting point. A smaller gamma is a more accurate answer. Because gamma_k^t may differ between devices and rounds, a device that is slow in one round can still contribute a useful answer.

The aggregation (steps 6 and 7 in symbols)

The server sets

wt+1=1K∑k∈Stwkt+1,w^{t+1} = \frac{1}{K} \sum_{k \in S_t} w_k^{t+1},

where S_t is the set of the K devices chosen in round t. Two-device check: with w_A = 2 and w_B = -1, the average is (2 - 1) / 2 = 0.5, matching the walkthrough.

The convergence condition

The analysis introduces a measure of how different the devices are. Their gradients can be compared through the quantity

B(w)=Ek[∥∇Fk(w)∥2]∥∇f(w)∥2,B(w) = \sqrt{\frac{\mathbb{E}_k\big[\lVert \nabla F_k(w) \rVert^2\big]}{\lVert \nabla f(w) \rVert^2}},

and the paper assumes B(w) stays bounded by some B_epsilon away from stationary points. If all devices hold identical data, B(w) = 1. Theorem 4 then gives a sufficient decrease of the global objective in one round, E[f(w^{t+1})] <= f(w^t) - rho ||grad f(w^t)||^2, where rho is a function of mu, K, gamma, B, the smoothness constant L and the lower bound on the Hessian. Remark 5 of the paper gives the simple conditions under which rho is positive: gamma B < 1 and B / sqrt(K) < 1. That is the trade-off the paper emphasises: more dissimilarity B requires more accurate local solutions or more devices per round.

Corollary 7 covers the convex case with exact local solves. For 1 << B <= 0.5 sqrt(K), choosing mu about 6 L B^2 gives a rate constant rho about 1 / (24 L B^2). The larger the dissimilarity, the larger mu must be, and the smaller the step of progress per round.

Results

The experiments use four real federated datasets and a synthetic family with tunable heterogeneity. Table 1 of the paper lists the real datasets:

DatasetDevicesSamplesSamples per device, meanSamples per device, stdev
MNIST1,00069,03569106
FEMNIST20018,34592159
Shakespeare143517,1063,6166,808
Sent14077240,7835332

The main findings:

  • Systems heterogeneity (Figure 1). With E = 20, forcing 0%, 50% or 90% of the selected devices to be stragglers makes FedAvg converge worse as the straggler share grows. Keeping partial work (FedProx with mu = 0) gives faster and more stable convergence than dropping. Adding the proximal term (mu > 0) further improves convergence, and makes some otherwise divergent runs converge.
  • Test accuracy. In the highly heterogeneous setting (90% stragglers), FedProx improves test accuracy over FedAvg by 22% on average (Figure 7 of the paper).
  • Statistical heterogeneity (Figure 2). On three synthetic datasets with increasing heterogeneity, FedAvg (mu = 0) converges worse as heterogeneity rises, and mu > 0 helps. The paper's dissimilarity measure B (Definition 3) tracks how heterogeneous each dataset is, which is why it is used in the analysis.
  • Tuning mu. The best mu values chosen from 1 for the five federated datasets in Figure 1 are 1, 1, 1, 0.001 and 0.01.

Misconceptions and tradeoffs

It is tempting to think that FedProx is just a regulariser on the server. In fact the penalty acts on each device's local subproblem, because it is the local solver that is pulled back toward the global model. The server still does plain averaging, because w^{t+1} is the mean of the returned models.

It is tempting to think that keeping partial work is always an improvement. In fact the paper shows it helps relative to dropping stragglers, but only up to a point: with mu = 0, too much local work on non-identical data can still diverge. The penalty is what makes the extra work safe.

It is tempting to think that a larger mu is always more stable. In fact a large mu slows progress, because it forces updates to stay near the start. The paper tunes mu from a small candidate set and reports that the best values differ by dataset. It also tests an adaptive rule: raise mu when the loss rises, lower it when the loss falls for several rounds.

When to use it. Use the FedProx idea when devices have uneven compute or hold non-identical data, and when dropping slow devices would waste or bias the training signal. It is cheap to add: it is one extra term and a solver that accepts a starting point.

When not to use it. When all devices are homogeneous and fully available, plain SGD or FedAvg is simpler and the penalty only costs speed. The paper's analysis is for the heterogeneous federated setting and gives no guarantee that the penalty helps when all devices are alike.

Alternatives. Dropping stragglers (FedAvg) is simplest but wastes work. Keeping partial work with no penalty (mu = 0) is the other option, and the paper shows it can diverge on heterogeneous data.

Limits. The theory needs bounded dissimilarity and, for the main theorem, that mu exceed the Hessian lower bound. The experiments sample devices uniformly and weight averages by data size, which the paper says its analysis does not cover. The paper also reports that its own sampling scheme gave more stable performance for both methods, a result observed in its setup rather than proved in general. The method still needs mu to be tuned, and the paper leaves automatic tuning to future work.

Reading guide

  • Section 1, Introduction. The two challenges, statistical and systems heterogeneity, in plain terms. Needs Federated Learning.
  • Section 2, Background. Why federated learning differs from data-centre distributed optimisation, and what earlier methods assumed. Read it with Communication-Efficient Learning of Deep Networks from Decentralized Data alongside.
  • Section 3, Methods. The objective, the local subproblem, the gamma-inexact definition and Algorithms 1 and 2. Needs Proximal Point Method for the penalty idea, and L2 Regularization for the quadratic term.
  • Section 4, Convergence analysis. Local dissimilarity, Theorem 4, Theorem 6, Corollary 7, Corollary 9. Needs Stochastic Gradient Descent for the comparison with SGD, and Convex Function for the convex case.
  • Section 5, Experiments. Figures 1 to 3 and Table 1. Needs Empirical Risk Minimization for the training objectives used in the datasets.
  • Section 6 and the Appendices. The conclusion and the full proofs. Read the proof of Theorem 4 only after the analysis section.

Check yourself

QuestionRecall. What is the proximal term in FedProx, and what does its strength mu control?Show answer

It is mu/2 times the squared distance from the device's local answer to the global model at the start of the round. It is added to the device's loss so that the local solution stays near the global model. A larger mu keeps the answer closer to the start and slows the device's progress.

QuestionComputation. A device has loss `F(w) = (w - 6)^2 / 2`, starts at `w^t = 0`, and uses `mu = 2`. What is its penalised answer?Show answer

The subproblem is (w - 6)^2 / 2 + w^2. Its derivative is (w - 6) + 2 w = 3 w - 6, which is zero at w = 2. Equivalently, w = 6 / (1 + mu) = 6 / 3 = 2.

QuestionWhy. Why does dropping slow devices (FedAvg) push the global model toward the devices that are not dropped?Show answer

Dropped devices contribute nothing to the average, so the global update reflects only the devices that finished. If slow devices hold systematically different data, their data is missing from every round, and the model fits the remaining devices better than the population. The paper's point is that this increases statistical heterogeneity, which is why dropping and naive partial work both hurt convergence.

QuestionApplied. In a round with `K = 10` selected devices at the paper's 50% straggler setting, how many devices does FedAvg average, and how many does FedProx average?Show answer

FedAvg drops the 5 stragglers and averages the 5 devices that finished. FedProx keeps all 10 returned models, including the 5 partial ones, and averages all of them.

Sources

  • Tian Li, Anit Kumar Sahu, Manzil Zaheer, Maziar Sanjabi, Ameet Talwalkar, Virginia Smith. Federated Optimization in Heterogeneous Networks. arXiv:1812.06127 (2018); MLSys 2020. https://arxiv.org/abs/1812.06127
  • H. Brendan McMahan et al. Communication-Efficient Learning of Deep Networks from Decentralized Data. arXiv:1602.05629. https://arxiv.org/abs/1602.05629

Read the full paper

Tian Li, Anit Kumar Sahu, Manzil Zaheer et al., 2018. arXiv:1812.06127