A Better Alternative to Error Feedback for Communication-Efficient Distributed Learning
Samuel Horváth, Peter Richtárik
Introduction
We consider distributed optimization problems of the form
Communication Bottleneck. In distributed training, model updates (or gradient vectors) have to be exchanged in each iteration. Due to the size of the communicated messages for commonly considered deep models (Alistarh et al., 2016), this represents significant bottleneck of the whole optimization procedure. To reduce the amount of data that has to be transmitted, several strategies were proposed.
One of the most popular strategies is to incorporate local steps and communicated updates every few iterations only (Stich, 2019a; Lin et al., 2018a; Stich & Karimireddy, 2020; Karimireddy et al., 2019a; Khaled et al., 2020). Unfortunately, despite their practical success, local methods are poorly understood and their theoretical foundations are currently lacking. Almost all existing error guarantees are dominated by a simple baseline, minibatch SGD (Woodworth et al., 2020).
Considering both practice and theory, compression operators can be split into two groups: biased and unbiased. For the unbiased compressors, is required to be an unbiased estimator of the update . Once this requirement is lifted, extra tricks are necessary for Distributed Compressed Stochastic Gradient Descent (DCSGD) (Alistarh et al., 2016; 2018; Khirirat et al., 2018) employing such a compressor to work, even if the full gradient is computed by each node. Indeed, the naive approach can lead to exponential divergence (Beznosikov et al., 2020), and Error Feedback (EF) (Seide et al., 2014; Karimireddy et al., 2019b) is the only known mechanism able to remedy the situation.
Contributions. Our contributions can be summarized as follows:
Induced Compressor. When used within the stabilizing EF framework, biased compressors (e.g., Top-) can often achieve superior performance when compared to their unbiased counterparts (e.g., Rand-). This is often attributed to their low variance. However, despite ample research in this area, EF remains the only known mechanism that allows the use of these powerful biased compressors. Our key contribution is the development of a simple but remarkably effective alternative—and this is the only alternative we know of—which we argue leads to better and more versatile methods both in theory and practice. In particular, we propose a general construction that can transform any biased compressor, such as Top-, into an unbiased one for which we coin the name induced compressor (Section 3). Instead of using the desired biased compressor within EF, our proposal is to instead use the induced compressor within an appropriately chosen existing method designed for unbiased compressors, such as distributed compressed SGD (DCSGD) (Khirirat et al., 2018), variance reduced DCSGD (DIANA) (Mishchenko et al., 2019a) or accelerated DIANA (ADIANA) (Li et al., 2020). While EF can bee seen as a version of DCSGD which can work with biased compressors, variance reduced nor accelerated variants of EF were not known at the time of writing this paper.
Better Theory for DCSGD. As a secondary contribution, we provide a new and tighter theoretical analysis of DCSGD under weaker assumptions. If is -quasi convex (not necessarily convex) and local functions are -smooth (weaker version of -smoothness with strong growth condition), we obtain the rate where and is the parameter which bounds the second moment of the compression operator, and is the number of iterations. This rate has linearly decreasing dependence on the number of nodes , which is strictly better than the best-known rate for DCSGD with EF, whose convergence does not improve as the number of nodes increases, which is one of the main disadvantages of using EF. Moreover, EF requires extra assumptions. In addition, while the best-known rates for EF (Karimireddy et al., 2019b; Beznosikov et al., 2020) are expressed in terms of functional values, our theory guarantees convergence in both iterates and functional values. Another practical implication of our findings is the reduction of the memory requirements by half; this is because in DCSGD one does not need to store the error vector.
Partial Participation. We further extend our results to obtain the first convergence guarantee for partial participation with arbitrary distributions over nodes, which plays a key role in Federated Learning (FL).
Experimental Validation. Finally, we provide an experimental evaluation on an array of classification tasks with CIFAR10 dataset corroborating our theoretical findings.
Error Feedback is not a Good Idea when Using Unbiased Compressors
In this section we first introduce the notions of unbiased and general compression operators, and then compare Distributed Compressed SGD (DCSGD) without (Algorithm 1) and with (Algorithm 2) Error Feedback.
Unbiased vs General Compression Operators. We start with the definition of unbiased and general compression operators (Cordonnier, 2018; Stich et al., 2018; Koloskova et al., 2019).
The following lemma provides a link between these notions (see, e.g. Beznosikov et al. (2020)).
Distributed SGD with vs without Error Feedback. In the rest of this section, we compare the convergence rates for DCSGD (Algorithm 1) and DCSGD with EF (Algorithm 2). We do this comparison under standard assumptions (Karimi et al., 2016; Bottou et al., 2018; Necoara et al., 2019; Gower et al., 2019; Stich, 2019b; Stich & Karimireddy, 2020), listed next.
First, we assume throughout that has a unique minimizer , and let .
The stochastic gradient used in Algorithms 1 and 2 satisfies
Note that this assumption implies .
where is the minimum functional value of and .
This assumption generalizes standard smoothness and boundedness of variance assumptions. For more details and discussion, see the works of Gower et al. (2019); Stich (2019b). Equipped with these assumptions, we are ready to proceed with the convergence theory.
where , , and .
If (no compression), Theorem 2 recovers the optimal rate of Distributed SGD (Stich, 2019b). If , there is an extra term in the convergence rate, which appears due to heterogenity of data (, but in general). In addition, the rate is negatively affected by extra variance due to presence of compression which leads to and .
Induced Compressor: Fixing Bias with Error-Compression
To get some intuition about this procedure, recall the structure used in Error Feedback. The gradient estimator is first compressed with and the error is stored in memory and used to modify the gradient in the next iteration. In our proposed approach, instead of storing the error , we compress it with an unbiased compressor (which can be seen as a parameter allowing flexibility in the design of the induced compressor) and communicate both of these compressed vectors. Note that this procedure results in extra variance as we do not work with the exact error, but with its unbiased estimate only. On the other hand, there is no bias and error accumulation that one needs to correct for. In addition, due to our construction, at least the same amount of information is sent to the master as in the case of plain : indeed, we send both and . The drawback of this is the necessity to send more bits. However, Theorem 3 provides the freedom in generating the induced compressor through the choice of the unbiased compressor . In theory, it makes sense to choose with similar compression factor to the compressor we are transforming as this way the total number of communicated bits per iteration is preserved, up to the factor of two.
Remark: The operator proposed by Elibol et al. (2020) can be seen as a special case of our induced compressor with , and .
Extensions
We now develop several extensions of Algorithm 1 relevant to distributed optimization in general, and to Federated Learning in particular. This is all possible due to the simplicity of our approach. Note that in the case of Error Feedback, these extensions have either not been obtained yet, or similarly to Section 2, the results are worse when compared to our derived bounds for unbiased compressors.
To prove convergence, we exploit the following lemma.
The following theorem establishes the convergence rate for Algorithm 1 with partial participation.
Obtaining Linear Convergence. Note that in all the previous theorems, we can only guarantee a sublinear convergence rate. Linear rate is obtained in the special case when and . The first condition is satisfied, when for all , thus when is also minimizer of every local function . Furthermore, the effect od can be removed using compression of gradient differences, as pioneered in the DIANA algorithm (Mishchenko et al., 2019a). Note that if weak growth condition holds (Vaswani et al., 2019). Moreover, one can remove effect of by either computing full gradients locally or by incorporating variance reduction such as SVRG (Johnson & Zhang, 2013). It was shown by Horváth et al. (2019b) that both and can be removed for the setting of Theorem 2. These results can be easily extended to partial participation using our proof technique for Theorem 5. Note that this reduction is not possible for Error Feedback as the analysis of the DIANA algorithm is heavily dependent on the unbiasedness property. This points to another advantage of the induced compressor framework introduced in Section 3.
Acceleration. We now comment on the combination of compression and acceleration/momentum. This setting is very important to consider as essentially all state-of-the-art methods for training deep learning models, including Adam (Kingma & Ba, 2015; Reddi et al., 2018), rely on the use of momentum in one form or another. One can treat the unbiased compressed gradient as a stochastic gradient (Gorbunov et al., 2020) and the theory for momentum SGD (Yang et al., 2016; Gadat et al., 2018; Loizou & Richtárik, 2017) would be applicable with an extra smoothness assumption. Moreover, it is possible to remove the variance caused by stochasticity and obtain linear convergence with an accelerated rate, which leads to the Accelerated DIANA method (Li et al., 2020). Similarly to our previous discussion, both of these techniques are heavily dependent on the unbiasedness property. It is an intriguing question, but out of the scope of the paper, to investigate the combined effect of momentum and Error Feedback and see whether these techniques are compatible theoretically.
Experiments
In this section, we compare Algorithms 1 and 2 for several compression operators. If the method contains “ + EF ”, it means that EF is applied, thus Algorithm 2 is applied. Otherwise, Algorithm 1 is displayed. To be fair, we always compare methods with the same communication complexity per iteration. All experimental details can be found in the Appendix.
Failure of DCSGD with biased Top-. In this experiment, we present example considered in Beznosikov et al. (2020), which was used as a counterexample to show that some form of error correction is needed in order for biased compressors to work/provably converge. In addition, we run experiments on their construction and show that while Error Feedback fixes divergence, it is still significantly dominated by unbiased non-uniform sparsification(NU Rand-), which works by only keeping one non-zero coordinate sampled with probability equal to , where denotes element-wise absolute value, as can be seen in Figure 1. The details can be found in the Appendix.
Error Feedback for Unbiased Compression Operators. In our second experiment, we compare the effect of Error Feedback in the case when an unbiased compressor is used. Note that unbiased compressors are theoretically guaranteed to work both with Algorithm 1 and 2. We can see from Figure 2 that adding Error Feedback can hurt the performance; we use TernGrad (Wen et al., 2017) (coincides with QSGD (Alistarh et al., 2016) and natural dithering (Horváth et al., 2019a) with the infinity norm and one level) as compressors. This agrees with our theoretical findings. In addition, for sparsification techniques such as Random Sparsification or Gradient Sparsification (Wangni et al., 2018), we observed that when sparsity is set to be 10 %, Algorithm 1 converges for all the selected values of step-sizes, but Algorithm 2 diverges and a smaller step-size needs to be used. This is an important observation as many practical works (Li et al., 2014; Wei et al., 2015; Aji & Heafield, 2017; Hsieh et al., 2017; Lin et al., 2018b; Lim et al., 2018) use sparsification techniques mentioned in this section, but proposed to use EF, while our work shows that using unbiasedness property leads not only to better convergence but also to memory savings.
Unbiased Alternatives to Biased Compression. In this section, we investigate candidates for unbiased compressors than can compete with Top-, one of the most frequently used compressors. Theoretically, Top- is not guaranteed to work by itself and might lead to divergence (Beznosikov et al., 2020) unless Error Feedback is applied. One would usually compare the performance of Top- with EF to Rand-, which keeps randomly selected coordinates and then scales the output by to preserve unbiasedness. Rather than naively comparing to Rand-, we propose to use more nuanced unbiased approaches. The first one is Gradient Sparsification proposed by Wagni et al. (Wangni et al., 2018), which we refer to here as Rand- (Wangni et al.), where the probability of keeping each coordinate scales with its magnitude and communication budget. As the second alternative, we propose to use our induced compressor, where is Top- and unbiased part is Rand- (Wangni et al.) with communication budget . It should be noted that can be considered as a hyperparameter to tune. For our experiment, we chose it to be for simplicity. Figure 3 suggests that our induced compressor outperforms all of its competitors as can be seen for both VGG11 and Resnet18. Moreover, induced compressor as well as Rand- do not require extra memory to store the error vector. Finally, Top- without EF suffers a significant decrease in performance, which stresses the necessity of error correction.
Conclusion
In this paper, we argue that if compressed communication is required for distributed training due to communication overhead, it is better to use unbiased compressors. We show that this leads to strictly better convergence guarantees with fewer assumptions. In addition, we propose a new construction for transforming any compressor into an unbiased one using a compressed EF-like approach. Besides theoretical superiority, usage of unbiased compressors enjoys lower memory requirements. Our theoretical findings are corroborated with empirical evaluation.
As a future work we plan to investigate the question of the appropriate choice of the inducing compressor . Our preliminary studies show that there is much to be discovered here, both in theory and in terms of developing further practical guidelines to those already contained in this work. The question of (theoretically) optimizing for and is difficult, as it necessitates a deeper theoretical understanding of biased compressors, which is currently missing. An alternative is to impose some assumptions on the structure of gradients encountered during the iterative process, or to perform an extensive experimental evaluation on desired tasks to provide guidelines for practitioners.
References
Appendix
Appendix A Experimental Details
To be fair, we always compare methods with the same communication complexity per iteration. We report the number of epochs (passes over the dataset) with respect to training loss and testing accuracy. The test accuracy is obtained by evaluating the best model in terms of validation accuracy. A validation accuracy is computed based on % randomly selected training data. We tune the step-size using based on the training loss. For every experiment, we randomly distributed the training dataset among workers; each worker computes its local gradient-based on its own dataset. We used a local batch size of . All the provided figures display the mean performance with one standard error over independent runs. For a fair comparison, we use the same random seed for the compared methods. Our experimental results are based on a Python implementation of all the methods running in PyTorch. All reported quantities are independent of the system architecture and network bandwidth.
Dataset and Models. We do an evaluation on CIFAR10 dataset. We consider VGG11 (Simonyan & Zisserman, 2015) and ResNet18 (He et al., 2016) models and step-sizes and .
Momentum. In this extra experiment, we look at the effect of momentum on Algorithm 1 and 2. We set momentum to . Similarly to Figure 2, we work with the unbiased compressor, concretely TernGrad (Wen et al., 2017) (coincides with QSGD (Alistarh et al., 2016) and natural dithering (Horváth et al., 2019a) with the infinity norm and one level), to see the effect of adding Error Feedback. We can see from Figure 4 that adding Error Feedback can hurt the performance, which agrees with our theoretical findings.
Appendix B Example 1, Beznosikov et al. (2020)
In this section, we present example considered in Beznosikov et al. (2020), which was used as a counterexample to show that some form of error correction is needed in order for biased compressors to work/provably converge. In addition, we run experiments on their construction and show that while Error Feedback fixes divergence, it is still significantly dominated by unbiased non-uniform sparsification as can be seen in Figure 1. The construction follows.
Consider and define the following smooth and strongly convex quadratic functions
where . Then, with the initial point
Repeated application gives , which diverges exponentially fast to since .
As a initial point, we use in our experiments and we choose step size , where is smoothness parameter of . Note that zero vector is the unique minimizer of .
Appendix C Proofs
C.2 Proof of Theorem 2
We use the update of Algorithm 1 to bound the following quantity
Taking full expectation and , we obtain
The rest of the analysis is closely related to the one of Stich (2019b). We would like to point out that similar results to Stich (2019b) were also present in (Lacoste-Julien et al., 2012; Stich et al., 2018; Grimmer, 2019).
We first rewrite the previous inequality to the form
where , , , .
We proceed with lemmas that establish a convergence guarantee for every recursion of type (10).
Let , be as in (10) for and for constant stepsizes , . Then it holds for all :
This follows by relaxing (10) using ,and unrolling the recursion
Let , as in (10) for and for decreasing stepsizes , , with parameter , and weights . Then
where .
We start by re-arranging (10) and multiplying both sides with
where the equality follows from the definition of and and the inequality from . Again we have a telescoping sum:
,
and for .
By applying these two estimates we conclude the proof. ∎
The convergence can be obtained as the combination of these two lemmas.
Let , as in (10), . Then there exists stepsizes and weighs , , such that
For integer , we choose stepsizes and weights as follows
for and t_{0}=\bigl{\lceil}\frac{T}{2}\bigr{\rceil}. We will now show that these choices imply the claimed result.
We start with the case . For this case, the choice gives
If , then we obtain from Lemma 6 that
From Lemma 7 we have for the second half of the iterates:
Now we observe that the restart condition satisfies:
because . These conclude the proof.
Having these general convergence lemmas for the recursion of the form (10), the proof of the theorem follows directly from Lemmas 6 and 8 with , , . It is easy to check that condition is satisfied.
C.3 Proof of Theorem 3
We have to show that our new compression is unbiased and has bounded variance. We start with the first property with .
where the first equality follows from tower property and the second from unbiasedness of . For the second property, we also use tower property
where the first and second inequalities follow directly from (2) and (3).
C.4 Proof of Lemma 4 (Horváth & Richtárik, 2019)
For the first part of the claim, it was shown that is positive semidefinite (Richtárik & Takáč, 2016), thus we can bound , where , which implies that (8) holds for this choice of .
Since by assumption we have , we can further bound
To obtain (9), it remains to combine this with (13).
C.5 Proof of Theorem 5
Similarly to the proof of Theorem 2, we use the update of Algorithm 1 to bound the following quantity