Why are Adaptive Methods Good for Attention Models?

Jingzhao Zhang, Sai Praneeth Karimireddy, Andreas Veit, Seungyeon Kim, Sashank J Reddi, Sanjiv Kumar, Suvrit Sra

Introduction

Stochastic gradient descent (SGD) is the canonical algorithm for training neural networks . SGD iteratively updates model parameters in the negative gradient direction and seamlessly scales to large-scale settings. Though a well-tuned SGD outperforms adaptive methods in many tasks including ImageNet classification (see Figure 1(a)), certain tasks necessitate the use of adaptive variants of SGD (e.g., Adagrad , Adam , AMSGrad ), which employ adaptive learning rates. For instance, consider training an attention model using BERT . Figure 1(e) shows that in spite of extensive hyperparameter tuning, SGD converges much slower than Adam during BERT training.

In this work, we provide one explanation for why adaptivity can facilitate convergence with theoretical and empirical evidence. The significant hint that initializes our work comes from the distribution of the stochastic gradients. For Imagenet, the norms of the mini-batch gradients are typically quite small and well concentrated around their mean. On the other hand, the mini-batch gradient norms for BERT take a wide range of values and are sometimes much larger than their mean value. More formally, while the distribution of the stochastic gradients in Imagenet is well approximated by a Gaussian, the distribution for BERT seems to be heavy-tailed. Such observation leads us to the question: does adaptivity stabilize optimization under heavy-tailed noise?

We provide a positive answer to the above question by performing both theoretical and empirical studies of the convergence of optimization methods under heavy-tailed noise. In this setting, some of the stochastic gradients are much larger than the mean and can excessively influence the updates of SGD. This makes SGD unstable and leads to its poor performance. A natural strategy to stabilize the updates is to clip the magnitude of the stochastic gradients. We prove that indeed it is sufficient to ensure convergence even under heavy-tailed noise. Based on the analysis, we then motivate the design of a novel algorithm (ACClip) that outperforms ADAM on BERT related tasks. Specifically, we make the following contributions:

We empirically show that in tasks on which Adam outperforms SGD (BERT pretraining), the noise in stochastic gradients is heavy-tailed. On the other hand, on tasks where traditionally SGD outperforms Adam (ImageNet training), we show that the noise is well concentrated.

In section 3, we study the convergence of gradient methods under heavy-tailed noise condition where SGD’s performance degrades and its convergence might fail. We then establish (with upper and lower bounds) the convergence of clipped gradient methods under the same condition and prove that they obtain theoretically optimal rates.

Though clipping speeds up SGD, it does not close the gap between SGD and ADAM. In section 4, we motivated the a novel adaptive-threshold coordinate-wise clipping algorithm and in section 5 experimentally show that it outperforms Adam on BERT training tasks.

Adaptive step sizes. Adaptive step sizes during optimization have long been studied . More recently, Duchi et al. developed the Adagrad algorithm that benefits from the sparsity in stochastic gradients. Inspired by Adagrad, several adaptive methods have been proposed in the deep learning community . Recently, there has been a surge in interest to study the theoretical properties of these adaptive gradient methods due to , which pointed out the non-convergence of Adam and proposed an alternative algorithm, AMSGrad. Since then, many works studied different interesting aspects of adaptive methods, see . Another direction of related work is normalized gradient descent, which has been studied for quasi-convex and non-convex settings . In contrast to our work, these prior works assume standard noise distributions that might not be applicable to key modern applications such as attention models, which exhibit heavy-tailed noise. Furthermore, convergence rates of adaptive methods are mostly worse than SGD.

Noise in neural network. There has been little study of the actual stochastic gradient noise distributions in neural network training. To our knowledge, start the topic and observe heavy tailed noise in network training. Our work differs in two important ways: First, we treat the noise as a high dimensional vector, while treat deviations in each coordinate as scaler noises to estimate tail index. Hence, we observe that the example given in is well-concentrated when viewed as a random vector. This is also confirmed by . More experimental comparisons are in Appendix H. Second, we focus on convergence of optimization algorithm, the previously mentioned works focus on Langevin dynamics and escaping saddle points. The convergence rate given in is for global Holder-continuous functions, which restricts the function variations and excludes examples like quadratic functions. Our analysis instead provides the first convergence rates under the standard L-smoothness setting. Further, studies accelerated first order methods under less concentrated noise, however, there “heavy-tailedness” refers to non-sub-Gaussianity.

Heavy-tailed noise in stochastic gradients

To gain intuition about the difference between SGD and adaptive methods, we start our discussion with the study of noise distributions of stochastic gradient that arise during neural network training. In particular, we focus on noise distributions while training two popular deep learning models — BERT and ResNet. Note that BERT and ResNet are typically trained with Adam and SGD (with momentum) respectively and can thus, provide insights about difference between these optimizers.

