O N THE C ONVERGENCE OF F ED A VG ON N ON -IID D ATA
A BSTRACT
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 communicationefﬁciency 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.
I NTRODUCTION
Federated Learning (FL), also known as federated optimization, allows multiple parties to collaboratively train a model without data sharing (Kone v cn`y et al., 2015; Shokri and Shmatikov, 2015;
McMahan et al., 2017; Kone v cn`y, 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.
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-efﬁcient FL algorithms (McMahan et al., 2017;
Smith et al., 2017; Sahu et al., 2018; Sattler et al., 2019).
Federated averaging ( FedAvg ) is the ﬁrst 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.
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-iid 2 , 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. , 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.
Yu et al.
; 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 ﬁrst to show the convergence rate of
FedAvg without making the two assumptions.
We show in Theorem 1, 2, and 3 that FedAvg has O ( 1 T ) convergence rate.
In particular, Theoremshows that to attain a ﬁxed precision (cid:15) , the number of communications is
[Equation]
Here, G , Γ , p k , and σ k are problem-related constants deﬁned in Section 3.1.
The most interesting insight is that E is a knob controlling the convergence rate: neither setting E over-small ( E =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 sampling 3 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 ﬁrst to theoretically demonstrate [Table] that FedAvg with certain schemes (see Table 1) can achieve O ( 1 T ) 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 ﬁxed to η throughout, FedAvg would converge to a solution at least Ω( η ( E − 1))
away from the optimal.
To establish Theorem 4, we construct a speciﬁc (cid:96) 2 -norm regularized linear regression model which satisﬁes 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.
F EDERATED A VERAGING ( F ED A VG )
Problem formulation.
In this work, we consider the following distributed optimization model:
[Equation]
where N is the number of devices, and p k is the weight of the k -th device such that p k ≥ [-
-]0 and (cid:80)
Nk =1 p k = 1 .
Suppose the k -th device holds the n k training data: x k, 1 , x k, 2 , · · · , x k,n k .
The local objective F k ( · ) is deﬁned by
[Equation]
where (cid:96) ( · ; · ) is a user-speciﬁed 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, w t , to all the devices.
Second, every device (say the k -th) lets w kt = w t and then performs E ( ≥ 1 ) local updates :
[Equation]
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, w 1 t + E , · · · , w Nt + E , to produce the new global model, w t + E .
Because of the non-iid and partial device participation issues, the aggregation step can vary.
IID versus non-iid.
Suppose the data in the k -th device are i.i.d.
sampled from the distribution D k .
Then the overall distribution is a mixture of all local data distributions: D = (cid:80) Nk =1 p k D k .
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, D k
= 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
[Equation]
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 ofﬂine.
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 ﬁrst 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 S t ( |S t | = K ) be the set of the indices of the ﬁrst K responded devices in the t -th iteration.
The aggregation step performs
[Equation]
w kt + E .
It can be proved that NK (cid:80) k ∈S t p k 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 (cid:98) 2 TE (cid:99) .
During the broadcast, the central server sends w t to all the devices.
During the aggregation, all or part of the N devices sends its output, say w kt + E , to the server.
C ONVERGENCE A NALYSIS OF F ED A VG IN N ON - IID S ETTING
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 sufﬁciently 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 { w t } 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 ﬁrst 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 ).
3. N OTATION AND A SSUMPTIONS
We make the following assumptions on the functions F 1 , · · · , F N .
Assumption 1 and 2 are standard; typical examples are the (cid:96) 2 -norm regularized linear regression, logistic regression, and softmax classiﬁer.
Assumption 1.
F 1 , · · · , F N are all L -smooth: for all v and w , F k ( v ) ≤ F k ( w )
+ ( v − w ) T ∇ F k ( w ) + L 2 (cid:107) v − w (cid:107) 22 .
Assumption 2.
F 1 , · · · , F N are all µ -strongly convex: for all v and w , F k ( v ) ≥ F k ( w )
+ ( v − w ) T ∇ F k ( w ) + µ 2 (cid:107) v − w (cid:107) 2 2 .
Assumptions 3 and 4 have been made by the works Zhang et al. ; Stich (2018); Stich et al.
(2018); Yu et al.
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 (cid:13)(cid:13) ∇ F k ( w kt , ξ kt ) − ∇ F k ( w kt ) (cid:13)(cid:13) 2 ≤ σ 2 k for k = 1 , · · · , N .
Assumption 4.
The expected squared norm of stochastic gradients is uniformly bounded, i.e.,
E (cid:13)(cid:13) ∇ F k ( w kt , ξ kt ) (cid:13)(cid:13) 2 ≤ G 2 for all k = 1 , · · · , N and t = 0 , · · · , T −
Quantifying the degree of non-iid (heterogeneity).
Let F ∗ and F ∗ k be the minimum values of F and F k , respectively.
We use the term Γ =
F ∗ − (cid:80) Nk
=1 p k F ∗ 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 reﬂects the heterogeneity of the data distribution.
3. C ONVERGENCE R ESULT : F ULL D EVICE P ARTICIPATION
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 w T as the solution.
We always require T is evenly divisible by E so that FedAvg can output w T as expected.
Theorem 1.
Let Assumptions 1 to 4 hold and L, µ, σ k , G be deﬁned therein.
Choose κ =
Lµ , γ = max { 8 κ, E } and the learning rate η t = [Equation] [Equation] t ) .
Then FedAvg with full device participation satisﬁes
[Equation]
where
[Equation]
3. C ONVERGENCE R ESULT : P ARTIAL D EVICE P ARTICIPATION
As discussed in Section 2, partial device participation has more practical interest than full device participation.
Let the set S t ( ⊂ [ N ] ) index the active devices in the t -th iteration.
To establish the convergence bound, we need to make assumptions on S t .
Assumption 5 assumes the K indices are selected from the distribution p k independently and with replacement.
The aggregation step is simply averaging.
This is ﬁrst proposed in (Sahu et al., 2018), but they did not provide theoretical analysis.
Assumption 5 (Scheme I) .
Assume S t contains a subset of K indices randomly selected with replacement according to the sampling probabilities p 1 , · · · , p N .
The aggregation step of FedAvg performs w t ←− [Equation] K (cid:80) k ∈S [Equation]
kt .
Theorem 2.
Let Assumptions 1 to 4 hold and L, µ, σ k , G be deﬁned therein.
Let κ, γ , η t , and B be deﬁned in Theorem 1.
Let Assumption 5 hold and deﬁne C
= 4 K E 2 G 2 .
Then
[Equation]
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 S t contains a subset of K indices uniformly sampled from [ N ] without replacement.
Assume the data is balanced in the sense that p 1 = · · · = p N = 1 N .
The aggregation step of FedAvg performs w t ←− NK (cid:80) k ∈S t p k w kt .
Theorem 3.
Replace Assumption 5 by Assumption 6 and C by C =
N − K N − 1 4 K E 2 G 2 .
Then the same bound in Theorem 2 holds.
Scheme II requires p 1 = · · · = p N = 1 N which obviously violates the unbalance nature of FL.
Fortunately, this can be addressed by the following transformation.
Let (cid:101) F k ( w ) =
p k NF k ( w ) be a scaled local objective F k .
Then the global objective becomes a simple average of all scaled local objectives:
[Equation]
Theorem 3 still holds if L, µ, σ k , G are replaced by (cid:101) L (cid:44) νL , (cid:101) µ (cid:44) ςµ , (cid:101) σ k = √ νσ , and (cid:101) G = √ νG , respectively.
Here, ν = N · max k p k and ς = N · min k p k .
3. D ISCUSSIONS
Choice of E .
Since (cid:107) w 0 − w ∗ (cid:107) 2 ≤ 4 µ 2 G 2 for µ -strongly convex F , the dominating term in eqn.
(6) is
O [Equation]
[Equation]
Let T (cid:15) denote the number of required steps for FedAvg to achieve an (cid:15) accuracy.
It follows from eqn.
(7) that the number of required communication rounds is roughly
[Equation]
Thus, T (cid:15) E is a function of E that ﬁrst 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 w kt can converge to the minimizer of F k , 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 F 1 , · · · , F N 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 as K 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 Theoremsand 3.
Scheme I selects K devices according to the probabilities p 1 , · · · , p N with replacement.
The non-uniform sampling results in faster convergence than uniform sampling, especially when p 1 , · · · , p N 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 ﬁrst 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 p 1 , · · · , p N are highly non-uniform, then ν = N · max k p k is big and ς = N · min k p k is small, which makes the convergence of FedAvg slow.
This point of view is empirically veriﬁed in our experiments.
N ECESSITY OF L EARNING R ATE D ECAY
In this section, we point out that diminishing learning rates are crucial for the convergence of FedAvg in the non-iid setting.
Speciﬁcally, we establish the following theorem by constructing a ridge regression model (which is strongly convex and smooth).
Theorem 4.
We artiﬁcially construct a strongly convex and smooth distributed optimization problem.
With full batch size, E > 1 , and any ﬁxed step size, FedAvg will converge to sub-optimal points.
Speciﬁcally, let ˜ w ∗ be the solution produced by FedAvg with a small enough and constant η , and w ∗ the optimal solution.
Then we have
[Equation]
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 ﬁxed learning rate, FedAvg does not converges to the optimum.
Second, FedAvg behaves very differently from gradient descent.
Note that FedAvg with E =and full batch size is exactly the Full Gradient Descent ; with a proper and ﬁxed learning rate, its global convergence to the optimum is guaranteed Nesterov (2013).
However, Theoremshows 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 efﬁciency 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 beneﬁt of performing multiple local updates.
Theorem 4 motivates more efﬁcient alternatives to FedAvg .
R ELATED W ORK
Federated learning (FL) was ﬁrst proposed by McMahan et al.
(2017) for collaboratively learning a model without collecting users’ data.
The research work on FL is focused on the communicationefﬁciency Kone v cn ` y et al.
; McMahan et al. ; Sahu et al. ; Smith et al. and data privacy Bagdasaryan et al.
; Bonawitz et al. (2017); Geyer et al. ; Hitaj et al.
(2017); Melis et al.
This work is focused on the communication-efﬁciency issue.
FedAvg , a synchronous distributed optimization algorithm, was proposed by McMahan et al.
(2017) as an effective heuristic.
Sattler et al.
; 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.
; 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 efﬁciency 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 ﬁrst version) (Khaled et al., 2019).
Khaled et al.
(2019) used ﬁxed learning rate η and showed O ( 1 T ) convergence to a point O ( η 2 E 2 ) away from the optimal.
In fact, the suboptimality is due to their ﬁxed learning rate.
As we show in Theorem 4, using a ﬁxed 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 efﬁciently solved by the second-order algorithms Mahajan et al.
; Reddi et al. ; Shamir et al.
Shusen Wang et al.
; 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. ; Smith et al. (2016; 2017) are more generally applicable and more relevant to FL.
N UMERICAL E XPERIMENTS
Models and datasets We examine our theoretical results on a logistic regression with weight decay λ
= 1 e − 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.
[Figure]
i r e d r ound [Figure]
Experiment settings For all experiments, we initialize all runnings with w 0 = 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 =
η 0 1+ 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 conﬁguration.
Impact of E
We expect that T (cid:15) /E , the required communication round to achieve curtain accuracy, is a hyperbolic ﬁnction of E as equ (8) indicates.
Intuitively, a small E means a heavy communication burden, while a large E means a low convergence rate.
One needs to trade off between communication efﬁciency 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 (cid:15) /E contains a term O (cid:16) EG 2 K (cid:17) .
Figure 1b shows that K has limited inﬂuence 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 justiﬁes that when the variance resulting sampling is not too large (i.e., B (cid:29) 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., p k ’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 ﬁne tuned.
All the results show the crucial position of appropriate sampling and averaging schemes for FedAvg .
C ONCLUSION
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 inﬂuence 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. A CKNOWLEDGEMENTS
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 Artiﬁcial Intelligence (BAAI)
A P ROOF OF T HEOREM
We analyze FedAvg in the setting of full device participation in this section.
A. A DDITIONAL N OTATION
Let w kt be the model parameter maintained in the k -th device at the t -th step.
Let I E be the set of global synchronization steps, i.e., I E = { nE | n = 1 , 2 , · · · } .
If t + 1 ∈ I E , i.e., the time step to communication, FedAvg activates all devices.
Then the update of FedAvg with partial devices active can be described as
[Equation]
Here, an additional variable v kt +1 is introduced to represent the immediate result of one step SGD update from w kt .
We interpret w kt +1 as the parameter obtained after communication steps (if possible).
In our analysis we deﬁne two virtual sequences v t = (cid:80)
Nk
=1 p k v kt and w t =
(cid:80)
Nk
=1 p k w kt .
This is motivated by (Stich, 2018).
v t +1 results from an single step of SGD from w t .
When t + 1 / ∈ I E , both are inaccessible.
When t + 1 ∈ I E , we can only fetch w t +1 .
For convenience, we deﬁne g t =
(cid:80)
Nk
=1 p k ∇ F k ( w kt ) and g t =
(cid:80)
Nk
=1 p k ∇ F k ( w kt , ξ kt ) .
Therefore, v t +1 =
w t − η t g t and E g t = g t .
A. K EY L EMMAS
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 ≤ 14 L , we have E
[Equation]
where Γ = F ∗ − (cid:80) Nk =1 p k F (cid:63)k ≥ 0 .
Lemma 2 (Bounding the variance) .
Assume Assumption 3 holds.
It follows that
E
[Equation]
N
[Equation]
=
[Equation]
p
[Equation]
k σ 2 k .
Lemma 3 (Bounding the divergence of { w kt } ) .
Assume Assumption 4, that η t is non-increasing and η t ≤ 2 η t + E for all t ≥ 0 .
It follows that
[Equation]
A. C OMPLETING THE P ROOF OF T HEOREM
Proof.
It is clear that no matter whether t + 1 ∈ I E or t + 1 / ∈ I E , we always have w t
+
=
v t +1 .
Let ∆ t = E (cid:107) w t +1 − w (cid:63) (cid:107) 2 .
From Lemma 1, Lemma 2 and Lemma 3, it follows that
[Equation]
11) where
B
[Equation]
For a diminishing stepsize, η t = βt + γ for some β > 1 µ and γ > 0 such that η 1 ≤ min { 1 µ , 14 L } = 14 L and η t ≤ 2 η t + E .
We will prove ∆ t ≤ vγ + t where v = max (cid:110) β 2 B βµ − 1 , ( γ + 1)∆ 1 (cid:111) .
We prove it by induction.
Firstly, the deﬁnition of v ensures that it holds for t = 1 .
Assume the conclusion holds for some t , it follows that
[Equation]
Then by the strong convexity of F ( · ) ,
[Equation]
Speciﬁcally, if we choose β = 2 µ , γ = max { 8 Lµ − 1 , E } and denote κ =
Lµ , then η t = 2 µ 1 γ + t and
[Equation]
A. D EFERRED PROOFS OF KEY LEMMAS
Proof of Lemma 1.
Notice that v t +1 =
w t − η t g t , then[-(cid:107) v t +1 − w (cid:63) (cid:107) 
 = (cid:107) w t − η t g t − w (cid:63) − η t g t + η t g t (cid:107)= (cid:107) w t − w (cid:63) − η t g t (cid:107)-]
[Equation]
Note that E
A 2 = 0 .
We next focus on bounding A 1 .
Again we split A 1 into three terms:
[Equation]
From the the L -smoothness of F k ( · ) [Equation] it follows that
[Equation]
[Equation]
By the convexity of (cid:107)·(cid:107) 2 and eqn.
(14), we have
[Equation]
Note that
[Equation]
By Cauchy-Schwarz inequality and AM-GM inequality, we have
[Equation]
By the µ -strong convexity of F k ( · )
[Equation]
we have
[Equation]
[Equation]
By combining eqn.
[Equation]
eqn. [Equation] eqn.
(16) and eqn.
[Equation]
it follows that
[Equation]
where we use eqn.
(14) again.
We next aim to bound C .
We deﬁne γ t = 2 η t (1 − 2 Lη t ) .
Since η t ≤ 14 L , η t ≤ γ t ≤ 2 η t .
Then we split C into two terms:
[Equation]
where in the last equation, we use the notation Γ = (cid:80) Nk
=1 p k ( F ∗ − F ∗ k ) =
F ∗ − (cid:80) Nk
=1 p k F ∗ k .
To bound D , we have
[Equation]
where the ﬁrst inequality results from the convexity of F k ( · ) , the second inequality from AM-GM inequality and the third inequality from eqn.
Therefore
[Equation]
where in the last inequality, we use the following facts: (1) η t L − 1 ≤ − 34 ≤ 0 and (cid:80)
Nk
=1 p k ( F k ( w t ) − F ∗ ) =
F ( w t ) − F ∗ ≥ 0 (2) Γ ≥ 0 and 4 Lη 2 t + γ t η t L ≤ 6 η 2 t L and (3) γ t 2 η t ≤ 1 .
Recalling the expression of A 1 and plugging C into it, we have
[Equation]
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 σ 2 k , then
[Equation]
Proof of Lemma 3.
Since FedAvg requires a communication each E steps.
Therefore, for any t ≥ 0 , there exists a t 0 ≤ t , such that t − t 0 ≤ E − 1 and w kt 0 =
w t 0 for all k = 1 , 2 , · · · , N .
Also, we use the fact that η t is non-increasing and η t 0 ≤ 2 η t for all t − t 0 ≤ E − 1 , then
[Table]
B P ROOFS OF T HEOREMS 2 AND
We analyze FedAvg in the setting of partial device participation in this section.
B. A DDITIONAL N OTATION
Recall that w kt is the model parameter maintained in the k -th device at the t -th step.
I E
= { 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 ∈ I E , the scenario considered here is that FedAvg randomly activates a subset of devices according to some sampling schemes.
Again, g t = (cid:80) Nk
=1 p k ∇ F k ( w kt ) and g t =
(cid:80)
Nk
=1 p k F k ( w kt , ξ kt ) .
Therefore, v t +1 =
w t − η t g t and E g t = g t .
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 by H t the multiset selected which allows any element to appear more than once.
Note that
H t is only well deﬁned for t ∈ I E .
For convenience, we denote by S t =
H N ( t,E ) the most recent set of chosen devices where N ( t, E ) =
max { n | n ≤ t, n ∈ I E } .
Updating scheme.
Limited to realistic scenarios (for communication efﬁciency and low straggler effect), FedAvg ﬁrst samples a random multiset S t of devices and then only perform updates on them.
This make the analysis a little bit intricate, since S t varies each E steps.
However, we can use a thought trick to circumvent this difﬁculty.
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 ] ,
[Equation]
samples S t +1 and average { v k t +1 } k ∈S
[Equation]
+
[Equation]
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 E S t ( · ) , when we take expectation to erase the latter type of randomness.
B. K EY L EMMAS
Two schemes.
For full device participation, we always have w t +
= v
t +1 .
This is true when t + 1 / ∈ I E for partial device participation.
When t +1 ∈ I E , 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
[Equation]
We ﬁnd two sampling and averaging schemes satisfying the requirement and provide convergence guarantees.
(I)
The server establishes S t +1 by i.i.d.
with replacement sampling an index k ∈ { 1 , · · · , N } with probabilities p 1 , · · · , p N for K times.
Hence S t +1 is a multiset which allows a element to occur more than once.
Then the server averages the parameters by w kt +1 = 1 K (cid:80) k ∈S t +1 v
kt +1 .
This is ﬁrst proposed in (Sahu et al., 2018) but lacks theoretical analysis.
(II)
The server samples S t +1 uniformly in a without replacement fashion.
Hence each element in S t +1 only occurs once.
Then server averages the parameters by w kt +
= (cid:80) k ∈S t +1 p k NK v kt +1 .
Note that when the p k
’s are not all the same , one cannot ensure (cid:80)
k ∈S t +1 p k NK = 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., w t +1 ) is equal to the weighted average of parameters in all devices after SGD updates (i.e., v t +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 v t +1 and w t +1 is bounded.
E S t (cid:107) v t +1 − w t
+
(cid:107)is actually the variance of w t +1 .
Lemma 4 (Unbiased sampling scheme) .
If t + 1 ∈ I E , for Scheme I and Scheme II, we have
[Equation]
Lemma 5 (Bounding the variance of w t ) .
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 v t +1 and w t +1 is bounded by
[Equation]
(2) For Scheme II, assuming p 1 = p 2 = · · · = p N = 1 N , the expected difference between v t +1 and w t +1 is bounded by
[Equation]
B. C OMPLETING THE P ROOF OF T HEOREM 2 AND
Proof.
Note that
[Equation]
When expectation is taken over S t +
[Equation]
the last term ( A 3 ) vanishes due to the unbiasedness of w t +1 .
If t + 1 / ∈ I E , A 1 vanishes since w t +1 = v t +1 .
We use Lemma 5 to bound A 2 .
Then it follows that
[Equation]
If t + 1 ∈ I E , we additionally use Lemma 5 to bound A 1 .
Then
[Equation]
where C is the upper bound of 1 η 2 t E S t (cid:107) v t +
− w t +1 (cid:107) 2 ( C is deﬁned 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.
Speciﬁcally, for a diminishing stepsize, η t = βt + γ for some β > 1 µ and γ > 0 such that η 1 ≤ min { 1 µ , 14 L } = 14 L and η t ≤ 2 η t + E , we can prove
E (cid:107) w t +1 − w ∗ (cid:107) 2 ≤ vγ + t where v = max (cid:110) β 2 ( B + C ) βµ − 1 , ( γ + 1) (cid:107) w 1 − w ∗ (cid:107) 2 (cid:111) .
Then by the strong convexity of F ( · ) ,
[Equation]
Speciﬁcally, if we choose β = 2 µ , γ = max { 8 L µ − 1 , E } and denote κ = L µ , then η t = 2 µ 1 γ + t and
[Equation]
B. D EFERRED PROOFS OF KEY LEMMAS
Proof of Lemma 4.
We ﬁrst give a key observation which is useful to prove the followings.
Let { x i } Ni =1 denote any ﬁxed deterministic sequence.
We sample a multiset S t (with size K ) by the procedure where for each sampling time, we sample x k with probability q k for each time.
Pay attention that two samples are not necessarily independent.
We only require each sampling distribution is identically.
Let S t
= { i 1 , · · · , i K } ⊂
[ N ] (some i k ’s may have the same value).
Then
[Equation]
For Scheme I, q k = p k and for Scheme II, q k = 1 N .
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 S t +
= { i 1 , · · · , i K } denote the multiset of chosen indexes.
(1) For Scheme I, w t +1 = 1 K (cid:80)
Kl
=
v i l t +1 .
Taking
expectation over S t +1 , we have
[Equation]
where the ﬁrst equality follows from v i l t +1 are independent and unbiased.
To bound eqn.
(22), we use the same argument in Lemma 5.
Since t + 1 ∈ I E , we know that the time t 0 =
t − E
+
[Equation]
where the last inequality results from (cid:80) Nk =1 p k ( v kt +1 − w t 0 ) =
v t +1 − w t 0 and E (cid:107) x − E x (cid:107) 2 ≤ E (cid:107) x (cid:107) 2 .
Similarly, we have
[Equation]
where in the last inequality we use the fact that η t is non-increasing and η t 0 ≤ 2 η t .
(2) For Scheme II, when assuming p 1 = p 2 = · · · = p N = 1 N , we again have w t +1 = 1 K (cid:80)
Kl
{+=
+}
v i l t +1 .
[Equation]
[Equation]
=
K
[Equation]

 =
KN
[Equation]
where we use the following equalities: (1) P ( i ∈ S t +1 )
=
KN and P ( i, j ∈ S t +1 )
=
K ( K − 1) N ( N − 1) for all i (cid:54) =
j and (2) (cid:80) i ∈
[ N ] (cid:13)(cid:13) v it +1 − v t +1 (cid:13)(cid:13)
+ (cid:80) i (cid:54) =
j (cid:104) v it +1 − v t +1 , v jt +1 − v t +1 (cid:105) = 0 .
Therefore,
[Equation]
where in the last inequality we use the same argument in (1).
C T HE EMPIRICAL RISK MINIMIZATION EXAMPLE IN S ECTIONC. D ETAIL OF THE EXAMPLE
Let p > 1 be a positive integer.
To avoid the trivial case
[Equation]
we assume N > 1 .
Consider the following quadratic optimization
[Equation]
where A ∈ R ( Np +1) × ( Np +1) , w , b ∈ R
Np +1 and µ > 0 .
Speciﬁcally, let b =
e 1 (cid:44) (1 , 0 , · · · , 0) (cid:62) , and A be a symmetric and tri-diagonal matrix deﬁned by
[Equation]
) where i, j are row and column indices, respectively.
We partition A into a sum of N symmetric matrices ( A = (cid:80) Nk =1 A k ) and b into b = (cid:80) Nk =1 b k .
Speciﬁcally, we choose b 1 = b =
e 1 and b 2 = · · · = b N = 0 .
To give the formulation of A k ’s, we ﬁrst introduce a series of sparse and symmetric matrices B k (1 ≤ k ≤ N ) :
[Equation]
[Equation]
[Equation]
p +
[Equation]
kp
[Equation] [Equation]
|
[Equation]
= {+
+} and i
[Equation]
j ∈
[( k −
[Equation]
p +
[Equation]
kp + 1]
[Equation]
Now A k ’s are given by A 1 = B 1 + E 1 , 1 , A k = B k (2 ≤ k ≤ N − 1) and A N = B N + E Np +1 ,
Np +1 , where E i,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 ( A k , b k ) to the k -th device and construct its corresponding local objective by
[Equation]
[Equation]
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.
Speciﬁcally, in a quantitative way, we have
[Equation]
where (cid:101) w ∗ is the solution produced by FedAvg and w ∗ is the optimal solution.
C. N UMERICAL ILLUSTRATION ON THE EXAMPLE
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 } .
C. S OME PROPERTIES OF THE EXAMPLE
Recall that the symmetric matrix A ∈ R ( Np +1) ×
( Np +1) is deﬁned in eqn.
Observe that A is invertible and for all vector w ∈ R
Np
[Equation]
[Equation]
which implies that 0 ≺ A (cid:22) 4 I .
[Figure]
The sparse and symmetric matrices B k (1 ≤ k ≤ N ) deﬁned in eqn.
(25) can be rewritten as ( B k ) = [Equation]

[Equation]
From theory of linear algebra, it is easy to follow this proposition.
Proposition 1.
By the way of construction, A k ’s have following properties:
A k is positive semideﬁnite with (cid:107) A k (cid:107) 2 ≤ 4 ;
2. rank( A 2 ) = · · · = rank( A N − 1 ) = p and rank( A 1 ) = rank( A N ) = p + 1 ; 3.
For each k , there exist a matrix X k ∈ R r k × ( Np +1)
such that A k = X (cid:62) k
X k where r k = rank
( A k ) .
Given any k , each row of X k has non-
zero entries only on a block of coordinates, namely I k
= { ( k − 1) p + 1 , ( k − 1) p + 2 , · · · , kp + 1 } .
As a result, A = (cid:80) Nk =
1 A k =
X (cid:62) X , where X =
( X (cid:62) 1 , · · · , X (cid:62) N ) (cid:62) ∈
R
( Np +2)
× ( Np +1) .
w ∗ =
A − 1 b is the global minimizer of problem eqn.
(23), given by ( w ∗ )
i = 1 − i
Np +2 (1 ≤ i ≤ Np + 1) .
Let (cid:101) w (cid:44) (1 , · · · ,(cid:124) (cid:123)(cid:122)
(cid:125) p + , 0 , · · · ,(cid:124) (cid:123)(cid:122) (cid:125)
( N − 1) p ) (cid:62) ∈
R
Np +1 , then A 1 (cid:101) w = X
(cid:62) 1 X 1 (cid:101) w = b 1 .
From Proposition 1, we can rewrite these local quadratic objectives in form of a ridge linear regression.
Speciﬁcally, for k = 1 ,
[Equation]
where C is some constant irrelevant with w ).
For 2 ≤ k ≤ N ,
[Equation]
Similarly, the global quadratic objective eqn.
(23) can be written as F ( w ) = 12 N (cid:107) X ( w − w ∗ ) (cid:107) 22 + 12 µ (cid:107) w (cid:107) 2 .
Data in each device are sparse in the sense that non-zero features only occur in the block I k of coordinates.
Blocks on neighboring devices only overlap one coordinate, i.e., |I k
∩ I k +1 | = 1 .
These observations imply that the training data in this example is not identically distributed.
The k -th device has r k (= p or p + 1) non-zero feature vectors which are vertically concatenated into the feature matrix X k .
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 n 1 = · · · = n N = p + 1 in this case, which implies that the training data in this example is balanced distributed.
C. P ROOF OF T HEOREM 5.
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 ﬁrst provide the result when µ = 0 .
For convenience, we slightly abuse the notation such that w t 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 ﬁrst worker that holds data ( A 1 , b 1 ) runs E step of SGD on F 1 ( w ) from w t , it follows that
[Equation]
For the rest of workers, we have w ( k ) t
[Equation]
Therefore, from the algorithm,
[Equation]
Deﬁne ρ (cid:44) (cid:107) 1 N (cid:80) Ni =
( I − η A i ) E (cid:107) 2 .
Next we show that when η < 14 , we have ρ < 1 .
From
Proposition 1, (cid:107) A k (cid:107) 2 ≤ 4 and A k (cid:23) 0 for ∀ k ∈ [ N ] .
This means (cid:107) I − η A k (cid:107) 2 ≤ 1 for all k ∈ [ N ] .
Then for any x ∈ R Np +1 and (cid:107) x (cid:107) 2 = 1 , we have x (cid:62) ( I − η A k ) E x ≤ 1 and it is monotonically decreasing when E is increasing.
Then
[Equation]
since 0 ≺ A (cid:22) 4 I means 0 (cid:22) ( I − ηN A ) ≺ I .
Then (cid:107) w t +1 − w t (cid:107) 2 ≤ ρ (cid:107) w t − w t − 1 (cid:107) 2 ≤ ρ t (cid:107) w 1 − w 0 (cid:107) 2 .
By the triangle inequality, (cid:107) w t +
[Equation]
t
[Equation]
which implies that { w t } t ≥ 1 is a Cauchy sequence and thus has a limit denoted by (cid:101) w ∗ .
We have
[Equation]
Now we can discuss the impact of E .
(1) When E = 1 , it follows from eqn.
(28) that (cid:101) w ∗ =
A − 1 b = w ∗ , i.e., FedAvg converges to the global minimizer.
(2) When E = ∞ , lim E →∞ η (cid:80) E − 1 l =
( I − η A 1 ) l b =
A +1 b 1 = (cid:101) w and lim E →∞ 1 N (cid:80) Ni
=
( I − η A
i ) E = diag { (1 − 1 N ) I p ; 1 − 1 N ) I − 1 N M ; 1 − 1 N ) I
p } 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 totally N −completely the same matrices (i.e., 1 p +1 ee 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 (cid:101) w ∗ = (1 ,
(cid:124) (cid:123)(cid:122) (cid:125) p
V
V ( N − 2) p +
(cid:124) (cid:123)(cid:122) (cid:125) ( N − 2) p + , 0 , · · · ,(cid:124) (cid:123)(cid:122)
(cid:125) p T where
V =
( I − M ) −
From (4) of Proposition 1, (cid:101) w ∗ is different from w ∗ (3) When 2 ≤ E < ∞ , note that
[Equation]
The right hand side of the last equation cannot be zero.
Quantiﬁcationally speaking, we have the following lemma.
We defer the proof for the next subsection.
Lemma 6.
If the step size η is sufﬁciently small, then in this example, we have
[Equation]
Since A 1 A 2 (cid:54) = 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 A i with
A i + µ I and assume µ < 1 4+ µ instead of the original.
The discussion on different choice of E is unaffected.
C. P ROOF OF L EMMA
Proof.
We will derive the conclusion mainly from the expression eqn.
Let f ( η ) be a function of η .
We say a matrix T is Θ( f ( η ))
if and only if there exist some positive constants namely C 1 and
C 2 such that C 1 f ( η ) ≤ (cid:107) T (cid:107) ≤ C 2 f ( η ) for all η > 0 .
In the following analysis, we all consider the regime where η is sufﬁciently small.
Denote by V = (cid:80) Ni
=
A 2 i .
First we have
[Equation]
[Equation]
Then by plugging this equation into the right hand part of eqn.
(29), we have
[Equation]
Second from eqn.
(31), we have that
[Equation]
Plugging the last two equations into eqn.
(29), we have
[Equation]
where the last inequality holds because (i) we require η to be sufﬁciently small and (ii) (cid:107)
A − 1 x (cid:107) ≥ 14 (cid:107) x (cid:107) for any vector x as a result of 0 < (cid:107) A (cid:107) ≤ 4 .
The last equality uses the fact (i) V − A 1 A =
A 1 (cid:80) ni =
A i and (ii)
A 1 A i =
for any i ≥ 3 .
D E XPERIMENTAL D ETAILS D. E XPERIMENTAL S ETTING
Model and loss.
We examine our theoretical results on a multinomial logistic regression.
Specifically, let f ( w ; x i ) denote the prediction model with the parameter w =
( W , b ) and the form f ( w ; x i ) =
softmax ( Wx i + b ) .
The loss function is given by
[Equation]
CrossEntropy
[Equation]
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.
Speciﬁcally, 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 ( X k , Y k ) according to the model y = argmax( softmax ( W k x + b k )) with x ∈ R 60 , W k ∈ R 10 × 60 and b k ∈ R 10 , where
X k ∈ R n k ×
and Y k ∈ R n k .
We model each entry of W k and b k as N ( µ k , 1) with µ k ∼ N (0 , α ) , and ( x k ) j ∼ N ( v k , 1 j 1 . 2 ) with v k ∼ N ( B k , 1) and B k ∼ 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 n k 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 w 0 = 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 =
η 0 1+ 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 conﬁguration.
[Table]
[Equation]
[Table]
[Equation]
[Table]
D. T HEORETICAL VERIFICATION
The impact of E .
From our theory, when the total steps T is sufﬁciently large, the required number of communication rounds to achieve a certain precision is
[Equation]
which is s a function of E that ﬁrst decreases and then increases.
This implies that the optimal local step E ∗ exists.
What’s more, the T (cid:15) /E evaluated at E ∗ is
[Equation]
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
The impact of K .
Our theory suggests that a larger K may accelerate convergence since T (cid:15) /E contains a term O (cid:16) EG 2 K (cid:17) .
We ﬁx 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 subﬁgure 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 ﬁgure.
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 inﬂuence of sampling and averaging schemes.
As stated in Section 3.3, Scheme I iid samples (with replacement) K indices with weights p k and simply averages the models, which is proposed by Sahu et al.
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 .
We did not ﬁne 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 ﬁndings of
Sahu et al.
They noticed that Scheme I performs slightly better than another scheme: server
[Figure]
ﬁrst uniformly samples devices and then averages local models with weight p k / (cid:80) l ∈ S t p l .
However, our theoretical framework cannot apply to it, since for t ∈
I , E S t w t = v t 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 =and η 0 = 0 .
1 for these experiments.
However, transformed Scheme II performs well except that it has a lower convergence rate than Scheme I.
[Figure]