YellowFin and the Art of Momentum Tuning
Jian Zhang, Ioannis Mitliagkas
Introduction
Accelerated forms of stochastic gradient descent (SGD), pioneered by Polyak and Nesterov , are the de-facto training algorithms for deep learning. Their use requires a sane choice for their hyperparameters: typically a learning rate and momentum parameter . However, tuning hyperparameters is arguably the most time-consuming part of deep learning, with many papers outlining best tuning practices written . Deep learning researchers have proposed a number of methods to deal with hyperparameter optimization, ranging from grid-search and smart black-box methods to adaptive optimizers. Adaptive optimizers aim to eliminate hyperparameter search by tuning on the fly for a single training run: algorithms like AdaGrad , RMSProp and Adam use the magnitude of gradient elements to tune learning rates individually for each variable and have been largely successful in relieving practitioners of tuning the learning rate.
Recently some researchers have started favoring simple momentum SGD over the previously mentioned adaptive methods , often reporting better test scores . Motivated by this trend, we ask the question: can simpler adaptive methods based on momentum SGD perform as well or better? We empirically show, with a hand-tuned learning rate, Polyak’s momentum SGD achieves faster convergence than Adam for a large class of models. We then formulate the optimization update as a dynamical system and study certain robustness properties of the momentum operator. Inspired by our analysis, we design \tuner, an automatic hyperparameter tuner for momentum SGD. \tunersimultaneously tunes the learning rate and momentum on the fly, and can handle the complex dynamics of asynchronous execution. Our contribution and outline are as follows:
In Section 2, we demonstrate examples where momentum offers convergence robust to learning rate misspecification and curvature variation in a class of non-convex objectives. This robustness is desirable for deep learning. It stems from a known but obscure fact: the momentum operator’s spectral radius is constant in a large subset of the hyperparameter space.
In Section 3, we use these robustness insights and a simple quadratic model analysis to motivate the design of \tuner, an automatic tuner for momentum SGD. \tuneruses on-the-fly measurements from the gradients to tune both a single learning rate and a single momentum.
In Section 3.3, we discuss common stability concerns related to the phenomenon of exploding gradients . We present a natural extension to our basic tuner, using adaptive gradient clipping, to stabilize training for objectives with exploding gradients.
In Section 4 we present closed-loop YellowFin, suited for asynchronous training. It uses a novel component for measuring the total momentum in a running system, including any asynchrony-induced momentum, a phenomenon described in . This measurement is used in a negative feedback loop to control the value of algorithmic momentum.
We provide a thorough empirical evaluation of the performance and stability of our tuner. In Section 5, we demonstrate empirically that on ResNets and LSTMs \tunercan converge in fewer iterations compared to: (i) hand-tuned momentum SGD (up to x speedup); and (ii) hand-tuned Adam (x to x speedup). Under asynchrony, the closed-loop control architecture speeds up \tuner, making it up to x faster than Adam. Our experiments include runs on different models, randomized over at least different random seeds. \tuneris stable and achieves consistent performance: the normalized sample standard deviation of test metrics varies from to . We released PyTorch and TensorFlow implementations TensorFlow: goo.gl/zC2rjG. PyTorch: goo.gl/N4sFfsthat can be used as drop-in replacements for any optimizer. \tunerhas also been implemented in various other packages. Its large-scale deployment in industry has taught us important lessons about stability; we discuss those challenges and our solution in Section 3.3. We conclude with related work and discussion in Section 6 and 7.
The momentum operator
In this section, we identify the main technical insight behind the design of \tuner: gradient descent with momentum can exhibit linear convergence robust to learning rate misspecification and to curvature variation. The robustness to learning rate misspecification means tolerance to a less-carefully-tuned learning rate. On the other hand, the robustness to curvature variation means empirical linear convergence on a class of non-convex objectives with varying curvatures. After preliminary on momentum, we discuss these two properties desirable for deep learning objectives.
We aim to minimize some objective . In machine learning, is referred to as the model and the objective is some loss function. A low loss implies a well-fit model. Gradient descent-based procedures use the gradient of the objective function, , to update the model iteratively. These procedures can be characterized by the convergence rate with respect to the distance to a minimum.
Let be a local minimum of and denote the model after steps of an iterative procedure. The iterates converge to with linear rate , if
Polyak’s momentum gradient descent is one of these iterative procedures, given by
where denotes a single learning rate and a single momentum for all model variables. Momentum’s main appeal is its established ability to accelerate convergence . On a -strongly convex -smooth function with condition number , the optimal convergence rate of gradient descent without momentum is . On the other hand, for certain classes of strongly convex and smooth functions, like quadratics, the optimal momentum value,
yields the optimal accelerated linear convergence rate . This guarantee does not generalize to arbitrary strongly convex smooth functions . Nonetheless, this linear rate can often be observed in practice even on non-quadratics (cf. Section 2.2).
Key insight: Consider a quadratic objective with condition number . Even though its curvature is different along the different directions, Polyak’s momentum gradient descent, with , achieves the same linear convergence rate along all directions. Specifically, let and be the i-th coordinates of and . For any with an appropriate learning rate, the update in (1) can achieve simultaneously along all axes . This insight has been hidden away in proofs.
In this quadratic case, curvature is different across different axes, but remains constant on any one-dimensional slice. In the next section (Section 2.2), we extend this insight to non-quadratic one-dimensional functions. We then present the main technical insight behind the design of \tuner: similar linear convergence rate can be achieved in a class of one-dimensional non-convex objectives where curvature varies; this linear convergence behavior is robust to learning rate misspecification and to the varying curvature. These robustness properties are behind a tuning rule for learning rate and momentum in Section 2.2. We extend this rule to handle SGD noise and generalize it to multidimensional objectives in Section 3.
2 Robustness properties of the momentum operator
In this section, we analyze the dynamics of momentum on a class of one-dimensional, non-convex objectives. We first introduce the notion of generalized curvature and use it to describe the momentum operator. Then we discuss the robustness properties of the momentum operator.
Curvature along different directions is encoded in the different eigenvalues of the Hessian. It is the only feature of a quadratic needed to characterize the convergence of gradient descent. Specifically, gradient descent achieves a linear convergence rate on one-dimensional quadratics with constant curvature . On one-dimensional non-quadratic objectives with varying curvature, this neat characterization is lost. We can recover it by defining a new kind of “curvature” with respect to a specific minimum.
Generalized curvature describes, in some sense, non-local curvature with respect to minimum . It coincides with curvature on quadratics. On non-quadratic objectives, it characterizes the convergence behavior of gradient descent-based algorithms. Specifically, we recover the fact that starting at point , distance from minimum is reduced by in one step of gradient descent. Using a state-space augmentation, we can rewrite the momentum update of (1) as
where the momentum operator at time is defined as
Assume that generalized curvature and hyperparameters satisfy
Then as proven in Appendix A, the spectral radius of the momentum operator at step depends solely on the momentum parameter: , for all . The inequalities in (6) define the robust region, the set of learning rate and momentum achieving this spectral radius.
We know that the spectral radius of an operator, , describes its asymptotic behavior when applied multiple times: . For any , there exists a matrix norm such that . Unfortunately, the same does not always hold for the composition of different operators, even if they have the same spectral radius, . It is not always true that . However, a homogeneous spectral radius often yields the rate empirically. In other words, this linear convergence rate is not guaranteed. Instead, we demonstrate examples to expose the robustness properties: if the learning rate and momentum are in the robust region, the homogeneity of spectral radii can empirically yield linear convergence with rate ; this behavior is robust with respect to learning rate misspecification and to varying curvature.
For a one-dimensional quadratic with curvature , we have generalized curvature for all . Lemma 3 implies the spectral radius if
In Figure 2, we plot for different and when . The solid line segments correspond to the robust region. As we increase momentum, a linear rate of convergence, , is robustly achieved by an ever-widening range of learning rates: higher values of momentum are more robust to learning rate mispecification. This property influences the design of our tuner: more generally for a class of one-dimensional non-convex objectives, as long as the learning rate and momentum are in the robust region, i.e. satisfy (6) at every step, then momentum operators at all steps have the same spectral radius. In the case of quadratics, this implies a convergence rate of , independent of the learning rate. Having established that, we can just focus on optimally tuning momentum.
Momentum is robust to varying curvature
As discussed in Section 2.1, the intuition hidden in classic results is that for certain strongly convex smooth objectives, momentum at least as high as the value in (2) can achieve the same rate of linear convergence along all axes with different curvatures. We extend this intuition to certain one-dimensional non-convex functions with varying curvatures along their domains; we discuss the generalization to multidimensional cases in Section 3.1. Lemma 3 guarantees constant, time-homogeneous spectral radii for momentum operators assuming (6) is satisfied at every step. This assumption motivates a “long-range” extension of the condition number.
The GCN captures variations in generalized curvature along a scalar slice. From Lemma 3 we get
as the description of the robust region. The momentum and learning rate satisfying (9) guarantees a homogeneous spectral radius of for all . Specifically, is the smallest momentum value that allows for homogeneous spectral radii. We demonstrate with examples that homogeneous spectral radii suggest an empirical linear convergence behavior on a class of non-convex objectives. In Figure 3(a), the non-convex objective, composed of two quadratics with curvatures and , has a GCN of . Using the tuning rule of (9), and running the momentum algorithm (Figure 3(b)) practically yields the linear convergence predicted by Lemma 3. In Figures 3(c,d), we demonstrate an LSTM as another example. As we increase the momentum value (the same value for all variables in the model), more model variables follow a convergence rate. In these examples, the linear convergence is robust to the varying curvature of the objectives. This property influences our tuner design: in the next section, we extend the tuning rules of (9) to handle SGD noise; we generalize the extended rule to multidimensional cases as the tuning rule in \tuner.
The \tunertuner
Here we describe our tuner for momentum SGD that uses the same learning rate for all variables. We first introduce a noisy quadratic model as the local approximation of an arbitrary one-dimensional objective. On this approximation, we extend the tuning rule of (9) to SGD. In section 3.1, we generalize the discussion to multidimensional objectives; it yields the \tunertuning rule.
Let be defined as in (10), and follow the momentum update (1) with stochastic gradients for . Let , the expectation of squared distance to the optimum is
where the first and second term correspond to squared bias and variance, and their corresponding momentum dynamics are captured by operators
Even though it is possible to numerically work on (11) directly, we use a scalar, asymptotic surrogate in (13) based on the spectral radii of operators to simplify analysis and expose insights. This decision is supported by our findings in Section 2: the spectral radii can capture empirical convergence rate.
One of our design decisions for \tuneris to always work in the robust region of Lemma 3. We know that this implies a spectral radius of the momentum operator, , for the bias. Lemma 6 shows that under the exact same condition, the variance operator has spectral radius .
The spectral radius of the variance operator, is , if .
As a result, the surrogate objective of (13), takes the following form in the robust region.
We extend this surrogate to multidimensional cases to extract a noisy tuning rule for \tuner.
1 Tuning rule
In this section, we present SingleStep, the tuning rule of YellowFin (Algorithm 1). Based on the surrogate in (14), SingleStep is a multidimensional SGD version of the noiseless tuning rule in (9). We first generalize (9) and (14) to multidimensional cases, and then discuss SingleStep.
As discussed in Section 2.2, GCN captures the dynamic range of generalized curvatures in a one-dimensional objective with varying curvature. The consequent robust region described by (9) implies homogeneous spectral radii. On a multidimensional non-convex objective, each one-dimensional slice passing a minimum can have varying curvature. As we use a single and for the entire model, if simultaneously captures the dynamic range of generalized curvature over all these slices, and in (9) are in the robust region for all these slices. This implies homogeneous spectral radii according to Lemma 3, empirically facilitating convergence at a common rate along all the directions.
Let be an estimate of the current model’s distance to a local quadratic approximation’s minimum, and denote an estimate for gradient variance. SingleStep minimizes the multidimensional surrogate after a single step (i.e. ) while ensuring and in the robust region for all directions. A single instance of SingleStep solves a single momentum and learning rate for the entire model at each iteration. Specifically, the extremal curvatures and denote estimates for the largest and smallest generalized curvature respectively. They are meant to capture both generalized curvature variation along all different directions (like the classic condition number) and also variation that occurs as the landscape evolves. The constraints keep the global learning rate and momentum in the robust region (defined in Lemma 3) for slices along all directions. SingleStep can be solved in closed form; we refer to Appendix D for relevant details on the closed form solution. \tuneruses functions CurvatureRange, Variance and Distance to measure quantities , , and respectively. These measurement functions can be designed in different ways. We present the implementations we used for our experiments, based completely on gradients, in Section 3.2.
2 Measurement functions in \tuner
This section describes our implementation of the measurement oracles used by \tuner: CurvatureRange, Variance, and Distance. We design the measurement functions with the assumption of a negative log-probability objective; this is in line with typical losses in machine learning, e.g. cross-entropy for neural nets and maximum likelihood estimation in general. Under this assumption, the Fisher information matrix—i.e. the expected outer product of noisy gradients—approximates the Hessian of the objective . This allows for measurements purely from minibatch gradients with overhead linear to model dimensionality. These implementations are not guaranteed to give accurate measurements. Nonetheless, their use in our experiments in Section 5 shows that they are sufficient for \tunerto outperform the state of the art on a variety of objectives. We also refer to Appendix E for details on zero-debias , slow start and smoothing for curvature range estimation.
Let be a noisy gradient, we estimate the curvatures range in Algorithm 2. We notice that the outer product has an eigenvalue with eigenvector . Thus under our negative log-likelihood assumption, we use to approximate the curvature of Hessian along gradient direction . Specifically, we maintain and as running averages of extreme curvature and , from a sliding window of width 20. As gradient directions evolve, we estimate curvatures along different directions. Thus and capture the curvature variations.
Gradient variance
Distance to optimum
In Algorithm 4, we estimate the distance to the optimum of the local quadratic approximation. Inspired by the fact that for a quadratic with Hessian and minimizer , we first maintain and as running averages of curvature and gradient norm . Then the distance is approximated using .
3 Stability on non-smooth objectives
The process of training neural networks is inherently non-stationary, with the landscape abruptly switching from flat to steep areas. In particular, the objective functions of RNNs with hidden units can exhibit occasional but very steep slopes . To deal with this issue, we use adaptive gradient clipping heuristics as a very natural addition to our basic tuner. It is discussed with extensive details in Appendix F. In Figure 6 in Appendix F, we present an example of an LSTM that exhibits the ’exploding gradient’ issue. The proposed adaptive clipping can stabilize the training process using \tunerand prevent large catastrophic loss spikes.
We validate the proposed adaptive clipping on the convolutional sequence to sequence learning model for IWSLT 2014 German-English translation. The default optimizer uses learning rate and Nesterov’s momentum , diverging to loss overflow due to ’exploding gradient’. It requires, as in Gehring et al. , strict manually set gradient norm threshold to stabilize. In Table 3.3, we can see YellowFin, with adaptive clipping, outperforms the default optimizer using manually set clipping, with 0.84 higher validation BLEU4 after 120 epochs.
Closed-loop YellowFin
Asynchrony is a parallelization technique that avoids synchronization barriers . It yields better hardware efficiency, i.e. faster steps, but can increase the number of iterations to a given metric, i.e. statistical efficiency, as a tradeoff . Mitliagkas et al. interpret asynchrony as added momentum dynamics. We design closed-loop YellowFin, a variant of \tunerto automatically control algorithmic momentum, compensate for asynchrony and accelerate convergence. We use the formula in (16) to model the dynamics in the system, where the total momentum, , includes both asynchrony-induced and algorithmic momentum, , in (1).
We first use (16) to design an robust estimator for the value of total momentum at every iteration. Then we use a simple negative feedback control loop to adjust the value of algorithmic momentum so that matches the target momentum decided by \tunerin Algorithm 1. In Figure 4, we demonstrate momentum dynamics in an asynchronous training system. As directly using the target value as algorithmic momentum, \tuner(middle) presents total momentum strictly larger than the target momentum, due to asynchrony-induced momentum. Closed-loop YellowFin (right) automatically brings down algorithmic momentum, match measured total momentum to target value and, as we will see, speeds up convergence comparing to \tuner. We refer to Appendix G for details on estimator and Closed-loop YellowFin in Algorithm 5.
Experiments
We empirically validate the importance of momentum tuning and evaluate \tunerin both synchronous (single-node) and asynchronous settings. In synchronous settings, we first demonstrate that, with hand-tuning, momentum SGD is competitive with Adam, a state-of-the-art adaptive method. Then, we evaluate \tunerwithout any hand tuning in comparison to hand-tuned Adam and momentum SGD. In asynchronous settings, we show that closed-loop YellowFin accelerates with momentum closed-loop control, significantly outperforming Adam.
We evaluate on convolutional neural networks (CNN) and recurrent neural networks (RNN). For CNN, we train ResNet for image recognition on CIFAR10 and CIFAR100 . For RNN, we train LSTMs for character-level language modeling with the TinyShakespeare (TS) dataset , word-level language modeling with the Penn TreeBank (PTB) , and constituency parsing on the Wall Street Journal (WSJ) dataset . We refer to Table 3 in Appendix H for model specifications. To eliminate influences of a specific random seed, in our synchronous and asynchronous experiments, the training loss and validation metrics are averaged from 3 runs using different random seeds.
We tune Adam and momentum SGD on learning rate grids with prescribed momentum for SGD. We fix the parameters of Algorithm 1 in all experiments, i.e. \tunerruns without any hand tuning. We provide full specifications, including the learning rate (grid) and the number of iterations we train on each model in Appendix I. For visualization purposes, we smooth training losses with a uniform window of width . For Adam and momentum SGD on each model, we pick the configuration achieving the lowest averaged smoothed loss. To compare two algorithms, we record the lowest smoothed loss achieved by both. Then the speedup is reported as the ratio of iterations to achieve this loss. We use this setup to validate our claims.
In Table 2, we compare tuned momentum SGD and tuned Adam on ResNets with training losses shown in Figure 8 in Appendix J. We can observe that momentum SGD achieves x and x speedup to tuned Adam on CIFAR10 and CIFAR100 respectively. In Figure 5 and Table 2, with the exception of PTB LSTM, momentum SGD also produces better training loss, as well as better validation perplexity in language modeling and validation F1 in parsing. For the parsing task, we also compare with tuned Vanilla SGD and AdaGrad, which are used in the NLP community. Figure 5 (right) shows that fixed momentum 0.9 can already speedup Vanilla SGD by x, achieving observably better validation F1. We refer to Appendix J.2 for further discussion on the importance of momentum adaptivity in \tuner.
\tunercan match hand-tuned momentum SGD and can outperform hand-tuned Adam
In our experiments, \tuner, without any hand-tuning, yields training loss matching hand-tuned momentum SGD for all the ResNet and LSTM models in Figure 5 and 8. When comparing to tuned Adam in Table 2, except being slightly slower on PTB LSTM, \tunerachieves x to x speedups in training losses on the other four models. More importantly, \tunerconsistently shows better validation metrics than tuned Adam in Figure 5. It demonstrates that \tunercan match tuned momentum SGD and outperform tuned state-of-the-art adaptive optimizers. In Appendix J.4, we show \tunerfurther speeding up with finer-grain manual learning rate tuning.
2 Asynchronous experiments
In this section, we evaluate closed-loop YellowFin with focus on the number of iterations to reach a certain solution. To that end, we run asynchronous workers on a single machine and force them to update the model in a round-robin fashion, i.e. the gradient is delayed for iterations. Figure 1 (right) presents training losses on the CIFAR100 ResNet, using \tunerin Algorithm 1, closed-loop YellowFin in Algorithm 5 and Adam with the learning rate achieving the best smoothed loss in Section 5.1. We can observe closed-loop \tunerachieves x speedup to \tuner, and consequently a x speedup to Adam. This demonstrates that (1) closed-loop YellowFin accelerates by reducing algorithmic momentum to compensate for asynchrony and (2) can converge in less iterations than Adam in asynchronous-parallel training.
Related work
Many techniques have been proposed on tuning hyperparameters for optimizers. General hyperparameter tuning approaches, such as random search and Bayesian approaches , can directly tune optimizers. As another trend, adaptive methods, including AdaGrad , RMSProp and Adam , uses per-dimension learning rate. Schaul et al. use a noisy quadratic model similar to ours to tune the learning rate in Vanilla SGD. However they do not use momentum which is essential in training modern neural nets. Existing adaptive momentum approach either consider the deterministic setting or only analyze the stochastic setting with learning rate . In contrast, we aim at practical momentum adaptivity for stochastically training neural nets.
Discussion
We presented \tuner, the first optimization method that automatically tunes momentum as well as the learning rate of momentum SGD. \tuneroutperforms the state-of-the-art adaptive optimizers on a large class of models both in synchronous and asynchronous settings. It estimates statistics purely from the gradients of a running system, and then tunes the hyperparameters of momentum SGD based on noisy, local quadratic approximations. As future work, we believe that more accurate curvature estimation methods, like the method can further improve \tuner. We also believe that our closed-loop momentum control mechanism in Section 4 could accelerate other adaptive methods in asynchronous-parallel settings.
Acknowledgements
We are grateful to Christopher Ré for his valuable guidance and support. We thank Bryan He, Paroma Varma, Chris De Sa, Tri Dao, Albert Gu, Fred Sala, Alex Ratner and Theodoros Rekatsinas for helpful discussions and feedbacks. We gratefully acknowledge the support of the D3M program under No. FA8750-17-2-0095. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of DARPA or the U.S. government.
References
Appendix A Proof of Lemma 3
To prove Lemma 3, we first prove a more generalized version in Lemma 7. By restricting to be a one dimensional quadratics function, the generalized curvature itself is the only eigenvalue. We can prove Lemma 3 as a straight-forward corollary. Lemma 7 also implies, in the multiple dimensional correspondence of (4), the spectral radius if the curvature on all eigenvector directions (eigenvalue) satisfies (6).
Let the gradients of a function be described by
where . Now, assume that the following condition holds for all eigenvalues of :
then the spectral radius of is controlled by momentum with
Let be an eigenvalue of matrix , it gives . We define the blocks in as , , and which gives
assuming generally is invertible. Note we use for simplicity in writing. The equation implies that
with . In other words, satisfied that with being one eigenvalue of . I.e.
On the other hand, (19) guarantees that . We know both and are symmetric. Thus for all eigenvalues of , we have which guarantees for all . As the spectral radius is equal to the magnitude of the largest eigenvalue of , we have the spectral radius of being .
Appendix B Proof of Lemma 5
We first prove Lemma 8 and Lemma 9 as preparation for the proof of Lemma 5. After the proof for one dimensional case, we discuss the trivial generalization to multiple dimensional case.
From the recurrence of momentum SGD, we have
By putting the equation in to matrix form, (22) is a straight-forward result from unrolling the recurrence for times. Note as we set with no uncertainty in momentum SGD, we have . ∎
We prove by first deriving the recurrence for and respectively and combining them in to a matrix form. For , we have
Note the second term in the second equality is zero because and are deterministic. Thus . ∎
Appendix C Proof of Lemma 6
Again we first present a proof of a multiple dimensional generalized version of Lemma 6. The proof of Lemma 6 is a one dimensional special case of Lemma 10. Lemma 10 also implies that for multiple dimension quadratics, the corresponding spectral radius if on all the eigenvector directions with being the eigenvalue (curvature).
We have if all eigenvalues of satisfies
Let be an eigenvalue of matrix , it gives which can be alternatively expressed as
assuming is invertible, i.e. , where the blocks in
with . (30) can be transformed using straight-forward algebra as
Using similar simplification technique as in (30), we can further simplify into
if , as is diagonalizable, we have with being an eigenvalue of symmetric . The analytic solution to the equation can be explicitly expressed as
When the condition in (29) holds, we have . One can verify that
Thus the roots in (33) are conjugate with . In conclusion, the condition in (29) can guarantee all the eigenvalues of has magnitude . Thus the spectral radius of is controlled by . ∎
Appendix D Analytical solution to (15)
The problem in (15) does not need iterative solver but has an analytical solution. Substituting only the second constraint, the objective becomes with . By setting the gradient of to 0, we can get a cubic equation whose root can be computed in closed form using Vieta’s substitution. As is uni-modal in , the optimizer for (15) is exactly the maximum of and , the right hand-side of the first constraint in (15).
Appendix E Practical implementation
In Section 3.2, we discuss estimators for learning rate and momentum tuning in \tuner. In our experiment practice, we have identified a few practical implementation details which are important for improving estimators. Zero-debias is proposed by Kingma and Ba , which accelerates the process where exponential average adapts to the level of original quantity in the beginning. We applied zero-debias to all the exponential average quantities involved in our estimators. In some LSTM models, we observe that our estimated curvature may decrease quickly along the optimization process. In order to better estimate extremal curvature and with fast decreasing trend, we apply zero-debias exponential average on the logarithmic of and , instead of directly on and . Except from the above two techniques, we also implemented the slow start heuristic proposed by . More specifically, we use as our learning rate with as the size of our sliding window in and estimation. It discount the learning rate in the first steps and helps to keep the learning rate small in the beginning when the exponential averaged quantities are not accurate enough.
Appendix F Adaptive gradient clipping in \tuner
Gradient clipping has been established in literature as a standard—almost necessary—tool for training such objectives . However, the classic tradeoff between adaptivity and stability applies: setting a clipping threshold that is too low can hurt performance; setting it to be high, can compromise stability. \tuner, keeps running estimates of extremal gradient magnitude squares, and in order to estimate a generalized condition number. We posit that is an ideal gradient norm threshold for adaptive clipping. In order to ensure robustness to extreme gradient spikes, like the ones in Figure 6, we also limit the growth rate of the envelope in Algorithm 2 as follows:
Our heuristics follows along the lines of classic recipes like . However, instead of using the average gradient norm to clip, it uses a running estimate of the maximum norm .
In Section 3.3, we saw that adaptive clipping stabilizes the training on objectives that exhibit exploding gradients. In Figure 7, we demonstrate that the adaptive clipping does not hurt performance on models that do not exhibit instabilities without clipping. Specifically, for both PTB LSTM and CIFAR10 ResNet, the difference between \tunerwith and without adaptive clipping diminishes quickly.
Appendix G Closed-loop \tunerfor asynchronous training
In Section 4, we briefly discuss the closed-loop momentum control mechanism in closed-loop YellowFin. In this section, after presenting more preliminaries on asynchrony, we show with details on the mechanism: it measures the dynamics on a running system and controls momentum with a negative feedback loop.
Asynchrony is a popular parallelization technique that avoids synchronization barriers. When training on asynchronous workers, staleness (the number of model updates between a worker’s read and write operations) is on average , i.e., the gradient in the SGD update is delayed by iterations as . Asynchrony yields faster steps, but can increase the number of iterations to achieve the same solution, a tradeoff between hardware and statistical efficiency . Mitliagkas et al. interpret asynchrony as added momentum dynamics. Experiments in Hadjis et al. support this finding, and demonstrate that reducing algorithmic momentum can compensate for asynchrony-induced momentum and significantly reduce the number of iterations for convergence. Motivated by that result, we use the model in (36), where the total momentum, , includes both asynchrony-induced and algorithmic momentum, , in (1).
We will use this expression to design an estimator for the value of total momentum, . This estimator is a basic building block of closed-loop YellowFin, that removes the need to manually compensate for the effects of asynchrony.
Measuring the momentum dynamics
Closed-loop YellowFin estimates total momentum on a running system and uses a negative feedback loop to adjust algorithmic momentum accordingly. Equation (16) gives an estimate of on a system with staleness , based on (16).
We use -stale model values to match the staleness of the gradient, and perform all operations in an elementwise fashion. This way we get a total momentum measurement from each variable; the median combines them into a more robust estimate.
Closing the asynchrony loop
Given a reliable measurement of , we can use it to adjust the value of algorithmic momentum so that the total momentum matches the target momentum as decided by \tunerin Algorithm 1. Closed-loop YellowFin in Algorithm 5 uses a simple negative feedback loop to achieve the adjustment.
Appendix H Model specification
The model specification is shown in Table 3 for all the experiments in Section 5. CIRAR10 ResNet uses the regular ResNet units while CIFAR100 ResNet uses the bottleneck units. Only the convolutional layers are shown with filter size, filter number as well as the repeating count of the units. The layer counting for ResNets also includes batch normalization and Relu layers. The LSTM models are also diversified for different tasks with different vocabulary sizes, word embedding dimensions and number of layers.
Appendix I Specification for synchronous experiments
In Section 5.1, we demonstrate the synchronous experiments with extensive discussions. For the reproducibility, we provide here the specification of learning rate grids. The number of iterations as well as epochs, i.e. the number of passes over the full training sets, are also listed for completeness. For \tunerin all the experiments in Section 5, we uniformly use sliding window size for extremal curvature estimation and for smoothing. For momentum SGD and Adam, we use the following configurations.
Momentum SGD learning rates , momentum 0.9
Adam learning rates
Momentum SGD learning rates , momentum 0.9
Adam learning rates
Momentum SGD learning rates , momentum 0.9
Adam learning rates
Momentum SGD learning rates , momentum 0.9
Adam learning rates
Decrease learning rate by factor 0.97 every epoch for all optimizers, following the design by Karpathy et al. .
Momentum SGD learning rates , momentum 0.9
Adam learning rates
Vanilla SGD learning rates
Adagrad learning rates
Decrease learning rate by factor 0.9 every epochs after 14 epochs for all optimizers, following the design by Choe and Charniak .
Appendix J Additional experiment results
In Figure 8, we demonstrate the training loss on CIFAR10 ResNet and CIFAR100 ResNet. Specifically, \tunercan match the performance of hand-tuned momentum SGD, and achieves 1.93x and 1.38x speedup comparing to hand-tuned Adam respectively on CIFAR10 and CIFAR100 ResNet.
J.2 Importance of momentum adaptivity
To further emphasize the importance of momentum adaptivity in \tuner, we run YF on CIFAR100 ResNet and TS LSTM. In the experiments, \tunertunes the learning rate. Instead of also using the momentum tuned by YF, we continuously feed prescribed momentum value and to the underlying momentum SGD optimizer which YF is tuning. In Figure 9, when comparing to \tunerwith prescribed momentum 0.0 or 0.9, \tunerwith adaptively tuned momentum achieves observably faster convergence on both TS LSTM and CIFAR100 ResNet. It empirically demonstrates the essential role of momentum adaptivity in \tuner.
J.3 Tuning momentum can improve Adam in async.-parallel setting
We conduct experiments on PTB LSTM with 16 asynchronous workers using Adam using the same protocol as in Section 5.2. Fixing the learning rate to the value achieving the lowest smoothed loss in Section 5.1, we sweep the smoothing parameter of the first order moment estimate in grid . serves the same role as momentum in SGD and we call it the momentum in Adam. Figure 10 shows tuning momentum for Adam under asynchrony gives measurably better training loss. This result emphasizes the importance of momentum tuning in asynchronous settings and suggests that state-of-the-art adaptive methods can perform sub-optimally when using prescribed momentum.
J.4 Accelerating \tunerwith finer grain learning rate tuning
As an adaptive tuner, \tunerdoes not involve manual tuning. It can present faster development iterations on model architectures than grid search on optimizer hyperparameters. In deep learning practice for computer vision and natural language processing, after fixing the model architecture, extensive optimizer tuning (e.g. grid search or random search) can further improve the performance of a model. A natural question to ask is can we also slightly tune \tunerto accelerate convergence and improve the model performance. Specifically, we can manually multiply a positive number, the learning rate factor, to the auto-tuned learning rate in \tunerto further accelerate.
In this section, we empirically demonstrate the effectiveness of learning rate factor on a 29-layer ResNext (2x64d) on CIFAR10 and a Tied LSTM model with 650 dimensions for word embedding and two hidden units layers on the PTB dataset. When running \tuner, we search for the optimal learning rate factor in grid . Similarly, we search the same learning rate factor grid for Adam, multiplying the factor to its default learning rate . To further strengthen the performance of Adam as a baseline, we also run it on conventional logarithmic learning rate grid for ResNext and for Tied LSTM. We report the best metric from searching the union of learning rate factor grid and logarithmic learning rate grid as searched Adam results. Empirically, learning factor and works best for Adam respectively on ResNext and Tied LSTM.
As shown in Figure 11, with the searched best learning rate factor, \tunercan improve validation perplexity on Tied LSTM from to , an improvement of more than . Similarly, the searched learning rate factor can improve test accuracy from to on ResNext. More importantly, we can observe, with learning rate factor search on the two models, \tunercan achieve better validation metric than the searched Adam results. It demonstrates that finer-grain learning rate tuning, i.e. the learning rate factor search, can be effectively applied on \tunerto improve the performance of deep learning models.