We first investigate the distribution of the gradient noise norm gf(x)\left\lVert g-\nabla f(x)\right\rVert in the aforementioned neural network models, where gg is the stochastic gradient computed from a minibatch sample. In particular, we fix the model at initialization without doing any updates. We then iterate through the dataset to compute the noise norm for each minibatch. Figure 1 (b) and (f) show these distributions for ResNet50 on ImageNet and BERT on the Wikipedia and books dataset at model initialization respectively. For comparison, we plot distributions of a normalized sum of squared Gaussians, a well-concentrated distribution, and a Levy-α\alpha-stable distribution, a heavy-tailed distribution, in Figure 1 (c) and (g) respectively. We observe that the noise distribution for BERT appears heavy-tailed, while that of ResNet50 is well-concentrated. Results for noise distributions at other stages of training are displayed in Figure 2.

To support this observation, in Figure 1 (d) and (h) we further show the empirical variance of stochastic gradients with respect to the sample size used in the estimation. The results highlight that while the corresponding estimator converges for Imagenet, the empirical variance does not converge in BERT training even as the sample size approaches 10710^{7}.

From the obeservation that the noise can be heavy-tailed, we hypothesize that this is one major aspect that determines the performance of SGD and adaptive methods. In the rest of the paper, we argue and provide evidence that adaptive methods can be faster than SGD in scenarios where heavy-tailed noise distributions arise. More experiment details can be found in Section 5.

Convergence of gradient methods under heavy-tailed noise

In this section we study the performance of SGD and adaptive methods under heavy-tailed noise. More precisely, we analyze algorithms of the following form

where xkx_{k} represent the current parameters, ηk\eta_{k} is the step size and gkg_{k} is the stochastic (mini-batch) gradient evaluated at xkx_{k}. We show that if the stochasticity in the gradient gkg_{k} is heavy-tailed, it is critical for the step sizes to be adaptive i.e. ηk\eta_{k} must depend on the observed gradients. We propose to use one such algorithm GClip and prove that it obtains optimal convergence rates.

The above assumption with α=2\alpha=2 corresponds to the standard variance bound, but in general is weaker. It is indeed possible (e.g. Pareto or α\alpha-stable Levy random variables) for the variance of g(x)g(x) to be unbounded, while simultaneously satisfying assumption 1 for α<2\alpha<2. One should note that even if the variance may not actually be infinite in practice, it might be too large to be practically useful. All our analyses and insights carry over to this setting as well.

The possibility that the variance is unbounded has a profound impact on the optimization process.

The issue is that SGD is easily influenced by a single-stochastic gradient, which could be very large and incorrect. A simple strategy to circumvent this issue is to use a biased clipped stochastic gradient estimator. This allows us to circumvent the problem of unbounded variance and ensures optimal convergence rates even under heavy-tailed noise. Our results are summarized in Table 1, and all proofs are relegated to the Appendices.

1 Convergence of Clipped Methods

A simple clipping strategy is to globally clip the norm of the update to threshold τk\tau_{k}:

We refer to this strategy as GClip (Global Clip), as opposed to coordinate-wise clipping which we discuss later. We first state the rates for smooth non-convex functions.

Suppose that ff is LL-smooth and that the stochastic gradients satisfy Assumption 1 for α(1,2]\alpha\in(1,2]. Let {xk}\{x_{k}\} be the iterates of GClip with parameters ηk=η=min{14L,σαLτα,124Lτ}\eta_{k}=\eta=\min\{\frac{1}{4L},\frac{\sigma^{\alpha}}{L\tau^{\alpha}},\frac{1}{24L\tau}\} and \tau_{k}=\tau=\max\{2,48^{1/(\alpha-1)}\sigma^{\alpha/(\alpha-1)},8\sigma,\big{(}\frac{f_{0}}{\sigma^{2}K}\big{)}^{\frac{\alpha}{3\alpha-2}}\big{/}L^{\frac{2\alpha-2}{3\alpha-2}},\}. Then for F0:=f(x0)fF_{0}:=f(x_{0})-f^{*},

We prove improved rates of convergence for non-smooth strongly-convex functions in a bounded domain. Due to limited space, we relegate the definitions and assumptions to Appendix A.

Suppose that the stochastic gradients satisfy Assumption 4 for α(1,2]\alpha\in(1,2]. Let {xk}\{x_{k}\} be the iterates of projected GClip (proj-GClip) with clipping parameter τk=Gkα1\tau_{k}=Gk^{\alpha-1} and steps-size ηk=4μ(k+1)\eta_{k}=\frac{4}{\mu(k+1)}. Define the output to be a kk-weighted combination of the iterates: xˉk=j=1kjxj1/(j=1kj).\bar{x}_{k}=\sum_{j=1}^{k}jx_{j-1}/(\sum_{j=1}^{k}j)\,. Then the output xˉk\bar{x}_{k} satisfies:

