Year: 2020

Abstract:
Federated learning enables a large amount of edge computing devices to jointly learn a model without data sharing. As a leading algorithm in this setting, Federated Averaging (FedAvg) runs Stochastic Gradient Descent (SGD) in parallel on a small subset of the total devices and averages the sequences only once in a while. Despite its simplicity, it lacks theoretical guarantees under realistic settings. In this paper, we analyze the convergence of FedAvg on non-iid data and establish a convergence rate of O( 1 T ) for strongly convex and smooth problems, where T is the number of SGDs. Importantly, our bound demonstrates a trade-off between communicationefficiency and convergence rate. As user devices may be disconnected from the server, we relax the assumption of full device participation to partial device participation and study different averaging schemes; low device participation rate can be achieved without severely slowing down the learning. Our results indicates that heterogeneity of data slows down the convergence, which matches empirical observations. Furthermore, we provide a necessary condition for FedAvg on non-iid data: the learning rate η must decay, even if full-gradient is used; otherwise, the solution will be Ω(η) away from the optimal.

heading: 1 INTRODUCTION
text: Federated Learning (FL), also known as federated optimization, allows multiple parties to collaboratively train a model without data sharing (Konevcnỳ et al., 2015; Shokri and Shmatikov, 2015; McMahan et al., 2017; Konevcnỳ, 2017; Sahu et al., 2018; Zhuo et al., 2019). Similar to the centralized parallel optimization (Jakovetic, 2013; Li et al., 2014a;b; Shamir et al., 2014; Zhang and Lin, 2015; Meng et al., 2016; Reddi et al., 2016; Richtárik and Takác, 2016; Smith et al., 2016; Zheng et al., 2016; Shusen Wang et al., 2018), FL let the user devices (aka worker nodes) perform most of the computation and a central parameter server update the model parameters using the descending directions returned by the user devices. Nevertheless, FL has three unique characters that distinguish it from the standard parallel optimization Li et al. (2019).
∗Equal contribution.
First, the training data are massively distributed over an incredibly large number of devices, and the connection between the central server and a device is slow. A direct consequence is the slow communication, which motivated communication-efficient FL algorithms (McMahan et al., 2017; Smith et al., 2017; Sahu et al., 2018; Sattler et al., 2019). Federated averaging (FedAvg) is the first and perhaps the most widely used FL algorithm. It runs E steps of SGD in parallel on a small sampled subset of devices and then averages the resulting model updates via a central server once in a while.1 In comparison with SGD and its variants, FedAvg performs more local computation and less communication.
Second, unlike the traditional distributed learning systems, the FL system does not have control over users’ devices. For example, when a mobile phone is turned off or WiFi access is unavailable, the central server will lose connection to this device. When this happens during training, such a non-responding/inactive device, which is called a straggler, appears tremendously slower than the other devices. Unfortunately, since it has no control over the devices, the system can do nothing but waiting or ignoring the stragglers. Waiting for all the devices’ response is obviously infeasible; it is thus impractical to require all the devices be active.
Third, the training data are non-iid2, that is, a device’s local data cannot be regarded as samples drawn from the overall distribution. The data available locally fail to represent the overall distribution. This does not only bring challenges to algorithm design but also make theoretical analysis much harder. While FedAvg actually works when the data are non-iid McMahan et al. (2017), FedAvg on non-iid data lacks theoretical guarantee even in convex optimization setting.
There have been much efforts developing convergence guarantees for FL algorithm based on the assumptions that (1) the data are iid and (2) all the devices are active. Khaled et al. (2019); Yu et al. (2019); Wang et al. (2019) made the latter assumption, while Zhou and Cong (2017); Stich (2018); Wang and Joshi (2018); Woodworth et al. (2018) made both assumptions. The two assumptions violates the second and third characters of FL. Previous algorithm Fedprox Sahu et al. (2018) doesn’t require the two mentioned assumptions and incorporates FedAvg as a special case when the added proximal term vanishes. However, their theory fails to cover FedAvg.
Notation. Let N be the total number of user devices and K (≤ N ) be the maximal number of devices that participate in every round’s communication. Let T be the total number of every device’s SGDs, E be the number of local iterations performed in a device between two communications, and thus TE is the number of communications.
Contributions. For strongly convex and smooth problems, we establish a convergence guarantee for FedAvg without making the two impractical assumptions: (1) the data are iid, and (2) all the devices are active. To the best of our knowledge, this work is the first to show the convergence rate of FedAvg without making the two assumptions.
We show in Theorem 1, 2, and 3 that FedAvg has O( 1T ) convergence rate. In particular, Theorem 3 shows that to attain a fixed precision , the number of communications is
T E = O
[ 1 (( 1 + 1
K
) EG2 + ∑N k=1 p 2 kσ 2 k + Γ +G 2
E
)] . (1)
Here, G, Γ, pk, and σk are problem-related constants defined in Section 3.1. The most interesting insight is that E is a knob controlling the convergence rate: neither setting E over-small (E = 1 makes FedAvg equivalent to SGD) nor setting E over-large is good for the convergence.
This work also makes algorithmic contributions. We summarize the existing sampling3 and averaging schemes for FedAvg (which do not have convergence bounds before this work) and propose a new scheme (see Table 1). We point out that a suitable sampling and averaging scheme is crucial for the convergence of FedAvg. To the best of our knowledge, we are the first to theoretically demonstrate
1In original paper (McMahan et al., 2017), E epochs of SGD are performed in parallel. For theoretical analyses, we denote by E the times of updates rather than epochs.
2Throughout this paper, “non-iid” means data are not identically distributed. More precisely, the data distributions in the k-th and l-th devices, denote Dk and Dl, can be different.
3Throughout this paper, “sampling” refers to how the server chooses K user devices and use their outputs for updating the model parameters. “Sampling” does not mean how a device randomly selects training samples.
that FedAvg with certain schemes (see Table 1) can achieve O( 1T ) convergence rate in non-iid federated setting. We show that heterogeneity of training data and partial device participation slow down the convergence. We empirically verify our results through numerical experiments.
Our theoretical analysis requires the decay of learning rate (which is known to hinder the convergence rate.) Unfortunately, we show in Theorem 4 that the decay of learning rate is necessary for FedAvg with E > 1, even if full gradient descent is used.4 If the learning rate is fixed to η throughout, FedAvg would converge to a solution at least Ω(η(E − 1)) away from the optimal. To establish Theorem 4, we construct a specific `2-norm regularized linear regression model which satisfies our strong convexity and smoothness assumptions.
Paper organization. In Section 2, we elaborate on FedAvg. In Section 3, we present our main convergence bounds for FedAvg. In Section 4, we construct a special example to show the necessity of learning rate decay. In Section 5, we discuss and compare with prior work. In Section 6, we conduct empirical study to verify our theories. All the proofs are left to the appendix.
2 FEDERATED AVERAGING (FEDAVG)
Problem formulation. In this work, we consider the following distributed optimization model:
min w
{ F (w) , N∑ k=1 pkFk(w) } , (2)
where N is the number of devices, and pk is the weight of the k-th device such that pk ≥ 0 and∑N k=1 pk = 1. Suppose the k-th device holds the nk training data: xk,1, xk,2, · · · , xk,nk . The local objective Fk(·) is defined by
Fk(w) , 1
nk nk∑ j=1 `(w;xk,j), (3)
where `(·; ·) is a user-specified loss function.
Algorithm description. Here, we describe one around (say the t-th) of the standard FedAvg algorithm. First, the central server broadcasts the latest model, wt, to all the devices. Second, every device (say the k-th) lets wkt = wt and then performs E (≥ 1) local updates:
wkt+i+1 ←− wkt+i − ηt+i∇Fk(wkt+i, ξkt+i), i = 0, 1, · · · , E − 1
where ηt+i is the learning rate (a.k.a. step size) and ξkt+i is a sample uniformly chosen from the local data. Last, the server aggregates the local models, w1t+E , · · · ,wNt+E , to produce the new global model, wt+E . Because of the non-iid and partial device participation issues, the aggregation step can vary.
4It is well know that the full gradient descent (which is equivalent to FedAvg with E = 1 and full batch) do not require the decay of learning rate.
5The sampling scheme is proposed by Sahu et al. (2018) for FedAvg as a baseline, but this convergence rate is our contribution.
6The convergence relies on the assumption that data are balanced, i.e., n1 = n2 = · · · = nN . However, we can use a rescaling trick to get rid of this assumption. We will discuss this point later in Section 3.
IID versus non-iid. Suppose the data in the k-th device are i.i.d. sampled from the distribution Dk. Then the overall distribution is a mixture of all local data distributions: D = ∑N k=1 pkDk. The prior work Zhang et al. (2015a); Zhou and Cong (2017); Stich (2018); Wang and Joshi (2018); Woodworth et al. (2018) assumes the data are iid generated by or partitioned among the N devices, that is, Dk = D for all k ∈ [N ]. However, real-world applications do not typically satisfy the iid assumption. One of our theoretical contributions is avoiding making the iid assumption.
Full device participation. The prior work Coppola (2015); Zhou and Cong (2017); Stich (2018); Yu et al. (2019); Wang and Joshi (2018); Wang et al. (2019) requires the full device participation in the aggregation step of FedAvg. In this case, the aggregation step performs
wt+E ←− N∑ k=1 pkw k t+E .
Unfortunately, the full device participation requirement suffers from serious “straggler’s effect” (which means everyone waits for the slowest) in real-world applications. For example, if there are thousands of users’ devices in the FL system, there are always a small portion of devices offline. Full device participation means the central server must wait for these “stragglers”, which is obviously unrealistic.
Partial device participation. This strategy is much more realistic because it does not require all the devices’ output. We can set a threshold K (1 ≤ K < N ) and let the central server collect the outputs of the first K responded devices. After collecting K outputs, the server stops waiting for the rest; the K + 1-th to N -th devices are regarded stragglers in this iteration. Let St (|St| = K) be the set of the indices of the first K responded devices in the t-th iteration. The aggregation step performs
wt+E ←− N
K ∑ k∈St pkw k t+E .
It can be proved that NK ∑ k∈St pk equals one in expectation.
Communication cost. The FedAvg requires two rounds communications— one broadcast and one aggregation— per E iterations. If T iterations are performed totally, then the number of communications is b 2TE c. During the broadcast, the central server sends wt to all the devices. During the aggregation, all or part of the N devices sends its output, say wkt+E , to the server.
3 CONVERGENCE ANALYSIS OF FEDAVG IN NON-IID SETTING
In this section, we show that FedAvg converges to the global optimum at a rate of O(1/T ) for strongly convex and smooth functions and non-iid data. The main observation is that when the learning rate is sufficiently small, the effect of E steps of local updates is similar to one step update with a larger learning rate. This coupled with appropriate sampling and averaging schemes would make each global update behave like an SGD update. Partial device participation (K < N ) only makes the averaged sequence {wt} have a larger variance, which, however, can be controlled by learning rates. These imply the convergence property of FedAvg should not differ too much from SGD. Next, we will first give the convergence result with full device participation (i.e., K = N ) and then extend this result to partial device participation (i.e., K < N ).

heading: 3.1 NOTATION AND ASSUMPTIONS
text: We make the following assumptions on the functions F1, · · · , FN . Assumption 1 and 2 are standard; typical examples are the `2-norm regularized linear regression, logistic regression, and softmax classifier. Assumption 1. F1, · · · , FN are all L-smooth: for all v and w, Fk(v) ≤ Fk(w) + (v − w)T∇Fk(w) + L2 ‖v −w‖ 2 2. Assumption 2. F1, · · · , FN are all µ-strongly convex: for all v and w, Fk(v) ≥ Fk(w) + (v − w)T∇Fk(w) + µ2 ‖v −w‖ 2 2.
Assumptions 3 and 4 have been made by the works Zhang et al. (2013); Stich (2018); Stich et al. (2018); Yu et al. (2019). Assumption 3. Let ξkt be sampled from the k-th device’s local data uniformly at random. The variance of stochastic gradients in each device is bounded: E
∥∥∇Fk(wkt , ξkt )−∇Fk(wkt )∥∥2 ≤ σ2k for k = 1, · · · , N . Assumption 4. The expected squared norm of stochastic gradients is uniformly bounded, i.e., E ∥∥∇Fk(wkt , ξkt )∥∥2 ≤ G2 for all k = 1, · · · , N and t = 0, · · · , T − 1
Quantifying the degree of non-iid (heterogeneity). Let F ∗ and F ∗k be the minimum values of F and Fk, respectively. We use the term Γ = F ∗ − ∑N k=1 pkF ∗ k for quantifying the degree of non-iid. If the data are iid, then Γ obviously goes to zero as the number of samples grows. If the data are non-iid, then Γ is nonzero, and its magnitude reflects the heterogeneity of the data distribution.

