L OCAL SGD C ONVERGES F AST AND C OMMUNICATES L ITTLE
A BSTRACT
Mini-batch stochastic gradient descent (SGD) is state of the art in large scale distributed training.
The scheme can reach a linear speedup with respect to the number of workers, but this is rarely seen in practice as the scheme often suffers from large network delays and bandwidth limits.
To overcome this communication bottleneck recent works propose to reduce the communication frequency.
An algorithm of this type is local SGD that runs SGD independently in parallel on different workers and averages the sequences only once in a while.
This scheme shows promising results in practice, but eluded thorough theoretical analysis.
We prove concise convergence rates for local SGD on convex problems and show that it converges at the same rate as mini-batch SGD in terms of number of evaluated gradients, that is, the scheme achieves linear speedup in the number of workers and mini-batch size.
The number of communication rounds can be reduced up to a factor of T 1 / 2 —where T denotes the number of total steps—compared to mini-batch SGD.
This also holds for asynchronous implementations.
Local SGD can also be used for large scale training of deep learning models.
The results shown here aim serving as a guideline to further explore the theoretical and practical aspects of local SGD in these applications.
I NTRODUCTION
Stochastic Gradient Descent (SGD) (Robbins & Monro, 1951) consists of iterations of the form
[Equation]
[Equation] ) for iterates (weights) x t , x t +1 ∈ R d , stepsize (learning rate) η t > 0 , and stochastic gradient g t ∈ R d with the property E g t = ∇ f ( x t ) , for a loss function f : R d → R .
This scheme can easily be parallelized by replacing g t in (1) by an average of stochastic gradients that are independently computed in parallel on separate workers ( parallel SGD ).
This simple scheme has a major drawback: in each iteration the results of the computations on the workers have to be shared with the other workers to compute the next iterate x t +1 .
Communication has been reported to be a major bottleneck for many large scale deep learning applications, see e.g. (Seide et al., 2014;
Alistarh et al., 2017;
Zhang et al., 2017; Lin et al., 2018b).
Mini-batch parallel SGD addresses this issue by increasing the compute to communication ratio.
Each worker computes a mini-batch of size b before communication.
This scheme is implemented in state-of-the-art distributed deep learning frameworks (Abadi et al., 2016; Paszke et al., 2017; Seide & Agarwal, 2016).
Recent work in (You et al., 2017; Goyal et al., 2017) explores various limitations of this approach, as in general it is reported that performance degrades for too large mini-batch sizes (Keskar et al., 2016; Ma et al., 2018;
Yin et al., 2018).
In this work we follow an orthogonal approach, still with the goal to increase the compute to communication ratio: Instead of increasing the mini-batch size, we reduce the communication frequency.
Rather than keeping the sequences on different machines in sync, we allow them to evolve locally on each machine, independent from each other, and only average the sequences once in a while ( local SGD ).
Such strategies have been explored widely in the literature, under various names.
An extreme instance of this concept is one-shot SGD (McDonald et al., 2009; Zinkevich et al., 2010) where the local sequences are only exchanged once, after the local runs have converged.
Zhang
116 communication overhead b=1, H=
perfect speedup     116 communication overhead gain b=1, H=1 b=2, H=
b=1, H=2 b=2,
H= perform
The question of how often communication rounds need to be initiated has eluded a concise theoretical answer so far.
Whilst there is practical evidence, the theory does not even resolve the question whether averaging helps when optimizing convex functions.
Concretely, whether running local SGD on K workers is K times faster than running just a single instance of SGD on one worker.
We ﬁll this gap in the literature and provide a concise convergence analysis of local SGD.
We show that averaging helps.
Frequent synchronization of K local sequences increases the convergence rate by a factor of K , i.e. a linear speedup can be attained.
Thus, local SGD is as efﬁcient as parallel mini-batch SGD in terms of computation, but the communication cost can be drastically reduced.
1. C ONTRIBUTIONS
We consider ﬁnite-sum convex optimization problems f : R d → R of the form
[Equation]
where f is L -smooth 2 and µ -strongly convex 3 .
We consider K parallel mini-batch SGD sequences with mini-batch size b that are synchronized (by averaging) after at most every H iterations.
For appropriate chosen stepsizes and an averaged iterate ˆ x T after T steps (for T sufﬁciently large, see Section 3 below for the precise statement of the convergence result with bias and variance terms) and synchronization delay H
= O ( (cid:112)
T/ ( Kb ))
we show convergence
[Equation]
with second moment bound G 2 ≥ E (cid:107)∇ f i ( x ) (cid:107) 2 .
Thus, we see that compared to parallel minibatch SGD the communication rounds can be reduced by a factor
H =
O ( (cid:112)
T/ ( Kb )) without hampering the asymptotic convergence.
Equation (3) shows perfect linear speedup in terms of computation, but with much less communication that mini-batch SGD.
The resulting speedup when taking communication cost into account is illustrated in Figure 1 (see also Section D below).
Under the assumption that (3) is tight, one has thus now two strategies to improve the compute to communication ratio (denoted by ρ ): (i) either to increase the mini-batch size b or (ii) to increase the communication interval H .
Both strategies give the same improvement when b and H are small (linear speedup).
Like mini-batch SGD that faces some limitations for b (cid:29) 1 (as discussed in e.g. (Dekel et al., 2012; Ma et al., 2018; Yin et al., 2018)), the parameter H cannot be chosen too large in local SGD.
We give some pratical guidelines in Section
[Equation] Our proof is simple and straightforward, and we imagine that—with slight modiﬁcations of the proof—the technique can also be used to analyze other variants of SGD that evolve sequences on [Equation] different worker that are not perfectly synchronized.
Although we do not yet provide convergence guarantees for the non-convex setting, we feel that the positive results presented here will spark further investigation of local SGD for this important application (see e.g. (Yu et al., 2018)).
1. R ELATED W ORK
A parallel line of work reduces the communication cost by compressing the stochastic gradients before communication.
For instance, by limiting the number of bits in the ﬂoating point representation (Gupta et al., 2015; Na et al., 2017; Sa et al., 2015), or random quantization (Alistarh et al., 2017; Wen et al., 2017).
The ZipML framework applies this technique also to the data (Zhang et al., 2017).
Sparsiﬁcation methods reduce the number of non-zero entries in the stochastic gradient (Alistarh et al., 2017; Wangni et al., 2017).
A very aggressive—and promising—sparsiﬁcation method is to keep only very few coordinates of the stochastic gradient by considering only the coordinates with the largest magnitudes (Seide et al., 2014; Strom, 2015; Dryden et al., 2016; Aji & Heaﬁeld, 2017;
Sun et al., 2017; Lin et al., 2018b; Stich et al., 2018).
Allowing asynchronous updates provides an alternative solution to disguise the communication overhead to a certain amount (Niu et al., 2011; Sa et al., 2015; Lian et al., 2015), though alternative strategies might be better when high accuracy is desired (Chen et al., 2016).
The analysis of Agarwal & Duchi (2011) shows that asynchronous SGD on convex functions can tolerated delays up to O ( (cid:112) T/K ) , which is identical to the maximal length of the local sequences in local SGD.
Asynchronous SGD converges also for larger delays (see also (Zhou et al., 2018))
but without linear speedup, a similar statement holds for local SGD (see discussion in Section 3).
The current frameworks for the analysis of asynchronous SGD do not cover local SGD.
A fundamental difference is that asynchronous SGD maintains a (almost) synchronized sequence and gradients are computed with respect this unique sequence (but just applied with delays), whereas each worker in local SGD evolves a different sequence and computes gradient with respect those iterates.
For the training of deep neural networks, Bijral et al.
(2016) discuss a stochastic averaging schedule whereas Zhang et al.
(2016) study local SGD with more frequent communication at the beginning of the optimization process.
The elastic averaging technique (Zhang et al., 2015) is different to local
SGD, as it uses the average of the iterates only to guide the local sequences but does not perform a hard reset after averaging.
Among the ﬁrst theoretical studies of local SGD in the non-convex setting are (Coppola, 2015; Zhou & Cong, 2018) that did not establish a speedup, in contrast to two more recent analyses (Yu et al., 2018; Wang & Joshi, 2018).
Yu et al.
(2018) show linear speedup of local
SGD on non-convex functions for H
= O ( T 1 / 4 K − 3 / 4 ) , which is more restrictive than the constraint on H in the convex setting.
Lin et al.
(2018a) study empirically hierarchical variants of local SGD.
Local SGD with averaging in every step, i.e. H = 1 , is identical to mini-batch SGD.
Dekel et al.
(2012) show that batch sizes b
= T δ , for δ ∈ (0 , 12 ) are asymptotically optimal for mini-batch SGD, however they also note that this asymptotic bound might be crude for practical purposes.
Similar considerations might also apply to the asymptotic upper bounds on the communication frequency H derived here.
Local SGD with averaging only at the end, i.e. H = T , is identical to one-shot SGD. Jain et al. (2018) give concise speedup results in terms of bias and variance for one-shot SGD with constant stepsizes for the optimization of quadratic least squares problems. In contrast, our upper bounds become loose when H → T and our results do not cover one-shot SGD.
Recently, Woodworth et al.
(2018) provided a lower bound for parallel stochastic optimization (in the convex setting, and not for strongly convex functions as considered here).
The bound is not known to be tight for local SGD.
1. O UTLINE
We formally introduce local SGD in Section 2 and sketch the convergence proof in Section 3.
In
Section 4 show numerical results to illustrate the result.
We analyze asynchronous local SGD in
Section 5.
The proof of the technical results, further discussion about the experimental setup and implementation guidelines are deferred to the appendix.
{+1: Initialize variables x k 
+}
=
x 0 for k ∈ [ K ] 2: for t in 0 . . .
T − 1 do 3: parallel for k ∈ [ K ] do 4:
Sample i kt uniformly in [ n ] 5: if t + 1 ∈ I T then 6: x kt +1 ← 1 K (cid:80) Kk =1 x kt (cid:46) global synchronization 7: else 8: x kt +1 ← x kt − η t ∇ f i t ( x kt ) (cid:46) local update 9: end if 10: end parallel for 11: end for  L OCAL SGD
The algorithm local SGD (depicted in Algorithm 1) generates in parallel K sequences { x kt } Tt =0 of iterates, k ∈
[ K ] .
Here K denotes the level of parallelization, i.e. the number of distinct parallel sequences and T the number of steps (i.e. the total number of stochastic gradient evaluations is TK ).
Let I T ⊆
[ T ] with T ∈ I T denote a set of synchronization indices .
Then local SGD evolves the sequences { x kt } Tt =
in the following way:
[Equation]
where indices i kt ∼ u .
a .
r .
[ n ] and { η t } t ≥ 0 denotes a sequence of stepsizes.
If I T =
[ T ] then the synchronization of the sequences is performed every iteration.
In this case, (4) amounts to parallel or mini-batch SGD with mini-batch size K .
On the other extreme, if I T = { T } , the synchronization only happens at the end, which is known as one-shot averaging .[-1: Initialize variables x k 
 =-]