The rates of convergence for the strongly convex and non-convex cases in Theorem 4 and Theorem 2 exactly match those of the usual SGD rates (O(1/k)\mathcal{O}(1/\sqrt{k}) for convex and O(k14)\mathcal{O}(k^{-\frac{1}{4}}) for non-convex) when α=2\alpha=2 and gracefully degrade for α(1,2]\alpha\in(1,2]. As we will next show, both the strongly convex rates and non-convex rates of GClip are in fact optimal for every α(1,2]\alpha\in(1,2].

2 Theoretic lower bounds

For any α(1,2]\alpha\in(1,2] and any (possibly randomized) algorithm A\mathcal{A}, there exists a problem ff which is 1-strongly convex and 1-smooth (μ=1\mu=1 and L=1L=1), and stochastic gradients which satisfy Assumptions 4 with G1G\leq 1 such that the output xkx_{k} of the algorithm A\mathcal{A} after processing kk stochastic gradients has an error

Given any α(1,2]\alpha\in(1,2], smoothness constant LL, and (possibly randomized) algorithm A\mathcal{A}, there exists a constant c1c_{1} and an LL-smooth function ff with stochastic gradients satisfying Assumption 1 for any given σc1(f(0)f)L\sigma\geq c_{1}\sqrt{(f(0)-f^{*})L} such that the output xkx_{k} of the algorithm A\mathcal{A} after processing kk stochastic gradients has an error

Theorem 6, proven in Appendix G, extends the recent work of [2, Theorem 1] to heavy-tailed noise. Here, the lower-bound matches the upper-bound in Theorem 2 up to constants, proving its optimality.

Faster Optimization with Adaptive Coordinate-wise Clipping

The previous section showed that adaptive step sizes (which depend on the gradients) are essential for convergence under heavy-tailed noise, and also showed that GClip provides the optimal rates. There are of course other adaptive methods such as Adam which employs not only the current gradients but also all past gradients to adaptively set coordinate-wise step-sizes. In this section, we study why coordinate-wise clipping may yield even faster convergence than GClip, and show how to modify GClip to design an Adaptive Coordinate-wise Clipping algorithm (ACClip).

The first technique we use is applying coordinate-wise clipping instead of global clipping. We had previously assumed a global bound on the α\alpha-moment of the norm (or variance) of the stochastic gradient is bounded by σ\sigma. However, σ\sigma might be hiding some dimension dependence dd. We show a more fine-grained model of the noise in order to tease out this dependence.

Suppose we run GClip under Assumption 2 to obtain the sequence {xk}\{x_{k}\}. If ff is μ\mu-strongly convex, with appropriate step-sizes and averaging, the output xˉk\bar{x}_{k} satisfies

Thus, the convergence of GClip can have a strong dependence on dd, which for large-scale problems might be problematic. We show next that using coordinate-wise clipping removes this dependency:

Suppose we run CClip under the Assumption of 2 with τk=Bkα1\tau_{k}=Bk^{\alpha-1} to obtain the sequence {xk}\{x_{k}\}. Then, if ff is μ\mu-strongly convex, with appropriate step-sizes and averaging, the output xˉk\bar{x}_{k} satisfies

Note that B2Bα\lVert B\rVert_{2}\leq\lVert B\rVert_{\alpha}. CClip has a worst-case convergence independent of dd under the coordinate-wise noise model. Similar comparison between GClip and CClip can be done for non-convex conditions too, but we skip for conciseness. Though we only compare upper-bounds here, when the noise across coordinates is independent the upper bounds may be tight (see Lemma 12).

2 Online moment estimation

We now present the second technique that is motivated by our observation in Figure 2. There, the distribution of gradient noise at the beginning of different epochs is shown during training for BERT with Wikipedia (top) as well as ResNet with ImageNet (bottom). The result highlights that the noise distribution is not only heavy-tailed, but also non-stationary during BERT training and becomes increasingly more concentrated. In contrast, for the ResNet model the noise distribution remains mostly unchanged.

Since the scale of the noise changes drastically during training for BERT model and our theoretical analysis suggest that we should clip proportional to the noise level, we propose to use an exponential moving average estimator to estimate the moment and clip the gradient accordingly (line 4,5 of Alg 1). This, combined with the momentum term leads to our proposed ACClip algorithm in Algorithm 1. On a high level, the algorithm applies clipping to the momentum term, where the clipping threshold is proportional to the estimated moment using an exponential moving average. From our experiment, we found the conservative choice of α=1\alpha=1 leads to the best performance.

Experiments

In this section, we first verify the effect of coordinate-wise clipping and moment estimation introduced in Section 4. We then perform extensive evaluations of ACClip on BERT pre-training and fine-tuning tasks and demonstrate its advantage over Adam in Section 5.2. For completeness, an experiment on ImageNet is included in Appendix I. Finally, we start with a few more experiments on the noise distribution in neural network training.