heading: 3.2 CONVERGENCE RESULT: FULL DEVICE PARTICIPATION
text: Here we analyze the case that all the devices participate in the aggregation step; see Section 2 for the algorithm description. Let the FedAvg algorithm terminate after T iterations and return wT as the solution. We always require T is evenly divisible by E so that FedAvg can output wT as expected. Theorem 1. Let Assumptions 1 to 4 hold and L, µ, σk, G be defined therein. Choose κ = Lµ , γ = max{8κ,E} and the learning rate ηt = 2µ(γ+t) . Then FedAvg with full device participation satisfies
E [F (wT )]− F ∗ ≤ 2κ
γ + T
( B
µ + 2L‖w0 −w∗‖2
) , (4)
where
B = N∑ k=1 p2kσ 2 k + 6LΓ + 8(E − 1)2G2. (5)

heading: 3.3 CONVERGENCE RESULT: PARTIAL DEVICE PARTICIPATION
text: As discussed in Section 2, partial device participation has more practical interest than full device participation. Let the set St (⊂ [N ]) index the active devices in the t-th iteration. To establish the convergence bound, we need to make assumptions on St. Assumption 5 assumes the K indices are selected from the distribution pk independently and with replacement. The aggregation step is simply averaging. This is first proposed in (Sahu et al., 2018), but they did not provide theoretical analysis. Assumption 5 (Scheme I). Assume St contains a subset of K indices randomly selected with replacement according to the sampling probabilities p1, · · · , pN . The aggregation step of FedAvg performs wt ←− 1K ∑ k∈St w k t . Theorem 2. Let Assumptions 1 to 4 hold and L, µ, σk, G be defined therein. Let κ, γ, ηt, and B be defined in Theorem 1. Let Assumption 5 hold and define C = 4KE 2G2. Then
E [F (wT )]− F ∗ ≤ 2κ
γ + T
( B + C
µ + 2L‖w0 −w∗‖2
) . (6)
Alternatively, we can select K indices from [N ] uniformly at random without replacement. As a consequence, we need a different aggregation strategy. Assumption 6 assumes the K indices are selected uniformly without replacement and the aggregation step is the same as in Section 2. However, to guarantee convergence, we require an additional assumption of balanced data. Assumption 6 (Scheme II). Assume St contains a subset of K indices uniformly sampled from [N ] without replacement. Assume the data is balanced in the sense that p1 = · · · = pN = 1N . The aggregation step of FedAvg performs wt ←− NK ∑ k∈St pkw k t . Theorem 3. Replace Assumption 5 by Assumption 6 and C by C = N−KN−1 4 KE
2G2. Then the same bound in Theorem 2 holds.
Scheme II requires p1 = · · · = pN = 1N which obviously violates the unbalance nature of FL. Fortunately, this can be addressed by the following transformation. Let F̃k(w) = pkNFk(w) be a scaled local objective Fk. Then the global objective becomes a simple average of all scaled local objectives:
F (w) = N∑ k=1 pkFk(w) = 1 N N∑ k=1 F̃k(w).
Theorem 3 still holds if L, µ, σk, G are replaced by L̃ , νL, µ̃ , ςµ, σ̃k = √ νσ, and G̃ = √ νG, respectively. Here, ν = N ·maxk pk and ς = N ·mink pk.

heading: 3.4 DISCUSSIONS
text: Choice of E. Since ‖w0−w∗‖2 ≤ 4µ2G 2 for µ-strongly convex F , the dominating term in eqn. (6) is
O
(∑N k=1 p 2 kσ 2 k + LΓ + ( 1 + 1K ) E2G2 + κG2
µT
) . (7)
Let T denote the number of required steps for FedAvg to achieve an accuracy. It follows from eqn. (7) that the number of required communication rounds is roughly
T E ∝ ( 1 + 1 K ) EG2 + ∑N k=1 p 2 kσ 2 k + LΓ + κG 2 E . (8)
Thus, T E is a function of E that first decreases and then increases, which implies that over-small or over-large E may lead to high communication cost and that the optimal E exists. Stich (2018) showed that if the data are iid, then E can be set to O( √ T ). However, this setting does not work if the data are non-iid. Theorem 1 implies that E must not exceed Ω( √ T ); otherwise, convergence is not guaranteed. Here we give an intuitive explanation. If E is set big, then wkt can converge to the minimizer of Fk, and thus FedAvg becomes the one-shot average Zhang et al. (2013) of the local solutions. If the data are non-iid, the one-shot averaging does not work because weighted average of the minimizers of F1, · · · , FN can be very different from the minimizer of F .
Choice of K. Stich (2018) showed that if the data are iid, the convergence rate improves substantially asK increases. However, under the non-iid setting, the convergence rate has a weak dependence on K, as we show in Theorems 2 and 3. This implies FedAvg is unable to achieve linear speedup. We have empirically observed this phenomenon (see Section 6). Thus, in practice, the participation ratio KN can be set small to alleviate the straggler’s effect without affecting the convergence rate.
Choice of sampling schemes. We considered two sampling and averaging schemes in Theorems 2 and 3. Scheme I selects K devices according to the probabilities p1, · · · , pN with replacement. The non-uniform sampling results in faster convergence than uniform sampling, especially when p1, · · · , pN are highly non-uniform. If the system can choose to activate any of the N devices at any time, then Scheme I should be used.
However, oftentimes the system has no control over the sampling; instead, the server simply uses the first K returned results for the update. In this case, we can assume the K devices are uniformly sampled from all the N devices and use Theorem 3 to guarantee the convergence. If p1, · · · , pN are highly non-uniform, then ν = N ·maxk pk is big and ς = N ·mink pk is small, which makes the convergence of FedAvg slow. This point of view is empirically verified in our experiments.

