Stochastic Optimization with Heavy-Tailed Noise via Accelerated Gradient Clipping
Eduard Gorbunov, Marina Danilova, Alexander Gasnikov
Introduction
In this paper we focus on the following problem
However, there are a lot of important applications where the noise distribution in the stochastic gradient is significantly heavy-tailed . For such problems SGD is often less robust and shows poor performance in practice. Furthermore, existing results for the convergence with high-probability for SGD are also much worse in the presence of heavy-tailed noise than its “light-tailed counterparts”. In this case, rates of the convergence in expectation can be insufficient to describe the behavior of the method.
To illustrate this phenomenon we consider a simple example of stochastic optimization problem and apply SGD with constant stepsize to solve it. After that, we present a natural and simple way to resolve the issue of SGD based on the clipping of stochastic gradients. However, we need to introduce some important notations and definitions before we start to discuss this example.
i.e. we have an access to the unbiased estimator of with uniformly bounded by variance where is some non-negative number. These assumptions on the stochastic gradient are standard in the stochastic optimization literature . Below we introduce one of the most important definitions in this paper.
Such distributions are often called sub-Gaussian ones (see and references therein). One can show (see Lemma 2 from ) that this definition is equivalent to
2 Simple Motivational Example: Convergence in Expectation and Clipping
In this section we consider SGD applied to solve the problem (1) with , where is a random vector with zero mean and the variance by (see the details in Section H.1). The state-of-the-art theory (e.g. ) says that convergence properties in expectation of SGD in this case depend only on the stepsize , condition number of , initial suboptimality and the variance , but does not depend on distribution of . However, the trajectory of SGD significantly depends on the distribution of . To illustrate this we consider different distributions of with the same , i.e., Gaussian distribution, Weibull distribution and Burr Type XII distribution with proper shifts and scales to get needed mean and variance for (see the details in Section H.1). For each distribution, we run SGD several times from the same starting point, the same stepsize , and the same batchsize, see typical runs in Figure 1.
This simple example shows that SGD in all cases rapidly reaches a neighborhood of the solution and then starts to oscillate there. However, these oscillations are significantly larger for the second and the third cases where stochastic gradients are heavy-tailed. Unfortunately, guarantees for the convergence in expectation cannot express this phenomenon, since in expectation the convergence guarantees for all cases are identical.
Moreover, in practice, e.g., in training big machine learning models, it is often used only a couple runs of SGD or another stochastic method. The training process can take hours or even days, so, it is extremely important to obtain good accuracy of the solution with high probability. However, as our simple example shows, SGD fails to converge robustly if the noise in stochastic gradients is heavy-tailed which was also noticed for several real-world problems like training AlexNet on CIFAR10 (see ) and training an attention model via BERT (see ).
Clearly, since the distributions of stochastic gradients in the second and the third cases are heavy tailed the probability of sampling too large (in terms of the norm) and, as a consequence, too large is high even if we are close to the solution. Once the current point is not too far from the solution and SGD gets a stochastic gradient with too large norm the method jumps far from the solution. Therefore, we see large oscillations. Since the reason of such oscillations is large norm of stochastic gradient it is natural to clip it, i.e., update according to The obtained method is known in literature as clipped-SGD (see and references therein). Among the good properties of clipped-SGD we emphasize its robustness to the heavy-tailed noise in stochastic gradients (see also ). In our tests, trajectories of clipped-SGD oscillate not significantly even for heavy-tailed distributions, and clipping does not spoil the rate of convergence. These two factors make clipped-SGD preferable than SGD when we deal with heavy-tailed distributed stochastic gradients (see further discussion in Section B.2).
3 Related Work
In the light-tailed case high-probability complexity bounds and complexity bounds in expectation for SGD and AC-SA differ only in logarithmical factors of , see the details in Table 1. Such bounds were obtained in for SGD in the convex case and then were extended to the -strongly convex case in for modification of SGD called Stochastic Intermediate Gradient Method (SIGM). Finally, optimal complexities were derived in for the method called AC-SA in the convex case and for Multi-Staged AC-SA (MS-AC-SA) in the strongly convex case.
Without light tails assumption the most straightforward results lead to and dependency on in the complexity bounds. Such bounds can be obtained from the complexity bounds for the convergence in expectation via Markov’s inequality. However, for small these bounds become unacceptably poor. Classical results reduce these dependence to but they have worse dependence on than corresponding results relying on light tails assumption.
For a long time the following question was open: is it possible to design stochastic methods having the same or comparable complexity bounds as in the light-tailed case but without light tails assumption on stochastic gradients? In and the authors give a positive answer to this question but only partially. Let us discuss the results from these papers in detail.
In Nazin et al. develop a new algorithm called Robust Stochastic Mirror Descent (RSMD) which is based on a special truncation of stochastic gradients and derive complexity guarantees similar to SGD in the convex case but without light assumption, see Table 1. This technique is very similar to gradient clipping. Moreover, in authors consider also composite problems with non-smooth composite term. However, in the optimization problem is defined on some compact convex set with diameter and the analysis depends substantially on the boundedness of . Using special restarts technique together with iterative squeezing of the set Nazin et al. extend their method to the -strongly convex case, see Table 2. Finally, in the discussion section of authors formulate the following question: is it possible to develop such accelerated stochastic methods that have the same or comparable complexity bounds as in the light-tailed case but do not require stochastic gradients to be light-tailed?
In the strongly convex case the positive answer to this question was given by Davis et al. where authors propose a new method called proxBoost that is based on robust distance estimation and proximal point method , see Table 2. However, this approach requires solving an auxiliary optimization problem at each iteration that can lead to poor performance in practice.
In our paper we close the gap in theory, i.e., we provide a positive answer to the following question: Is it possible to develop such an accelerated stochastic method that have the same or comparable complexity bound as for AC-SA in the convex case but do not require stochastic gradients to be light-tailed?
4 Our Contributions
One of the main contributions of our paper is a new method called Clipped Stochastic Similar Triangles Method (clipped-SSTM). For the case when the objective function is convex and -smooth we derive the following complexity bound without light tails assumption on the stochastic gradients: This bound outperforms all known bounds for this setting (see Table 1) and up to the difference in logarithmical factors recovers the complexity bound of AC-SA derived under light tails assumption. That is, in this paper we close the gap in theory theory of smooth convex stochastic optimization with heavy-tailed noise. Moreover, unlike in , we do not assume boundedness of the set where the optimization problem is defined, which makes our analysis more complicated. We also study different batchsize policies for clipped-SSTM.
Using restarts technique we extend clipped-SSTM to the -strongly convex objectives and obtain a new method called Restarted clipped-SSTM (R-clipped-SSTM). For this method we prove the following complexity bound (again, without light tails assumption on the stochastic gradients): Our bound outperforms the state-of-the-art result from in terms of the dependence on , see Table 2 for the details.
We prove the first high-probability complexity guarantees for clipped-SGD in convex and strongly convex cases without light tails assumption on the stochastic gradients, see Tables 1 and 2. The complexity we prove for clipped-SGD in the convex case is comparable with corresponding bound for SGD derived under light tails assumption. In the -strongly convex case we derive a new complexity bound for the restarted version of clipped-SGD (R-clipped-SGD) which is comparable with its “light-tailed counterpart”.
We conduct several numerical experiments with the proposed methods in order to justify the theory we develop. In particular, we show that clipped-SSTM can outperform SGD and clipped-SGD in practice even without using large batchsizes. Moreover, in our experiments we illustrate how clipping makes the convergence of SGD and SSTM more robust and reduces their oscillations.
5 Paper Organization
The remaining part of the paper is organized as follows. In Section 2 we present clipped-SSTM together with the main complexity result in the convex case that we prove for this method. Then, we present the first high-probability complexity bounds for clipped-SGD for for the convex problems. In Section 4 we provide our numerical experiments justifying our theoretical results. Finally, in Section 5 we provide some concluding remarks and discuss the limitations and possible extensions of the results developed in the paper. Due to the space limitations, we put the exact formulations of all theorems, results for the strongly convex problems and the full proofs in the Appendix (see Sections F and G), together with auxiliary and technical results and additional experiments (see Section H). Moreover, in Section F.1.2 we present a sketch of the proof of the main convergence result for clipped-SSTM and explain the intuition behind it.
Accelerated SGD with Clipping
In our method we use a clipped stochastic gradient that is defined in the following way:
where is a mini-batched version of . That is, in order to compute one needs to get i.i.d. samples , compute its average and then project the result on the Euclidean ball with radius and center at the origin. Next theorem summarizes the main convergence result for clipped-SSTM.
Assume that function is convex and -smooth. Then for all and such that we have that after iterations of clipped-SSTM with , and that holds with probability at least where . In other words, if we choose to be equal to the maximum from (27), then the method achieves with probability at least after iterations and requires oracle calls.
The theorem says that for any clipped-SSTM converges to -solution with probability at least and requires exactly the same number of stochastic first-order oracle calls (up to the difference in constant and logarithmical factors) as optimal stochastic methods like AC-SA or Stochastic Similar Triangles Method . However, our method achieves this rate under less restrictive assumption. Indeed, Theorem 2.1 holds even in the case when the stochastic gradient satisfies only (2) and can have heavy-tailed distribution. In contrast, all existing results that establish (30) and that are known in the literature hold only in the light-tails case, see Section 1.3.1.
Finally, when is big then Theorem 2.1 says that at iteration clipped-SGD requires large batchsizes (see (26)) which is proportional to for last iterates. It can make the cost of one iteration extremely high, therefore, we also consider different stepsize policies that remove this drawback in Section F.1.1. In particular, the following result shows that clipped-SSTM achieves the same oracle complexity even with constant batchsizes when stepsize parameter is chosen properly.
Let the assumptions of Theorem F.1 hold and . Then and clipped-SSTM achieves with probability at least after iterations/oracle calls.
SGD with Clipping
In this section we present our complexity results for clipped-SGD (see Algorithm 2) in the convex case.
Next theorem summarizes the main convergence result for clipped-SGD in this case.
Assume that function is convex and -smooth. Then for all and such that we have that after iterations of clipped-SGD with and where and stepsize that with probability at least where . In other words, the method achieves with probability at least after iterations and requires oracle calls.
To the best of our knowledge, it is the first result for clipped-SGD establishing non-trivial complexity guarantees for the convergence with high probability. Up to the difference in logarithmical factors our bound recovers the complexity bound for SGD which was obtained under light tails assumption and the complexity bound for RSMD. However, unlike in , we do not assume that the optimization problem is defined on the bounded set. The proof technique is similar to one we use to prove Theorem F.1. One can find the full proof in Section G.3.1.
Numerical Experiments
We have testedOne can find the code here: https://github.com/eduardgorbunov/accelerated_clipping. clipped-SSTM and clipped-SGD on the logistic regression problem, the datasets were taken from LIBSVM library . To implement methods we use Python 3.7 and standard libraries. One can find additional experiments and details in Section H.2.
First of all, using standard solvers from scipy library we find good enough approximation of the solution of the problem for each dataset. For simplicity, we denote this approximation by . Then, we numerically study the distribution of and plot corresponding histograms for each dataset, see Figure 2.
These histograms hint that near the solution for heart dataset tails of stochastic gradients are not heavy and the norm of the noise can be well-approximated by Gaussian distribution, whereas for diabetes and australian we see the presense of outliers that makes the distribution heavy-tailed.
Next, let us consider numerical results for SGD and SSTM with and without clipping applied to solve logistic regression problem on these datasets, see Figures 3- 5.
For all methods we used constant batchsizes , stepsizes and clipping levels were tuned, see Section H.2 for the details. In our experiments we also consider clipped-SGD with periodically decreasing clipping level (d-clipped-SGD in Figures), i.e. the method starts with some initial clipping level and after every epochs or, equivalently, after every iterations the clipping level is multiplied by some constant .
Let us discuss the obtained numerical results. First of all, d-clipped-SGD stabilizes the oscillations of SGD even if the initial clipping level was high. In contrast, clipped-SGD with too large clipping level behaves similarly to SGD. Secondly, we emphasize that due to the fact that we used small bathcsizes SSTM has very large oscillations in comparison to SGD. Actually, fast error/noise accumulation is a typical drawback of accelerated SGD with small batchsizes . Moreover, deterministic accelerated and momentum-based methods often have non-monotone behavior (see and references therein). However, to some extent clipped-SSTM suffers from the first drawback less than SSTM and has comparable convergence rate with SSTM. Finally, in our experiments on heart and australian datasets clipped-SSTM converges faster than SGD and clipped-SGD and oscillates little, while on diabetes dataset it also converges faster than SGD, but oscillates more if parameter is not fine-tuned.
We also want to mention that the behavior of SGD on heart and diabetes datasets correlates with the insights from Section 1.2 and our numerical study of the distribution of . Indeed, for heart dataset SGD has little oscillations since the distribution of , where is the last iterate, is well concentrated near its mean and can be approximated by Gaussian distribution (see the details in Section H.2). In contrast, Figure 4 shows that SGD oscillates more than in the previous example. One can explain such behavior using Figure 2 showing that the distribution of has heavier tails than for heart dataset.
However, we do not see any oscillations of SGD for australian dataset despite the fact that according to Figure 2 the distribution of in this case has heavier tails than in previous examples. Actually, there is no contradiction and in this case it simply means that SGD does not get close to the solution in terms of functional value, despite the fact that we used . In Section H.2 we present the results of different tests where we tried to use bigger stepsize in order to reach oscillation region faster and show that in fact in that region SGD oscillates significantly more, but clipping fixes this issue without spoiling the convergence rate.
Discussion
In this paper we close the gap in the theory of high-probability complexity bounds for stochastic optimization with heavy-tailed noise. In particular, we propose a new accelerated stochastic method — clipped-SSTM — and prove the first accelerated high-probability complexity bounds for smooth convex stochastic optimization without light-tails assumption. Moreover, we extend our results to the strongly convex case and prove new complexity bounds outperforming the state-of-the-art results. Finally, we derive first high-probability complexity bounds for the popular method called clipped-SGD in convex and strongly convex cases and conduct a numerical study of the considered methods.
Broader Impact
Our contribution is primarily theoretical. Therefore, a broader impact discussion is not applicable.
Acknowledgments and Disclosure of Funding
The research of E. Gorbunov and A. Gasnikov was partially supported by the Ministry of Science and Higher Education of the Russian Federation (Goszadaniye) 075-00337-20-03. The research of Marina Danilova was funded by RFBR, project number 20-31-90073.
Appendix Stochastic Optimization with Heavy-Tailed Noise via Accelerated Gradient Clipping
Next, we introduce some standard definitions.
It is well-known that -smoothness implies (see )
Since in this paper we focus only on smooth optimization problems we introduce strong convexity in the following way.
Throughout the paper, we use to denote any solution of problem (1) assuming its existence. By the complexity of stochastic first-order method we always mean the total number of stochastic first-order oracle calls that the method needs in order to produce such a point that with probability at least for some and . Finally, in the complexity bounds we often use to denote where is the starting point of the method.
Appendix B Related Work: Additional Details
The first terms in maximums above correspond to the Central Limit Theorem regime, while the second terms correspond to the heavy-tailed regime, see Section D.2. These bounds show that heavy tailed distributions of the stochastic gradients significantly spoil complexity bounds of SGD and restarted-SGD when the confidence level is small enough.
B.2 Related Work on Gradient Clipping
Appendix C Basic Facts
In this section we enumerate for convenience basic facts that we use many times in our proofs.
Appendix D Auxiliary Results
D.2 About the Sum of i.i.d. Random Variables with Heavy Tails
where and . Since
This simple observation can play a significant role in deriving complexity results for non-smooth convex optimization under the assumption that stochastic gradients are heavy-tailed, see for the details.
Appendix E Technical Results
Consider two sequences of non-negative numbers and such that
Using together with the inequality above we derive (21). ∎
Appendix F Accelerated SGD with Clipping: Exact Formulations and Missing Proofs
In this section we provide exact formulations of all the results that we have for clipped-SSTM and R-clipped-SSTM together with the full proofs.
Recall that in order to compute one needs to get i.i.d. samples , compute its average
and then project the result on the Euclidean ball with radius and center at the origin. We also notice that
Next theorem summarizes the main convergence result for clipped-SSTM.
Assume that function is convex and -smooth. Then for all and such that
we have that after iterations of clipped-SSTM with
In other words, if we choose to be equal to the maximum from (27), then the method achieves with probability at least after iterations and requires
One can easily notice that multiplicative constant factors in formulas for and are too big and seem to be impractical, but in practice one can tune these constants to get good enough performance. That is, big constants in (26) and (27) are needed only in our analysis in order to get bound (30).
Finally, when is big then Theorem F.1 says that at iteration clipped-SGD requires large batchsizes (see (26)) which is proportional to for last iterates. It can make the cost of one iteration extremely high, therefore, we consider different stepsize policies that remove this drawback.
(Medium batchsize). If and are such that is bigger than the maximum from (27), then for we have
and the method achieves with probability at least after iterations and requires
(Constant batchsize). If and are such that is bigger than the maximum from (27) for some positive constant , then for we have
and the method achieves with probability at least after iterations and requires
Finally, if , then for and clipped-SSTM finds -solution with probability at least after iterations and requires oracle calls per iteration.
In the second case the corollary establishes rate for clipped-SSTM with constant batchsizes, i.e. for all . The ability of clipped-SSTM to converge with constant batchsizes makes it more practical and applicable for wider class of problems where it can be very expensive to compute large batchsizes, e.g. training deep neural networks. Moreover, when is not too small, i.e. , this rate is optimal (up to logarithmical factors) and also recovers the rate of RSMD.
and as in (26), we get for and derive the following result.
Let the assumptions of Theorem F.1 hold, is chosen as in (35) and is computed via (26). Then clipped-SSTM achieves with probability at least after
We start with the following lemma that is pretty standard in the analysis of Stochastic Similar Triangles Method, e.g. see the proof of Theorem 1 from .
That is, if , then the result above gives a preliminary upper bound for . The first and the second terms in the r.h.s. of (36) come from the analysis of Similar Triangles Method and three last terms have a stochastic nature. In particular, they explicitly depend on differences between clipped mini-batched stochastic gradients and full gradients at , so, if with probability , then we easily get needed convergence rate. However, we are interested in the more general case and, as a consequence, to continue the proof, we need to find a good enough upper bound for the last three terms from (36). In other words, we need to show that choosing parameters , and properly we can upper bound these terms by something that coincides with up to numerical multiplicative constant. The proof of convergence result for RSMD from where authors provide upper bound for similar sums hints that Bernstein’s inequality (see Lemma D.1) applied to estimate these terms can help us to reach our goal. In order to apply Bernstein’s inequality one should derive tight bounds for such characteristics of as upper bounds for the magnitude, bias, variance and distortion and the next lemma provides us with this.
For all the following inequality holds:
Moreover, if for some , then for this we have:
Clearly, clipping introduces a bias in which influences the convergence of the method. Hence, the clipping level should be chosen in a very accurate way. Below we informally describe what does it mean and present the sketch of the remaining part of the proof.
Imagine the ideal situation: with probability for all , i.e. we have an access to the full gradients at points . Then it is natural to choose in such a way that in order to recover Similar Triangles Method (STM) that converges with optimal rate in the deterministic case. In other words, one can pick such that and get an optimal method. Since we know that in this case the method should converge with rate in terms of one can expect that the gradient’s norm decays with rate, so, one can choose to be proportional to . It is exactly what we do when we define as .
The ideal case described above gives a good insight on how to choose in the general case and can be described as follows: if we want to prevent our gradient estimator from large deviations from with high probability, then it is needed to choose such that with high probability where is some positive number. This choice guarantees that with high probability clipped mini-batched gradient cannot deviates from significantly and, as a consequence, the convergence rate of clipped-SSTM in terms of the number of iterations needed to achieve the desired accuracy of the solution with high probability becomes similar to the convergence rate of STM up to some logarithmical factors depending on the confidence level.
In particular, we choose such that with high probability. Moreover, we derive this relation by induction via refined estimation of the three last terms from the r.h.s. of (36) that is based on the new variant of advanced recurrences technique from . The main trick there is in showing by induction that sequence is bounded by some constant multiplied by and in deriving simultaneously for all . With such bounds and Lemma F.5 in hand, it is possible to apply Bernstein’s inequality to three sums from the r.h.s. of (36) since all summands are bounded with high probability. After applying Bernstein’s inequality we adjust parameters and in such a way that after rearranging the terms in the obtained upper bounds we get that r.h.s. in (36) (with ) is smaller than up to some multiplicative numerical constant. This finishes the proof.
To conclude, the key tools in our analysis are Bernstein’s inequality (see Lemma D.1) and advanced recurrences technique that helps us to show boundedness of and with high probability. We provide detailed proofs of presented result in the Appendix (see Section F.3).
F.2 Strongly Convex Case
In this section we assume additionally that is -strongly convex. For this case we modify Algorithm 1 and propose a new method called Restarted Clipped Similar Triangles Method (R-clipped-SSTM), see Algorithm 3.
At each iteration R-clipped-SSTM runs clipped-SSTM for iterations from the current point and use its output as next iterate . In literature this approach is known as the restarts technique . Choosing and parameters , and in a proper way one can get an accelerated method for strongly convex objectives. Theorem below states the main convergence result for R-clipped-SSTM.
Assume that is -strongly convex and -smooth. If we choose , and such that
where and , then we have that after runs of clipped-SSTM in R-clipped-SSTM the inequality
holds with probability at least . That is, if we choose to be equal to the maximum from (45) and with some numerical constant , then the method achieves with probability at least after
In other words, R-clipped-SSTM has the same convergence rate as optimal stochastic methods for strongly convex problems like Multi-Staged AC-SA (MS-AC-SA) or Stochastic Similar Triangles Method for strongly convex problems (SSTM_sc) . Moreover, in Theorem F.6 we do not assume that stochastic gradients are sampled from sub-Gaussian distribution while corresponding results for MS-AC-SA and SSTM_sc are substantially based on the light tails assumption. Our bound outperforms the state-of-the-art result from in terms of the dependence on . It is worth to mention here that using special restarts technique Nazin et al. generalize their method (RSMD) for the strongly convex case, but since RSMD is not accelerated their approach gives only non-accelerated convergence rate.
We also emphasize that big numerical factors in formulas for and are needed only in our analysis and in practice they can be tuned. However, when is big bathsizes become of the order . It can make the cost of one iteration extremely high, therefore, as for clipped-SSTM we consider a different stepsize policy removing this drawback.
Let the assumptions of Theorem F.6 hold. Assume that conditions (42), (43), (44) and (45) are satisfied for
Then after runs of clipped-SSTM in R-clipped-SSTM the method achieves with probability at least . Moreover, the total number of iterations of clipped-SSTM equals
with for all , .
When is big the obtained bound is comparable with bounds for restarted-RSMD and proxBoost, see Table 2.
F.3 Proofs
Since (see Lemma E.1) and we can continue our derivations:
By definition of we have which implies
since . Putting all together we derive that
where in the last inequality we use the convexity of . Taking into account and we sum up these inequalities for and get
Proof of (39). In order to prove this bound we introduce following indicator random variables:
From the assumptions of the lemma, we have that which implies
The introduced notation helps us to rewrite in the following way:
We use this representation to obtain the following inequality:
Next, we derive an upper bound for the expectation of using Markov’s inequality:
Proof of (41). To derive (41) we use (40):
holds for all . Taking into account that for all and using new notation , , we derive that for all
First of all, we notice that for each iterates lie in the ball . We prove it using induction. Since , and we have that . Next, assume that for some . By definitions of and we have that . Since is a convex combination of , and is a convex set we conclude that . Finally, since is a convex combination of and we have that lies in as well.
The rest of the proof is based on the refined analysis of inequality (64). In particular, via induction we prove that for all with probability at least the following statement holds: inequalities
hold for . Then, inequalities
hold for where the last inequality follows from . Taking such that
we obtain that probability event implies
for . Since we have to choose such that
w.r.t. we get that should satisfy
Having inequalities (67) in hand we show in the rest of the proof that (65) holds for with big enough probability. First of all, we introduce new random variables:
for . Note that these random variables are bounded with probability , i.e. with probability we have
Secondly, we use the introduced notation and get that implies
Finally, we do some preliminaries in order to apply Bernstein’s inequality (see Lemma D.1) and obtain that implies
It remains to provide tight upper bounds for ①, ②, ③, ④ and ⑤, i.e. in the remaining part of the proof we show that for some .
Secondly, these summands are bounded with probability :
In other words, sequence is bounded martingale difference sequence with bounded conditional variances . Therefore, we can apply Bernstein’s inequality, i.e. we apply Lemma D.1 with , and and get that for all
or, equivalently, with probability at least
The choice of will be clarified further, let us now choose in such a way that . This implies that is the positive root of the quadratic equation
That is, with probability at least
Next, we notice that probability event implies that
where the last inequality follows from and simple arithmetic.
Upper bound for ②. First of all, we notice that probability event implies
Upper bound for ③. We derive the upper bound for ③ using the same technique as for ①. First of all, we notice that the summands in ③ are conditionally independent:
Secondly, the summands are bounded with probability :
or, equivalently, with probability at least
As in our derivations of the upper bound for ① we choose such that , i.e.
That is, with probability at least
Next, we notice that probability event implies that
Upper bound for ④. The probability event implies
Upper bound for ⑤. Again, we use corollaries of probability event :
Now we summarize all bound that we have: probability event implies
Taking into account these inequalities we get that probability event implies
That is, by definition of and we have proved that
Since (see Lemma E.1) we get that with probability at least
In other words, clipped-SSTM with achieves with probability at least after iterations and requires
Theorem F.1 implies that with probability at least
and batchsizes are chosen according to (26):
We consider two different options for .
If is bigger than , then we take which implies that
That is, if is small enough to satisfy for some constant , then due to (80) we have that after
of clipped-SSTM we obtain such point that with probability at least inequality holds and the method requires
If is bigger than for some , then we take which implies that
That is, if is small enough to satisfy for some constant , then due to (81) we have that after
of clipped-SSTM we obtain such point that with probability at least inequality holds and the method requires
stochastic first-order oracle calls. Finally, if all assumptions on , and hold for , then for all
i.e. one iteration of clipped-SSTM requires oracle calls, and with probability at least after
Since we have that . Next, there are two possible situations.
If , then we are in the settings of Theorem F.1. This means that clipped-SSTM achieves with probability at least after
If , then we are in the settings of Corollary F.2 which implies that clipped-SSTM achieves with probability at least after
Finally, we combine these two cases and obtain that with clipped-SSTM guarantees with probability at least after
First of all, consider behavior of clipped-SSTM during the first run in R-clipped-SSTM. We notice that the proof of Theorem F.1 will be valid if we substitute everywhere by its upper bound . From -strong convexity of we have
therefore, one can choose . It implies that after iterations of clipped-SSTM we have
with probability at least , hence with the same probability since . In other words, with probability at least
Then, by induction one can show that for arbitrary the inequality
holds with probability at least . Therefore, these inequalities hold simultaneously with probability at least . Using this we derive that inequality
holds with probability . That is, after restarts R-clipped-SSTM generates such a point that with probability at least . Moreover, if equals the maximum from (45) and with some numerical constant , then , the total number of iterations of clipped-SSTM equals
and the overall number of stochastic first-order oracle calls is
Similarly to the proof of Theorem F.6 (see the previous subsection) we derive that under assumptions of the corollary after restarts R-clipped-SSTM generates such a point that with probability at least . Moreover, and satisfy the following system of inequalities
Then, for all and batchsizes satisfy
i.e. the algorithm requires oracle calls per iteration. Finally, the total number of iterations is
Appendix G SGD with Clipping: Exact Formulations and Missing Proofs
In this section we provide exact formulations of all the results that we have for clipped-SGD and R-clipped-SGD together with the full proofs.
Assume that function is convex and -smooth. Then for all and such that
we have that after iterations of clipped-SGD with
where and stepsize
where and
In other words, the method achieves with probability at least after iterations and requires
To the best of our knowledge, it is the first result for clipped-SGD establishing non-trivial complexity guarantees for the convergence with high probability. One can find the full proof in Section G.3.1.
G.2 Strongly Convex Case
Next, we consider the situation when is additionally -strongly convex and propose a restarted version of clipped-SGD (R-clipped-SGD), see Algorithm 4.
For this method we prove the following result.
Assume that is -strongly convex and -smooth. If we choose , and such that
where and , then we have that after runs of clipped-SGD in R-clipped-SGD the inequality
holds with probability at least . That is, if we choose with some numerical constant , then the method achieves with probability at least after
This theorem implies that R-clipped-SGD has the same complexity as the restarted version of RSMD from up to the difference in logarithmical factors. We notice that the main difference between our result and one from is that we do not need to assume that the optimization problem is considered on the bounded set.
However, in order to get (94) R-clipped-SGD requires to know strong convexity parameter . In order to remove this drawback we analyse clipped-SGD for the strongly convex case and get the following result.
Assume that function is -strongly convex and -smooth. Then for all and such that
we have that after iterations of clipped-SGD with
where and stepsize
In other words, the method achieves with probability at least after iterations and requires
Unfortunately, our approach leads to worse complexity bound than we have for R-clipped-SGD: in the second term of the maximum in (99) we get an extra factor that can be large. Nevertheless, to the best of our knowledge it is the first non-trivial complexity result for clipped-SGD that guarantees convergence with high probability. One can find the full proof of Theorem G.3 in Section G.3.3.
G.3 Proofs
Since is convex and -smooth, we get the following inequality:
where and the last inequality follows from the convexity of . Using notation we derive that for all
Let us define , then
Summing up these inequalities for we obtain
Noticing that for Jensen’s inequality gives we have
Taking into account that and changing the indices we get that for all
The remaining part of the proof is based on the analysis of inequality (101). In particular, via induction we prove that for all with probability at least the following statement holds: inequalities
hold for . Since is -smooth, we have that probability event implies
for , where the clipping level is defined as
Having inequalities (103) in hand we show in the rest of the proof that (102) holds for with big enough probability. First of all, we introduce new random variables:
for . Note that these random variables are bounded with probability , i.e. with probability we have
Secondly, we use the introduced notation and get that implies
Finally, we do some preliminaries in order to apply Bernstein’s inequality (see Lemma D.1) and obtain that implies
It remains to provide tight upper bounds for ①, ②, ③, ④ and ⑤, i.e. in the remaining part of the proof we show that for some .
Secondly, these summands are bounded with probability :
In other words, sequence is a bounded martingale difference sequence with bounded conditional variances . Therefore, we can apply Bernstein’s inequality, i.e. we apply Lemma D.1 with , and and get that for all
or, equivalently, with probability at least
The choice of will be clarified further, let us now choose in such a way that . This implies that is the positive root of the quadratic equation
That is, with probability at least
Next, we notice that probability event implies that
where the last inequality follows from and simple arithmetic.
Upper bound for ②. First of all, we notice that probability event implies
Upper bound for ③. We derive the upper bound for ③ using the same technique as for ①. First of all, we notice that the summands in ③ are conditionally independent:
Secondly, the summands are bounded with probability :
or, equivalently, with probability at least
As in our derivations of the upper bound for ① we choose such that , i.e.
That is, with probability at least
Next, we notice that probability event implies that
Upper bound for ④. The probability event implies
Upper bound for ⑤. Again, we use corollaries of probability event :
Now we summarize all bound that we have: probability event implies
Taking into account these inequalities and our assumptions on and (see (85) and (86)) we get that probability event implies
That is, by definition of and we have proved that
Since and we get that with probability at least
In other words, clipped-SGD achieves with probability at least after iterations and requires
First of all, consider behavior of clipped-SGD during the first run in R-clipped-SGD. We notice that the proof of Theorem G.1 will be valid if we substitute everywhere by its upper bound . From -strong convexity of we have
therefore, one can choose . It implies that after iterations of clipped-SGD we have
with probability at least , hence with the same probability since . In other words, with probability at least
Then, by induction one can show that for arbitrary the inequality
holds with probability at least . Therefore, these inequalities hold simultaneously with probability at least . Using this we derive that inequality
holds with probability . That is, after restarts R-clipped-SGD generates such point that with probability at least . Moreover, if with some numerical constant , then the total number of iterations of clipped-SGD equals
and the overall number of stochastic first-order oracle calls is
where in the last inequality we use . Next, -strong convexity of implies and
for all . Using notation we rewrite this inequality in the following form:
The rest of the proof is based on the refined analysis of inequality (115). In particular, via induction we prove that for all with probability at least the following statement holds: inequalities
hold for . Since is -smooth, we have that probability event implies
Having inequalities (118) in hand we show in the rest of the proof that (116) holds for with big enough probability. First of all, we introduce new random variables:
for . Note that these random variables are bounded with probability , i.e. with probability we have
Secondly, we use the introduced notation and get that implies
Finally, we do some preliminaries in order to apply Bernstein’s inequality (see Lemma D.1) and obtain that implies
It remains to provide tight upper bounds for ①, ②, ③, ④ and ⑤, i.e. in the remaining part of the proof we show that .
Secondly, these summands are bounded with probability :
In other words, sequence is a bounded martingale difference sequence with bounded conditional variances . Therefore, we can apply Bernstein’s inequality, i.e. we apply Lemma D.1 with , and and get that for all
or, equivalently, with probability at least
The choice of will be clarified further, let us now choose in such a way that . This implies that is the positive root of the quadratic equation
That is, with probability at least
Next, we notice that probability event implies that
where the last inequality follows from and simple arithmetic.
Upper bound for ②. First of all, we notice that probability event implies
Upper bound for ③. We derive the upper bound for ③ using the same technique as for ①. First of all, we notice that the summands in ③ are conditionally independent:
Secondly, the summands are bounded with probability :
or, equivalently, with probability at least
As in our derivations of the upper bound for ① we choose such that , i.e.
That is, with probability at least
Next, we notice that probability event implies that
Upper bound for ④. The probability event implies
Upper bound for ⑤. Again, we use corollaries of probability event :
Now we summarize all bounds that we have: probability event implies
Taking into account these inequalities and our assumptions on and (see (96) and (97)) we get that probability event implies
That is, by definition of and we have proved that
As a result, we get that with probability at least
In other words, clipped-SGD achieves with probability at least after
iterations, where and requires
Appendix H Extra Experiments
In this section we provide a detailed description of experiments from Section 1.2 together with additional experiments. In these experiments we consider the following problem:
That is, for given the r.h.s. of the formula above depends only on the stepsize , initial suboptimality and the variance .
We emphasize that the obtained bound and the convergence in expectation itself does not imply non-trivial upper bound for with high-probability without additional assumptions on the distribution of random vector . In fact, the trajectory of SGD significantly depends on the distribution of . To illustrate this we consider different distributions of with the same .
In the first case we consider from standard normal distribution, i.e. is a Gaussian random vector with zero mean and covariance matrix . Clearly, in this situation .
Next, we consider a random vector with i.i.d. components having Weibull distribution . The cumulative distribution function (CDF) for Weibull distribution with parameters and is
There are explicit formulas for mean and variance for Weibull distribution:
where denotes the gamma function. Having these formulas one can easily shift and scale the distribution in order to get a random variable with zero mean and the variance equal .
Finally, we consider a random vector with i.i.d. components having Burr Type XII distribution having the following cumulative distribution function
where and are the positive parameters. There are explicit formulas for mean and variance for Burr distribution:
where the -th moment (if exists) is defined as follows :
For all experiments we considered the dimension , the stepsize and for clipped-SGD we set . The result of independent runs of SGD and clipped-SGD are presented in Figures 6-10. These numerical tests show that for Weibull and Burr Type XII distributions SGD have significantly larger oscillations than for Gaussian distribution in all tests. In contrast, clipped-SGD behaves much more robust in all cases during all runs without significant oscillations.
H.2 Additional Details and Experiments with Logistic Regression
In this section, we provide additional details of the experiments presented in Section 4 together with extra numerical results. In particular, we consider the logistic regression problem:
We notice that in all experiments that we did with logistic regression the initial suboptimality was of order . Moreover, as it was mentioned in the main part of the paper the parameters for the methods were tuned. One can find parameters that we used in the experiments from Section 4 in Table 4.
Next, we provide our numerical study of the distribution of , where is the last iterate produced by SGD in experiments presented in Section 4, see Figure 11.
As we mentioned in the main part of the paper these histograms are very similar to ones presented in Figure 2, so, the insights that we got from Figure 2 are right. However, in our experiments with australian dataset SGD with the stepsize did not reach needed suboptimality in order to oscillate.
Therefore, we run SGD along with its clipped variants with the same batchsize for bigger number of epochs and also tuned their parameters. One can find the results of these runs in Figure 12.
We see that SGD with this stepsize achieves better suboptimality but it also oscillates significantly more. In contrast, clipped-SGD and d-clipped-SGD do not have significant oscillations and converge with the same rate as SGD. Moreover, clipped-SSTM shows slightly better performance in this case. Finally, we numerically studied the distribution of , where is the last iterate produced by SGD, see Figure 13.
These histograms imply that the noise in stochastic gradients is heavy-tailed and explain an unstable behavior of SGD in this case.
Finally, we conducted experiments on larger datasets: a9a and w8a. The results of our numerical test are reported on Figures 14 and 15. We notice that SSTM with given stepsize and batchsize suffers from noise accumulation, while clipped-SSTM does not have this drawback and shows comparable performance with SGD on a9a and much better performance on w8a.
Figure 15 shows the gradient’s noise distributions for both datasets. While the distribution of stochastic gradients at the optimum for a9a have sub-Gaussian-like distribution, for w8a they have heavy-tailed distribution.