In this section we instantiate the argument in Section 4 with a set of experiments. As seen in Figure 3(b), global clipping improves the vanilla SGD algorithm but is still far from the ADAM baseline. We apply two techniques (coordinate-wise clipping and online moment estimation) onto the clipped SGD algorithm analyzed in Section 3. We use a set of experiments on Transformer-XL training to demonstrate the effect of each technique.

We train a 6-layer Transformer-XL model on PTB dataset as a proof of concept. Our main experiments will be on BERT pretraining and finetuning described in the next subsection 5.2. We use adapt the author’s github repohttps://github.com/kimiyoung/transformer-xl/tree/master/pytorch, and replace the number of layers of the base model by 6. We then select the PTB data as input and set the maximum target length to be 128. The results are shown in Figure 3(b).

Observations

From Figure 3(b), we can tell that global clipping (orange curve) indeed speeds up vanilla SGD but is still much worse compared to the ADAM baseline provided by the code base. After replacing global clipping with coordinate-wise clipping, we see that the performance is already comparable to the ADAM baseline. Finally, after using the moment estimation to determine the clipping threshold, we are able to achieve faster convergence than ADAM.

2 Performance of ACClip for BERT pre-training and fine-tuning

We now evaluate the empirical performance of our proposed ACClip algorithm on BERT pre-training as well fine-tuning using the SQUAD v1.1 dataset. As a baseline, we use Adam optimizer and the same training setup as in the BERT paper . For ACClip, we set τ=1,learning rate=1e-4,β1=0.9,β2=0.99,ϵ=1e-5\tau=1,\textit{learning rate}=\text{1e-4},\beta_{1}=0.9,\beta_{2}=0.99,\epsilon=\text{1e-5} and weight decay=1e-5\textit{weight decay}=\text{1e-5}. We compare both setups on BERT models of three different sizes, BERTbase with 6 and 12 layers as well as BERTlarge with 24 layers.

Figure 3(b) and 3(c) shows the loss for pretraining BERTbase using SGD with momentum, GClip, Adam and ACClip. The learning rates and hyperparameters for each method have been extensively tuned to provide best performance on validation set. However, even after extensive tuning, there remains a large gap between (clipped) SGD momentum and adaptive methods. Furthermore, clipped SGD achieves faster convergence as well as lower final loss compared to standard SGD. Lastly, the proposed optimizer ACClip achieves a lower loss than the Adam. Table 2 further shows that ACClip achieves lower loss and higher masked-LM accuracy for all model sizes.

Next, we evaluate ACClip on the SQUAD v1.1 fine-tuning task. We again follow the procedure outlined in and present the results on the Dev set in Table 3. Both for F1 as well as for exact match, the proposed algorithm outperforms Adam on all model sizes. The experimental results on BERT pretraining and fine-tuning indicate the effectiveness of the proposed algorithm.

3 Noise Patterns in BERT and ImageNet Training

In our initial analysis in Figure 1, we observe that training an attention model on Wikipedia leads to heavy-tailed noise whereas training a ResNet on ImageNet data leads to well-concentrated noise. Here, we aim to disentangle the effect that model architecture and training data have on the shape of gradient noise. To this end, we measure the distribution of the gradient noise norm in an Attention and a ResNet model on both Wikipedia and synthetic Gaussian data. We used BERTbase as the Attention model, and the ResNet is constructed by removing the self-attention modules within the transformer blocks. Gaussian synthetic data is generated by replacing the token embedding layer with normalized Gaussian input. The resulting noise histograms are shown in Figure 4. The figure shows that the Attention model leads to heavy-tailed noise independently of input data. For the ResNet model, we observe that Gaussian input leads to Gaussian noise, whereas Wikipedia data leads to be heavy-tailed noise. We thus conclude that the heavy-tailed noise pattern results from both the model architecture as well as the data distribution.

Discussion

One immediate extension from this work is to view RMSProp as a clipping algorithm and prove its convergence under shifting noise. The update for RMSProp and ACClip with β1=0\beta_{1}=0 can be written with effective step-sizes hrmsh_{\text{rms}} and hcliph_{\text{clip}} respectively as below:

Given any set of parameters for RMSProp, if we set the parameters for ACClip as

In summary, our work theoretically and empirically ties the advantage of adaptive methods over SGD to the heavy-tailed nature of gradient noise. A careful analysis of the noise and its impact yielded two insights: that clipping is an excellent strategy to deal with heavy-tailed noise, and that the ACClip yields state of the art performance for training attention models. Our results add to a growing body of work which demonstrate the importance of the structure of the noise in understanding neural network training. We believe additional such investigations into the source of the heavy tailed-ness, as well as a characterization of the noise can lead to further insights with significant impact on practice.

Broader impact

We study convergence rates of gradient methods under a more relaxed noise condition. The result under this setting reaches conclusions that are closer to practice compared to results under the standard setting. Hence, our work provides one way to bridge the theory-practice gap and can facilitate more future works in this direction.

References

Appendix A Additional definitions and assumptions

Here we describe some of the formal assumptions which were previously skipped.