In order to measure the longest interval between subsequent synchronization steps, we introduce the gap of a set of integers.
Deﬁnition 2.1 (gap) .
The gap of a set P := { p 0 , . .
. , p t } of t + 1 integers, p i ≤ p i +1 for i = 0 , . . .
, t − 1 , is deﬁned as gap( P ) :
= max i =1 ,...,t ( p i − p
i − 1 ) .
2. V ARIANCE REDUCTION IN LOCAL SGD
Before jumping to the convergence result, we ﬁrst discuss an important observation.
Parallel (mini-batch) SGD.
For carefully chosen stepsizes η t , SGD converges at rate O (cid:0) σ 2 T (cid:1) 5 on strongly convex and smooth functions f , where σ 2 ≥ E (cid:107)∇ f i kt ( x kt )
− ∇ f ( x kt ) (cid:107) 2 for t > 0 , k ∈
[ K ] is an upper bound on the variance, see for instance (Zhao & Zhang, 2015).
By averaging K stochastic gradients—such as in parallel SGD—the variance decreases by a factor of K , and we conclude that parallel SGD converges at a rate O (cid:0) σ 2 TK (cid:1) , i.e. achieves a linear speedup.
Towards local SGD.
For local SGD such a simple argument is elusive.
For instance, just capitalizing the convexity of the objective function f is not enough: this will show that the averaged iterate of
K independent SGD sequences converges at rate O (cid:0) σ 2 T (cid:1) , i.e. no speedup can be shown in this way.
This indicates that one has to show that local SGD decreases the variance σ 2 instead, similar as in parallel SGD.
Suppose the different sequences x kt evolve close to each other.
Then it is reasonable to assume that averaging the stochastic gradients ∇ f i k t ( x k t ) for all k ∈
[ K ] can still yield a reduction in the variance by a factor of K —similar as in parallel SGD.
Indeed, we will make this statement precise in the proof below.
2. C ONVERGENCE R ESULT AND D ISCUSSION
Theorem 2.2.
Let f be L -smooth and µ -strongly convex, E i (cid:13)(cid:13) ∇ f i ( x kt ) − ∇ f ( x kt ) (cid:13)(cid:13) 2 ≤ σ 2 ,
E i (cid:13)(cid:13) ∇ f i ( x kt )
(cid:13)(cid:13) 2 ≤ G 2 , for t = 0 , . . .
, T − 1 , where { x kt } Tt =0 for k ∈
[ K ] are generated according to (4) with gap( I T ) ≤ H and for stepsizes η t = 4 µ ( a + t ) with shift parameter a > max { 16 κ, H } , for κ = Lµ .
Then
[Equation]
where ˆ x T = 1 KS T (cid:80) Kk =
[Equation]
(cid:80) [Equation] [Equation] =
w t x kt , for w t
=
( a + t ) 2 and S T =
(cid:80) T {+− 1 t =
+}
w t ≥ 13 T 3 .
We were not especially careful to optimize the constants (and the lower order terms) in (5), so we now state the asymptotic result.
Corollary 2.3.
Let ˆ x T be as deﬁned as in Theorem 2.2, for parameter a = max { 16 κ, H } .
Then
[Equation]
For the last estimate we used E µ (cid:107) x 0 − x (cid:63) (cid:107) ≤ 2 G for µ -strongly convex f , as derived in (Rakhlin et al., 2012, Lemma 2).
Remark 2.4 (Mini-batch local SGD) .
So far, we assumed that each worker only computes a single stochastic gradient.
In mini-batch local SGD, each worker computes a mini-batch of size b in each iteration.
This reduces the variance by a factor of b , and thus Theorem (2.2) gives the convergence rate of mini-batch local SGD when σ 2 is replaced by σ 2 b .
We now state some consequences of equation (6).
For the ease of the exposition we omit the dependency on L , µ , σ 2 and G 2 below, but depict the dependency on the local mini-batch size b .
Convergence rate.
For T large enough and assuming σ > 0 , the very ﬁrst term is dominating in (6) and local SGD converges at rate O
(1 / ( KTb )) .
That is, local SGD achieves a linear speedup in both, the number of workers K and the mini-batch size b .
Global synchronization steps.
It needs to hold H
= O ( (cid:112)
T/ ( Kb ))
to get the linear speedup.
This yields a reduction of the number of communication rounds by a factor O ( (cid:112)
T/ ( Kb ))
compared to parallel mini-batch SGD without hurting the convergence rate.
Extreme Cases.
We have not optimized the result for extreme settings of H , K , L or σ .
For instance, we do not recover convergence for the one-shot averaging, i.e. the setting H =
T (though convergence for H
= o ( T ) , but at a lower rate).
Unknown Time Horizon/Adaptive Communication Frequency Zhang et al.
(2016) empirically observe that more frequent communication at the beginning of the optimization can help to get faster time-to-accuracy (see also Lin et al. (2018a)).
Indeed, when the number of total iterations T is not known beforehand (as it e.g. depends on the target accuracy, cf.
(6) and also Sectionbelow), then increasing the communication frequency seems to be a good strategy to keep the communication low, why still respecting the constraint H
= O ( (cid:112)
T/ ( Kb )) for all T .
P ROOF O UTLINE
We now give the outline of the proof.
The proofs of the lemmas are given in Appendix A.
Perturbed iterate analysis.
Inspired by the perturbed iterate framework of (Mania et al., 2017)
we ﬁrst deﬁne a virtual sequence { ¯ x t } t ≥ 0 in the following way:
[Equation]
where the sequences { x kt } t ≥ 0 for k ∈ [ K ] are the same as in (4).
Notice that this sequence never has to be computed explicitly, it is just a tool that we use in the analysis.
Further notice that ¯ x t = x kt for k ∈
[ K ] whenever t ∈ I T .
Especially, when I T =
[ T ] , then ¯ x t ≡ x kt for every k ∈ [ K ] , t ∈
[ T ] .
It will be useful to deﬁne
[Equation]
Observe ¯ x t +
=
¯ x t − η t g t and E g t = ¯ g t .
Now the proof proceeds as follows: we show (i) that the virtual sequence { ¯ x t } t ≥ 0 almost behaves like mini-batch SGD with batch size K (Lemma 3.1 and 3.2), and (ii) the true iterates { x kt } t ≥ 0 ,k ∈
[ K ] do not deviate much from the virtual sequence (Lemma 3.3).
These are the main ingredients in the proof.
To obtain the rate we exploit a technical lemma from (Stich et al., 2018).
Lemma 3.1.
Let { x t } t ≥ 0 and { ¯ x t } t ≥ 0 for k ∈ [ K ] be deﬁned as in (4) and (7) and let f be L -smooth and µ -strongly convex and η t ≤ 14 L .
Then
[Equation]
Bounding the variance.
From equation (9) it becomes clear that we should derive an upper bound on E (cid:107) g t − ¯ g t (cid:107) 2 .
We will relate this to the variance σ 2 .
Lemma 3.2.
Let σ 2 ≥ E i (cid:107)∇ f i ( x kt ) − ∇ f ( x kt ) (cid:107) 2 for k ∈
[ K ] , t ∈ [ T ] .
Then E (cid:107) g
t − ¯ g t (cid:107) 2 ≤ σ 2 K .
Bounding the deviation.
Further, we need to bound 1 K (cid:80)
Kk =1 E (cid:13)(cid:13)
¯ x t − x kt (cid:13)(cid:13) 2 .
For this we impose a condition on I T and an additional condition on the stepsize η t .
Lemma 3.3.
If gap( I T ) ≤ H and sequence of decreasing positive stepsizes { η t } t ≥ 0 satisfying η t ≤ 2 η t + H for all t ≥ 0 , then
[Equation]
where G 2 is a constant
such that E i (cid:107)∇ f i ( x kt ) (cid:107) 2 ≤ G 2 for k ∈ [ K ] , t ∈ [ T ] .
Optimal Averaging.
Similar as in (Lacoste-Julien et al., 2012; Shamir & Zhang, 2013;
Rakhlin et al., 2012)
we deﬁne a suitable averaging scheme for the iterates { ¯ x t } t ≥ 0 to get the optimal convergence rate.
In contrast to (Lacoste-Julien et al., 2012) that use linearly increasing weights, we use quadratically increasing weights, as for instance (Shamir & Zhang, 2013; Stich et al., 2018).
Lemma 3.4 ((Stich et al., 2018)) .
Let { a t } t ≥ 0 , a t ≥ 0 , { e t } t ≥ 0 , e t ≥ 0 be sequences satisfying
[Equation]
B + η 3 t C ,
[Equation]
11) for η t = 4 µ ( a + t ) and constants A > 0 , B, C ≥ 0 , µ > 0 , a > 1 .
Then
[Equation]
[Equation]
for w t = ( a + t ) 2 and S T : = (cid:80) T − 1 t [-=
-]=0 w t =
T 6 (cid:0) 2 T 2 + 6 aT − 3 T + 6 a 2 − 6 a + 1 (cid:1) ≥ 13 T 3 .
Proof.
This is a reformulation of Lemma 3.3 in (Stich et al., 2018).
Proof of Theorem 2.2.
By convexity of f we have E f (ˆ x T ) − f (cid:63) ≤ 1 S T (cid:80) T − 1 t =
w t E (cid:0) f
(¯ x t ) − f (cid:63) (cid:1) .
The proof of the theorem thus follows immediately from the four lemmas that we have presented, i.e. by Lemma 3.4 with e t := E ( f (¯ x t ) − f (cid:63) ) and constants A = 12 , (Lemma 3.1), B = σ 2 K , (Lemma 3.2) and C = 8 G 2 H 2 L , (Lemma 3.3).
Observe that the stepsizes η t = 4 µ ( a + t ) satisfy both the conditions of Lemma 3.1 ( η 0 = 4 µa ≤ 14 L , as a ≥ 16 κ ) and of Lemma 3.3 (cid:0) η t η t
+ H = a + t + H
a + t ≤ 2 , as a ≥ H (cid:1) .
(cid:3)
[Figure]
[Figure]
N UMERICAL I LLUSTRATION
In this section we show some numerical experiments to illustrate the results of Theorem 2.2.
Speedup.
When Algorithm 1 is implemented in a distributed setting, there are two components that determine the wall-clock time: (i) the total number of gradient computations, TK , and (ii) the total time spend for communication.
In each communication round 2( K − 1) vectors need to be exchanged, and there will be T/H communication rounds.
Typically, the communication is more expensive than a single gradient computation.
We will denote this ratio by a factor ρ ≥ 1 (in practice, ρ can be 10–100, or even larger on slow networks).
The parameter T depends on the desired accuracy (cid:15) > 0 , and according to (6) we roughly have T ( (cid:15), H, K )
≈ 1 K(cid:15)[-(cid:16) 
-]
[Equation]
Thus, the theoretical speedup S ( K ) of local SGD on K machines compared to SGD on one machine ( H = 1 , K = 1 ) is
[Equation]
Theoretical.
Examining (13), we see that (i) increasing H can reduce negative scaling effects due to parallelization (second bracket in the denominator of (13)), and (ii) local SGD only shows linear scaling for (cid:15) (cid:28) 1 (i.e. T large enough, in agreement with the theory).
In Figure 2 we depict S ( K ) , once for (cid:15) = 0 in Figure 2b, and for positive (cid:15) > 0 in Figure 2a under the assumption ρ = 25 .
We see that for (cid:15) =
the largest values of H give the best speedup, however, when only a few epochs need to be performed, then the optimal values of H change with the number of workers K .
We also see that for a small number of workers H = 1 is never optimal.
If T is unknown, then these observations seem to indicate that the technique from (Zhang et al., 2016), i.e. adaptively increasing H over time seems to be a good strategy to get the best choice of H when the time horizon is unknown.
Experimental.
We examine the practical speedup on a logistic regression problem, f ( x ) =n (cid:80) ni =
[Equation] log(1 + [Equation] x ))
+ [Equation] 2 (cid:107) x (cid:107) 2 , where a i ∈ R d and b i ∈ {− 1 , +1 } are the data samples.
The regularization parameter is set to λ = 1 /n .
We consider the w8a dataset (Platt, 1999)
( d = 300 , n = 49749 ).
We initialize all runs with x 0 =
d
and measure the number of iterations to reach the target accuracy (cid:15) .
We consider the target accuracy reached, when either the last iterate, the uniform average, the average with linear weights, or the average with quadratic weights (such as in Theorem 2.2) reaches the target accuracy.
By extensive grid search we determine for each conﬁguration ( H, K, B ) the best stepsize from the set { min(32 , cnt +1 ) , 32 c } , where c can take the values c
= 2 i for i
∈ Z .
For more details on the experimental setup refer Section D in the appendix.
We depict the results in Figure 3, again under the assumption ρ = 25 . do 4: (cid:46) 11: end
Conclusion.
The restriction on H imposed by theory is not severe for T → ∞ .
Thus, for training that either requires many passes over the data or that is performed only on a small cluster, large values of H are advisable.
However, for smaller T (few passes over the data), the O (1 / √ K ) dependency shows signiﬁcantly in the experiment.
This has to be taken into account when deploying the algorithm on a massively parallel system, for instance through the technique mentioned in (Zhang et al., 2016).
A SYNCHRONOUS L OCAL SGD
In this section we present asynchronous local SGD that does not require that the local sequences are synchronized.
This does not only reduce communication bottlenecks, but by using load-balancing techniques the algorithm can optimally be tuned to heterogeneous settings (slower workers do less computation between synchronization, and faster workers do more).
We will discuss this in more detail in Section C.
Asynchronous local SGD generates in parallel K sequences { x kt } Tt =0 of iterates, k ∈
[ K ] .
Similar as in Section 2 we introduce sets of synchronization indices, I kt ⊆
[ T ] with T ∈ I kT for k ∈ [ K ] .
Note that the sets do not have to be equal for different workers.
Each worker k evolves locally a sequence x kt in the following way:
[Equation]
where ¯¯ x kt +1 denotes the state of the aggregated variable at the time when worker k reads the aggregated variable.
To be precise, we use the notation
[Equation]
where W k,h t ⊆
[ T ] denotes all updates that have been written at the time the read takes place.
The sets W k,ht are indexed by iteration t , worker k that initiates the read and h ∈ [ K ] .
Thus W k,ht denotes all updates of the local sequence { x ht } t ≥ 0 , that have been reported back to the server at the time worker k reads (in iteration t ).
This notation is necessary, as we don’t necessarily have
W k,ht = W k (cid:48) ,h t for k (cid:54) =
k (cid:48) .
We have W k,ht ⊆ W k,ht (cid:48) for t (cid:48) ≥ t , as updates are not overwritten.
When we cast synchronized local SGD in this notation, then it holds W k,ht
[Equation]
for all k, h, k (cid:48) , h (cid:48) , as all the writes and reads are synchronized.
Theorem 5.1.
Let f , σ , G and κ be as in Theorem 5.1 and sequences { x kt } Tt =0 for k ∈ [ K ] generated according to (14) with gap( I kT ) ≤ H for k ∈ K and for stepsizes η t = 4 µ ( a + t ) with shift parameter a > max { 16 κ, H + τ } .
If there exists τ > 0 , s.t. W k,ht ⊇ [ t − τ ] for all k, h ∈ [ K ] , t ∈ [ T ] , then
[Equation]
where ˆ x T =
[-Kk =1 (cid:80) T − 1 t =0 w t x kt , for w t = ( a + t ) 2 and S T = (cid:80) T − 1 t =
 w t ≥ 13 T 3 .-][Equation]