heading: 4 NECESSITY OF LEARNING RATE DECAY
text: In this section, we point out that diminishing learning rates are crucial for the convergence of FedAvg in the non-iid setting. Specifically, we establish the following theorem by constructing a ridge regression model (which is strongly convex and smooth).
Theorem 4. We artificially construct a strongly convex and smooth distributed optimization problem. With full batch size, E > 1, and any fixed step size, FedAvg will converge to sub-optimal points. Specifically, let w̃∗ be the solution produced by FedAvg with a small enough and constant η, and w∗ the optimal solution. Then we have
‖w̃∗ −w∗‖2 = Ω((E − 1)η) · ‖w∗‖2.
where we hide some problem dependent constants.
Theorem 4 and its proof provide several implications. First, the decay of learning rate is necessary of FedAvg. On the one hand, Theorem 1 shows with E > 1 and a decaying learning rate, FedAvg converges to the optimum. On the other hand, Theorem 4 shows that with E > 1 and any fixed learning rate, FedAvg does not converges to the optimum.
Second, FedAvg behaves very differently from gradient descent. Note that FedAvg with E = 1 and full batch size is exactly the Full Gradient Descent; with a proper and fixed learning rate, its global convergence to the optimum is guaranteed Nesterov (2013). However, Theorem 4 shows that FedAvg with E > 1 and full batch size cannot possibly converge to the optimum. This conclusion doesn’t contradict with Theorem 1 in Khaled et al. (2019), which, when translated into our case, asserts that w̃∗ will locate in the neighborhood of w∗ with a constant learning rate.
Third, Theorem 4 shows the requirement of learning rate decay is not an artifact of our analysis; instead, it is inherently required by FedAvg. An explanation is that constant learning rates, combined with E steps of possibly-biased local updates, form a sub-optimal update scheme, but a diminishing learning rate can gradually eliminate such bias.
The efficiency of FedAvg principally results from the fact that it performs several update steps on a local model before communicating with other workers, which saves communication. Diminishing step sizes often hinders fast convergence, which may counteract the benefit of performing multiple local updates. Theorem 4 motivates more efficient alternatives to FedAvg.

heading: 5 RELATED WORK
text: Federated learning (FL) was first proposed by McMahan et al. (2017) for collaboratively learning a model without collecting users’ data. The research work on FL is focused on the communicationefficiency Konevcnỳ et al. (2016); McMahan et al. (2017); Sahu et al. (2018); Smith et al. (2017) and data privacy Bagdasaryan et al. (2018); Bonawitz et al. (2017); Geyer et al. (2017); Hitaj et al. (2017); Melis et al. (2019). This work is focused on the communication-efficiency issue.
FedAvg, a synchronous distributed optimization algorithm, was proposed by McMahan et al. (2017) as an effective heuristic. Sattler et al. (2019); Zhao et al. (2018) studied the non-iid setting, however, they do not have convergence rate. A contemporaneous and independent work Xie et al. (2019) analyzed asynchronous FedAvg; while they did not require iid data, their bound do not guarantee convergence to saddle point or local minimum. Sahu et al. (2018) proposed a federated optimization framework called FedProx to deal with statistical heterogeneity and provided the convergence guarantees in non-iid setting. FedProx adds a proximal term to each local objective. When these proximal terms vanish, FedProx is reduced to FedAvg. However, their convergence theory requires the proximal terms always exist and hence fails to cover FedAvg.
When data are iid distributed and all devices are active, FedAvg is referred to as LocalSGD. Due to the two assumptions, theoretical analysis of LocalSGD is easier than FedAvg. Stich (2018) demonstrated LocalSGD provably achieves the same linear speedup with strictly less communication for strongly-convex stochastic optimization. Coppola (2015); Zhou and Cong (2017); Wang and Joshi (2018) studied LocalSGD in the non-convex setting and established convergence results. Yu et al. (2019); Wang et al. (2019) recently analyzed LocalSGD for non-convex functions in heterogeneous settings. In particular, Yu et al. (2019) demonstrated LocalSGD also achieves O(1/ √ NT ) convergence (i.e., linear speedup) for non-convex optimization. Lin et al. (2018) empirically shows variants of LocalSGD increase training efficiency and improve the generalization performance of large batch sizes while reducing communication. For LocalGD on non-iid data (as opposed to LocalSGD), the best result is by the contemporaneous work (but slightly later than our first version) (Khaled et al., 2019). Khaled et al. (2019) used fixed learning rate η and showed O( 1T )
convergence to a point O(η2E2) away from the optimal. In fact, the suboptimality is due to their fixed learning rate. As we show in Theorem 4, using a fixed learning rate η throughout, the solution by LocalGD is at least Ω((E − 1)η) away from the optimal. If the data are iid, distributed optimization can be efficiently solved by the second-order algorithms Mahajan et al. (2018); Reddi et al. (2016); Shamir et al. (2014); Shusen Wang et al. (2018); Zhang and Lin (2015) and the one-shot methods Lee et al. (2017); Lin et al. (2017); Wang (2019); Zhang et al. (2013; 2015b). The primal-dual algorithms Hong et al. (2018); Smith et al. (2016; 2017) are more generally applicable and more relevant to FL.

heading: 6 NUMERICAL EXPERIMENTS
text: Models and datasets We examine our theoretical results on a logistic regression with weight decay λ = 1e− 4. This is a stochastic convex optimization problem. We distribute MNIST dataset (LeCun et al., 1998) among N = 100 workers in a non-iid fashion such that each device contains samples of only two digits. We further obtain two datasets: mnist balanced and mnist unbalanced. The former is balanced such that the number of samples in each device is the same, while the latter is highly unbalanced with the number of samples among devices following a power law. To manipulate heterogeneity more precisly, we synthesize unbalanced datasets following the setup in Sahu et al. (2018) and denote it as synthetic(α, β) where α controls how much local models differ from each other and β controls how much the local data at each device differs from that of other devices. We obtain two datasets: synthetic(0,0) and synthetic(1,1). Details can be found in Appendix D.
Experiment settings For all experiments, we initialize all runnings with w0 = 0. In each round, all selected devices run E steps of SGD in parallel. We decay the learning rate at the end of each round by the following scheme ηt = η01+t , where η0 is chosen from the set {1, 0.1, 0.01}. We evaluate the averaged model after each global synchronization on the corresponding global objective. For fair comparison, we control all randomness in experiments so that the set of activated devices is the same across all different algorithms on one configuration.
Impact of E We expect that T /E, the required communication round to achieve curtain accuracy, is a hyperbolic finction ofE as equ (8) indicates. Intuitively, a smallE means a heavy communication burden, while a largeE means a low convergence rate. One needs to trade off between communication efficiency and fast convergence. We empirically observe this phenomenon on unbalanced datasets in Figure 1a. The reason why the phenomenon does not appear in mnist balanced dataset requires future investigations.
Impact of K Our theory suggests that a larger K may slightly accelerate convergence since T /E contains a term O ( EG2
K
) . Figure 1b shows that K has limited influence on the convergence of
FedAvg in synthetic(0,0) dataset. It reveals that the curve of a large enough K is slightly better. We observe similar phenomenon among the other three datasets and attach additional results in Appendix D. This justifies that when the variance resulting sampling is not too large (i.e., B C), one can use a small number of devices without severely harming the training process, which also removes the need to sample as many devices as possible in convex federated optimization.
Effect of sampling and averaging schemes. We compare four schemes among four federated datasets. Since the original scheme involves a history term and may be conservative, we carefully set the initial learning rate for it. Figure 1c indicates that when data are balanced, Schemes I and II achieve nearly the same performance, both better than the original scheme. Figure 1d shows that when the data are unbalanced, i.e., pk’s are uneven, Scheme I performs the best. Scheme II suffers from some instability in this case. This is not contradictory with our theory since we don’t guarantee the convergence of Scheme II when data is unbalanced. As expected, transformed Scheme II performs stably at the price of a lower convergence rate. Compared to Scheme I, the original scheme converges at a slower speed even if its learning rate is fine tuned. All the results show the crucial position of appropriate sampling and averaging schemes for FedAvg.