We define the standard notion of smoothness.

ff is LL-smooth, i.e. there exist positive constants LL such that x,y\forall x,y, f(y)f(x)+f(x),yx+L2yx2.f(y)\leq f(x)+\langle\nabla f(x),y-x\rangle+\frac{L}{2}\lVert y-x\rVert^{2}\,.

Note that we only need the smoothness assumption for non-convex functions.

A.2 Assumptions in the strongly convex setting

For strongly-convex optimization, instead of bounding the noise, we assume that the stochastic oracle has bounded moment.

Note that the above assumption implies a uniform bound on gradient norm. Such bound is necessary for nonsmooth strongly convex problems, as one can no longer factor out the gradient norm using the smoothness assumption. See for example, .

ff is μ\mu-strongly convex, if there exist positive constants μ\mu such that x,y\forall x,y,

The strong convexity assumption and the bounded gradient assumption implies that the domain is bounded, which we state explicitly below,

We look for a solution xx within a bounded convex set X\mathcal{X}.

We didn’t upper bound the domain diameter as it is not used explicitly in the proof. To ensure all updates are within a domain, we use the projected version of (GClip) defined as follows:

The projection operator x=projX(y)x=\operatorname{proj}_{\mathcal{X}}(y) finds the point xXx\in\mathcal{X} that has the least distance to yy.

Appendix B Effect of global clipping on variance and bias

We focus on (GClip) under stochastic gradients which satisfy Assumption 1.

By the fact that g^(x)τ\hat{g}(x)\leq\tau, we get

As we increase the clipping parameter τ\tau, note that the variance (the first term in Lemma 9) increases while the bias (which is the second term) decreases. This way, we can carefully trade-off the variance of our estimator against its bias, thereby ensuring convergence of the algorithm.

Appendix C Non-convex Rates (Proof of Theorem 2)

The lemma in the previous section can be readily used in the nonsmooth strongly convex setting. However, we need a variant of Lemma 9 in the smooth case.

For any g(x)g(x) suppose that assumption 1 holds with α(1,2]\alpha\in(1,2]. If f(x)τ/2\|\nabla f(x)\|\leq\tau/2, then the estimator g^:=min{1,τ/gk}gk\hat{g}:=\min\{1,\tau/\|g_{k}\|\}g_{k} from (GClip) with global clipping parameter τ0\tau\geq 0 satisfies:

The expectation is taken with respect to the randomness in noise. The second last inequality follows by the fact that f(x)g^(x)<2τ\|\nabla f(x)-\hat{g}(x)\|<2\tau.

Next, we need a subprocedure at the end proof of Lemma 2 from .

At each iteration, we consider two cases, either f(xk)<τ/2\|\nabla f(x_{k})\|<\tau/2 or f(xk)τ/2\|\nabla f(x_{k})\|\geq\tau/2.

Here the last step used the AM-GM inequality. Then, taking expectation in both sides and using Lemma 10 gives

In the last step we used {ηk=η14L}\{\eta_{k}=\eta\leq\frac{1}{4L}\}.

Recall g^k=min{1,τ/gk}gk\hat{g}_{k}=\min\{1,\tau/\|g_{k}\|\}g_{k} and parameter choices ηk=η=min{14L,1Lτα,124Lτ}\eta_{k}=\eta=\min\{\frac{1}{4L},\frac{1}{L\tau^{\alpha}},\frac{1}{24L\tau}\} and τk=τ=max{2,481/(α1)σα/(α1),8σ,σK13α2}\tau_{k}=\tau=\max\{2,48^{1/(\alpha-1)}\sigma^{\alpha/(\alpha-1)},8\sigma,\sigma K^{\frac{1}{3\alpha-2}}\}. We use f\nabla f as a shorthand for f(xk)\nabla f(x_{k}):

The second line follows by Lemma 11 and (C). The third line follows by that τ2\tau\geq 2, and fτ/2\|\nabla f\|\geq\tau/2 imply p2f2pf/3.\tfrac{p}{2}\|\nabla f\|^{2}\geq p\|\nabla f\|/3. Then, by τ481/(α1)σα/(α1)\tau\geq 48^{1/(\alpha-1)}\sigma^{\alpha/(\alpha-1)}, we have σα(τ/4)α1112\tfrac{\sigma^{\alpha}}{(\tau/4)^{\alpha-1}}\leq\tfrac{1}{12}. By τ8σ\tau\geq 8\sigma, 83στ/3f/6\tfrac{8}{3}\sigma\leq\tau/3\leq\|\nabla f\|/6.

The last inequality above follows by 124Lτ\frac{1}{24L\tau}.

Rearrange and sum the terms above for some fixed step-size and threshold {τk=τ}\{\tau_{k}=\tau\} to get

Since we use a stepsize η1Lτα\eta\leq\frac{1}{L\tau^{\alpha}}, we can simplify T2T_{2} as

