Is Local SGD Better than Minibatch SGD?
Blake Woodworth, Kumar Kshitij Patel, Sebastian U. Stich, Zhen Dai, Brian Bullins, H. Brendan McMahan, Ohad Shamir, Nathan Srebro
Introduction
It is often important to leverage parallelism in order to tackle large scale stochastic optimization problems. A prime example is the task of minimizing the loss of machine learning models with millions or billions of parameters over enormous training sets.
One popular distributed approach is local stochastic gradient descent (SGD) , also known as “parallel SGD” or “Federated Averaging”Federated Averaging is a specialization of local SGD to the federated setting, where (a) data is assumed to be heterogenous (not i.i.d.) across workers, (b) only a handful of clients are used in each round, and (c) updates are combined with a weighted average to accommodate unbalanced datasets. , which is commonly applied to large scale convex and non-convex stochastic optimization problems, including in data center and “Federated Learning” settings . Local SGD uses parallel workers which, in each of rounds, independently execute steps of SGD starting from a common iterate, and then communicate and average their iterates to obtain the common iterate from which the next round begins. Overall, each machine computes stochastic gradients and executes SGD steps locally, for a total of overall stochastic gradients computed (and so samples used), with rounds of communication (every steps of computation).
Given the appeal and usage of local SGD, there is significant value in understanding its performance and limitations theoretically, and in comparing it to other alternatives and baselines that have the same computation and communication structure. That is, other methods that are distributed across machines and compute gradients per round of communication for rounds, for a total of gradients per machine and communication steps. This structure can also be formalized through the graph oracle model of Woodworth et al. [29, see also Section 2].
So, how does local SGD compare to other algorithms with the same computation and communication structure? Is local SGD (or perhaps an accelerated variant) optimal in the same way that (accelerated) SGD is optimal in the sequential setting? Is it better than baselines?
A natural alternative and baseline is minibatch SGD – a simple method for which we have a complete and tight theoretical understanding. Within the same computation and communication structure, minibatch SGD can be implemented as follows: Each round, calculate the stochastic gradient estimates (at the current iterate) on each machine, and then average all estimates to obtain a single gradient estimate. That is, we can implement minibatch SGD that takes stochastic gradient steps, with each step using a minibatch of size —this is the fair and correct minibatch SGD to compare to, and when we refer to “minibatch SGD” we refer to this implementation ( steps with minibatch size ).
Local SGD seems intuitively better than minibatch SGD, since even when the workers are not communicating, they are making progress towards the optimum. In particular, local SGD performs times more updates over the course of optimization, and can be thought of as computing gradients at less “stale” and more “updated” iterates. For this reason, it has been argued that local SGD is at least as good as minibatch SGD, especially in convex settings where averaging iterates cannot hurt you. But can we capture this advantage theoretically to understand how and when local SGD is better than minibatch SGD? Or even just establish that local SGD is at least as good?
A string of recent papers have attempted to analyze local SGD for convex objectives, [e.g. 23, 25, 13, 4]. However, a satisfying analysis has so far proven elusive. In fact, every analysis that we are aware of for local SGD in the general convex (or strongly convex) case with a typical noise scaling (e.g. as arising from supervised learning) not only does not improve over minibatch SGD, but is actually strictly dominated by minibatch SGD! But is this just a deficiency of these analyses, or is local SGD actually not better, and perhaps worse, than minibatch SGD? In this paper, we show that the answer to this question is “sometimes.” There is a regime in which local SGD indeed matches or improves upon minibatch SGD, but perhaps surprisingly, there is also a regime in which local SGD really is strictly worse than minibatch SGD.
In Section 3, we start with the special case of quadratic objectives and show that, at least in this case, local SGD is strictly better than minibatch SGD in the worst case, and that an accelerated variant is even minimax optimal.
We then turn to general convex objectives. In Section 4 we prove the first error upper bound on the performance of local SGD which is not dominated by minibatch SGD’s upper bound with a typical noise scaling. In doing so, we identify a regime (where is large and ) in which local SGD performs strictly better than minibatch in the worst case. However, our upper bound does not show that local SGD is always as good or better than minibatch SGD. In Section 5, we show that this is not just a failure of our analysis. We prove a lower bound on the worst-case error of local SGD that is higher than the worst-case error of minibatch SGD in a certain regime! We demonstrate this behaviour empirically, using a logistic regression problem where local SGD indeed behaves much worse than mini-batch SGD in the theoretically-predicted problematic regime.
Thus, while local SGD is frequently better than minibatch SGD—and we can now see this both in theory and in practice [see experiments by e.g. 31, 15, 35]—our work identifies regimes in which users should be wary of using local SGD without considering alternatives like minibatch SGD, and might want to seek alternative methods that combine the best of both, and attain optimal performance in all regimes.
Preliminaries
We consider the stochastic convex optimization problem:
For simplicity, we consider initializing all algorithms at zero. Then, Local SGD with machines, stochastic gradients per round, and rounds of communication calculates its th iterate on the th machine for via
where i.i.d., and refers to dividing . For each , minibatch SGD calculates its th iterate via
We also introduce another strawman baseline, which we will refer to as “thumb-twiddling” SGD. In thumb-twiddling SGD, each machine computes just one (rather than ) stochastic gradients per round of communication and “twiddles its thumbs” for the remaining computational steps, resulting in minibatch SGD steps, but with a minibatch size of only (instead of , i.e. as if we used ). This is a silly algorithm that is clearly strictly worse than minibatch SGD, and we would certainly expect any reasonable algorithm to beat it. But as we shall see, previous work has actually struggled to show that local SGD even matches, let alone beats, thumb-twiddling SGD. In fact, we will show in Section 5 that, in certain regimes, local SGD truly is worse than thumb-twiddling.
For a particular algorithm , we define its worst-case performance with respect to as:
The worst-case performance of minibatch SGD for general convex objectives is tightly understood :
In order to know if an algorithm like local or minibatch SGD is “optimal” in the worst case requires understanding the minimax error, i.e. the best error that any algorithm with the requisite computation and communication structure can guarantee in the worst case. This requires formalizing the set of allowable algorithms. One possible formalization is the graph oracle model of Woodworth et al. which focuses on the dependence structure between different stochastic gradient computations resulting from the communication pattern. Using this method, Woodworth et al. prove lower bounds which are applicable to our setting. Minibatch SGD does not match these lower bounds (nor does accelerated minibatch SGD, see Cotter et al. ), but these lower bounds are not known to be tight, so the minimax complexity and minimax optimal algorithm are not yet known.
Table 1 summarizes the best existing analyses of local SGD that we are aware of that can be applied to our setting. We present the upper bounds as they would apply in our setting, and after optimizing over the stepsize and other parameters. A detailed derivation of these upper bounds from the explicitly-stated theorems in other papers is provided in Appendix A. As we can see from the table, in the natural scaling , every previous upper bound is strictly dominated by minibatch SGD. Worse, these upper bounds can even be worse than even thumb-twiddling SGD when (although they are sometimes better). In particular, the first term of each previous upper bound (in terms of ) is never better than (the optimization term of minibatch and thumb-twiddling SGD), and can be much worse.
We should note that in an extremely low noise regime , the bound of Khaled et al. can sometimes improve over minibatch SGD. However, this only happens when steps of sequential SGD is better than minibatch SGD—i.e. when you are better off ignoring of the machines and just doing serial SGD on a single machine (such an approach would have error ). This is a trivial regime in which every update for any of these algorithms is essentially an exact gradient descent step, thus there is no need for parallelism in the first place. See Appendix A.3 for further details. The upper bound we develop in Section 4, in contrast, dominates their guarantee and shows an improvement over minibatch that cannot be achieved on a single machine (i.e. without leveraging any parallelism). Furthermore, this improvement can occur even in the natural scaling and even when minibatch SGD is better than serial SGD on one machine.
We emphasize that Table 1 lists the guarantees specialized to our setting—some of the bounds are presented under slightly weaker assumptions, or with a more detailed dependence on the noise: Stich and Karimireddy , Haddadpour et al. analyze local SGD assuming not-quite-convexity; and Wang and Joshi , Dieuleveut and Patel derive guarantees under both multiplicative and additive bounds on the noise. Dieuleveut and Patel analyze local SGD with the additional assumption of a bounded third derivative, but even with this assumption do not improve over mini-batch SGD. Numerous works study local SGD in the non-convex setting [see e.g. 35, 30, 27, 25, 9]. Although their bounds would apply in our convex setting, due to the much weaker assumptions they are understandably much worse than minibatch SGD. There is also a large body of work studying the special case , i.e. where the iterates are averaged just one time at the end . However, these analyses do not easily extend to multiple rounds, and the constraint can provably harm performance [see 21]. Finally, local SGD has been studied with heterogeneous data, i.e. where each machine receives stochastic gradients from different distributions—see Kairouz et al. [11, Sec. 3.2] a recent survey.
In this work, we focus on understanding the best achievable error for a given , , and . However, one might also want to know to what extent it is possible to reduce communication without paying for it. Concretely, fix , and consider as a baseline an algorithm which computes stochastic gradients on each machine sequentially, but is allowed to communicate after every step. We can then ask to what extent we can compete against this baseline while using less communication. One way to do this is to use Local SGD, which reduces communcation by a factor of . However, the amount by which we can reduce communcation using Local SGD is easily determined once we know the error of Local SGD for each fixed . Therefore, this viewpoint of reducing communcation is essentially equivalent to the one we take.
Good News: Quadratic Objectives
As we have seen, existing analyses of local SGD are no better than that of minibatch SGD. In the special case where is quadratic, we will now show that not only is local SGD sometimes as good as minibatch SGD, but it is always as good as minibatch SGD, and sometimes better. In fact, an accelerated variant of local SGD is minimax optimal for quadratic objectives. More generally, we show that the local SGD anologue for a large family of serial first-order optimization algorithms enjoys an error guarantee which depends only on the product and not on or individually. In particular, we consider the following family of linear update algorithms:
We say that a first-order optimization algorithm is a linear update algorithm if, for fixed linear functions , the algorithm generates its st iterate according to
This family captures many standard first-order methods including SGD, which corresponds to the linear mappings and . Another notable algorithm in this class is AC-SA , an accelerated variant of SGD which also has linear updates. Some important non-examples, however, are adaptive gradient methods like AdaGrad —these have linear updates, but the linear functions are data-dependent.
For a linear update algorithm , we will use local- to denote the local SGD analogue with replacing SGD. That is, during each round of communication, each machine independently executes iterations of and then the resulting iterates are averaged. For quadratic objectives, we show that this approach inherits the guarantee of with the benefit of variance reduction:
We prove this in Appendix B by showing that the average iterate is updated according to —even in the middle of rounds of communication when is not explicitly computed. In particular, we first show that
Then, by the linearity of and , we prove
and its variance is reduced to . Therefore, ’s guarantee carries over while still benefitting from the lower variance.
To rephrase Theorem 1, on quadratic objectives, local- is in some sense equivalent to iterations of with the gradient variance reduced by a factor of . Furthermore, this guarantee depends only on the product , and not on or individually. Thus, averaging the th iterate of independent executions of , sometimes called “one-shot averaging,” enjoys the same error upper bound as iterations of size- minibatch-.
Nevertheless, it is important to highlight the boundaries of Theorem 1. Firstly, ’s error guarantee must not rely on any particular structure of the stochastic gradients themselves, as this structure might not hold for the implicit updates of local-. Furthermore, even if some structure of the stochastic gradients is maintained for local-, the particular iterates generated by local- will generally vary with and (even holding constant). Thus, Theorem 1 does not guarantee that local- with two different values of and would perform the same on any particular instance. We have merely proven matching upper bounds on their worst-case performance.
We apply Theorem 1 to yield error upper bounds for local-SGD and local-AC-SA (based on the AC-SA algorithm of Ghadimi and Lan ) which is minimax optimal:
For any quadratic , there are constants and such that local-SGD returns a point such that
In particular, local-AC-SA is minimax optimal for quadratic objectives.
Comparing the bound above for local SGD with the bound for minibatch SGD (5), we see that the local SGD bound is strictly better, due to the first term scaling as as opposed to . We note that minibatch SGD can also be accelerated , leading to a bound with better dependence on , but this is again outmatched by the bound for the (accelerated) local-AC-SA algorithm above. A similar, improved bound can also be proven when the objective is a strongly convex quadratic.
Local SGD and related methods have been previously analyzed for quadratic objectives, but in slightly different settings. Jain et al. study a similar setting and analyze our “minibatch SGD” for and fixed , but varying and . They show that when is sufficiently small relative to , then minibatch SGD can compete with steps of serial SGD. They also show that for fixed and , when is sufficiently small then the average of independent runs of minibatch SGD with steps and minibatch size can compete with steps of minibatch SGD with minibatch size . These results are qualitatively similar to ours, but they analyze a specific algorithm while we are able to provide a guarantee for a broader class of algorithms. Dieuleveut and Patel analyze local SGD on quadratic objectives and show a result analogous to our Theorem 1. However, their result only holds when is sufficiently small relative to and . Finally, there is a literature on “one-shot-averaging” for quadratic objectives, which corresponds to an extreme where the outputs of an algorithm applied to several different training sets are averaged, [e.g. 33, 34]. These results also highlight similar phenomena, but they do not apply as broadly as Theorem 1 and they do not provide as much insight into local SGD specifically.
More Good News: General Convex Objectives
In this section, we present the first analysis of local SGD for general convex objectives that is not dominated by minibatch SGD. For the first time, we can identify a regime of , , and in which local SGD provably performs better than minibatch SGD in the worst case. Furthermore, our analysis dominates all previous upper bounds.
Let . When , an appropriate average of the iterates of Local SGD with an optimally tuned constant stepsize satisfies for a universal constant
If , then an appropriate average of the iterates of Local SGD with decaying stepsizes satisfies for a universal constant
This is proven in Appendix C. We use a similar approach as Stich , who analyzes the behavior of the averaged iterate , even when it is not explicitly computed. They show, in particular, that the averaged iterate evolves almost according to size--minibatch SGD updates, up to a term proportional to the dispersion of the individual machines’ iterates . Stich bounds this with , but this bound is too pessimistic—in particular, it holds even if the gradients are replaced by arbitrary vectors of norm . In Lemma 5, we improve this bound to which allows for our improved guarantee.In recent work, Stich and Karimireddy present a new analysis of local-SGD which, in the general convex case is of the form . As stated, this is strictly worse than minibatch SGD. However, we suspect that this bound should hold for any because, intuitively, having more machines should not hurt you. If this is true, then optimizing their bound over yields a similar result as Theorem 2. Our approach resembles that of Khaled et al. , which we became aware of in the process of preparing this manuscript, however our analysis is more refined. In particular, we optimize more carefully over the stepsize so that our analysis applies for any , , and (rather than just ) and shows an improvement over minibatch SGD in a significantly broader regime, including when (see Appendix A.3 for additional details).
We now compare the upper bound from Theorem 2 with the guarantee of minibatch SGD. For clarity, and in order to highlight the role of , , and in the convergence rate, we will compare rates for general convex objectives when , and we will also ignore numerical constants and the logarithmic factor in Theorem 2. In this setting, the worst-case error of minibatch SGD is:
Our guarantee for local SGD from Theorem 2 reduces to:
These guarantees have matching statistical terms of , which cannot be improved by any first-order algorithm . Therefore, in the regime where the statistical term dominates both rates, i.e. and , both algorithms will have similar worst-case performance. When we leave this noise-dominated regime, we see that local SGD’s guarantee is better than minibatch SGD’s when and is worse when . This makes sense intuitively: minibatch SGD benefits from computing very precise gradient estimates, but pays for it by taking fewer gradient steps; conversely, each local SGD update is much noisier, but local SGD is able to make times more updates.
This establishes that for general convex objectives in the large- and large- regime, local SGD will strictly outperform minibatch SGD. However, in the large- and small- regime, we are only comparing upper bounds, so it is not clear that local SGD will in fact perform worse than minibatch SGD. Nevertheless, it raises the question of whether this is the best we can hope for from local SGD. Is local SGD truly better than minibatch SGD in some regimes but worse in others? Or, should we believe the intuitive argument suggesting that local SGD is always at least as good as minibatch SGD?
Bad News: Minibatch SGD Can Outperform Local SGD
In Section 3, we saw that when the objective is quadratic, local SGD is strictly better than minibatch SGD, and enjoys an error guarantee that depends only on and not or individually. In Section 4, we analyzed local SGD for general convex objectives and showed that local SGD sometimes outperforms minibatch SGD. However, we did not show that it always does, nor that it is always even competitive with minibatch SGD. We will now show that this is not simply a failure of our analysis—in a certain regime, local SGD really is inferior (in the worst-case) to minibatch SGD, and even to thumb-twiddling SGD. We show this by constructing a simple, smooth piecewise-quadratic objective in three dimensions, on which local SGD performs poorly. We define this hard instance as
For , there exists such that for any and , local SGD initialized at with any fixed stepsize, will output a point such that for a universal constant
In order to compare this lower bound with Theorem 2 and with minibatch SGD, we again consider the general convex setting with . Then, the lower bound reduces to . Comparing this to Theorem 2, we see that our upper bound is tight up to a factor of in the optimization term. Furthermore, comparing this to the worst-case error of minibatch SGD (9), we see that local SGD is indeed worse than minibatch SGD in the worst case when is small enough relative to . The cross-over point is somewhere between and ; for smaller , minibatch SGD is better than local SGD in the worst case, for larger , local SGD is better in the worst case. Since the optimization terms of minibatch SGD and thumb-twiddling SGD are identical, this further indicates that local SGD is even outperformed by thumb-twiddling SGD in the small and large regime.
Finally, it is interesting to note that in the strongly convex case (where ), the gap between local GD and minibatch SGD can be even more dramatic: In that case, the optimization term of minibatch SGD scales as (see Stich and references therein), while our theorem implies that local SGD cannot obtain a term better than . This implies an exponentially worse dependence on in that term, and a worse bound as long as .
In order to prove Theorem 3 we constructed an artificial, but easily analyzable, situation where we could prove analytically that local SGD is worse than mini-batch. In Figure 1, we also demonstrate the behaviour empirically on a logistic regression task, by plotting the suboptimality of local SGD, minibatch SGD, and thumb-twiddling SGD iterates with optimally tuned stepsizes. As is predicted by Theorem 3, we see local SGD goes from performing worse than minibatch in the small regime, but improving relative to the other algorithms as increases to and then , when local SGD is far superior to minibatch. For each fixed , increasing causes thumb-twiddling SGD to improve relative to minibatch SGD, but does not have a significant effect on local SGD, which is consistent with introducing a bias which depends on but not on . This highlights that the “problematic regime” for local SGD is where there are few iterations per round.
Future work
In this paper, we provided the first analysis of local SGD showing improvement over minibatch SGD in a natural setting, but also demonstrated that local SGD can sometimes be worse than minibatch SGD, and is certainly not optimal.
As can be seen from Table 1, our upper and lower bounds for local SGD are still not tight. The first term depends on versus —we believe the correct behaviour might be in between, namely , matching the bias of -step SGD. The exact worst case behaviour of local SGD is therefore not yet resolved.
But beyond obtaining a precise analysis of local SGD, our paper highlights a more important challenge: we see that local SGD is definitely not optimal, and does not even always improve over minibatch SGD. Can we suggest an optimal algorithm in this setting? Or at least a method that combines the advantages of both local SGD and minibatch SGD and enjoys guarantees that dominate both? Our work motivates developing such an algorithm, which might also have benefits in regimes where local SGD is already better than minibatch SGD.
To answer this question will require new upper bounds and perhaps also new lower bounds. Looking to the analysis of local AC-SA for quadratic objectives in Corollary 1, we might hope to design an algorithm which achieves error
for general convex objectives. That is, an algorithm which combines the optimization term for steps of accelerated gradient descent with the optimal statistical term. If this were possible, it would match the lower bound of Woodworth et al. and therefore be optimal with respect to this communication structure.
This work is partially supported by NSF-CCF/BSF award 1718970/2016741, NSF-DMS 1547396, and a Google Faculty Research Award. BW is supported by a Google PhD Fellowship. Part of this work was done while NS was visiting Google. Work by SS was done while visiting TTIC.
References
Appendix A Comparisons Between Existing Local SGD Analyses and Minibatch SGD
In this section, we describe the derivation of the entries in Table 1 for the cases in which it is not obvious. In particular, these previous analyses were stated based on different assumptions (stronger as well as weaker) which need to be reconciled with ours. Since local SGD is often analyzed in the strongly convex setting (or with weaker assumptions that are implied by strong convexity), we will make use of the following fact: If an algorithm guarantees error at most when applied to a -strongly convex function, then we can apply the algorithm to in order to ensure error . This applies for any , so we can actually infer that the algorithm, in fact, guarantees error at most .
Since our purpose is to show that these analyses are dominated by minibatch SGD, the entries in the table are, in some sense, the most optimistic interpretation of the bounds stated in the paper. For example, if error is guaranteed for strongly convex functions, we actually enter into the table, which is a lower bound on the actual guarantee.
For reference, we restate the worst-case guarantee of minibatch SGD:
A.2 Stich and Karimireddy [25]
A.3 Khaled et al. [13]
The relevant analysis from Khaled et al. is given in their Corollary 2, which is their only analysis that upper bounds the error in terms of the objective function suboptimality and in the setting where each machine receives i.i.d. stochastic gradients. Their Corollary 2 states that when , the error is bounded byThere is a typo in their statement which omits the factor of ( in their notation) from the numerator of the first term.
In the case where , it is clear that this is strictly worse than minibatch SGD since . However, consider the case of arbitrary , and and suppose Khaled et al. ’s guarantee is less than , in which case
Consequently, (20) is either greater than or greater than . This does not mean that their upper bound is worse than minibatch SGD. However, it is worse than minibatch SGD unless .
If we interrogate what this regime corresponds to, we see that it is actually a trivial regime where steps of serial SGD, which achieves error , is actually better than minibatch SGD. That is, rather than implementing minibatch SGD distributed across the machines, we are actually better off just ignoring of the available machines and doing serial SGD. If this is really the right thing to do, then there was never any need for parallelism in the first place, and thus there is no reason to use local SGD, which performs no better than serial SGD in this case anyways.
Appendix B Proofs from Section 3
We will show that the average of the iterates at any particular time evolves according to with a lower variance stochastic gradient, even though this average iterate is not explicitly computed by the algorithm at every step. It is easily confirmed from (6) that
where we used that is linear. We will now show that is an unbiased estimate of with variance bounded by . Therefore, is updated exactly according to with a lower variance stochastic gradient.
By the linearity of and
It is easily confirmed that SGD and AC-SA are linear update algorithms, which allows us to apply Theorem 1. In addition, Simchowitz shows that any randomized algorithm that accesses an deterministic first order oracle at most times will have error at least in the worst case for an -smooth, convex quadratic objective, for some universal constant . Therefore, the first term of local-AC-SA’s guarantee cannot be improved. The second term of the guarantee also cannot be improved —in fact, this term cannot be improved even by an algorithm which is allowed to make sequential calls to a stochastic gradient oracle. ∎
Appendix C Proof of Theorem 2
This proof is nearly identical to the proof of Lemma 3.1 due to Stich , and we claim no technical innovation here. We include it in order to be self-contained.
We begin by analyzing the distance of from the optimum. Below, expectations are taken over the all of the random variables which determine the iterates .
For any vectors , . In addition, for any point and -smooth , , thus
By the -strong convexity of , we have that
Finally, using the fact that for any vectors and any , we have
Combining these with (29), we conclude that for
By the convexity of and the fact that , this implies
We will proceed to bound the final term in Lemma 1 more tightly than was done by Stich , which allows us to improve on their upper bound. To do so, we will use the following technical lemmas:
For any -smooth and convex , and any , and
This proof follows closely from . Define the -smooth, convex functions
By setting the gradients of these convex functions equal to zero, it is clear that minimizes and minimizes . For any -smooth and convex , for any , , therefore,
This is the second claim of the Lemma, and combining these last two inequalities proves the first claim. ∎
Let be any -smooth and -strongly convex function, and let . Then for any
This Lemma and its proof are essentially identical to [12, Lemma 6], we include it here in order to keep our results self-contained, and we are more explicit about the steps used.
where the inequality follows from Lemma 2. Since , we further conclude that
Finally, by the -strong convexity of
First, we note that are identically distributed. Therefore,
Under the conditions of Lemma 1, with the additional condition that the sequence of stepsizes is non-increasing and for all , for any and any
If , then it further satisfies
for all and . In addition,
where for the final inequality we used Lemma 3 and the fact that the stepsizes are less than ,. Since the iterates are averaged every iterations, for each , there must be a with such that . Therefore, we can unroll the recurrence above to conclude that
In the special case , we have
Next, we show that Local SGD is always at least as good as steps of sequential SGD. To do so, we use the following result from Stich :
with , there exists a sequence and weights such that
We now argue that Local SGD is never worse than steps of sequential SGD:
Let . When , an appropriate average of the iterates of Local SGD with an optimally tuned constant stepsize satisfies for a universal constant
In the case , then an appropriate average of the iterates of Local SGD with decreasing stepsize satisfies for a universal constant
Define and consider the st iterate on some machine , . If , then . In this case, for
Here, for the first inequality we used the variance bound on the stochastic gradients; for the second inequality we used the -smoothness and -strong convexity of ; and for the final inequality we used that and rearranged.
If, on the other hand, , then . Since the local iterates on the different machines are identically distributed,
Where for the first inequality we used Jensen’s inequality, and for the final equality we used that the local iterates are identically distributed. From here, using the same computation as above, we conclude that in either case
Choose a constant learning rate and define the averaged iterate
The stepsizes and weights are chosen as follows: If , then and . If and , then and . If and , then and . This completes the proof. ∎
Finally, we prove our main analysis of Local SGD. Portions of the analysis of the strongly convex case follow closely the proof of [24, Lemma 3]. See 2
We will prove the first terms in the ’s in Theorem in two parts, first for the convex case , then for the strongly convex case . Then, we conclude by invoking Lemma 7 showing that Local SGD is never worse than steps of SGD on a single machine, which corresponds to the second terms in the ’s in the Theorem statement.
By Lemma 1 and the first claim of Lemma 5, the mean iterate satisfies
Consider a fixed stepsize which will be chosen later, and consider the average of the iterates
For the strongly convex case, following Stich ’s proof of Lemma 6, we choose stepsizes according to the following set of cases: If , then and . If and , then and . If and , then and . We note that in the second and third cases, the stepsize is either constant or equal to (for ) within each individual round of communication.
By Lemma 1 and the first claim of Lemma 5, during the rounds of communication for which the stepsize is constant, we have the recurrence:
On the other hand, during the rounds of communication in which the stepsize is decreasing, we have by Lemma 1 and the second claim of Lemma 5 that:
Furthermore, during the rounds (i.e. when ) where the stepsize is decreasing,
First, suppose , and consider the steps during which :
Now, consider the remaining steps. Rearranging, we have
So, since where and , we have
Finally, we recall (102), , and note that thus
This concludes the proof for the case .
If , we use the constant stepsize and weights . Rearranging (94) therefore gives
Finally, we note that so
We also observe that so with we have
Appendix D Proofs from Section 5
Here, we will prove the lower bound in Theorem 3. Recall the objective and stochastic gradient estimator for the hard instance are defined by
Due to the structure of the objective (120), which decomposes as a sum over three terms which each depend only on a single coordinate, the local-SGD dynamics on each coordinate of the optimization variable are independent of each other. For this reason, we are able to analyze local-SGD on each coordinate separately.
Define the -smooth and -strongly convex function
Define a stochastic gradient estimator for via
for . Observe that the third coordinate of local-SGD on evolves exactly the same as local-SGD on the univariate function . In the next three lemmas, we analyze the behavior of local-SGD on :
Consider the nd iterate of SGD with fixed stepsize :
Define , then
Now, consider the third iterate of SGD, :
Since is convex, by Jensen’s inequality
The idea of this proof is simple: steps of SGD initialized at some point is equivalent to doing two steps of SGD initialized at to get , then doing two more steps initialized at to get , and so forth until steps have been completed. The only minor complication is if is odd, in which case we start by doing three steps initialized at to get and continue in steps of two.
Let and let be the output of local-SGD on using a fixed stepsize and initialized at zero. Then
Since each coordinate evolves independently when optimizing using local-SGD, we can ignore the first two coordinates and focus only on the third. Observe that using local-SGD on with a fixed stepsize and initialized at zero to obtain is exactly equivalent to using local-SGD on with the same fixed stepsize and initialized at . The different initialization is due to the fact that the local-SGD dynamics do not change with the change of variables . Let denote the averaged iterate of local-SGD initialized at with stepsize after the th round of communication and let denote its th iterate during the th round of communication on the th machine. We will start by proving that when and either or then
Repeatedly applying Lemma 9 shows that for each
Again, we can repeatedly apply Lemma 9 to show
We now analyze the progress of SGD on the first two coordinates of in the following lemma:
Let be the output of local-SGD on using a fixed stepsize and initialized at zero. Then with probability 1,
Since the stochastic gradient estimator has no noise along the first and second coordinates, and since the separate coordinates evolve independently, is exactly the output of steps of deterministic gradient descent with fixed stepsize on the univariate function . Similarly, is the output of steps of deterministic gradient descent with fixed stepsize on . Thus,
Combining Lemmas 10 and 11, we are ready to prove the theorem: See 3
Consider optimizing the objective defined in (120) using the stochastic gradient oracle (121) initialized at zero and using a fixed stepsize . The variance of the stochastic gradient oracle is equal to . This function is -smooth, and -strongly convex. We will be choosing and so that is -smooth and -strongly convex. Finally, the objective is minimized at the point and . This point has norm we will choose so that .
By Lemma 10, the output of local-SGD, satisfies
By Lemma 11, the output of local-SGD, satisfies
Consider two cases: first, suppose that . Then,
Suppose instead that . Since , . Similarly, since , . Therefore, implies
This statement holds for any . Consider three cases: first, suppose . Then
Consider next the case that and choose . Then
Finally, consider the case that and choose . Then,
Combining these cases completes the proof. ∎