heading: 7 CONCLUSION
text: Federated learning becomes increasingly popular in machine learning and optimization communities. In this paper we have studied the convergence of FedAvg, a heuristic algorithm suitable for federated setting. We have investigated the influence of sampling and averaging schemes. We have provided theoretical guarantees for two schemes and empirically demonstrated their performances. Our work sheds light on theoretical understanding of FedAvg and provides insights for algorithm design in realistic applications. Though our analyses are constrained in convex problems, we hope our insights and proof techniques can inspire future work.

heading: ACKNOWLEDGEMENTS
text: Li, Yang and Zhang have been supported by the National Natural Science Foundation of China (No. 11771002 and 61572017), Beijing Natural Science Foundation (Z190001), the Key Project of MOST of China (No. 2018AAA0101000), and Beijing Academy of Artificial Intelligence (BAAI).

heading: A PROOF OF THEOREM 1
text: We analyze FedAvg in the setting of full device participation in this section.

heading: A.1 ADDITIONAL NOTATION
text: Let wkt be the model parameter maintained in the k-th device at the t-th step. Let IE be the set of global synchronization steps, i.e., IE = {nE | n = 1, 2, · · · }. If t + 1 ∈ IE , i.e., the time step to communication, FedAvg activates all devices. Then the update of FedAvg with partial devices active can be described as
vkt+1 = w k t − ηt∇Fk(wkt , ξkt ), (9)
wkt+1 = { vkt+1 if t+ 1 /∈ IE ,∑N k=1 pkv k t+1 if t+ 1 ∈ IE .
(10)
Here, an additional variable vkt+1 is introduced to represent the immediate result of one step SGD update from wkt . We interpret w k t+1 as the parameter obtained after communication steps (if possible).
In our analysis, we define two virtual sequences vt = ∑N k=1 pkv k t and wt = ∑N k=1 pkw k t . This is motivated by (Stich, 2018). vt+1 results from an single step of SGD from wt. When t + 1 /∈ IE , both are inaccessible. When t + 1 ∈ IE , we can only fetch wt+1. For convenience, we define gt = ∑N k=1 pk∇Fk(wkt ) and gt = ∑N k=1 pk∇Fk(wkt , ξkt ). Therefore, vt+1 = wt − ηtgt and Egt = gt.

heading: A.2 KEY LEMMAS
text: To convey our proof clearly, it would be necessary to prove certain useful lemmas. We defer the proof of these lemmas to latter section and focus on proving the main theorem.
Lemma 1 (Results of one step SGD). Assume Assumption 1 and 2. If ηt ≤ 14L , we have
E ‖vt+1 −w?‖2 ≤ (1− ηtµ)E ‖wt −w?‖2 + η2tE ‖gt − gt‖ 2 + 6Lη2tΓ + 2E N∑ k=1 pk ∥∥wt −wtk∥∥2
where Γ = F ∗ − ∑N k=1 pkF ? k ≥ 0.
Lemma 2 (Bounding the variance). Assume Assumption 3 holds. It follows that
E ‖gt − gt‖ 2 ≤ N∑ k=1 p2kσ 2 k.
Lemma 3 (Bounding the divergence of {wkt }). Assume Assumption 4, that ηt is non-increasing and ηt ≤ 2ηt+E for all t ≥ 0. It follows that
E [ N∑ k=1 pk ∥∥wt −wtk∥∥2 ] ≤ 4η2t (E − 1)2G2.

heading: A.3 COMPLETING THE PROOF OF THEOREM 1
text: Proof. It is clear that no matter whether t+ 1 ∈ IE or t+ 1 /∈ IE , we always have wt+1 = vt+1. Let ∆t = E ‖wt+1 −w?‖2. From Lemma 1, Lemma 2 and Lemma 3, it follows that
∆t+1 ≤ (1− ηtµ)∆t + η2tB (11) where
B = N∑ k=1 p2kσ 2 k + 6LΓ + 8(E − 1)2G2.
For a diminishing stepsize, ηt = βt+γ for some β > 1 µ and γ > 0 such that η1 ≤ min{ 1 µ , 1 4L} = 1 4L and ηt ≤ 2ηt+E . We will prove ∆t ≤ vγ+t where v = max { β2B βµ−1 , (γ + 1)∆1 } .
We prove it by induction. Firstly, the definition of v ensures that it holds for t = 1. Assume the conclusion holds for some t, it follows that
∆t+1 ≤ (1− ηtµ)∆t + η2tB
= ( 1− βµ
t+ γ
) v
t+ γ +
β2B
(t+ γ)2
= t+ γ − 1 (t+ γ)2 v +
[ β2B
(t+ γ)2 − βµ− 1 (t+ γ)2 v ] ≤ v t+ γ + 1 .
Then by the strong convexity of F (·),
E[F (wt)]− F ∗ ≤ L
2 ∆t ≤
L
2
v
γ + t .
Specifically, if we choose β = 2µ , γ = max{8 L µ − 1, E} and denote κ = L µ , then ηt = 2 µ 1 γ+t and
E[F (wt)]− F ∗ ≤ 2κ
γ + t
( B
µ + 2L∆1
) .

heading: A.4 DEFERRED PROOFS OF KEY LEMMAS
text: Proof of Lemma 1. Notice that vt+1 = wt − ηtgt, then
‖vt+1 −w?‖2 = ‖wt − ηtgt −w? − ηtgt + ηtgt‖ 2
= ‖wt −w? − ηtgt‖ 2︸ ︷︷ ︸
A1
+ 2ηt 〈wt −w? − ηtgt,gt − gt〉︸ ︷︷ ︸ A2 +η2t ‖gt − gt‖ 2 (12)
Note that EA2 = 0. We next focus on bounding A1. Again we split A1 into three terms:
‖wt −w? − ηtgt‖ 2 = ‖wt −w?‖2−2ηt 〈wt −w?,gt〉︸ ︷︷ ︸ B1 + η2t ‖gt‖ 2︸ ︷︷ ︸ B2
(13)
From the the L-smoothness of Fk(·), it follows that∥∥∇Fk (wkt )∥∥2 ≤ 2L (Fk (wkt )− F ?k ) . (14) By the convexity of ‖·‖2 and eqn. (14), we have
B2 = η 2 t ‖gt‖ 2 ≤ η2t N∑ k=1 pk ∥∥∇Fk (wkt )∥∥2 ≤ 2Lη2t N∑ k=1 pk ( Fk(w k t )− F ∗k ) .
Note that
B1 = −2ηt 〈wt −w?,gt〉 = −2ηt N∑ k=1 pk 〈 wt −w?,∇Fk(wkt ) 〉 = −2ηt
N∑ k=1 pk 〈 wt −wkt ,∇Fk(wkt ) 〉 − 2ηt N∑ k=1 pk 〈 wkt −w?,∇Fk(wkt ) 〉 . (15)
By Cauchy-Schwarz inequality and AM-GM inequality, we have
− 2 〈 wt −wkt ,∇Fk ( wkt )〉 ≤ 1 ηt ∥∥wt −wkt ∥∥2 + ηt ∥∥∇Fk (wkt )∥∥2 . (16) By the µ-strong convexity of Fk(·), we have
− 〈 wkt −w?,∇Fk ( wkt )〉 ≤ − ( Fk ( wkt ) − Fk(w∗) ) − µ
2 ∥∥wkt −w?∥∥2 . (17) By combining eqn. (13), eqn. (15), eqn. (16) and eqn. (17), it follows that
A1 = ‖wt −w? − ηtgt‖ 2 ≤ ‖wt −w?‖2 + 2Lη2t N∑ k=1 pk ( Fk(w k t )− F ∗k ) + ηt
N∑ k=1 pk ( 1 ηt ∥∥wt −wtk∥∥2 + ηt ∥∥∇Fk (wkt )∥∥2)
− 2ηt N∑ k=1 pk ( Fk ( wkt ) − Fk(w∗) + µ 2 ∥∥wkt −w?∥∥2) = (1− µηt) ‖wt −w?‖2 +
N∑ k=1 pk ∥∥wt −wtk∥∥2
+ 4Lη2t N∑ k=1 pk ( Fk(w k t )− F ∗k ) − 2ηt N∑ k=1 pk ( Fk ( wkt ) − Fk(w∗) ) ︸ ︷︷ ︸
C
where we use eqn. (14) again.
We next aim to bound C. We define γt = 2ηt(1− 2Lηt). Since ηt ≤ 14L , ηt ≤ γt ≤ 2ηt. Then we split C into two terms:
C = −2ηt(1− 2Lηt) N∑ k=1 pk ( Fk(w k t )− F ∗k ) + 2ηt N∑ k=1 pk (Fk(w ∗)− F ∗k )
= −γt N∑ k=1 pk ( Fk(w k t )− F ∗ ) + (2ηt − γt) N∑ k=1 pk (F ∗ − F ∗k )
= −γt N∑ k=1 pk ( Fk(w k t )− F ∗ ) ︸ ︷︷ ︸
D
+4Lη2tΓ
where in the last equation, we use the notation Γ = ∑N k=1 pk (F ∗ − F ∗k ) = F ∗ − ∑N k=1 pkF ∗ k .
To bound D, we have N∑ k=1 pk ( Fk(w k t )− F ∗ ) = N∑ k=1 pk ( Fk(w k t )− Fk(wt) ) + N∑ k=1 pk (Fk(wt)− F ∗)
≥ N∑ k=1 pk 〈 ∇Fk(wt),wkt −wt 〉 + (F (wt)− F ∗)
≥ −1 2 N∑ k=1 pk [ ηt ‖∇Fk(wt)‖2 + 1 ηt ∥∥wkt −wt∥∥2]+ (F (wt)− F ∗) ≥ −
N∑ k=1 pk [ ηtL (Fk(wt)− F ∗k ) + 1 2ηt ∥∥wkt −wt∥∥2]+ (F (wt)− F ∗) where the first inequality results from the convexity of Fk(·), the second inequality from AM-GM inequality and the third inequality from eqn. (14).
Therefore
C = γt N∑ k=1 pk [ ηtL (Fk(wt)− F ∗k ) + 1 2ηt ∥∥wkt −wt∥∥2]− γt (F (wt)− F ∗) + 4Lη2tΓ = γt(ηtL− 1)
N∑ k=1 pk (Fk(wt)− F ∗) + ( 4Lη2t + γtηtL ) Γ + γt 2ηt N∑ k=1 pk ∥∥wkt −wt∥∥2
≤ 6Lη2tΓ + N∑ k=1 pk ∥∥wkt −wt∥∥2
where in the last inequality, we use the following facts: (1) ηtL − 1 ≤ − 34 ≤ 0 and∑N k=1 pk (Fk(wt)− F ∗) = F (wt) − F ∗ ≥ 0 (2) Γ ≥ 0 and 4Lη2t + γtηtL ≤ 6η2tL and (3)
γt 2ηt ≤ 1.
Recalling the expression of A1 and plugging C into it, we have
A1 = ‖wt −w? − ηtgt‖ 2
≤ (1− µηt) ‖wt −w?‖2 + 2 N∑ k=1 pk ∥∥wt −wtk∥∥2 + 6η2tLΓ (18)
Using eqn. (18) and taking expectation on both sides of eqn. (12), we erase the randomness from stochastic gradients, we complete the proof.
Proof of Lemma 2. From Assumption 3, the variance of the stochastic gradients in device k is bounded by σ2k, then
E ‖gt − gt‖ 2 = E ∥∥∥∥∥ N∑ k=1 pk(∇Fk(wkt , ξkt )−∇Fk(wkt )) ∥∥∥∥∥ 2 ,
= N∑ k=1 p2kE ∥∥∇Fk(wkt , ξkt )−∇Fk(wkt )∥∥2 ,
≤ N∑ k=1 p2kσ 2 k.
Proof of Lemma 3. Since FedAvg requires a communication each E steps. Therefore, for any t ≥ 0, there exists a t0 ≤ t, such that t− t0 ≤ E − 1 and wkt0 = wt0 for all k = 1, 2, · · · , N . Also, we use
the fact that ηt is non-increasing and ηt0 ≤ 2ηt for all t− t0 ≤ E − 1, then
E N∑ k=1 pk ∥∥wt −wkt ∥∥2 = E N∑ k=1 pk ∥∥(wkt −wt0)− (wt −wt0)∥∥2
≤ E N∑ k=1 pk ∥∥wkt −wt0∥∥2
≤ N∑ k=1 pkE t−1∑ t=t0 (E − 1)η2t ∥∥∇Fk(wkt , ξkt )∥∥2
≤ N∑ k=1 pk t−1∑ t=t0 (E − 1)η2t0G 2
≤ N∑ k=1 pkη 2 t0(E − 1) 2G2
≤ 4η2t (E − 1)2G2.

heading: B PROOFS OF THEOREMS 2 AND 3
text: We analyze FedAvg in the setting of partial device participation in this section.

heading: B.1 ADDITIONAL NOTATION
text: Recall that wkt is the model parameter maintained in the k-th device at the t-th step. IE = {nE | n = 1, 2, · · · } is the set of global synchronization steps. Unlike the setting in Appendix A, when it is the time to communicate, i.e., t+ 1 ∈ IE , the scenario considered here is that FedAvg randomly activates a subset of devices according to some sampling schemes. Again, gt = ∑N k=1 pk∇Fk(wkt )
and gt = ∑N k=1 pkFk(w k t , ξ k t ). Therefore, vt+1 = wt − ηtgt and Egt = gt.
Multiset selected. All sampling schemes can be divided into two groups, one with replacement and the other without replacement. For those with replacement, it is possible for a device to be activated several times in a round of communication, even though each activation is independent with the rest. We denote byHt the multiset selected which allows any element to appear more than once. Note that Ht is only well defined for t ∈ IE . For convenience, we denote by St = HN(t,E) the most recent set of chosen devices where N(t, E) = max{n|n ≤ t, n ∈ IE}.
Updating scheme. Limited to realistic scenarios (for communication efficiency and low straggler effect), FedAvg first samples a random multiset St of devices and then only perform updates on them. This make the analysis a little bit intricate, since St varies each E steps. However, we can use a thought trick to circumvent this difficulty. We assume that FedAvg always activates all devices at the beginning of each round and then uses the parameters maintained in only a few sampled devices to produce the next-round parameter. It is clear that this updating scheme is equivalent to the original. Then the update of FedAvg with partial devices active can be described as: for all k ∈ [N ],
vkt+1 = w k t − ηt∇Fk(wkt , ξkt ), (19)
wkt+1 = { vkt+1 if t+ 1 /∈ IE , samples St+1 and average {vkt+1}k∈St+1 if t+ 1 ∈ IE .
(20)
Sources of randomness. In our analysis, there are two sources of randomness. One results from the stochastic gradients and the other is from the random sampling of devices. All the analysis in Appendix A only involve the former. To distinguish them, we use the notation ESt(·), when we take expectation to erase the latter type of randomness.

heading: B.2 KEY LEMMAS
text: Two schemes. For full device participation, we always have wt+1 = vt+1. This is true when t+ 1 /∈ IE for partial device participation. When t+1 ∈ IE , we hope this relation establish in the sense of expectation. To that end, we require the sampling and averaging scheme to be unbiased in the sense that
ESt+1wt+1 = vt+1.
We find two sampling and averaging schemes satisfying the requirement and provide convergence guarantees.
(I) The server establishes St+1 by i.i.d. with replacement sampling an index k ∈ {1, · · · , N} with probabilities p1, · · · , pN for K times. Hence St+1 is a multiset which allows a element to occur more than once. Then the server averages the parameters by wkt+1 = 1 K ∑ k∈St+1 v k t+1.
This is first proposed in (Sahu et al., 2018) but lacks theoretical analysis.
(II) The server samples St+1 uniformly in a without replacement fashion. Hence each element in St+1 only occurs once.Then server averages the parameters by wkt+1 = ∑ k∈St+1 pk N Kv k t+1.
Note that when the pk’s are not all the same, one cannot ensure ∑ k∈St+1 pk N K = 1.
Unbiasedness and bounded variance. Lemma 4 shows the mentioned two sampling and averaging schemes are unbiased. In expectation, the next-round parameter (i.e., wt+1) is equal to the weighted average of parameters in all devices after SGD updates (i.e., vt+1). However, the original scheme in (McMahan et al., 2017) (see Table 1) does not enjoy this property. But it is very similar to Scheme II except the averaging scheme. Hence our analysis cannot cover the original scheme.
Lemma 5 shows the expected difference between vt+1 and wt+1 is bounded. ESt ‖vt+1 −wt+1‖ 2 is actually the variance of wt+1.
Lemma 4 (Unbiased sampling scheme). If t+ 1 ∈ IE , for Scheme I and Scheme II, we have
ESt(wt+1) = vt+1.
Lemma 5 (Bounding the variance of wt). For t + 1 ∈ I, assume that ηt is non-increasing and ηt ≤ 2ηt+E for all t ≥ 0. We have the following results.
(1) For Scheme I, the expected difference between vt+1 and wt+1 is bounded by
ESt ‖vt+1 −wt+1‖ 2 ≤ 4
K η2tE 2G2.
(2) For Scheme II, assuming p1 = p2 = · · · = pN = 1N , the expected difference between vt+1 and wt+1 is bounded by
ESt ‖vt+1 −wt+1‖ 2 ≤ N −K N − 1 4 K η2tE 2G2.

heading: B.3 COMPLETING THE PROOF OF THEOREM 2 AND 3
text: Proof. Note that
‖wt+1 −w∗‖2 = ‖wt+1 − vt+1 + vt+1 −w∗‖2
= ‖wt+1 − vt+1‖2︸ ︷︷ ︸ A1 + ‖vt+1 −w∗‖2︸ ︷︷ ︸ A2 + 2〈wt+1 − vt+1,vt+1 −w∗〉︸ ︷︷ ︸ A3 .
When expectation is taken over St+1, the last term (A3) vanishes due to the unbiasedness of wt+1. If t+ 1 /∈ IE , A1 vanishes since wt+1 = vt+1. We use Lemma 5 to bound A2. Then it follows that
E ‖wt+1 −w∗‖2 ≤ (1− ηtµ)E ‖wt −w?‖2 + η2tB.
If t+ 1 ∈ IE , we additionally use Lemma 5 to bound A1. Then
E ‖wt+1 −w∗‖2 = E ‖wt+1 − vt+1‖2 + E ‖vt+1 −w∗‖2
≤ (1− ηtµ)E ‖wt −w?‖2 + η2t (B + C), (21)
where C is the upper bound of 1 η2t ESt ‖vt+1 −wt+1‖ 2 (C is defined in Theorem 2 and 3).
The only difference between eqn. (21) and eqn. (11) is the additional C. Thus we can use the same argument there to prove the theorems here. Specifically, for a diminishing stepsize, ηt = βt+γ for some β > 1µ and γ > 0 such that η1 ≤ min{ 1 µ , 1 4L} = 1 4L and ηt ≤ 2ηt+E , we can prove
E ‖wt+1 −w∗‖2 ≤ vγ+t where v = max { β2(B+C) βµ−1 , (γ + 1)‖w1 −w ∗‖2 } .
Then by the strong convexity of F (·),
E[F (wt)]− F ∗ ≤ L
2 ∆t ≤
L
2
v
γ + t .
Specifically, if we choose β = 2µ , γ = max{8 L µ − 1, E} and denote κ = L µ , then ηt = 2 µ 1 γ+t and
E[F (wt)]− F ∗ ≤ 2κ
γ + t
( B + C
µ + 2L‖w1 −w∗‖2
) .

heading: B.4 DEFERRED PROOFS OF KEY LEMMAS
text: Proof of Lemma 4. We first give a key observation which is useful to prove the followings. Let {xi}Ni=1 denote any fixed deterministic sequence. We sample a multiset St (with size K) by the procedure where for each sampling time, we sample xk with probability qk for each time. Pay attention that two samples are not necessarily independent. We only require each sampling distribution is identically. Let St = {i1, · · · , iK} ⊂ [N ] (some ik’s may have the same value). Then
ESt ∑ k∈St xk = ESt K∑ k=1 xik = KEStxi1 = K N∑ k=1 qkxk.
For Scheme I, qk = pk and for Scheme II, qk = 1N . It is easy to prove this lemma when equipped with this observation.
Proof of Lemma 5. We separately prove the bounded variance for two schemes. Let St+1 = {i1, · · · , iK} denote the multiset of chosen indexes.
(1) For Scheme I, wt+1 = 1K ∑K l=1 v il t+1. Taking expectation over St+1, we have
ESt ‖wt+1 − vt+1‖ 2 = ESt 1
K2 K∑ l=1 ∥∥vilt+1 − vt+1∥∥2 = 1K N∑ k=1 pk ∥∥vkt+1 − vt+1∥∥2 (22)
where the first equality follows from vilt+1 are independent and unbiased.
To bound eqn. (22), we use the same argument in Lemma 5. Since t + 1 ∈ IE , we know that the time t0 = t− E + 1 ∈ IE is the communication time, which implies {wkt0} N k=1 is identical. Then
N∑ k=1 pk ∥∥vkt+1 − vt+1∥∥2 = N∑ k=1 pk ∥∥(vkt+1 −wt0)− (vt+1 −wt0)∥∥2
≤ N∑ k=1 pk ∥∥vkt+1 −wt0∥∥2
where the last inequality results from ∑N k=1 pk(v k t+1 −wt0) = vt+1 −wt0 and E‖x − Ex‖2 ≤ E‖x‖2. Similarly, we have
ESt ‖wt+1 − vt+1‖ 2 ≤ 1
K N∑ k=1 pkE ∥∥vkt+1 −wt0∥∥2
≤ 1 K N∑ k=1 pkE ∥∥vkt+1 −wkt0∥∥2
≤ 1 K N∑ k=1 pkE t∑ i=t0 E ∥∥ηi∇Fk(wki , ξki )∥∥2
≤ 1 K E2η2t0G 2 ≤ 4 K η2tE 2G2
where in the last inequality we use the fact that ηt is non-increasing and ηt0 ≤ 2ηt.
(2) For Scheme II, when assuming p1 = p2 = · · · = pN = 1N , we again have wt+1 = 1 K ∑K l=1 v il t+1.
ESt ‖wt+1 − vt+1‖ 2 = ESt ∥∥∥∥∥∥ 1K ∑ i∈St+1 vit+1 − vt+1 ∥∥∥∥∥∥ 2 = 1 K2 ESt ∥∥∥∥∥ N∑ i=1 I {i ∈ St} (vit+1 − vt+1) ∥∥∥∥∥ 2
= 1
K2 ∑ i∈[N ] P (i ∈ St+1) ∥∥vit+1 − vt+1∥∥2 +∑ i6=j P (i, j ∈ St+1) 〈vit+1 − vt+1,v j t+1 − vt+1〉  = 1
KN N∑ i=1 ∥∥vit+1 − vt+1∥∥2 +∑ i6=j K − 1 KN(N − 1) 〈vit+1 − vt+1,v j t+1 − vt+1〉
= 1
K(N − 1)
( 1− K
N ) N∑ i=1 ∥∥vit+1 − vt+1∥∥2 where we use the following equalities: (1) P (i ∈ St+1) = KN and P (i, j ∈ St+1) = K(K−1) N(N−1) for all
i 6= j and (2) ∑ i∈[N ] ∥∥vit+1 − vt+1∥∥2 +∑i 6=j〈vit+1 − vt+1,vjt+1 − vt+1〉 = 0. Therefore,
E ‖wt+1 − vt+1‖2 = N
K(N − 1)
( 1− K
N
) E [ 1
N N∑ i=1 ∥∥vit+1 − vt+1∥∥2 ]
≤ N K(N − 1)
( 1− K
N
) E [ 1
N N∑ i=1 ∥∥vit+1 −wt0∥∥2 ]
≤ N K(N − 1)
( 1− K
N
) 4η2tE 2G2.
where in the last inequality we use the same argument in (1).

heading: C THE EMPIRICAL RISK MINIMIZATION EXAMPLE IN SECTION 4

heading: C.1 DETAIL OF THE EXAMPLE
text: Let p > 1 be a positive integer. To avoid the trivial case, we assume N > 1. Consider the following quadratic optimization
min w
F (w) , 1
2N
[ w>Aw − 2b>w ] + µ
2 ‖w‖22, (23)
where A ∈ R(Np+1)×(Np+1) , w,b ∈ RNp+1 and µ > 0. Specifically, let b = e1 , (1, 0, · · · , 0)>, and A be a symmetric and tri-diagonal matrix defined by
(A)i,j = { 2, i = j ∈ [1, Np+ 1] , −1, |j − i| = 1 and i, j ∈ [1, Np+ 1] , 0, otherwise,
(24)
where i, j are row and column indices, respectively. We partition A into a sum of N symmetric matrices (A = ∑N k=1 Ak) and b into b = ∑N k=1 bk. Specifically, we choose b1 = b = e1 and b2 = · · · = bN = 0. To give the formulation of Ak’s, we first introduce a series of sparse and symmetric matrices Bk (1 ≤ k ≤ N):
(Bk)i,j =  1, i = j ∈ {(k − 1)p+ 1, kp+ 1}, 2, i = j and (k − 1)p+ 1 < i, j < kp+ 1, −1, |j − i| = 1 and i, j ∈ [(k − 1)p+ 1, kp+ 1] , 0, otherwise.
(25)
Now Ak’s are given by A1 = B1+E1,1,Ak = Bk (2 ≤ k ≤ N−1) and AN = BN+ENp+1,Np+1, where Ei,j is the matrix where only the (i, j)th entry is one and the rest are zero.
Back to the federated setting, we distribute the k-th partition (Ak,bk) to the k-th device and construct its corresponding local objective by
Fk(w) , 1
2
[ w>Akw − 2b>k w + µ‖w‖22 ] . (26)
In the next subsection (Appendix C.3), we show that the quadratic minimization with the global objective (23) and the local objectives (26) is actually a distributed linear regression. In this example, training data are not identically but balanced distributed. Moreover, data in each device are sparse in the sense that non-zero features only occur in one block. The following theorem (Theorem 5) shows that FedAvg might converge to sub-optimal points even if the learning rate is small enough. We provide a numerical illustration in Appendix C.2 and a mathematical proof in Appendix C.4.
Theorem 5. In the above problem of the distributed linear regression, assume that each device computes exact gradients (which are not stochastic). With a constant and small enough learning rate η and E > 1, FedAvg converges to a sub-optimal solution, whereas FedAvg with E = 1 (i.e., gradient descent) converges to the optimum. Specifically, in a quantitative way, we have
‖w̃∗ −w∗‖ ≥ (E − 1)η 16 ∥∥A1A2w∗∥∥ where w̃∗ is the solution produced by FedAvg and w∗ is the optimal solution.

heading: C.2 NUMERICAL ILLUSTRATION ON THE EXAMPLE
text: We conduct a few numerical experiments to illustrate the poor performance of FedAvg on the example introduced in Section 4. Here we set N = 5, p = 4, µ = 2 × 10−4. The annealing scheme of learning rates is given by ηt = 1/5 5+t·a where a is the best parameter chosen from the set {10−2, 10−4, 10−6}.

heading: C.3 SOME PROPERTIES OF THE EXAMPLE
text: Recall that the symmetric matrix A ∈ R(Np+1)×(Np+1) is defined in eqn. (24). Observe that A is invertible and for all vector w ∈ RNp+1,
w>Aw = 2 Np+1∑ i=1 w2i − 2 Np∑ i=1 wiwi+1 = w 2 1 + w 2 Np+1 + Np∑ i=1 (wi −wi+1)2 ≤ 4‖w‖22. (27)
which implies that 0 ≺ A 4I.
The sparse and symmetric matrices Bk (1 ≤ k ≤ N) defined in eqn. (25) can be rewritten as
(Bk) =  0(k−1)p×(k−1)p  1 −1 −1 2 −1 −1 . . . . . . . . . 2 −1
−1 1  (p+1)×(p+1)
0(N−k)p×(N−k)p
 .
From theory of linear algebra, it is easy to follow this proposition.
Proposition 1. By the way of construction, Ak’s have following properties:
1. Ak is positive semidefinite with ‖Ak‖2 ≤ 4;
2. rank(A2) = · · · = rank(AN−1) = p and rank(A1) = rank(AN ) = p+ 1;
3. For each k, there exist a matrix Xk ∈ Rrk×(Np+1) such that Ak = X>kXk where rk = rank(Ak). Given any k, each row of Xk has non-zero entries only on a block of coordinates, namely Ik = {(k − 1)p+ 1, (k − 1)p+ 2, · · · , kp+ 1}. As a result, A = ∑N k=1 Ak =
X>X, where X = (X>1 , · · · ,X>N )> ∈ R(Np+2)×(Np+1).
4. w∗ = A−1b is the global minimizer of problem eqn. (23), given by (w∗)i = 1− iNp+2 (1 ≤ i ≤ Np+ 1). Let w̃ , (1, · · · , 1︸ ︷︷ ︸
p+1 , 0, · · · , 0︸ ︷︷ ︸ (N−1)p )> ∈ RNp+1, then A1w̃ = X>1 X1w̃ = b1.
From Proposition 1, we can rewrite these local quadratic objectives in form of a ridge linear regression. Specifically, for k = 1,
F1(w) = 1
2
[ w>A1w − 2b>1 w + µ‖w‖2 ] ,
= 1
2
[ w>X>1 X1w − 2w̃>X>1 X1w + µ‖w‖2 ] ,
= 1
2 ‖X1 (w − w̃) ‖22 +
1 2 µ‖w‖2 + C,
where C is some constant irrelevant with w). For 2 ≤ k ≤ N ,
Fk(w) = 1
2
[ w>Akw − 2b>k w + µ‖w‖2 ] ,
= 1
2 ‖Xkw‖22 +
1 2 µ‖w‖2.
Similarly, the global quadratic objective eqn. (23) can be written as F (w) = 12N ‖X(w −w ∗)‖22 + 1 2µ‖w‖ 2 .
Data in each device are sparse in the sense that non-zero features only occur in the block Ik of coordinates. Blocks on neighboring devices only overlap one coordinate, i.e., |Ik ∩Ik+1| = 1. These observations imply that the training data in this example is not identically distributed.
The k-th device has rk (= p or p + 1) non-zero feature vectors which are vertically concatenated into the feature matrix Xk. Without loss of generality, we can assume all devices hold p + 1 data points since we can always add additional zero vectors to expand the local dataset. Therefore n1 = · · · = nN = p+ 1 in this case, which implies that the training data in this example is balanced distributed.

heading: C.4 PROOF OF THEOREM 5.
text: Proof of Theorem 5. To prove the theorem, we assume that (i) all devices hold the same amount of data points, (ii) all devices perform local updates in parallel, (iii) all workers use the same learning rate η and (iv) all gradients computed by each device make use of its full local dataset (hence this case is a deterministic optimization problem). We first provide the result when µ = 0.
For convenience, we slightly abuse the notation such that wt is the global parameter at round t rather than step t. Let w(k)t the updated local parameter at k-th worker at round t. Once the first worker that holds data (A1,b1) runs E step of SGD on F1(w) from wt, it follows that
w (1) t = (I− ηA1)Ewt + η E−1∑ l=0 (I− ηA1)lb1.
For the rest of workers, we have w(k)t = (I− ηAi)Ewt (2 ≤ k ≤ N). Therefore, from the algorithm,
wt+1 = 1
N N∑ k=1 w (k) t+1 =
( 1
N N∑ i=1
(I− ηAi)E ) wt + η
N E−1∑ l=0 (I− ηA1)lb1.
Define ρ , ‖ 1N ∑N i=1(I − ηAi)E‖2. Next we show that when η < 1 4 , we have ρ < 1. From Proposition 1, ‖Ak‖2 ≤ 4 and Ak 0 for ∀ k ∈ [N ]. This means ‖I− ηAk‖2 ≤ 1 for all k ∈ [N ]. Then for any x ∈ RNp+1 and ‖x‖2 = 1, we have x>(I − ηAk)Ex ≤ 1 and it is monotonically decreasing when E is increasing. Then
x>
( 1
N N∑ i=1
(I− ηAi)E ) x ≤ x> ( 1
N N∑ i=1 (I− ηAi)
) x
= x> ( I− η N A ) x < 1
since 0 ≺ A 4I means 0 (I− ηNA) ≺ I.
Then ‖wt+1 −wt‖2 ≤ ρ‖wt −wt−1‖2 ≤ ρt‖w1 −w0‖2. By the triangle inequality,
‖wt+n −wt‖2 ≤ n−1∑ i=0 ‖wt+i+1 −wt+i‖2 ≤ n−1∑ i=0 ρt+i‖w1 −w0‖2 ≤ ρt ‖w1 −w0‖2 1− ρ
which implies that {wt}t≥1 is a Cauchy sequence and thus has a limit denoted by w̃∗. We have
w̃∗ = ( I− 1
N N∑ i=1
(I− ηAi)E )−1 [ η
N E−1∑ l=0 (I− ηA1)lb
] . (28)
Now we can discuss the impact of E.
(1) When E = 1, it follows from eqn. (28) that w̃∗ = A−1b = w∗, i.e., FedAvg converges to the global minimizer.
(2) When E = ∞, lim E→∞
η ∑E−1 l=0 (I − ηA1)lb = A + 1 b1 = w̃ and lim
E→∞ 1 N
∑N i=1(I − ηAi)E =
diag{(1− 1N )Ip; (1− 1 N )I− 1 NM; (1− 1 N )Ip} where M ∈ R (N−2)p+1×(N−2)p+1 is some a symmetric matrix. Actually M is almost a diagonal matrix in the sense that there are totallyN−2 completely the same matrices (i.e., 1p+1ee
T ∈ R(p+1)×(p+1)) placed on the diagonal of M but each overlapping only the lower right corner element with the top left corner element of the next block. Therefore w̃∗ = (1, · · · , 1︸ ︷︷ ︸
p ,V11, · · · ,V(N−2)p+1,1︸ ︷︷ ︸ (N−2)p+1 , 0, · · · , 0︸ ︷︷ ︸ p )T where V = (I−M)−1.
From (4) of Proposition 1, w̃∗ is different from w∗
(3) When 2 ≤ E <∞, note that w̃∗ −w∗
= ( I− 1
N N∑ i=1
(I− ηAi)E )−1 [ η
N E−1∑ l=0 (I− ηA1)lA−
( I− 1
N N∑ i=1
(I− ηAi)E )] w∗.
(29) The right hand side of the last equation cannot be zero. Quantificationally speaking, we have the following lemma. We defer the proof for the next subsection.
Lemma 6. If the step size η is sufficiently small, then in this example, we have
‖w̃∗ −w∗‖ ≥ (E − 1)η 16 ∥∥A1A2w∗∥∥. (30) Since A1A2 6= 0 and w∗ is dense, the lower bound in eqn. (30) is not vacuous.
Now we have proved the result when µ = 0. For the case where µ > 0, we replace Ai with Ai + µI and assume µ < 14+µ instead of the original. The discussion on different choice of E is unaffected.

heading: C.5 PROOF OF LEMMA 6
text: Proof. We will derive the conclusion mainly from the expression eqn. (29). Let f(η) be a function of η. We say a matrix T is Θ(f(η)) if and only if there exist some positive constants namely C1 and C2 such that C1f(η) ≤ ‖T‖ ≤ C2f(η) for all η > 0. In the following analysis, we all consider the regime where η is sufficiently small.
Denote by V = ∑N i=1 A 2 i . First we have
I− 1 N N∑ i=1 (I− ηAi)E = I− 1 N N∑ i=1 (I− EηAi + E(E − 1) 2 η2A2i + Θ(η 3))
= Eη N A− E(E − 1) 2N η2V + Θ(η3). (31)
Then by plugging this equation into the right hand part of eqn. (29), we have
η
N E−1∑ l=0 (I− ηA1)lA−
( I− 1
N N∑ i=1
(I− ηAi)E )
= η
N E−1∑ l=0 (I− lηA1 + Θ(η2))A− ( Eη N A− E(E − 1) 2N η2V + Θ(η3) ) = η2
N
( E(E − 1)
2 (V −A1A) + Θ(η)
)
Second from eqn. (31), we have that( I− 1
N N∑ i=1
(I− ηAi)E )−1 = ( Eη
N A + Θ(η2)
)−1 = N
Eη A−1 + Θ(1).
Plugging the last two equations into eqn. (29), we have ‖w̃∗ −w∗‖ = ∥∥∥∥( NEηA−1 + Θ(1) ) η2 N ( E(E − 1) 2 (V −A1A) + Θ(η) ) w∗ ∥∥∥∥
= ∥∥∥∥(E − 12 ηA−1(V −A1A) + Θ(η) ) w∗ ∥∥∥∥
≥ (E − 1)η 16 ‖(V −A1A)w∗‖ = (E − 1)η
16 ‖A1A2w∗‖
where the last inequality holds because (i) we require η to be sufficiently small and (ii) ‖A−1x‖ ≥ 1 4‖x‖ for any vector x as a result of 0 < ‖A‖ ≤ 4. The last equality uses the fact (i) V −A1A = A1 ∑n i=2 Ai and (ii) A1Ai = 0 for any i ≥ 3.

heading: D EXPERIMENTAL DETAILS

heading: D.1 EXPERIMENTAL SETTING
text: Model and loss. We examine our theoretical results on a multinomial logistic regression. Specifically, let f(w;xi) denote the prediction model with the parameter w = (W,b) and the form f(w;xi) = softmax(Wxi + b). The loss function is given by
F (w) = 1
n n∑ i=1 CrossEntropy (f(w;xi),yi) + λ‖w‖22.
This is a convex optimization problem. The regularization parameter is set to λ = 10−4.
Datasets. We evaluate our theoretical results on both real data and synthetic data. For real data, we choose MNIST dataset (LeCun et al., 1998) because of its wide academic use. To impose statistical heterogeneity, we distribute the data among N = 100 devices such that each device contains samples of only two digits. To explore the effect of data unbalance, we further vary the number of samples among devices. Specifically, for unbalanced cases, the number of samples among devices follows a power law, while for balanced cases, we force all devices to have the same amount of samples.
Synthetic data allow us to manipulate heterogeneity more precisely. Here we follow the same setup as described in (Sahu et al., 2018). In particular, we generate synthetic samples (Xk,Yk) according to the model y = argmax(softmax(Wkx+ bk)) with x ∈ R60,Wk ∈ R10×60 and bk ∈ R10, where Xk ∈ Rnk×60 and Yk ∈ Rnk . We model each entry of Wk and bk asN (µk, 1) with µk ∼ N (0, α), and (xk)j ∼ N (vk, 1j1.2 ) with vk ∼ N (Bk, 1) and Bk ∼ N (0, β). Here α and β allow for more precise manipulation of data heterogeneity: α controls how much local models differ from each other and β controls how much the local data at each device differs from that of other devices. There are N = 100 devices in total. The number of samples nk in each device follows a power law, i.e., data are distributed in an unbalanced way. We denote by synthetic(α, β) the synthetic dataset with parameter α and β.
We summarize the information of federated datasets in Table 2.
Experiments. For all experiments, we initialize all runnings with w0 = 0. In each round, all selected devices run E steps of SGD in parallel. We decay the learning rate at the end of each round by the following scheme ηt = η01+t , where η0 is chosen from the set {1, 0.1, 0.01}. We evaluate the averaged model after each global synchronization on the corresponding global objective. For fair comparison, we control all randomness in experiments so that the set of activated devices is the same across all different algorithms on one configuration.

heading: D.2 THEORETICAL VERIFICATION
text: The impact of E. From our theory, when the total steps T is sufficiently large, the required number of communication rounds to achieve a certain precision is
T /E ≈ O
( EG2
K + EG2 +
∑N k=1 p 2 kσ 2 + LΓ + κG2
E
) ,
which is s a function of E that first decreases and then increases. This implies that the optimal local step E∗ exists. What’s more, the T /E evaluated at E∗ is
O G √√√√ N∑ k=1 p2kσ 2 + LΓ + κG2  , which implies that FedAvg needs more communication rounds to tackle with severer heterogeneity.
To validate these observations, we test FedAvg with Scheme I on our four datasets as listed in Table 2. In each round, we activate K = 30 devices and set η0 = 0.1 for all experiments in this part. For unbalanced MNIST, we use batch size b = 64. The target loss value is 0.29 and the minimum loss value found is 0.2591. For balanced MNIST, we also use batch size b = 64. The target loss value is 0.50 and the minimum loss value found is 0.3429. For two synthetic datasets, we choose b = 24. The target loss value for synthetic(0,0) is 0.95 and the minimum loss value is 0.7999. Those for synthetic(1,1) are 1.15 and 1.075.
The impact of K. Our theory suggests that a larger K may accelerate convergence since T /E contains a term O ( EG2
K
) . We fix E = 5 and η0 = 0.1 for all experiments in this part. We set the
batch size to 64 for two MNIST datasets and 24 for two synthetic datasets. We test Scheme I for illustration. Our results show that, no matter what value K is, FedAvg converges. From Figure 3, all the curves in each subfigure overlap a lot. To show more clearly the differences between the curves, we zoom in the last few rounds in the upper left corner of the figure. It reveals that the curve of a large enough K is slightly better. This result also shows that there is no need to sample as many devices as possible in convex federated optimization.
Sampling and averaging schemes. We analyze the influence of sampling and averaging schemes. As stated in Section 3.3, Scheme I iid samples (with replacement) K indices with weights pk and simply averages the models, which is proposed by Sahu et al. (2018). Scheme II uniformly samples (without replacement) K devices and weightedly averages the models with scaling factor N/K. Transformed Scheme II scales each local objective and uses uniform sampling and simple averaging. We compare Scheme I, Scheme II and transformed Scheme II, as well as the original scheme (McMahan et al., 2017) on four datasets. We carefully tuned the learning rate for the original scheme. In particular, we choose the best step size from the set {0.1, 0.5, 0.9, 1.1}. We did not fine tune the rest schemes and set η0 = 0.1 by default. The hyperparameters are the same for all schemes: E = 20,K = 10 and b = 64. The results are shown in Figure 1c and 1d.
Our theory renders Scheme I the guarantee of convergence in common federated setting. As expected, Scheme I performs well and stably across most experiments. This also coincides with the findings of Sahu et al. (2018). They noticed that Scheme I performs slightly better than another scheme: server
first uniformly samples devices and then averages local models with weight pk/ ∑ l∈St pl. However, our theoretical framework cannot apply to it, since for t ∈ I, EStwt = vt does not hold in general. Our theory does not guarantee FedAvg with Scheme II could converge when the training data are unbalanced distributed. Actually, if the number of training samples varies too much among devices, Scheme II may even diverge. To illustrate this point, we have shown the terrible performance on mnist unbalanced dataset in Figure 1b. In Figure 4, we show additional results of Scheme II on the two synthetic datasets, which are the most unbalanced. We choose b = 24,K = 10, E = 10 and η0 = 0.1 for these experiments. However, transformed Scheme II performs well except that it has a lower convergence rate than Scheme I.

Review summaries:
This paper analyzes the convergence of FedAvg, the most popular algorithm for federated learning. The highlight of the paper is removing the following two assumptions: (i) the data are iid across devices, and (ii) all the devices are active. For smooth and strongly convex problems, the paper proves an O(1/T) convergence rate to global optimum for learning rate decaying like 1/t with time. It is also shown that with constant learning rate eta, the solution found can be necessarily Omega(eta) away from the optimum (for a specific problem instance), thus justifying the decaying learning rate used in the positive result.