Denote F0=f(x0)fF_{0}=f(x_{0})-f^{\star} to ease notation. Then, adding T2T_{2} back to T1T_{1} and using a threshold τσK13α2\tau\geq\sigma K^{\frac{1}{3\alpha-2}} we get

This proves the statement of the theorem. ∎

Appendix D Strongly-Convex Rates (Proof of Theorem 4)

The first inequality follows by the nonexpansivity of projections onto convex sets.

After taking expectation and apply the inequality from Lemma 9, we get

Then take ηk=4μ(k+1),τk=Gk1α\eta_{k}=\frac{4}{\mu(k+1)},\tau_{k}=Gk^{\frac{1}{\alpha}} and multiply both side by kk, we get

Notice that k=1Kk2αα0K+1k2ααdk(K+1)2/α\sum_{k=1}^{K}k^{\frac{2-\alpha}{\alpha}}\leq\int_{0}^{K+1}k^{\frac{2-\alpha}{\alpha}}dk\leq(K+1)^{2/\alpha}. Sum over kk and we get

Devide both side by K(K+1)2\frac{K(K+1)}{2} and we get

Notice that for K1K\geq 1, K12(K+1)1K^{-1}\leq 2(K+1)^{-1}. We have

The theorem then follows by Jensen’s inequality. ∎

Appendix E Effect of coordinate-wise moment bound

We now examine how the rates would change if we replace Assumption 4 with Assumption 2.

We now look at(GClip) under assumption 2.

The proof of both the convex and non-convex rates following directly from the following Lemma.

For any g(x)g(x) suppose that assumption 2 with α(1,2]\alpha\in(1,2]. Then suppose we have a constant upper-bound

Note that the function ()α/2(\cdot)^{\alpha/2} is concave for α(1,2]\alpha\in(1,2]. Using Jensen’s inequality we can rewrite as:

Since the right hand-side can be as large as dα21Bααd^{\frac{\alpha}{2}-1}\lVert B\rVert_{\alpha}^{\alpha}, we have our first inequality. On the other hand, we also have an upper bound below:

where Bαα=i=1dBiα\lVert B\rVert^{\alpha}_{\alpha}=\sum_{i=1}^{d}B_{i}^{\alpha}. Thus, we have shown that

We know that Jensen’s inequality is tight when all the co-ordinates have equal values. This means that if the noise across the coordinates is linearly correlated the lower bound is tighter, whereas the upper bound is tighter if the coordinates depend upon each other in a more complicated manner or are independent of each other. ∎

Substituting this bound on GG in Theorems 4 and 2 gives us our corollaries.

E.2 Convergence of CClip (Proof of Theorem 8)

The proof relies on the key lemma which captures the bias-variance trade off under the new noise-assumption and coordinate-wise clipping.

For any g(x)g(x) suppose that assumption 2 with α(1,2]\alpha\in(1,2] holds. Denote gig_{i} to be ithi_{th} component of g(x)g(x), f(x)i\nabla f(x)_{i} to be ithi_{th} component of f(x)\nabla f(x). Then the estimator g^(x)=[g^1;;g^d]\hat{g}(x)=[\hat{g}_{1};\cdots;\hat{g}_{d}] from (CClip) with clipping parameter τ=[τ1;τ2;;τd]\tau=[\tau_{1};\tau_{2};\cdots;\tau_{d}] satisfies:

Apply Lemma 9 to the one dimensional case in each coordinate. ∎

After taking expectation and apply the inequality from Lemma 9, we get

Then take ηk=4μ(k+1),τi=Bik1α\eta_{k}=\frac{4}{\mu(k+1)},\tau_{i}=B_{i}k^{\frac{1}{\alpha}} and multiply both side by kk, we get

Notice that k=1Kk2αα0K+1k2ααdk(K+1)2/α\sum_{k=1}^{K}k^{\frac{2-\alpha}{\alpha}}\leq\int_{0}^{K+1}k^{\frac{2-\alpha}{\alpha}}dk\leq(K+1)^{2/\alpha}. Sum over kk and we get

Devide both side by K(K+1)2\frac{K(K+1)}{2} and we get

Notice that for K1K\geq 1, K12(K+1)1K^{-1}\leq 2(K+1)^{-1}. We have

The theorem then follows by Jensen’s inequality. ∎∎

Appendix F Lower Bound (Proof of Theorem 5)

We consider the following simple one-dimensional function class parameterized by bb:

Also suppose that for α(1,2]\alpha\in(1,2] and b[0,1/2]b\in[0,1/2] the stochastic gradients are of the form:

Note that the function class (3) has μ=1\mu=1 and optimum value fb(b)=0f_{b}(b)=0, and the α\alpha-moment of the noise in (4) satisfies G=B1G=B\leq 1. Thus, we want to prove the following:

For any α(1,2]\alpha\in(1,2] there exists a distribution χb\chi_{b} such that the stochastic gradients satisfy (4). Further, for any (possibly randomized) algorithm A\mathcal{A}, define Ak(fb+χb)\mathcal{A}_{k}\left(f_{b}+\chi_{b}\right) to be the output of the algorithm A\mathcal{A} after kk queries to the stochastic gradient g(x)g(x). Then:

Our lower bound construction is inspired by Theorem 2 of . Let Ak(fb+χb)\mathcal{A}_{k}(f_{b}+\chi_{b}) denote the output of any possibly randomized algorithm A\mathcal{A} after processing kk stochastic gradients of the function fbf_{b} (with noise drawn i.i.d. from distribution χb\chi_{b}). Similarly, let Dk(fb+χb)\mathcal{D}_{k}(f_{b}+\chi_{b}) denote the output of a deterministic algorithm after processing the kk stochastic gradients. Then from Yao’s minimax principle we know that for any fixed distribution B\mathcal{B} over [0,1/2][0,1/2],

In this rest of the proof, we will try obtain a lower bound for the right hand side above.

We now describe our construction of the three quantities to be defined: the problem distribution B\mathcal{B}, the noise distribution χb\chi_{b}, and the bijective mapping h()h(\cdot). All of our definitions are parameterized by α(1,2]\alpha\in(1,2] (which is given as input) and by ϵ(0,1/8]\epsilon\in(0,1/8] (which represents the desired target accuracy). We will pick ϵ\epsilon to be a fixed constant which depends on the problem parameters (e.g. kk) and should be thought of as being small.

Problem distribution: B\mathcal{B} picks b0=2ϵb_{0}=2\epsilon or b1=ϵb_{1}=\epsilon at random i.e. ν{0,1}\nu\in\{0,1\} is chosen by an unbiased coin toss and then we pick

Noise distribution: Define a constant γ=(4ϵ)1/(α1)\gamma=(4\epsilon)^{1/(\alpha-1)} and pν=(γα2νγϵ)p_{\nu}=(\gamma^{\alpha}-2\nu\gamma\epsilon). Simple computations verify that γ(0,1/2]\gamma\in(0,1/2] and that

Then, for a given ν{0,1}\nu\in\{0,1\} the stochastic gradient g(x)g(x) is defined as

To see that we have the correct gradient in expectation verify that

Next to bound the α\alpha moment of g(x)g(x) we see that

The above inequality used the bounds that α1\alpha\geq 1, x[0,1/2]x\in[0,1/2], and γ(0,1/2]\gamma\in(0,1/2]. Thus g(x)g(x) defined in (6) satisfies condition (4).

Bijective mapping: Note that here the only unknown variable is ν\nu which only affects pνp_{\nu}. Thus the mapping is bijective as long as the frequencies of the events are preserved. Hence given a stochastic gradient g(xi)g(x_{i}) the mapping we use is:

Given the definitions above, the output of algorithm Dk\mathcal{D}_{k} is thus simply a function of kk i.i.d. samples drawn from the Bernoulli distribution with parameter pνp_{\nu} (which is denoted by Bern(pν)\operatorname{Bern}(p_{\nu})). We now show how achieving a small optimization error implies being able to guess the value of ν\nu.

Suppose we are given problem and noise distributions defined as in (5) and (6), and an bijective mapping h()h(\cdot) as in (7). Further suppose that there is a deterministic algorithm Dk\mathcal{D}_{k} whose output after processing kk stochastic gradients satisfies

Suppose that we are given access to kk samples of Bern(pν)\operatorname{Bern}(p_{\nu}). Use these kk samples as the input h(fb+χb))h(f_{b}+\chi_{b})) to the procedure Dk\mathcal{D}_{k} (this is valid as previously discussed), and let the output of Dk\mathcal{D}_{k} be xk(ν)x^{(\nu)}_{k}. The assumption in the lemma states that

Then, using Markov’s inequality (and then taking square-roots on both sides) gives

Next using Pinsker’s inequality we can upper bound the right hand side as:

where TV\lvert\cdot\rvert_{TV} denotes the total-variation distance and KL(,)\operatorname{KL}(\cdot,\cdot) denotes the KL-divergence. Recall two properties of KL-divergence: i) for a product measures defined over the same measurable space (p1,,pk)(p_{1},\dots,p_{k}) and (q1,,qk)(q_{1},\dots,q_{k}),

Recalling that α(1,2]\alpha\in(1,2] gives us the statement of the lemma. ∎

Given Lemmas 15 and 16, this implies that for the above choice of ϵ\epsilon,

This finishes the proof of the theorem. Note that the readability of the proof was prioritized over optimality and it is possible to obtain significantly better constants. ∎

Appendix G Non-convex Lower Bound (Proof of Theorem 6)