Hence, for T large enough and ( H + τ ) =
O ( (cid:112) T/K ) , asynchronous local SGD converges with rate
O (cid:0) G 2 KT (cid:1) , the same rate as synchronous local SGD.
C ONCLUSION
We prove convergence of synchronous and asynchronous local SGD and are the ﬁrst to show that local SGD (for nontrivial values of H ) attains theoretically linear speedup on strongly convex functions when parallelized among K workers.
We show that local SGD saves up to a factor of O ( T 1 / 2 ) in global communication rounds compared to mini-batch SGD, while still converging at the same rate in terms of total stochastic gradient computations.
Deriving more concise convergence rates for local SGD could be an interesting future direction that could deepen our understanding of the scheme. For instance one could aim for a more ﬁne grained analysis in terms of bias and variance terms (similar as e.g. in Dekel et al.
(2012); Jain et al.
(2018)), relaxing the assumptions (here we relied on the bounded gradient assumption), or investigating the data dependence (e.g. by considering data-depentent measures like e.g. gradient diversity Yin et al.
There are also no apparent reasons that would limit the extension of the theory to non-convex objective functions; Lemma 3.3 does neither use the smoothness nor the strong convexity assumption, so this can be applied in the non-convex setting as well.
We feel that the positive results shown here can motivate and spark further research on non-convex problems.
Indeed, very recent work (Zhou &
Cong, 2018; Yu et al., 2018) analyzes local SGD for non-convex optimization problems and shows convergence of SGD to a stationary point, though the restrictions on H are stronger than here. A CKNOWLEDGMENTS
The author thanks Jean-Baptiste Cordonnier, Tao Lin and Kumar Kshitij Patel for spotting various typos in the ﬁrst versions of this manuscript, as well as Martin Jaggi for his support.
A M ISSING P ROOFS FOR S YNCHRONIZED L OCAL SGD
In this section we provide the proofs for the three lemmas that were introduced in Section
[Equation]
Proof of Lemma 3.1.
Using the update equation (7) we have
[Equation]
Observe that
[Equation]
where we used the inequality (cid:107) (cid:80) Ki
=
a i (cid:107) 2 ≤ K (cid:80) Ki
=1 (cid:107) a i (cid:107) 2 in (21).
By L -smoothness,
[Equation] [Equation]
and by µ -strong convexity
[Equation] [Equation]
To estimate the last term in (22) we use 2 (cid:104) a , b (cid:105) ≤ γ (cid:107) a (cid:107) 2 + γ − 1 (cid:107) b (cid:107) 2 , for γ > 0 .
This gives
[Equation]
where we have again used (23) in the last inequality.
By applying these three estimates to (22) we get
[Equation]
[Equation]
For η t ≤ 14 L it holds (cid:0) η t L − 12 (cid:1) ≤ − 14 .
By convexity of a ( f ( x ) − f (cid:63) ) +
[Equation]
[Table]
[Equation]
[Equation]
hence we can continue in (28) and obtain
[Equation]
Finally [Equation] we can plug (30) back into (18).
By taking expectation we get
[Equation]
Proof of Lemma 3.2.
By deﬁnition of g t and ¯ g t we have
[Equation]
where we used Var( (cid:80)
Kk =1 X k ) =
(cid:80)
Kk =1 Var( X k ) for independent random variables.
Proof of Lemma 3.3.
As the gap( I T ) ≤ H , there is an index t 0 , t − t 0 ≤ H such that ¯ x t
= x kt 0 for k ∈ [ K ] .
Observe, using E (cid:107) X − E X
(cid:107)
= E (cid:107) X (cid:107) 2 − (cid:107) E X (cid:107) 2 and (cid:107) (cid:80)
Hi[-=
-]
[Equation] [Equation] i (cid:107)
[Equation]
(cid:80)
Hi
[Equation]
1 (cid:107)
[Equation]
i (cid:107)
[Equation]
where we used η t ≤ η t 0 for t ≥ t 0 and the assumption E (cid:107)∇ f i kh ( x kh ) (cid:107) 2 ≤ G 2 .
Finally, the claim follows by the assumption on the stepsizes, η t 0 η t ≤ 2 .
B M ISSING P ROOF FOR A SYNCHRONOUS L OCAL SGD
In this Section we prove Theorem 5.1.
The proof follows closely the proof presented in Section 3.
We again introduce the virtual sequence
[Equation] [Equation]
as before.
By the property T ∈ I k T for k ∈ K we know that all workers will have written their updates when the algorithm terminates.
This assumption is not very critical and could be relaxed, but it facilitates the (already quite heavy) notation in the proof.
Observe, that Lemmas 3.1 and 3.2 hold for the virtual sequence { ¯ x t } Tt =0 .
Hence, all we need is a reﬁned version of Lemma 3.3 that bounds how far the local sequences can deviate from the virtual average.
Lemma B.1.
If gap( I kT ) ≤ H and ∃ τ > 0 , s.t. W k,ht ⊇ [ t − τ ] for all k, h ∈ [ K ] , t ∈ [ T ] , and sequence of decreasing positive stepsizes { η t } t ≥ 0 satisfying η t ≤ 2 η t
+ H + τ for all t ≥ 0 , then
[Equation]
) where G 2 is a constant such that E i (cid:107)∇ f i ( x kt ) (cid:107) 2 ≤ G 2 for k ∈ [ K ] , t ∈ [ T ] .
Here we use the notation [ s ] = {} for s < 0 , such that [ t − τ ] is also deﬁned for t < τ .
Proof.
As gap( I kT ) ≤ H there exists for every k ∈ K a t k , t − t k ≤ H , such that x kt k = ¯¯
x kt k .
Let t 0 :
= min { t 1 , . .
. , t K } and observe t 0 ≥ t − H .
Let t (cid:48)
= max { t 0 − τ, 0 } .
As W k,ht ⊇ [ t − τ ] for all k, h ∈ [ K ] , t ∈ [ T ] , it holds
[Equation]
for each k ∈ [ K ] .
In other words, all updates up to iteration t (cid:48) 0 have been written to the aggregated sequence.
We decompose the error term as
[Equation]
Now, using η t ≥ η t +1 , and t − t k ≤ H , we conclude (as in (35))
[Equation]
As t k − t (cid:48)
≤ τ , (cid:13)(cid:13) x kt k − ¯ x t
[Equation]
0 (cid:13)(cid:13) 2 ≤ η {+2 t (cid:48) 
+}
τ 2 G 2 , (41) and similarly, as t − t (cid:48) {+
+} ≤ H + τ , (cid:13)(cid:13)
˜ x t (cid:48) {+
+}
− ˜ x t (cid:13)(cid:13) {+2 ≤ η 2 t (cid:48) 
+}
[-(cid:48) 
-]
( H + τ ) 2 G 2 .
Finally, as η t (cid:48)
η t ≤ 2 , we can conclude (cid:13)(cid:13) ¯ x t − x kt (cid:13)(cid:13) 2 ≤ 12 η 2 t
( H + τ ) 2 G 2 .
(43) and the lemma follows.
Now the proof of Theorem 5.1 follows immediately.
Proof of Theorem 5.1.
As in the proof of Theorem 2.2 we rely on Lemma 3.4 to derive the convergence rate.
Again, we have A = 12 , B = σ 2 K , and C = LG 2 ( H + τ ) 2 (Lemma B.1).
It is easy to see that the stepsizes satisfy the condition of Lemma B.1, as clearly η t (cid:48)
η t ≤ η t (cid:48)
η t (cid:48)
+ H
+ τ = a + t + H + τ a + t ≤ 2 , as a ≥ H + τ .
C C OMMENTS ON I MPLEMENTATION I SSUES C. S YNCHRONOUS L OCAL SGD
In Theorem 5 we do not prove convergence of the sequences { x kt } t ≥ 0 of the iterates, but only convergence of a weighted average of all iterates.
In practice, the last iterate might often be sufﬁcient, but we like to remark that the weighted average of the iterates can easily be tracked on the ﬂy with an auxiliary sequence { y t } t> 0 , y
= x 0 , without storing all intermediate iterates, see Table 1 for some examples.
[Table]
C. A SYNCHRONOUS L OCAL SGD
As for synchronous local SGD, the weighted averages of the iterates (if needed), can be tracked on each worker locally by a recursive formula as explained above.
A more important aspect that we do not have discussed yet, is that Algorithm 2 allows for an easy procedure to balance the load in heterogeneous settings.
In our notation, we have always associated the local sequences { x kt } with a speciﬁc worker k .
However, the computation of the sequences does not need to be tied to a speciﬁc worker.
Thus, a fast worker k that has advanced his local sequence too much already, can start computing updates for another sequence k (cid:48)
(cid:54)
=
k , if worker k (cid:48) is lagged behind.
This was not possible in the synchronous model, as there all communications had to happen in sync.
We demonstrate this principle in Table 2 below for two workers.
Note that also the running averages can still be maintained.
[Table]
D D ETAILS ON E XPERIMENTS
We here state the precise procedure that was used to generate the ﬁgures in this report.
As brieﬂy stated in Section 4 we examine empirically the speedup on a logistic regression problem, f ( x ) =n
[Equation]
, where a i ∈ R d and b i ∈ {− 1 , +1 } are the data samples.
The regularization parameter is set to λ = 1 /n .
We consider the small scale w8a dataset (Platt, 1999)
( d = 300 , n = 49749 ).
For each run, we initialize x 0 =
d and measure the number of iterations 6 (and number of stochastic gradient evaluations) to reach the target accuracy (cid:15) ∈ { 0 . 005 , 0 . 0001 } .
As we prove convergence only for a special weighted sum of the iterates in Theorem 2.2 and not for standard criteria (last iterate or uniform average), we evaluate the function value for different weighted averages y t =(cid:80) ti =
w i (cid:80) ti =
w i x t , and consider the accuracy reached when one of the averages satisﬁes f ( y t ) − f (cid:63) ≤ (cid:15) , with f (cid:63) := 0 .
126433176216545 (numerically determined).
The precise formulas for the averages that we used are given in Table 1.
For each conﬁguration ( K, H, b, (cid:15) ) , we report the best result found with any of the following two stepsizes: η t :=
min(32 , cnt +1 ) and η t = 32 c .
Here c is a parameter that can take the values c = 2 i for i ∈ Z .
For each stepsize we determine the best parameter c by a grid search, and consider parameter c optimal, if parameters { 2 − 2 c, 2 − 1 c, 2 c, 2 2 c } yield worse results (i.e. more iterations to reach the target accuracy).
In Figures 4 and 5 we give additional results for mini-batch sizes b ∈ { 1 , 16 }
[Figure] [Figure]