SCAFFOLD: Stochastic Controlled Averaging for Federated Learning
Sai Praneeth Karimireddy, Satyen Kale, Mehryar Mohri, Sashank J. Reddi, Sebastian U. Stich, Ananda Theertha Suresh
Introduction
Federated learning has emerged as an important paradigm in modern large-scale machine learning. Unlike in traditional centralized learning where models are trained using large datasets stored in a central server (Dean et al., 2012; Iandola et al., 2016; Goyal et al., 2017), in federated learning, the training data remains distributed over a large number of clients, which may be phones, network sensors, hospitals, or alternative local information sources (Konečnỳ et al., 2016b, a; McMahan et al., 2017; Mohri et al., 2019; Kairouz et al., 2019). A centralized model (referred to as server model) is then trained without ever transmitting client data over the network, thereby ensuring a basic level of privacy. In this work, we investigate stochastic optimization algorithms for federated learning.
The key challenges for federated optimization are 1) dealing with unreliable and relatively slow network connections between the server and the clients, 2) only a small subset of clients being available for training at a given time, and 3) large heterogeneity (non-iid-ness) in the data present on the different clients (Konečnỳ et al., 2016a). The most popular algorithm for this setting is FedAvg (McMahan et al., 2017). FedAvg tackles the communication bottleneck by performing multiple local updates on the available clients before communicating to the server. While it has shown success in certain applications, its performance on heterogeneous data is still an active area of research (Li et al., 2018; Yu et al., 2019; Li et al., 2019b; Haddadpour & Mahdavi, 2019; Khaled et al., 2020). We prove that indeed such heterogeneity has a large effect on FedAvg—it introduces a drift in the updates of each client resulting in slow and unstable convergence. Further, we show that this client-drift persists even if full batch gradients are used and all clients participate throughout the training.
As a solution, we propose a new Stochastic Controlled Averaging algorithm (SCAFFOLD) which tries to correct for this client-drift. Intuitively, SCAFFOLD estimates the update direction for the server model () and the update direction for each client .We refer to these estimates as control variates and the resulting correction technique as stochastic controlled averaging. The difference is then an estimate of the client-drift which is used to correct the local update. This strategy successfully overcomes heterogeneity and converges in significantly fewer rounds of communication. Alternatively, one can see heterogeneity as introducing ‘client-variance’ in the updates across the different clients and SCAFFOLD then performs ‘client-variance reduction’ (Schmidt et al., 2017; Johnson & Zhang, 2013; Defazio et al., 2014). We use this viewpoint to show that SCAFFOLD is relatively unaffected by client sampling.
Finally, while accommodating heterogeneity is important, it is equally important that a method can take advantage of similarities in the client data. We prove that SCAFFOLD indeed has such a property, requiring fewer rounds of communication when the clients are more similar.
We derive tighter convergence rates for FedAvg than previously known for convex and non-convex functions with client sampling and heterogeneous data.
We give matching lower bounds to prove that even with no client sampling and full batch gradients, FedAvg can be slower than SGD due to client-drift.
We propose a new Stochastic Controlled Averaging algorithm (SCAFFOLD) which corrects for this client-drift. We prove that SCAFFOLD is at least as fast as SGD and converges for arbitrarily heterogeneous data.
We show SCAFFOLD can additionally take advantage of similarity between the clients to further reduce the communication required, proving the advantage of taking local steps over large-batch SGD for the first time.
We prove that SCAFFOLD is relatively unaffected by the client sampling obtaining variance reduced rates, making it especially suitable for federated learning.
Finally, we confirm our theoretical results on simulated and real datasets (extended MNIST by Cohen et al. (2017)).
Related work. For identical clients, FedAvg coincides with parallel SGD analyzed by (Zinkevich et al., 2010) who proved asymptotic convergence. Stich (2018) and, more recently Stich & Karimireddy (2019); Patel & Dieuleveut (2019); Khaled et al. (2020), gave a sharper analysis of the same method, under the name of local SGD, also for identical functions. However, there still remains a gap between their upper bounds and the lower bound of Woodworth et al. (2018). The analysis of FedAvg for heterogeneous clients is more delicate due to the afore-mentioned client-drift, first empirically observed by Zhao et al. (2018). Several analyses bound this drift by assuming bounded gradients (Wang et al., 2019; Yu et al., 2019), or view it as additional noise (Khaled et al., 2020), or assume that the client optima are -close (Li et al., 2018; Haddadpour & Mahdavi, 2019). In a concurrent work, (Liang et al., 2019) propose to use variance reduction to deal with client heterogeneity but still show rates slower than SGD and do not support client sampling. Our method SCAFFOLD can also be seen as an improved version of the distributed optimization algorithm DANE by (Shamir et al., 2014), where a fixed number of (stochastic) gradient steps are used in place of a proximal point update. A more in-depth discussion of related work is given in Appendix A. We summarize the complexities of different methods for heterogeneous clients in Table 2.
Setup
We formalize the problem as minimizing a sum of stochastic functions, with only access to stochastic samples:
The functions represents the loss function on client . All our results can be easily extended to the weighted case.
We assume that is bounded from below by and is -smooth. Further, we assume is an unbiased stochastic gradient of with variance bounded by . For some results, we assume (strong) convexity. Note that only bounds the variance within clients. We also define two non-standard terminology below.
-BGD or bounded gradient dissimilarity: there exist constants and such that
If are convex, we can relax the assumption to
-BHD or bounded Hessian dissimilarity:
Further, is -weakly convex i.e. .
The assumptions (A1) and (A2) are orthogonal—it is possible to have and , or but .
Convergence of FedAvg
In this section we review FedAvg and improve its convergence analysis by deriving tighter rates than known before. The scheme consists of two main parts: local updates to the model (1), and aggregating the client updates to update the server model (2). In each round, a subset of clients are sampled uniformly. Each of these clients copies the current sever model and performs local updates of the form:
Here is the local step-size. Then the clients’ updates are aggregated to form the new server model using a global step-size as:
We now state our novel convergence results for functions with bounded dissimilarity (proofs in Appendix D.2).
For -smooth functions which satisfy ((A1)), the output of FedAvg has expected error smaller than for some values of satisfying
Strongly convex: , , and
General convex: , , and
Non-convex: , , and
where and .
It is illuminating to compare our rates with those of the simpler iid. case i.e. with and . Our strongly-convex rates become . In comparison, the best previously known rate for this case was by Stich & Karimireddy (2019) who show a rate of . The main source of improvement in the rates came from the use of two separate step-sizes ( and ). By having a larger global step-size , we can use a smaller local step-size thereby reducing the client-drift while still ensuring progress. However, even our improved rates do not match the lower-bound for the identical case of (Woodworth et al., 2018). We bridge this gap for quadratic functions in Section 6.
We now compare FedAvg to two other algorithms FedProx by (Li et al., 2018) (aka EASGD by (Zhang et al., 2015)) and to SGD. Suppose that and i.e. we use full batch gradients and all clients have very similar optima. In such a case, FedAvg has a complexity of which is identical to that of FedProx (Li et al., 2018). Thus, FedProx does not have any theoretical advantage.
Next, suppose that all clients participate (no sampling) with and there is no variance . Then, the above for strongly-convex case simplifies to . In comparison, extending the proof of (Khaled et al., 2020) using our techniques gives a worse dependence on of . Similarly, for the non-convex case, our rates are tighter and have better dependence on than (Yu et al., 2019). However, simply running SGD in this setting would give a communication complexity of which is faster, and independent of similarity assumptions. In the next section we examine the necessity of such similarity assumptions.
2 Lower bounding the effect of heterogeneity
We now show that when the functions are distinct, the local updates of FedAvg on each client experiences drift thereby slowing down convergence. We show that the amount of this client drift, and hence the slowdown in the rate of convergence, is exactly determined by the gradient dissimilarity parameter in ((A1)).
We now examine the mechanism by which the client-drift arises (see Fig. 1). Let be the global optimum of and be the optimum of each client’s loss function . In the case of heterogeneous data, it is quite likely that each of these is far away from the other, and from the global optimum . Even if all the clients start from the same point , each of the will move towards their client optimum . This means that the average of the client updates (which is the server update) moves towards . This difference between and the true optimum is exactly the cause of client-drift. To counter this drift, FedAvg is forced to use much smaller step-sizes which in turn hurts convergence. We can formalize this argument to prove a lower-bound (see Appendix D.4 for proof).
For any positive constants and , there exist -strongly convex functions satisfying (A1) for which FedAvg with , and has an error
This implies that the term is unavoidable even if there is no stochasticity. Further, because FedAvg uses stochastic gradients, we also have the statistical lower-bound of . Together, these lower bounds prove that the rate derived in Theorem I is nearly optimal (up to dependence on ). In the next section, we introduce a new method SCAFFOLD to mitigate this client-drift.
SCAFFOLD algorithm
In this section we first describe SCAFFOLD and then discuss how it solves the problem of client-drift.
SCAFFOLD has three main steps: local updates to the client model (3), local updates to the client control variate (4), and aggregating the updates (5). We describe each in more detail.
Along with the server model , SCAFFOLD maintains a state for each client (client control variate ) and for the server (server control variate ). These are initialized to ensure that and can safely all be initialized to 0. In each round of communication, the server parameters are communicated to the participating clients . Each participating client initializes its local model with the server model . Then it makes a pass over its local data performing updates of the form:
Then, the local control variate is also updated. For this, we provide two options:
Option I involves making an additional pass over the local data to compute the gradient at the server model . Option II instead re-uses the previously computed gradients to update the control variate. Option I can be more stable than II depending on the application, but II is cheaper to compute and usually suffices (all our experiments use Option II). The client updates are then aggregated and used to update the server parameters:
This finishes one round of communication. Note that the clients in SCAFFOLD are stateful and retain the value of across multiple rounds. Further, if is always set to 0, then SCAFFOLD becomes equivalent to FedAvg. The full details are summarized in Algorithm 1.
If communication cost was not a concern, the ideal update on client would be
Such an update essentially computes an unbiased gradient of and hence becomes equivalent to running FedAvg in the iid case (which has excellent performance). Unfortunately such an update requires communicating with all clients for every update step. SCAFFOLD instead uses control variates such that
Then, SCAFFOLD (3) mimics the ideal update (6) with
Thus, the local updates of SCAFFOLD remain synchronized and converge for arbitrarily heterogeneous clients.
Convergence of SCAFFOLD
We state the rate of SCAFFOLD without making any assumption on the similarity between the functions. See Appendix E for the full proof.
For any -smooth functions , the output of SCAFFOLD has expected error smaller than for and some values of satisfying
Strongly convex: and
General convex: and
Non-convex: and
where and .
Let us first examine the rates without client sampling (). For the strongly convex case, the number of rounds becomes . This rate holds for arbitrarily heterogeneous clients unlike Theorem I and further matches that of SGD with times larger batch-size, proving that SCAFFOLD is at least as fast as SGD. These rates also match known lower-bounds for distributed optimization (Arjevani & Shamir, 2015) (up to acceleration) and are unimprovable in general. However in certain cases SCAFFOLD is provably faster than SGD. We show this fact in Section 6.
Now let . Then our rates in the strongly-convex case are and \big{(}\frac{N}{S}\big{)}^{\frac{2}{3}}\frac{1}{\epsilon} in the non-convex case. These exactly match the rates of SAGA (Defazio et al., 2014; Reddi et al., 2016c). In fact, when , and , the update of SCAFFOLD with option I reduces to SAGA where in each round consists of sampling one client . Thus SCAFFOLD can be seen as an extension of variance reduction techniques for federated learning, and one could similarly extend SARAH (Nguyen et al., 2017), SPIDER (Fang et al., 2018), etc. Note that standard SGD with client sampling is provably slower and converges at a sub-linear rate even with .
For simplicity, assume that and consider the ideal update of (6) which uses the full gradient every step. Clearly, this would converge at a linear rate even with . FedAvg would instead use an update . The difference between the ideal update (6) and the FedAvg update (1) is . We need a bound on the gradient-dissimilarity as in ((A1)) to bound this error. SCAFFOLD instead uses the update , and the difference from ideal update becomes
Thus, the error is independent of how similar or dissimilar the functions are, and instead only depends on the quality of our approximation . Since is smooth, we can expect that the gradient does not change too fast and hence is easy to approximate. Appendix E translates this intuition into a formal proof.
Usefulness of local steps
In this section we investigate when and why taking local steps might be useful over simply computing a large-batch gradient in distributed optimization. We will show that when the functions across the clients share some similarity, local steps can take advantage of this and converge faster. For this we consider quadratic functions and express their similarity with the parameter introduced in ((A2)).
For any -smooth quadratic functions with bounded Hessian dissimilarity ((A2)), the output of SCAFFOLD with (no sampling) has error smaller than for and some values of satisfying
Strongly convex: and
Weakly convex: and
where we define .
When and is large, the complexity of SCAFFOLD becomes . In contrast DANE, which being a proximal point method also uses large , requires rounds (Shamir et al., 2014) which is significantly slower, or needs an additional backtracking-line search to match the rates of SCAFFOLD (Yuan & Li, 2019). Further, Theorem IV is the first result to demonstrate improvement due to similairty for non-convex functions as far as we are aware.
Suppose that are identical. Recall that in ((A2)) measures the Hessian dissimilarity between functions and so for this case. Then Theorem IV shows that the complexity of SCAFFOLD is which (up to acceleration) matches the i.i.d. lower bound of (Woodworth et al., 2018). In contrast, SGD with times larger batch-size would require (note the absence of in the second term). Thus, for identical functions, SCAFFOLD (and in fact even FedAvg) improves linearly with increasing number of local steps. In the other extreme, if the functions are arbitrarily different, we may have . In this case, the complexity of SCAFFOLD and large-batch SGD match the lower bound of Arjevani & Shamir (2015) for the heterogeneous case.
The above insights can be generalized to when the functions are only somewhat similar. If the Hessians are -close and , then the complexity is . This bound implies that the optimum number of local steps one should use is . Picking a smaller increases the communication required whereas increasing it further would only waste computational resources. While this result is intuitive—if the functions are more ‘similar’, local steps are more useful—Theorem IV shows that it is the similarity of the Hessians which matters. This is surprising since the Hessians of may be identical even if their individual optima are arbitrarily far away from each other and the gradient-dissimilarity ((A1)) is unbounded.
Consider a simplified SCAFFOLD update with and no sampling ():
We would ideally want to perform the update using the full gradient . We reinterpret the correction term of SCAFFOLD as performing the following first order correction to the local gradient to make it closer to the full gradient :
Thus the SCAFFOLD update approximates the ideal update up to an error . This intuition is proved formally for quadratic functions in Appendix F. Generalizing these results to other functions is a challenging open problem.
Experiments
We run experiments on both simulated and real datasets to confirm our theory. Our main findings are i) SCAFFOLD consistently outperforms SGD and FedAvg across all parameter regimes, and ii) the benefit (or harm) of local steps depends on both the algorithm and the similarity of the clients data.
Our simulated experiments uses quadratic functions based on our lower-bounds in Theorem II. We use full-batch gradients () and no client sampling. Our real world experiments run logistic regression (convex) and 2 layer fully connected network (non-convex) on the EMNIST (Cohen et al., 2017). We divide this dataset among clients as follows: for similar data we allocate to each client i.i.d. data and the remaining by sorting according to label (cf. Hsu et al. (2019)).
We consider four algorithms: SGD, FedAvg SCAFFOLD and FedProx with SGD as the local solver (Li et al., 2018). On each client SGD uses the full local data to compute a single update, whereas the other algorithms take 5 steps per epoch (batch size is 0.2 of local data). We always use global step-size and tune the local step-size individually for each algorithm. SCAFFOLD uses option II (no extra gradient computations) and FedProx has fixed regularization to keep comparison fair. Additional tuning of the regularization parameter may sometimes yield improved empirical performance.
2 Simulated results
The results are summarized in Fig. 3. Our simulated data has Hessian difference ((A2)) and . We vary the gradient heterogeneity ((A1)) as . For all valued of , FedAvg gets slower as we increase the number of local steps. This is explained by the fact that client-drift increases as we increase the number of local steps, hindering progress. Further, as we increase , FedAvg continues to slow down exactly as dictated by Thms. I and II. Note that when heterogeneity is small (), FedAvg can be competitive with SGD.
SCAFFOLD is consistently faster than SGD, with being twice as fast and about 5 times faster. Further, its convergence is completely unaffected by , confirming our theory in Thm. III. The former observation that we do not see linear improvement with is explained by Thm. IV since we have . This sub linear improvement is still significantly faster than both SGD and FedAvg.
3 EMNIST results
We run extensive experiments on the EMNIST dataset to measure the interplay between the algorithm, number of epochs (local updates), number of participating clients, and the client similarity. Table 3 measures the benefit (or harm) of using more local steps, Table 4 studies the resilience to client sampling, and Table 5 reports preliminary results on neural networks. We are mainly concerned with minimizing the number of communication rounds. We observe that
SCAFFOLD is consistently the best. Across all range of values tried, we observe that SCAFFOLD outperforms SGD, FedAvg, and FedProx. The latter FedProx is always slower than the other local update methods, though in some cases it outperforms SGD. Note that it is possible to improve FedProx by carefully tuning the regularization parameter (Li et al., 2018). FedAvg is always slower than SCAFFOLD and faster than FedProx.
SCAFFOLD SGD FedAvg for heterogeneous clients. When similarity is , FedAvg gets slower with increasing local steps. If we take more than 5 epochs, its performance is worse than SGD’s. SCAFFOLD initially worsens as we increase the number of epochs but then flattens. However, its performance is always better than that of SGD, confirming that it can handle heterogeneous data.
SCAFFOLD and FedAvg get faster with more similarity, but not SGD. As similarity of the clients increases, the performance of SGD remains relatively constant. On the other hand, SCAFFOLD and FedAvg get significantly faster as similarity increases. Further, local steps become much more useful, showing monotonic improvement with the increase in number of epochs. This is because with increasing the i.i.d.ness of the data, both the gradient and Hessian dissimilarity decrease.
SCAFFOLD is resilient to client sampling. As we decrease the fraction of clients sampled, SCAFFOLD ,and FedAvg only show a sub-linear slow-down. They are more resilient to sampling in the case of higher similarity.
SCAFFOLD outperforms FedAvg on non-convex experiments. We see that SCAFFOLD is better than FedAvg in terms of final test accuracy reached, though interestingly FedAvg seems better than SGD even when similarity is 0. However, much more extensive experiments (beyond current scope) are needed before drawing conclusions.
Conclusion
Our work studied the impact of heterogeneity on the performance of optimization methods for federated learning. Our careful theoretical analysis showed that FedAvg can be severely hampered by gradient dissimilarity, and can be even slower than SGD. We then proposed a new stochastic algorithm (SCAFFOLD) which overcomes gradient dissimilarity using control variates. We demonstrated the effectiveness of SCAFFOLD via strong convergence guarantees and empirical evaluations. Further, we showed that while SCAFFOLD is always at least as fast as SGD, it can be much faster depending on the Hessian dissimilarity in our data. Thus, different algorithms can take advantage of (and are limited by) different notions of dissimilarity. We believe that characterizing and isolating various dissimilarities present in real world data can lead to further new algorithms and significant impact on distributed, federated, and decentralized learning.
We thank Filip Hanzely and Jakub Konečnỳ for discussions regarding variance reduction techniques and Blake Woodworth, Virginia Smith and Kumar Kshitij Patel for suggestions which improved the writing.
References
Appendix
As stated earlier, federated learning involves learning a centralized model from distributed client data. This centralized model benefits from all client data and can often result in a beneficial performance e.g. in including next word prediction (Hard et al., 2018; Yang et al., 2018), emoji prediction (Ramaswamy et al., 2019), decoder models (Chen et al., 2019b), vocabulary estimation (Chen et al., 2019a), low latency vehicle-to-vehicle communication (Samarakoon et al., 2018), and predictive models in health (Brisimi et al., 2018). Nevertheless, federated learning raises several types of issues and has been the topic of multiple research efforts studying the issues of generalization and fairness (Mohri et al., 2019; Li et al., 2019a), the design of more efficient communication strategies (Konečnỳ et al., 2016b, a; Suresh et al., 2017; Stich et al., 2018; Karimireddy et al., 2019; Basu et al., 2019), the study of lower bounds (Woodworth et al., 2018), differential privacy guarantees (Agarwal et al., 2018), security (Bonawitz et al., 2017), etc. We refer to Kairouz et al. (2019) for an in-depth survey of this area.
For identical clients, FedAvg coincides with parallel SGD analyzed by (Zinkevich et al., 2010) who proved asymptotic convergence. Stich (2018) and, more recently Stich & Karimireddy (2019); Patel & Dieuleveut (2019); Khaled et al. (2020), gave a sharper analysis of the same method, under the name of local SGD, also for identical functions. However, there still remains a gap between their upper bounds and the lower bound of Woodworth et al. (2018). The analysis of FedAvg for heterogeneous clients is more delicate due to the afore-mentioned client-drift, first empirically observed by Zhao et al. (2018). Several analyses bound this drift by assuming bounded gradients (Wang et al., 2019; Yu et al., 2019), or view it as additional noise (Khaled et al., 2020), or assume that the client optima are -close (Li et al., 2018; Haddadpour & Mahdavi, 2019). In a concurrent work, (Liang et al., 2019) propose to use variance reduction to deal with client heterogeneity but still show rates slower than SGD. We summarize the communication complexities of different methods for heterogeneous clients in Table 2.
The use of control variates is a classical technique to reduce variance in Monte Carlo sampling methods (cf. (Glasserman, 2013)). In optimization, they were used for finite-sum minimization by SVRG (Johnson & Zhang, 2013; Zhang et al., 2013a) and then in SAGA (Defazio et al., 2014) to simplify the linearly convergent method SAG (Schmidt et al., 2017). Numerous variations and extensions of the technique are studied in (Hanzely & Richtárik, 2019). Starting from (Reddi et al., 2016a), control variates have also frequently been used to reduce variance in finite-sum non-convex settings (Reddi et al., 2016c; Nguyen et al., 2018; Fang et al., 2018; Tran-Dinh et al., 2019). Further, they are used to obtain linearly converging decentralized algorithms under the guise of ‘gradient-tracking’ in (Shi et al., 2015; Nedich et al., 2016) and for gradient compression as ‘compressed-differences’ in (Mishchenko et al., 2019). Our method can be viewed as seeking to remove the ‘client-variance’ in the gradients across the clients, though there still remains additional stochasticity as in (Kulunchakov & Mairal, 2019), which is important in deep learning (Defazio & Bottou, 2019).
The problem of client-drift we described is a common phenomenon in distributed optimization. In fact, classic techniques such as ADMM mitigate this drift, though they are not applicable in federated learning. For well structured convex problems, CoCoA uses the dual variable as the control variates, enabling flexible distributed methods (Smith et al., 2018). DANE by (Shamir et al., 2014) obtain a closely related primal only algorithm, which was later accelerated by Reddi et al. (2016b) and recently extended to federated learning (Li et al., 2020). SCAFFOLD can be viewed as an improved version of DANE where a fixed number of (stochastic) gradient steps are used in place of a proximal point update. In a similar spirit, distributed variance reduction techniques have been proposed for the finite-sum case (Lee et al., 2015; Konečnỳ et al., 2016a; Cen et al., 2019). However, these methods are restricted to finite-sums and are not applicable to the stochastic setting studied here.
Appendix B Technicalities
We examine some additional definitions and introduce some technical lemmas.
We make precise a few definitions and explain some of their implications.
is -convex for and satisfies:
Here, we allow that (we refer to this case as the general convex case as opposed to strongly convex). It is also possible to generalize all proofs here to the weaker notion of PL-strong convexity (Karimi et al., 2016).
is unbiased stochastic gradient of with bounded variance
Note that ((A4)) only bounds the variance within the same client, but not the variance across the clients.
are -smooth and satisfy:
The assumption ((A5)) also implies the following quadratic upper bound on
If additionally the function are convex and is an optimum of , ((A5)) implies (via Nesterov (2018), Theorem 2.1.5)
Further, if is twice-differentiable, ((A5)) implies that for any .
B.2 Some technical lemmas
Now we cover some technical lemmas which are useful for computations later on. The two lemmas below are useful to unroll recursions and derive convergence rates. The first one is a slightly improved (and simplified) version of (Stich, 2019, Theorem 2). It is straightforward to remove the additional logarithmic terms if we use a varying step-size (Kulunchakov & Mairal, 2019, Lemma 13).
For every non-negative sequence and any parameters , , , , there exists a constant step-size and weights such that for ,
By substituting the value of , we observe that we end up with a telescoping sum and estimate
When , . For such an , we can lower bound using
This proves that for all ,
The lemma now follows by carefully tuning . Consider the following two cases depending on the magnitude of and :
Suppose . Then we can choose ,
Instead if , we pick to claim that
The next lemma is an extension of (Stich & Karimireddy, 2019, Lemma 13), (Kulunchakov & Mairal, 2019, Lemma 13) and is useful to derive convergence rates for general convex functions () and non-convex functions.
For every non-negative sequence and any parameters , , , there exists a constant step-size and weights such that,
Similar to the strongly convex case (Lemma 1), we distinguish the following cases:
When , and we pick to claim
In the other case, we have or . We choose \eta=\min\bigg{\{}\sqrt{\frac{d_{0}}{c_{1}(R+1)}},\sqrt{\frac{d_{0}}{c_{2}(R+1)}}\bigg{\}} to prove
for any , and
.
The proof of the first statement for any follows from the identity:
For the second inequality, we use the convexity of and Jensen’s inequality
Next we state an elementary lemma about expectations of norms of random vectors.
Expanding the above expression using relaxed triangle inequality (Lemma 3) proves the first claim:
For the second statement, is not deterministic and depends on . Hence we have to resort to the cruder relaxed triangle inequality to claim
and then use the tighter expansion of the second term:
The cross terms in the above expression have zero mean since form a martingale difference sequence. ∎
Appendix C Properties of convex functions
We now study two lemmas which hold for any smooth and strongly-convex functions. The first is a generalization of the standard strong convexity inequality ((A3)), but can handle gradients computed at slightly perturbed points.
The following holds for any -smooth and -strongly convex function , and any in the domain of :
Given any , , and , we get the following two inequalities using smoothness and strong convexity of :
Further, applying the relaxed triangle inequality gives
Combining all the inequalities together we have
The lemma follows since . ∎
Here, we see that a gradient step is a contractive operator.
For any -smooth and -strongly convex function , points in the domain of , and step-size , the following is true
Recall our bound on the step-size which implies that . Finally, apply the -strong convexity of to get
Appendix D Convergence of FedAvg
We outline the FedAvg method in Algorithm 2. In round we sample clients with and then perform the following updates:
Starting from the shared global parameters , we update the local parameters for
Compute the new global parameters using only updates from the clients and a global step-size :
Finally, for some weights , we output
Recall our bound on the gradient dissimilarity:
If are convex, we can relax the assumption to
We defined two variants of the bounds on the heterogeneity depending of whether the functions are convex or not. Suppose that the functions is indeed convex as in ((A3)) and -smooth as in ((A5)), then it is straightforward to see that (13) implies (14). Thus for convex functions, ((A1)) is mildly weaker. Suppose that the functions are convex and -smooth. Then (14) is satisfied with since
Thus, -BGD (14) is equivalent to the heterogeneity assumption of (Mishchenko et al., 2019) with . Instead, if we have the stronger assumption ((A1)) but the functions are possibly non-convex, then corresponds to the local dissimilarity defined in (Li et al., 2018). Note that assuming is negligible is quite strong and corresponds to the strong-growth condition (Vaswani et al., 2019).
D.2 Rates of convergence (Theorem I)
We first restate Theorem I with some additional details and then see its proof.
Suppose that the functions satisfies assumptions (A4), (A5), and (A1). Then, in each of the following cases, there exist weights and local step-sizes such that for any the output of FedAvg (12) satisfies
Strongly convex: satisfies ((A3)) for , , then
General convex: satisfies ((A3)) for , , then
Non-convex: satisfies ((A1)) and , then
where , , and .
D.3 Proof of convergence
We will only prove the rate of convergence for convex functions here. The corresponding rates for non-convex functions are easy to derive following the techniques in the rest of the paper.
where is the drift caused by the local updates on the clients defined to be
We can directly apply Lemma 5 with , , , and to the first term
For the second term , we repeatedly apply the relaxed triangle inequality (Lemma 4)
The last step used Assumption -BGD assumption (14) that . The extra improvement we get is due to sampling the functions without replacement. Plugging back the bounds on and ,
(bounded drift) Suppose our functions satisfies assumptions ((A1)) and ((A3))–((A5)). Then the updates of FedAvg for any step-size satisfying have bounded drift:
If , the lemma trivially holds since for all and . Assume here on. Recall that the local update made on client is . Then,
Adding the statements of Lemmas 7 and 8, we get
D.4 Lower bound for FedAvg (Theorem II)
We first formalize the class of algorithms we look at before proving out lower bound.
We assume that FedAvg is run with , , and arbitrary possibly adaptive positive step-sizes are used with and fixed within a round for all clients. Further, the server update is a convex combination of the client updates with non-adaptive weights.
Below we state a more formal version of Theorem II.
For any positive constants , , there exist -strongly convex functions satisfying (A1) for which that the output of FedAvg satisfying (A6) has the error for any :
Consider the following simple one-dimensional functions for any given and :
Let us start FedAvg from . A single local update for and in round is respectively
Then, straightforward computations show that the update at the end of round is of the following form for some averaging weight
Since was picked obliviously, we can assume that . If indeed , we can swap the definitions of and and the sign of . With this, we can simplify as
Observe that in the above expression, the right hand side is increasing with —this represents the effect of the client drift and increases the error as the step-size increases. The left hand side decreases with —this is the usual convergence observed due to taking gradient steps. The rest of the proof is to show that even with a careful balancing of the two terms, the effect of cannot be removed. Lemma 9 performs exactly such a computation to prove that for any ,
We finish the proof by noting that . ∎
Suppose that for all , and the following is true:
Then, there exists a constant such that for any sequence of step-sizes :
Define . Such a exists and is positive since . Then, satisfies
The second inequality follows because implies that is always positive. If , then we have a constant which satisfies
On the other hand, if , we have a tighter inequality
The last step used Bernoulli’s inequality and the fact that for . Observe that in the above expression, the right hand side is increasing with —this represents the effect of the client drift and increases the error as the step-size increases. The left hand side decreases with —this is the usual convergence observed due to taking gradient steps. The rest of the proof is to show that even with a careful balancing of the two terms, the effect of cannot be removed.
Suppose that all rounds after have a small step-size i.e. for all and hence satisfies (16). Then we will prove via induction that
For , (17) is trivially satisfied. Now for ,
The first step is because of (16) and the last step uses the induction hypothesis. The second step considers two cases for : either and , or . Finally note that using Bernoulli’s inequality. We have hence proved
Now suppose . Then (15) implies that for some constant . If instead no such exists, then we can set . Now finally observe that the previous proof did not make any assumption on , and in fact the inequality stated above holds for all . ∎
Appendix E Convergence of SCAFFOLD
We first restate the convergence theorem more formally, then prove the result for the convex case, and then for non-convex case. Throughout the proof, we will focus on the harder option II. The proofs for SCAFFOLD with option I are nearly identical and so we skip them.
Suppose that the functions satisfies assumptions (A4) and (A5). Then, in each of the following cases, there exist weights and local step-sizes such that for any the output (22) of SCAFFOLD satisfies:
Strongly convex: satisfies ((A3)) for , , then
Thus, the asymptotic rates of SCAFFOLD for general convex functions only incurs an additive term of the order of . For strongly convex functions, we only see the affects in the logarithmic terms.
We will rewrite SCAFFOLD using notation which is convenient for the proofs: represent the client models, is the aggregate server model, and and are the client and server control variates. For an equivalent description which is easier to implement, we refer to Algorithm 1. The server maintains a global control variate as before and each client maintains its own control variate . In round , a subset of clients of size are sampled uniformly from . Suppose that every client performs the following updates
Starting from the shared global parameters , we update the local parameters for
Update the control iterates using (option II):
We update the local control variates only for clients
Compute the new global parameters and global control variate using only updates from the clients :
Finally, for some weights , we output
Note that the clients are agnostic to the sampling and their updates are identical to when all clients are participating. Also note that the control variate choice (19) corresponds to (option II) of Algorithm 1. Further, the updates of the clients is forgotten and is defined only to make the proofs easier. While actually implementing the method, only clients participate and the rest remain inactive (see Algorithm 1).
We will first bound the variance of SCAFFOLD update in Lemma 12, then see how sampling of clients effects our control variates in Lemma 13, and finally bound the amount of client-drift in Lemma 14. We will then use these three lemmas to prove the progress in a single round in Lemma 15. Combining this progress with Lemmas 1 and 2 gives us the desired rates.
Before proceeding with the proof of our lemmas, we need some additional definitions of the various errors we track. As before, we define the effective step-size to be
We define client-drift to be how much the clients move from their starting point:
Because we are sampling the clients, not all the client control-variates get updated every round. This leads to some ‘lag’ which we call control-lag:
We study how the variance of the server update can be bounded.
The inequality before the last used the smoothness of . The last inequality which separates the mean and the variance is an application of Lemma 4: the variance of is bounded by . Similarly, as defined in (19) for any has variance smaller than and hence the variance of is smaller than .
We have previously related the variance of the server update to the control lag. We now examine how the control-lag grows each round.
Recall that after round , the control update rule (19) implies that is set as per
Plugging the above expression in the definition of we get
The final step applied Jensen’s inequality twice. We can then further simplify using the relaxed triangle inequality as
We will now bound the final source of error which is the client-drift.
Suppose our step-sizes satisfy and satisfies assumptions (A3)–(A5). Then, for any global we can bound the drift as
First, observe that if , since for all and that and the right hand side are both positive. Thus the lemma is trivially true if . For , we build a recursive bound of the drift.Starting from the definition of the update (18) and then applying the relaxed triangle inequality, we can expand
The final step follows from the relaxed triangle inequality (Lemma 3). Applying the contractive mapping Lemma 6 for shows
Once again using our relaxed triangle inequality to expand the other term , we get
The last step used the smoothness of . Combining the bounds on and in the original inequality and using gives
Recall that with the choice of in (19), the variance of is less than . Separating its mean and variance gives
Unrolling the recursion (25), we get the following for any
The inequality can be verified for manually. For ,
Again averaging over and multiplying by yields
E.2 Convergence of SCAFFOLD for non-convex functions (Theorem III)
Now that we have a bound on all errors, we can describe our progress.
Starting from our server update equation,
We can then apply Lemma 12 to bound the second moment of the server update as
The term can be bounded by using perturbed strong-convexity (Lemma 5) with , , , and to get
Plugging back, we can further simplify the expression to get
Now recall that Lemma 14 bounds the client-drift:
We now analyze the most general case of SCAFFOLD with option II on functions which are potentially non-convex. Just as in the non-convex proof, we will first bound the variance of the server update in Lemma 16, the change in control lag in Lemma 17 and finally we bound the client-drift in Lemma 18. Combining these three together gives us the progress made in one round in Lemma 19. The final rate is derived from the progress made using Lemma 2.
Recall that in round , we update the control variate as (19)
We introduce the following notation to keep track of the ‘lag’ in the update of the control variate: define a sequence of parameters such that for any and we have and for ,
By the update rule for control variates (19) and the definition of above, the following property always holds:
We can then define the following to be the error in control variate for round :
Also recall the closely related definition of client drift caused by local updates:
Let us analyze how the control variates effect the variance of the aggregate server update.
Recall that that the server update satisfies
Taking norm on both sides and separating mean and variance, we proceed as
We now analyze the ‘lag’ in the control variates due to us sampling only a small subset of clients each round. Because we cannot rely on convexity anymore but only on the Lipschitzness of the gradients, the control-lag increases faster in the non-convex case.
The proof proceeds similar to that of Lemma 13 except that we cannot rely on convexity. Recall that after round , the definition of (26) implies that
Plugging the above expression in the definition of we get
We can expand the second term with the relaxed triangle inequality to claim
We will expand the first term to claim for a constant to be chosen later
where we used Young’s inequality which holds for any . Combining the bounds for and ,
We will next bound the client drift . For this, convexity is not crucial and we will recover a very similar result to Lemma 14 only use the Lipschitzness of the gradient.
Suppose our step-sizes satisfy and satisfies assumptions (A4)–(A5). Then, for any global we can bound the drift as
First, observe that if , since for all and that and the right hand side are both positive. Thus the Lemma is trivially true if and we will henceforth assume . Starting from the update rule (18) for and
The inequalities above follow from repeated application of the relaxed triangle inequalities and the -Lipschitzness of . Averaging the above over , the definition of and (27) gives
Appendix F Usefulness of local steps (Theorem IV)
Given that we can bound all sources of error, we can finally prove the progress made in each round.
Starting from the smoothness of and taking conditional expectation gives
The third inequality follows from the observation that for any , and the last from the -Lipschitzness of . Now we use Lemma 17 to bound as
Let us state our rates of convergence for SCAFFOLD which interpolates between identical and completely heterogeneous clients. In this section, we always set and assume all clients participate .
Suppose that the functions are quadratic and satisfy assumptions (A4), (A5) and additionally (A2). Then, for global step-size in each of the following cases, there exist probabilities and local step-size such that the output (29) of SCAFFOLD when run with no client sampling () using update (28) satisfies:
Strongly convex: satisfies ((A3)) for , , then
General convex: satisfies , , and , then
Note that if , we match (up to acceleration) the lower bound in (Woodworth et al., 2018). While certainly when the functions are identical as studied in (Woodworth et al., 2018), our upper-bound is significantly stronger since it is possible that even for highly heterogeneous functions. For example, objective perturbation (Chaudhuri et al., 2011; Kifer et al., 2012) is an optimal mechanism to achieve differential privacy for smooth convex objectives (Bassily et al., 2014). Intuitively, objective perturbation relies on masking each client’s gradients by adding a large random linear term to the objective function. In such a case, we would have high gradient dissimilarity but no Hessian dissimilarity.
Our non-convex convergence rates are the first of their kind as far as we are aware—no previous work shows how one can take advantage of similarity for non-convex functions. However, we should note that non-convex quadratics do not have a global lower-bound on the function value . We will instead assume that almost surely lower-bounds the value of , implicitly assuming that the iterates remain bounded.
In the rest of this section, we will focus on proving Theorem VIII. We will show how to bound variance in Lemma 23, bound the amount of drift in Lemma 22, and show progress made in one step in Lemma 24. In all of these we do not use convexity, but strongly rely on the functions being quadratics. Then we combine these to derive the progress made by the server in one round—for this we need weak-convexity to argue that averaging the parameters does not hurt convergence too much. As before, it is straight-forward to derive rates of convergence from the one-round progress using Lemmas 1 and 2.
F.1 Additional notation and assumptions
For any matrix and vector , let . Since all functions in this section are quadratics, we can assume w.l.o.g they are of the following form:
for some and , . We also assume that is a symmetric matrix though this requirement is easily relaxed. Note that this implies and that . If are additionally convex, we have that is the optimum of and the optimum of . However, this is not necessarily true in general.
We will also focus on a simplified version of SCAFFOLD where in each round , client performs the following update starting from :
where the second part is specialized to quadratics and the expectation is conditioned over everything before current step of round . At the end of each round, as before, . The final output of the algorithm is chosen using probabilities as
Note that we are now possibly outputting iterates computed within a single round and that . Beyond this, the update above differs from our usual SCAFFOLD in two key aspects: a) it uses gradients computed at as control variates instead of those at either (as in option I) or (as in option II), and b) it uses full batch gradients to compute its control variates instead of stochastic gradients. The first issue is easy to fix and our proof extends to using both option I or option II using techniques in Section E. The second issue is more technical—using stochastic gradients for control variates couples the randomness across the clients in making the local-updates biased. While it may be possible to get around this (cf. (Lei & Jordan, 2017; Nguyen et al., 2017; Tran-Dinh et al., 2019)), we will not attempt to do so in this work. Note that if local update steps typically represents running multiple epochs on each client. Hence one additional epoch to compute the control variate does not significantly add to the cost.
Finally, we define the following sequence of positive numbers for notation convenience:
F.2 Lemmas tracking errors
We see how averaging can reduce variance. A similar argument was used in the special case of one-shot averaging in (Zhang et al., 2013b).
Suppose are quadratic functions and assumption (A4) is satisfied. Then let and be vectors in step and round generated using (28)—(29). Then,
The third equality was because are independent of each other conditioned on everything before round . ∎
We next see the effect of averaging on function values.
Suppose that is general-convex, then we have:
Since is -general convex, it follows that the function is convex in for any . The lemma now follows directly from using convexity and the definition of . ∎
We see how the client drift of SCAFFOLD depends on .
For the update (28), assuming ((A2)) and that are quadratics, the following holds for any
Note that if , then the first inequality directly proves the lemma. For the second inequality, we assumed and then applied our relaxed triangle inequality. By assumption (A2), we have the following for
Using the bound on the step-size gives
Simple computations now give the Lemma statement for all . ∎
We will see how to bound the variance of the output.
Consider the update (28) for quadratic with . Then, if further ((A2)), ((A5)) and ((A4)) are satisfied, we have
Further if are strongly convex satisfying ((A3)), we have
We can rewrite the update step (28) as below:
Similarly, the expected iterate satisfies the same equation without the
This implies that the difference satisfies
We can relate this to the function value as follows:
The last inequality used smoothness of and the one before that relied on the independence of . Now, if is general convex we have for that and hence
This proves our second statement of the lemma. For strongly convex functions, we have for ,
F.3 Lemmas showing progress
Now we focus only on a single client and monitor their progress.
Suppose ((A2)), ((A5)) and ((A4)) hold, and are quadratics. Then, the following holds for the update (28) with with is is non-convex or general-convex
Recall that is defined to be
The second to last inequality used that by ((A5)) and that by ((A2)). The final inequality used that . Now, multiplying Lemma 22 by we have
Adding this to our previous equation gives the following recursive bound:
The bound on our step-size implies that and recall that . This proves first statement of the lemma for non-strongly convex functions (). If additionally is strongly-convex with , we have
This can be used to tighten the inequality as follows
If , then and we have the strongly-convex version of the first statement.
Now we combine the progress made by each client in one step to calculate the server progress.
Suppose ((A2)), ((A5)) and ((A4)) hold, and are quadratics. Then, the following holds for the update (28) with and weights :
Set if s are not strongly-convex (is only general-convex).
Let us do the non-convex (and general convex) case first. By summing over Lemma 24 we have
proving the second part of the Lemma for weights . The proof of strongly convex follows a very similar argument. Unrolling Lemma 24 using weights gives
As in the general-convex case, we can use Lemmas 21, 20 and 23 to prove that
The proof of Theorem VIII follows by appropriately unrolling Lemma 25. For general-convex functions, we can simply use Lemma 2 with the probabilities set as . For strongly-convex functions, we use and follow the computations in Lemma 1.