The proof is based on the proof of Theorem 1 in . The only difference is that we assume bounded α\alpha-moment of the stochastic oracle instead of bounded variance as in the original proof. We refer readers to for more backgrounds and intuitions. For convenience, we study the stochastic setting (K=1K=1 in ) instead of batched setting. We denote a dd-dimensional vector xx as, x=[x(1);...;x(d)].x=[x_{(1)};...;x_{(d)}]. Let support(x)\text{support}(x) denote the set of coordinates where xx is nonzero, i.e.

Denote progβ(x)\text{prog}_{\beta}(x) as the highest index whose entry is β\beta-far from zero.

Note that the function progβ()\text{prog}_{\beta}(\,\cdot\,) is decreasing in β\beta. The function we use to prove the theorem is the same as in . We denote

The above function satisfies the following important properties,

The function fdf_{d} satisfies the following properties,

fdf_{d} is L0L_{0}-smooth, where L0=152L_{0}=152.

For all xx, fd(x)23\|\nabla f_{d}(x)\|_{\infty}\leq 23.

For all xx, prog0(fd(x))prog12(x)+1\text{prog}_{0}(\nabla f_{d}(x))\leq\text{prog}_{\frac{1}{2}}(x)+1

For all xx, if prog1(x)<d\text{prog}_{1}(x)<d, then fd(x)21\|\nabla f_{d}(x)\|^{2}\geq 1.

We also define the stochastic oracle gd(x)g_{d}(x) as below

where zBernoulli(p)z\sim\text{Bernoulli}(p). The stochasticity of gd(x)g_{d}(x) is only in the (prog14(x)+1)(\text{prog}_{\frac{1}{4}}(x)+1)th coordinate. It is easy to see that gd(x)g_{d}(x) is a probability-pp zero chain as in [2, Definition 2] i.e. it satisfies

The second claim is because progβ()\text{prog}_{\beta}(\,\cdot\,) is decreasing in β\beta and

The first claim is because if z=0z=0, then we explicitly set the (prog14(x)+1)(\text{prog}_{\frac{1}{4}}(x)+1)th coordinate to 0. The stochastic gradient additionally has bounded α\alpha-moment as we next show.

The stochastic oracle above is an unbiased estimator of the true gradient, and for any α(1,2]\alpha\in(1,2]

The unbiased-ness is easy to verify. For the bounded α\alpha-moment, observe that only the (prog14+1)(\text{prog}_{\frac{1}{4}}+1)-th coordinate is noisy and differs by a factor of (zp1)(\frac{z}{p}-1). Hence, we have

The first inequality followed from Jensen’s inequality and the convexity of α\lVert\,\cdot\,\rVert^{\alpha} for α(1,2]\alpha\in(1,2]:

Now we are ready to prove Theorem 6. Given accuracy parameter ϵ\epsilon, suboptimality Δ=f(0)f\Delta=f(0)-f^{*}, smoothness constant LL, and bounded α\alpha-moment GαG^{\alpha}, we define

where λ=304ϵL\lambda=\frac{304\epsilon}{L} and d=ΔL7296ϵ2d=\lfloor\frac{\Delta L}{7296\epsilon^{2}}\rfloor. Then,

Let xkx_{k} be the output of any zero-respecting algorithm A\mathcal{A}. By [2, Lemma 1], we know that with probability at least 1/2, prog1(xk)prog0(xk)<d\text{prog}_{1}(x_{k})\leq\text{prog}_{0}(x_{k})<d for all k(d1)2pk\leq\frac{(d-1)}{2p}. Now applying Lemma 17.5, we have that for all k(d1)2pk\leq\frac{(d-1)}{2p}:

Appendix H A Comparison with [25]

We are not the first to study the heavy-tailed noise behavior in neural network training. The novel work by Simsekli et al. studies the noise behavior of AlexNet on Cifar 10 and observed that the noise does not seem to come from Gaussian distribution. However, in our AlexNet training with ImageNet data, we observe that the noise histogram looks Gaussian as in Figure 5(a, b). We believe the difference results from that in , the authors treat the noise in each coordinate as an independent scaler noise, as described in the original work on applying tail index estimator. We on the other hand, consider each the noise as a high dimensional random vector computed from a minibatch. We are also able to observe heavy tailed noise if we fix a single minibatch and plot the noise in each dimension, as shown in Figure 5(c). The fact that noise is well concentrated on Cifar is also observed by Panigrahi et al. .

Furthermore, we used the tail index estimator presented in to estimate the tail index of noise norm distribution. Though some assumptions of the estimator are not satisfied (in our case, the symmetry assumption; in , the symmetry assumption and independence assumption), we think it can be an indicator for measuring the “heaviness” of the tail distribution.

Appendix I ACClip in ImageNet Training

For completeness, we test ACClip on ImageNet training with ResNet50. After hyperparameter tuning for all algorithms, ACClip is able to achieve better performance compared to ADAM, but worse performance compared to SGD. This is as expected because the noise distribution in ImageNet + ResNet50 training is well concentrated. The validation accuracy for SGD, ADAM, ACClip are 0.754,0.716,0.7300.754,0.716,0.730 respectively.