yellowfin and the art of momentum tuning - mlsys · 2019. 6. 15. · accelerated forms of...

18
YELLOWF IN AND THE ART OF MOMENTUM T UNING Jian Zhang 1 Ioannis Mitliagkas 2 ABSTRACT Hyperparameter tuning is one of the most time-consuming workloads in deep learning. State-of-the-art optimizers, such as AdaGrad, RMSProp and Adam, reduce this labor by adaptively tuning an individual learning rate for each variable. Recently researchers have shown renewed interest in simpler methods like momentum SGD as they may yield better test metrics. Motivated by this trend, we ask: can simple adaptive methods based on SGD perform as well or better? We revisit the momentum SGD algorithm and show that hand-tuning a single learning rate and momentum makes it competitive with Adam. We then analyze its robustness to learning rate misspecification and objective curvature variation. Based on these insights, we design YELLOWFIN, an automatic tuner for momentum and learning rate in SGD. YELLOWFIN optionally uses a negative-feedback loop to compensate for the momentum dynamics in asynchronous settings on the fly. We empirically show that YELLOWFIN can converge in fewer iterations than Adam on ResNets and LSTMs for image recognition, language modeling and constituency parsing, with a speedup of up to 3.28x in synchronous and up to 2.69x in asynchronous settings. 1 I NTRODUCTION Accelerated forms of stochastic gradient descent (SGD), pioneered by Polyak (1964) and Nesterov (1983), 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 (Sutskever et al., 2013). However, tuning hyperparameters is arguably the most time-consuming part of deep learning, with many pa- pers outlining best tuning practices written (Bengio, 2012; Orr & M¨ uller, 2003; Bengio et al., 2012; Bottou, 2012). Deep learning researchers have proposed a number of meth- ods to deal with hyperparameter optimization, ranging from grid-search and smart black-box methods (Bergstra & Ben- gio, 2012; Snoek et al., 2012) to adaptive optimizers. Adap- tive optimizers aim to eliminate hyperparameter search by tuning on the fly for a single training run: algorithms like AdaGrad (Duchi et al., 2011), RMSProp (Tieleman & Hin- ton, 2012) and Adam (Kingma & Ba, 2014) use the magni- tude of gradient elements to tune learning rates individually for each variable and have been largely successful in reliev- ing practitioners of tuning the learning rate. Recently some researchers have started favoring simple mo- mentum SGD over the previously mentioned adaptive meth- ods (Chen et al., 2016; Gehring et al., 2017), often reporting 1 Computer Science Department, Stanford University, CA, USA. 2 Mila, University of Montr ´ eal, Canada CIFAR AI Chair. Correspondence to: Jian Zhang <[email protected]>, Ioannis Mitliagkas <[email protected]>. Proceedings of the 2 nd SysML Conference, Palo Alto, CA, USA, 2019. Copyright 2019 by the author(s). 0k 30k 60k 90k 120k Iterations 10 0 10 1 Training loss Synchronous training Adam YellowFin 0k 30k 60k 90k 120k Iterations 10 0 10 1 Asynchronous training Adam YellowFin Closed-loop YellowFin Figure 1. YELLOWFIN in comparison to Adam on a ResNet (CI- FAR100, cf. Section 5) in synchronous and asynchronous settings. better test scores (Wilson et al., 2017). 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 anal- ysis, we design YELLOWFIN, an automatic hyperparameter tuner for momentum SGD. YELLOWFIN simultaneously 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 momen- tum offers convergence robust to learning rate mis- specification 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.

Upload: others

Post on 05-Oct-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: YellowFin and the Art of Momentum Tuning - MLSys · 2019. 6. 15. · Accelerated forms of stochastic gradient descent (SGD), pioneered byPolyak(1964) andNesterov(1983), are the de-facto

YELLOWFIN AND THE ART OF MOMENTUM TUNING

Jian Zhang 1 Ioannis Mitliagkas 2

ABSTRACTHyperparameter tuning is one of the most time-consuming workloads in deep learning. State-of-the-art optimizers,such as AdaGrad, RMSProp and Adam, reduce this labor by adaptively tuning an individual learning rate for eachvariable. Recently researchers have shown renewed interest in simpler methods like momentum SGD as they mayyield better test metrics. Motivated by this trend, we ask: can simple adaptive methods based on SGD perform aswell or better? We revisit the momentum SGD algorithm and show that hand-tuning a single learning rate andmomentum makes it competitive with Adam. We then analyze its robustness to learning rate misspecification andobjective curvature variation. Based on these insights, we design YELLOWFIN, an automatic tuner for momentumand learning rate in SGD. YELLOWFIN optionally uses a negative-feedback loop to compensate for the momentumdynamics in asynchronous settings on the fly. We empirically show that YELLOWFIN can converge in feweriterations than Adam on ResNets and LSTMs for image recognition, language modeling and constituency parsing,with a speedup of up to 3.28x in synchronous and up to 2.69x in asynchronous settings.

1 INTRODUCTION

Accelerated forms of stochastic gradient descent (SGD),pioneered by Polyak (1964) and Nesterov (1983), are thede-facto training algorithms for deep learning. Their userequires a sane choice for their hyperparameters: typicallya learning rate and momentum parameter (Sutskever et al.,2013). However, tuning hyperparameters is arguably themost time-consuming part of deep learning, with many pa-pers outlining best tuning practices written (Bengio, 2012;Orr & Muller, 2003; Bengio et al., 2012; Bottou, 2012).Deep learning researchers have proposed a number of meth-ods to deal with hyperparameter optimization, ranging fromgrid-search and smart black-box methods (Bergstra & Ben-gio, 2012; Snoek et al., 2012) to adaptive optimizers. Adap-tive optimizers aim to eliminate hyperparameter search bytuning on the fly for a single training run: algorithms likeAdaGrad (Duchi et al., 2011), RMSProp (Tieleman & Hin-ton, 2012) and Adam (Kingma & Ba, 2014) use the magni-tude of gradient elements to tune learning rates individuallyfor each variable and have been largely successful in reliev-ing practitioners of tuning the learning rate.

Recently some researchers have started favoring simple mo-mentum SGD over the previously mentioned adaptive meth-ods (Chen et al., 2016; Gehring et al., 2017), often reporting

1Computer Science Department, Stanford University, CA,USA. 2Mila, University of Montreal, Canada CIFAR AI Chair.Correspondence to: Jian Zhang <[email protected]>, IoannisMitliagkas <[email protected]>.

Proceedings of the 2nd SysML Conference, Palo Alto, CA, USA,2019. Copyright 2019 by the author(s).

0k 30k 60k 90k 120kIterations

100

101

Tra

inin

glo

ss

Synchronous trainingAdamYellowFin

0k 30k 60k 90k 120kIterations

100

101 Asynchronous trainingAdamYellowFinClosed-loopYellowFin

Figure 1. YELLOWFIN in comparison to Adam on a ResNet (CI-FAR100, cf. Section 5) in synchronous and asynchronous settings.

better test scores (Wilson et al., 2017). Motivated by thistrend, we ask the question: can simpler adaptive methodsbased on momentum SGD perform as well or better? Weempirically show, with a hand-tuned learning rate, Polyak’smomentum SGD achieves faster convergence than Adam fora large class of models. We then formulate the optimizationupdate as a dynamical system and study certain robustnessproperties of the momentum operator. Inspired by our anal-ysis, we design YELLOWFIN, an automatic hyperparametertuner for momentum SGD. YELLOWFIN simultaneouslytunes the learning rate and momentum on the fly, and canhandle the complex dynamics of asynchronous execution.Our contribution and outline are as follows:

• In Section 2, we demonstrate examples where momen-tum offers convergence robust to learning rate mis-specification and curvature variation in a class of non-convex objectives. This robustness is desirable for deeplearning. It stems from a known but obscure fact: themomentum operator’s spectral radius is constant in alarge subset of the hyperparameter space.

Page 2: YellowFin and the Art of Momentum Tuning - MLSys · 2019. 6. 15. · Accelerated forms of stochastic gradient descent (SGD), pioneered byPolyak(1964) andNesterov(1983), are the de-facto

YELLOWFIN and the Art of Momentum Tuning

• In Section 3, we use these robustness insights and asimple quadratic model analysis to motivate the designof YELLOWFIN, an automatic tuner for momentumSGD. YELLOWFIN uses on-the-fly measurements fromthe gradients to tune both a single learning rate and asingle momentum.

• In Section 3.3, we discuss common stability concernsrelated to the phenomenon of exploding gradients (Pas-canu et al., 2013). We present a natural extension toour basic tuner, using adaptive gradient clipping, to sta-bilize training for objectives with exploding gradients.

• In Section 4 we present closed-loop YELLOWFIN,suited for asynchronous training. It uses a novel com-ponent for measuring the total momentum in a runningsystem, including any asynchrony-induced momentum,a phenomenon described in (Mitliagkas et al., 2016).This measurement is used in a negative feedback loopto control the value of algorithmic momentum.

We provide a thorough empirical evaluation of the perfor-mance and stability of our tuner. In Section 5, we demon-strate empirically that on ResNets and LSTMs YELLOWFINcan converge in fewer iterations compared to: (i) hand-tunedmomentum SGD (up to 1.75x speedup); and (ii) hand-tunedAdam (0.77x to 3.28x speedup). Under asynchrony, theclosed-loop control architecture speeds up YELLOWFIN,making it up to 2.69x faster than Adam. Our experiments in-clude runs on 7 different models, randomized over at least 3different random seeds. YELLOWFIN is stable and achievesconsistent performance: the normalized sample standarddeviation of test metrics varies from 0.05% to 0.6%. We re-leased PyTorch and TensorFlow implementations 1that canbe used as drop-in replacements for any optimizer. YEL-LOWFIN has also been implemented in various other pack-ages. Its large-scale deployment in industry has taught usimportant lessons about stability; we discuss those chal-lenges and our solution in Section 3.3. We conclude withrelated work and discussion in Section 6 and 7.

Our goal is to explore the value of moment adaptation forSGD and provide a prototype, efficient tuner achieving this.While we report state-of-the-art performance results in sometasks, we do not claim that on-the-fly momentum adaptationis a necessary feature of a well-performing synchronous sys-tem. In Section 5.1 we demonstrate that a simple variationof YELLOWFIN, only using the momentum value to furtherrescale the step size, can yield an adaptive step size methodthat performs almost as well in some cases.

2 THE MOMENTUM OPERATOR

In this section, we identify the main technical insight be-hind the design of our tuner: gradient descent with mo-

1TensorFlow: goo.gl/zC2rjG. PyTorch: goo.gl/N4sFfs

mentum can exhibit linear convergence robust to learningrate misspecification and to curvature variation. The robust-ness to learning rate misspecification means tolerance to aless-carefully-tuned learning rate. On the other hand, therobustness to curvature variation means empirical linear con-vergence on a class of non-convex objectives with varyingcurvatures. After preliminary on momentum, we discussthese two properties desirable for deep learning objectives.

2.1 Preliminaries

We aim to minimize some objective f(x). In machine learn-ing, x is referred to as the model and the objective is someloss function. A low loss implies a well-fit model. Gradientdescent-based procedures use the gradient of the objectivefunction, ∇f(x), to update the model iteratively. Theseprocedures can be characterized by the convergence ratewith respect to the distance to a minimum.Definition 1 (Convergence rate). Let x∗ be a local minimumof f(x) and xt denote the model after t steps of an iterativeprocedure. The iterates converge to x∗ with linear rate β, if

‖xt − x∗‖ = O(βt‖x0 − x∗‖).

Polyak’s momentum gradient descent (Polyak, 1964) is oneof these iterative procedures, given by

xt+1 = xt − α∇f(xt) + µ(xt − xt−1), (1)

where α denotes a single learning rate and µ a single mo-mentum for all model variables. Momentum’s main appealis its established ability to accelerate convergence (Polyak,1964). On a γ-strongly convex δ-smooth function with con-dition number κ = δ/γ, the optimal convergence rate ofgradient descent without momentum is O(κ−1κ+1 ) (Nesterov,2013). On the other hand, for certain classes of stronglyconvex and smooth functions, like quadratics, the optimalmomentum value,

µ∗ =

(√κ− 1√κ+ 1

)2

, (2)

yields the optimal accelerated linear convergence rateO(√κ−1√κ+1

). This guarantee does not generalize to arbitrarystrongly convex smooth functions (Lessard et al., 2016).Nonetheless, this linear rate can often be observed in prac-tice even on non-quadratics (cf. Section 2.2).

Key insight: Consider a quadratic objective with conditionnumber κ > 1. Even though its curvature is different alongthe different directions, Polyak’s momentum gradient de-scent, with µ ≥ µ∗, achieves the same linear convergencerate√µ along all directions. Specifically, let xi,t and x∗i

be the i-th coordinates of xt and x∗. For any µ ≥ µ∗ withan appropriate learning rate, the update in (1) can achieve|xi,t − x∗i | ≤

√µt|xi,0 − x∗i | simultaneously along all axes

i. This insight has been hidden away in proofs.

Page 3: YellowFin and the Art of Momentum Tuning - MLSys · 2019. 6. 15. · Accelerated forms of stochastic gradient descent (SGD), pioneered byPolyak(1964) andNesterov(1983), are the de-facto

YELLOWFIN and the Art of Momentum Tuning

In this quadratic case, curvature is different across differentaxes, but remains constant on any one-dimensional slice. Inthe next section (Section 2.2), we extend this insight to non-quadratic one-dimensional functions. We then present themain technical insight behind the design of YELLOWFIN:similar linear convergence rate

õ can be achieved in a

class of one-dimensional non-convex objectives where cur-vature varies; this linear convergence behavior is robust tolearning rate misspecification and to the varying curvature.These robustness properties are behind a tuning rule forlearning rate and momentum in Section 2.2. We extend thisrule to handle SGD noise and generalize it to multidimen-sional objectives in Section 3.

2.2 Robustness properties of the momentum operator

In this section, we analyze the dynamics of momentum on aclass of one-dimensional, non-convex objectives. We firstintroduce the notion of generalized curvature and use itto describe the momentum operator. Then we discuss therobustness properties of the momentum operator.

Curvature along different directions is encoded in the dif-ferent eigenvalues of the Hessian. It is the only featureof a quadratic needed to characterize the convergence ofgradient descent. Specifically, gradient descent achievesa linear convergence rate |1 − αhc| on one-dimensionalquadratics with constant curvature hc. On one-dimensionalnon-quadratic objectives with varying curvature, this neatcharacterization is lost. We can recover it by defining a newkind of “curvature” with respect to a specific minimum.

Definition 2 (Generalized curvature). Let x∗ be a localminimum of f(x) : R → R. Generalized curvature withrespect to x∗, denoted by h(x), satisfies the following.

f ′(x) = h(x)(x− x∗). (3)

Generalized curvature describes, in some sense, non-localcurvature with respect to minimum x∗. It coincides withcurvature on quadratics. On non-quadratic objectives, itcharacterizes the convergence behavior of gradient descent-based algorithms. Specifically, we recover the fact thatstarting at point xt, the distance from minimum x∗ is re-duced by |1−αh(xt)| in one step of gradient descent. Usinga state-space augmentation, we can rewrite the momentumupdate of (1) as(

xt+1 − x∗xt − x∗

)= At

(xt − x∗xt−1 − x∗

)(4)

where the momentum operator At at time t is defined as

At ,

[1− αh(xt) + µ −µ

1 0

](5)

Lemma 3 (Robustness of the momentum operator). As-sume that generalized curvature h and hyperparameters

α, µ satisfy

(1−√µ)2 ≤ αh(xt) ≤ (1 +√µ)2. (6)

Then as proven in Appendix A, the spectral radius of themomentum operator at step t depends solely on the momen-tum parameter: ρ(At) =

õ, for all t. The inequalities in

(6) define the robust region, the set of learning rate α andmomentum µ achieving this

õ spectral radius.

We know that the spectral radius of an operator, A, de-scribes its asymptotic behavior when applied multiple times:‖Atx‖ ≈ O(ρ(A)t).2 Unfortunately, the same does notalways hold for the composition of different operators, evenif they have the same spectral radius, ρ(At) =

õ. It is

not always true that ‖At · · ·A1x‖ = O(√µt). However,

a homogeneous spectral radius often yields theõt rate

empirically. In other words, this linear convergence rate isnot guaranteed. Instead, we demonstrate examples to ex-pose the robustness properties: if the learning rate α andmomentum µ are in the robust region, the homogeneity ofspectral radii can empirically yield linear convergence withrate√µ; this behavior is robust with respect to learning

rate misspecification and to varying curvature.

Momentum is robust to learning rate misspecificationFor a one-dimensional quadratic with curvature h, we havegeneralized curvature h(x) = h for all x. Lemma 3 impliesthe spectral radius ρ(At)=

õ if

(1−√µ)2/h ≤ α ≤ (1 +√µ)2/h. (7)

0.0 0.5 1.0 1.5 2.0 2.5 3.0

Learning rate (α)

0.0

0.2

0.4

0.6

0.8

1.0Sp

ectr

alra

dius

µ = 0.0

µ = 0.1

µ = 0.3

µ = 0.5

Figure 2. Spectral radius ofmomentum operator on scalarquadratic for varying α.

In Figure 2, we plot ρ(At)for different α and µ whenh = 1. The solid linesegments correspond to therobust region. As we in-crease momentum, a linearrate of convergence,

õ, is

robustly achieved by an ever-widening range of learningrates: higher values of mo-mentum are more robust tolearning rate mispecification.

This property influences the design of our tuner: moregenerally for a class of one-dimensional non-convex objec-tives, as long as the learning rate α and momentum µ are inthe robust region, i.e. satisfy (6) at every step, then momen-tum operators at all steps t 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.

2For any ε > 0, there exists a matrix norm ‖ · ‖ such that‖A‖ ≤ ρ(A) + ε (Foucart, 2012).

Page 4: YellowFin and the Art of Momentum Tuning - MLSys · 2019. 6. 15. · Accelerated forms of stochastic gradient descent (SGD), pioneered byPolyak(1964) andNesterov(1983), are the de-facto

YELLOWFIN and the Art of Momentum Tuning

Momentum is robust to varying curvature As dis-cussed in Section 2.1, the intuition hidden in classic results isthat for certain strongly convex smooth objectives, momen-tum at least as high as the value in (2) can achieve the samerate of linear convergence along all axes with different cur-vatures. We extend this intuition to certain one-dimensionalnon-convex functions with varying curvatures along theirdomains; we discuss the generalization to multidimensionalcases in Section 3.1. Lemma 3 guarantees constant, time-homogeneous spectral radii for momentum operators At

assuming (6) is satisfied at every step. This assumption mo-tivates a “long-range” extension of the condition number.Definition 4 (Generalized condition number). We define thegeneralized condition number (GCN) with respect to a localminimum x∗ of a scalar function, f(x) : R→ R, to be thedynamic range of its generalized curvature h(x):

ν =supx∈dom(f) h(x)

infx∈dom(f) h(x)(8)

The GCN captures variations in generalized curvature alonga scalar slice. From Lemma 3 we get

µ ≥ µ∗ =(√

ν − 1√ν + 1

)2

,

(1−√µ)2infx∈dom(f) h(x)

≤ α ≤ (1 +√µ)2

supx∈dom(f) h(x)

(9)

as the description of the robust region. The momentum andlearning rate satisfying (9) guarantees a homogeneous spec-tral radius of

√µ for all At. Specifically, µ∗ is the smallest

momentum value that allows for homogeneous spectral radii.Similar to the optimal µ∗ in (2) for the quadratic case, wenotice that the optimal µ in (9) is objective dependent. Theoptimal momentum µ∗ is close to 1 for objectives with largegeneralized condition number ν, while objectives with smallν implies a optimal momentum µ∗ that is close to 0.

We demonstrate with examples that by using a momentumlarger than the objective-dependent µ∗, homogeneous spec-tral radii suggest an empirical linear convergence behavioron a class of non-convex objectives. In Figure 3(a), thenon-convex objective, composed of two quadratics withcurvatures 1 and 1000, has a GCN of 1000. Using the tun-ing rule of (9), and running the momentum algorithm (Fig-ure 3(b)) practically yields the linear convergence predictedby Lemma 3. In Figures 3(c,d), we demonstrate an LSTMas another example. As we increase the momentum value(the same value for all variables in the model), more modelvariables follow a

õ convergence rate. In these examples,

the linear convergence is robust to the varying curvatureof the objectives. This property influences our tuner de-sign: in the next section, we extend the tuning rules of (9)to handle SGD noise; we generalize the extended rule tomultidimensional cases as the tuning rule in YELLOWFIN.

The role of generalized curvature. GC defines a quan-tity that is an alternative to classic curvature and is directlyrelated to the contraction properties of the momentum op-erator on non-quadratic scalar problems. Note that similarquantities, e.g. the PL condition (Karimi et al., 2016), havebeen used in the analysis of gradient descent. The gener-alized condition number (GCN) is meant to describe thedynamic range of this contractivity around a minumum onnon-quadratic function.

3 THE YELLOWFIN TUNER

Here we describe our tuner for momentum SGD that usesthe same learning rate for all variables. We first introduce anoisy quadratic model f(x) as the local approximation of anarbitrary one-dimensional objective. On this approximation,we extend the tuning rule of (9) to SGD. In section 3.1, wegeneralize the discussion to multidimensional objectives; ityields the YELLOWFIN tuning rule.

Noisy quadratic model We consider a scalar quadratic

f(x) =h

2x2+C =

∑i

h

2n(x−ci)2 ,

1

n

∑i

fi(x) (10)

with∑i ci = 0. f(x) is a quadratic approximation of the

original objectives with h and C derived from measurementon the original objective. The function f(x) is defined asthe average of n component functions, fi. This is a commonmodel for SGD, where we use only a single data point (ora mini-batch) drawn uniformly at random, St ∼ Uni([n])to compute a noisy gradient, ∇fSt(x), for step t. Here,C = 1

2n

∑i hc

2i denotes the gradient variance. As opti-

mization on quadratics decomposes into scalar problemsalong the principal eigenvectors of the Hessian, the scalarmodel in (10) is sufficient to study local quadratic approx-imations of multidimensional objectives. Next we get anexact expression for the mean square error after runningmomentum SGD on the scalar quadratic in (10) for t stepsin Lemma 5; we delay the proof to Appendix B.Lemma 5. Let f(x) be defined as in (10), x1 = x0 andxt follow the momentum update (1) with stochastic gra-dients ∇fSt(xt−1) for t ≥ 2. Let e1 = [1, 0]T andf 1 = [1, 0, 0]T , the expectation of squared distance to theoptimum x∗ is

E(xt+1 − x∗)2 = (e>1 At[x1 − x∗, x0 − x∗]>)2

+ α2Cf >1 (I −B t)(I −B)−1f 1,(11)

where the first and second term correspond to squared biasand variance, and their corresponding momentum dynamicsare captured by operators

A =

[1− αh+ µ −µ

1 0

],

B =

(1− αh+ µ)2 µ2 −2µ(1− αh+ µ)1 0 0

1− αh+ µ 0 −µ

. (12)

Page 5: YellowFin and the Art of Momentum Tuning - MLSys · 2019. 6. 15. · Accelerated forms of stochastic gradient descent (SGD), pioneered byPolyak(1964) andNesterov(1983), are the de-facto

YELLOWFIN and the Art of Momentum Tuning

−20−15−10−5 0 5 10 15 20

x

0.0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8f

(x)

0 100 200 300 400 500

Iterations

10−710−610−510−410−310−210−1

100101102103

Dis

tanc

efr

omop

tim

um

0 50 100 150 200 250 300

Iterations

10−5

10−4

10−3

10−2

10−1

Dis

tanc

efr

omfin

alva

lue

µ = 0.9

0 50 100 150 200 250 300

Iterations

µ = 0.99

(a) (b) (c) (d)

Figure 3. (a) Non-convex toy example; (b) linear convergence rate achieved empirically on the example in (a) tuned according to (9);(c,d) LSTM on MNIST: as momentum increases from 0.9 to 0.99, the global learning rate and momentum falls in robust regions of moremodel variables. The convergence behavior (shown in grey) of these variables follow the robust rate

õ (shown in red).

Even though it is possible to numerically work on (11) di-rectly, we use a scalar, asymptotic surrogate in (13) basedon the spectral radii of operators to simplify analysis andexpose insights. This decision is supported by our find-ings in Section 2: the spectral radii can capture empiricalconvergence rate.

E(xt+1 − x∗)2

≈ρ(A)2t(x0 − x∗)2 + (1− ρ(B)t)α2C

1− ρ(B)

(13)

One of our design decisions for YELLOWFIN is to alwayswork in the robust region of Lemma 3. We know that thisimplies a spectral radius

õ of the momentum operator, A,

for the bias. Lemma 6, as proved in Appendix C, shows thatunder the exact same condition, the variance operator B hasspectral radius µ.Lemma 6. The spectral radius of the variance operator, Bis µ, if (1−√µ)2 ≤ αh ≤ (1 +

õ)2.

As a result, the surrogate objective of (13), takes the follow-ing form in the robust region.

E(xt+1 − x∗)2 ≈ µt(x0 − x∗)2 + (1− µt) α2C

1− µ (14)

We extend this surrogate to multidimensional cases to ex-tract a noisy tuning rule for YELLOWFIN.

3.1 Tuning ruleIn this section, we present SINGLESTEP, the tuning rule ofYellowFin (Algorithm 1). Based on the surrogate in (14),SINGLESTEP is a multidimensional SGD version of thenoiseless tuning rule in (9). We first generalize (9) and (14)to multidimensional cases, and then discuss the rule SIN-GLESTEP as well as its implementation in Algorithm 1.

As discussed in Section 2.2, GCN ν captures the dynamicrange of generalized curvatures in a one-dimensional ob-jective with varying curvature. The consequent robust re-gion described by (9) implies homogeneous spectral radii.

On a multidimensional non-convex objective, each one-dimensional slice passing a minimum x∗ can have varyingcurvature. As we use a single µ and α for the entire model,if ν simultaneously captures the dynamic range of general-ized curvature over all these slices, µ and α in (9) are in therobust region for all these slices. This implies homogeneousspectral radii

õ according to Lemma 3, empirically facili-

tating convergence at a common rate along all the directions.

Given homogeneous spectral radiiõ along all directions,

the surrogate in (14) generalizes on the local quadratic ap-proximation of multiple dimensional objectives. On this ap-proximation with minimum x∗, the expectation of squareddistance to x∗, E‖x0 − x∗‖2, decomposes into indepen-dent scalar components along the eigenvectors of the Hes-sian. We define gradient variance C as the sum of gradientvariance along these eigenvectors. The one-dimensionalsurrogates in (14) for the independent components sum toµt‖x0−x∗‖2+(1−µt)α2C/(1−µ), the multidimensionalsurrogate corresponding to the one in (14).

Algorithm 1 YELLOWFIN

function YELLOWFIN(gradient gt, β)hmax, hmin ← CURVATURERANGE(gt, β)C ← VARIANCE(gt, β)D ← DISTANCE(gt, β)µt, αt ← SINGLESTEP(C,D, hmax, hmin)return µt, αt

end function

(SINGLESTEP)

µt, αt =argminµµD2 + α2C

s.t. µ ≥(√

hmax/hmin − 1√hmax/hmin + 1

)2

α =(1−√µ)2hmin

(15)

Let D be an estimateof the current model’sdistance to a localquadratic approxima-tion’s minimum, and Cdenote an estimate forgradient variance. SIN-GLESTEP minimizesthe multidimensionalsurrogate after a single step (i.e. t = 1) while ensuring

Page 6: YellowFin and the Art of Momentum Tuning - MLSys · 2019. 6. 15. · Accelerated forms of stochastic gradient descent (SGD), pioneered byPolyak(1964) andNesterov(1983), are the de-facto

YELLOWFIN and the Art of Momentum Tuning

Algorithm 2 Curvature rangestate: hmax, hmin, hi, ∀i ∈ {1, 2, 3, ...}function CURVATURERANGE(gradient gt, β)

ht ← ‖gt‖2hmax,t ← max

t−w≤i≤thi, hmin,t ← min

t−w≤i≤thi

hmax ← β · hmax + (1− β) · hmax,t

hmin ← β · hmin + (1− β) · hmin,t

return hmax, hmin

end function

Algorithm 3 Gradient variance

state: g2 ← 0, g ← 0

function VARIANCE(gradient gt, β)

g2 ← β · g2 + (1− β) · gt � gtg ← β · g + (1− β) · gtreturn 1T·

(g2 − g2

)end function

Algorithm 4 Distance to opt.

state: ‖g‖ ← 0, h← 0

function DISTANCE(gradient gt, β)‖g‖ ← β · ‖g‖+ (1− β) · ‖gt‖h← β · h+ (1− β) · ‖gt‖2D ← β ·D + (1− β) · ‖g‖/hreturn D

end function

µ and α in the robust region for all directions. A singleinstance of SINGLESTEP solves a single momentumand learning rate for the entire model at each iteration.Specifically, the extremal curvatures hmin and hmax denoteestimates for the largest and smallest generalized curvaturerespectively. They are meant to capture both generalizedcurvature variation along all different directions (like theclassic condition number) and also variation that occursas the landscape evolves. The constraints keep the globallearning rate and momentum in the robust region (definedin Lemma 3) for slices along all directions.

The problem in (15) does not need iterative solver but has ananalytical solution. Substituting only the second constraint,the objective becomes p(x) = x2D2 + (1 − x)4/h2minCwith x =

√µ ∈ [0, 1). By setting the gradient of p(x) to 0,

we can get a cubic equation whose root x =õp can be

computed in closed form using Vieta’s substitution. As p(x)is uni-modal in [0, 1), the optimizer for (15) is exactly themaximum of µp and (

√hmax/hmin−1)2/(

√hmax/hmin+

1)2, the right hand-side of the first constraint in (15).

YELLOWFIN uses functions CURVATURERANGE, VARI-ANCE and DISTANCE to measure quantities hmax, hmin, Cand D respectively. These functions can be designed indifferent ways. We present the implementations used in ourexperiments, based completely on gradients, in Section 3.2.

3.2 Measurement functions in YELLOWFIN

This section describes our implementation of the measure-ment oracles used by YELLOWFIN: CURVATURERANGE,VARIANCE, and DISTANCE. We design the measurementfunctions with the assumption of a negative log-probabilityobjective; this is in line with typical losses in machine learn-ing, e.g. cross-entropy for neural nets and maximum like-lihood estimation in general. Under this assumption, theFisher information matrix—i.e. the expected outer prod-uct of noisy gradients—approximates the Hessian of theobjective (Duchi, 2016; Pascanu & Bengio, 2013). Thisallows for measurements purely being approximated fromminibatch gradients with overhead linear to model dimen-sionality. These implementations are not guaranteed to giveaccurate measurements. Nonetheless, their use in our ex-periments in Section 5 shows that they are sufficient forYELLOWFIN to outperform the state of the art on a variety

of objectives. We also refer to Appendix D for details onzero-debias (Kingma & Ba, 2014), slow start (Schaul et al.,2013) and smoothing for curvature range estimation.

Curvature range Let gt be a noisy gradient, we estimatethe curvatures range in Algorithm 2. We notice that theouter product gtgTt has an eigenvalue ht = ‖gt‖2 witheigenvector gt. Thus under our negative log-likelihood as-sumption, we use ht to approximate the curvature of Hes-sian along gradient direction gt. Note here we use empiricalFisher gtgTt instead of Fisher information matrix. EmpiricalFisher is typically used in practical natural gradient meth-ods (Martens, 2014; Roux et al., 2008; Duchi et al., 2011).For practically efficient measurement, we use the empiricalFisher as a coarse proxy of Fisher information matrix whichapproximates the Hessian of the objective. Specifically inAlgorithm 2, we maintain hmin and hmax as running aver-ages of extreme curvature hmin,t and hmax,t, from a slidingwindow of width 203. As gradient directions evolve, weestimate curvatures along different directions. Thus hmin

and hmax capture the curvature variations.

Gradient variance To estimate the gradient variance inAlgorithm 3, we use running averages g and g2 to keep trackof gt and gt � gt, the first and second order moment of thegradient. As Var(gt) = Eg2t − Egt � Egt, we estimate thegradient variance C in (15) using C = 1T· (g2 − g2).

Distance to optimum We estimate the distance to the op-timum of the local quadratic approximation in Algorithm 4.Inspired by the fact that ‖∇f(x )‖ ≤ ‖H ‖‖x − x ?‖ for aquadratic f(x) with Hessian H and minimizer x ∗, we main-tain h and ‖g‖ as running mean of curvature ht and gradientnorm ‖gt‖; the distance is approximated with ‖g‖/h.

3.3 Stability on non-smooth objectives

The process of training neural networks is inherently non-stationary, with the landscape abruptly switching from flatto steep areas. In particular, the objective functions ofRNNs with hidden units can exhibit occasional but very

3We use window width 20 across all the models and experi-ments in our paper. We refer to Section 5 for details on selectingthe window width

Page 7: YellowFin and the Art of Momentum Tuning - MLSys · 2019. 6. 15. · Accelerated forms of stochastic gradient descent (SGD), pioneered byPolyak(1964) andNesterov(1983), are the de-facto

YELLOWFIN and the Art of Momentum Tuning

0k 1k 2k 3kIterations

10−3

100

103

105G

radi

ent

norm

Without clippingWith clippingClipping thresh.

0k 1k 2k 3kIterations

10−1

100

101

102

Tra

inin

glo

ss

Without clippingWith clipping

Figure 4. A variation of the LSTM architecture in (Zhu et al., 2016)exhibits exploding gradients. The proposed adaptive gradientclipping threshold (blue) stabilizes the training loss.

0k 5k 10k 15k 20k 25k 30kIterations

3.54

5

6

7

Tra

inin

glo

ss

YF with clippingYF without clipping

0k 10k 20k 30k 40kIterations

10−1

100

Tra

inin

glo

ss YF with clippingYF without clipping

Figure 5. Training losses on PTB LSTM (left) and CIFAR10ResNet (right) for YellowFin with and without adaptive clipping.

steep slopes (Pascanu et al., 2013; Szegedy et al., 2013). Todeal with this issue, gradient clipping has been establishedin literature as a standard tool to stabilize the training usingsuch objectives (Pascanu et al., 2013; Goodfellow et al.,2016; Gehring et al., 2017).

We use adaptive gradient clipping heuristics as a very natu-ral addition to our basic tuner. However, the classic tradeoffbetween adaptivity and stability applies: setting a clippingthreshold that is too low can hurt performance; setting itto be high, can compromise stability. YELLOWFIN, keepsrunning estimates of extremal gradient magnitude squares,hmax and hmin in order to estimate a generalized conditionnumber. We posit that

√hmax is an ideal gradient norm

threshold for adaptive clipping. In order to ensure robust-ness to extreme gradient spikes, like the ones in Figure 4,we also limit the growth rate of the envelope hmax in Algo-rithm 2 as follows:

hmax ← β · hmax + (1− β) ·min {hmax,t, 100 · hmax}(16)

Our heuristics follows along the lines of classic recipeslike (Pascanu et al., 2013). However, instead of using theaverage gradient norm to clip, it uses a running estimate ofthe maximum norm hmax. In Figure 4, we demonstrate themechanism of our heuristic by presenting an example of anLSTM that exhibits ’exploding gradients’. The proposedadaptive clipping can stabilize the training process usingYELLOWFIN and prevent large catastrophic loss spikes.

We validate the proposed adaptive clipping on the convolu-tional sequence to sequence learning model (Gehring et al.,2017) for IWSLT 2014 German-English translation. The de-

fault optimizer (Gehring et al., 2017) uses learning rate 0.25and Nesterov’s momentum 0.99, diverging to loss overflowdue to ’exploding gradient’. It requires, as in Gehring et al.(2017), strict manually set gradient norm threshold 0.1 tostabilize. In Table 1, we can see YellowFin, with adaptiveclipping, outperforms the default optimizer using manuallyset clipping, with 0.84 higher validation BLEU4 after 120epochs. To further demonstrate the practical applicabilityof our gradient clipping heuristics, in Figure 5, we demon-strate that the adaptive clipping does not hurt performanceon models that do not exhibit instabilities without clipping.Specifically, for both PTB LSTM and CIFAR10 ResNet, thedifference between YELLOWFIN with and without adaptiveclipping diminishes quickly.

4 CLOSED-LOOP YELLOWFIN

Table 1. German-English trans-lation validation metrics usingconvolutional seq-to-seq model.

Loss BLEU4

Default w/o clip. divergeDefault w/ clip. 2.86 30.75

YF 2.75 31.59

Asynchrony is a paral-lelization technique thatavoids synchronizationbarriers (Niu et al., 2011).In this section, we proposea closed momentum loopvariant of YELLOWFINto accelerate convergencein asynchronous training.After some preliminaries, we show the mechanism of theextension: it measures the dynamics on a running systemand controls momentum with a negative feedback loop.

Preliminaries When training on M asynchronous work-ers, staleness (the number of model updates between aworker’s read and write operations) is on average τ =M−1,i.e., the gradient in the SGD update is delayed by τ itera-tions as ∇fSt−τ (xt−τ ). Asynchrony yields faster steps,but can increase the number of iterations to achieve thesame solution, a tradeoff between hardware and statisticalefficiency (Zhang & Re, 2014). Mitliagkas et al. (2016) in-terpret asynchrony as added momentum dynamics. Experi-ments in Hadjis et al. (2016) support this finding, and demon-strate that reducing algorithmic momentum can compensatefor asynchrony-induced momentum and significantly reducethe number of iterations for convergence. Motivated by thatresult, we use the model in (17), where the total momen-tum, µT , includes both asynchrony-induced and algorithmicmomentum, µ, in (1).

E[xt+1 − xt] = µTE[xt − xt−1]− αE∇f(xt) (17)

We will use this expression to design an estimator for thevalue of total momentum, µT . This estimator is a basicbuilding block of closed-loop YELLOWFIN; it removes theneed to manually compensate for the effects of asynchrony.

Page 8: YellowFin and the Art of Momentum Tuning - MLSys · 2019. 6. 15. · Accelerated forms of stochastic gradient descent (SGD), pioneered byPolyak(1964) andNesterov(1983), are the de-facto

YELLOWFIN and the Art of Momentum Tuning

0k 5k 10k 15k 20k 25k 30k 35k 40kIterations

�0.2

0.0

0.2

0.4

0.6

0.8M

omen

tum

Total mom.Target mom.

0k 5k 10k 15k 20k 25k 30k 35k 40kIterations

�0.2

0.0

0.2

0.4

0.6

0.8

Total mom.Target mom.

0k 5k 10k 15k 20k 25k 30k 35k 40kIterations

�0.2

0.0

0.2

0.4

0.6

0.8

Total mom.Target mom.Algorithmic mom.

Asynchrony-induced momentum

Figure 6. When running YELLOWFIN, total momentum µt equals algorithmic value in synchronous settings (left); µt is greater thanalgorithmic value on 16 asynchronous workers (middle). Closed-loop YELLOWFIN automatically lowers algorithmic momentum andbrings total momentum to match the target value (right). Red dots are total momentum estimates, µT , at each iteration. The solid red lineis a running average of µT .

Measuring the momentum dynamics Closed-loop YEL-LOWFIN estimates total momentum µT on a running systemand uses a negative feedback loop to adjust algorithmic mo-mentum accordingly. Equation (18) gives an estimate of µTon a system with staleness τ , based on (18).

µT = median

(xt−τ − xt−τ−1 + α∇St−τ−1f(xt−τ−1)

xt−τ−1 − xt−τ−2

)(18)

We use τ -stale model values to match the staleness of thegradient, and perform element-wise operations. This waywe get a total momentum measurement from each variable;the median combines them into a more robust estimate.

Closing the asynchrony loop Given a reliable measure-ment of µT , we can use it to adjust the value of algorithmicmomentum so that the total momentum matches the tar-get momentum as decided by YELLOWFIN in Algorithm 1.Closed-loop YELLOWFIN in Algorithm 5 uses a simplenegative feedback loop to achieve the adjustment.

Algorithm 5 Closed-loop YELLOWFIN

1: Input: µ← 0, α← 0.0001, γ ← 0.01, τ (staleness)2: for t← 1 to T do3: xt←xt−1 + µ(xt−1 − xt−2)− α∇Stf(xt−τ−1)4: µ∗, α← YELLOWFIN(∇Stf(xt−τ−1), β)5: µT ← median

(xt−τ−xt−τ−1+α∇St−τ−1

f(xt−τ−1)

xt−τ−1−xt−τ−2

). Measuring total momentum

6: µ← µ+ γ · (µ∗ − µT ) . Closing the loop7: end for

5 EXPERIMENTS

We empirically validate the importance of momentum tun-ing and evaluate YELLOWFIN in both synchronous (single-node) and asynchronous settings. In synchronous settings,we first demonstrate that, with hand-tuning, momentumSGD is competitive with Adam, a state-of-the-art adaptivemethod. Then, we evaluate YELLOWFIN without any handtuning in comparison to hand-tuned Adam and momentum

SGD. In asynchronous settings, we show that closed-loopYELLOWFIN accelerates with momentum closed-loop con-trol, significantly outperforming Adam.

We evaluate on convolutional neural networks (CNN) andrecurrent neural networks (RNN). For CNN, we trainResNet (He et al., 2016) for image recognition on CIFAR10and CIFAR100 (Krizhevsky et al., 2014). For RNN, wetrain LSTMs for character-level language modeling with theTinyShakespeare (TS) dataset (Karpathy et al., 2015), word-level language modeling with the Penn TreeBank (PTB)(Marcus et al., 1993), and constituency parsing on the WallStreet Journal (WSJ) dataset (Choe & Charniak). We re-fer to Table 3 in Appendix E for model specifications. Toeliminate influences of a specific random seed, in our syn-chronous and asynchronous experiments, the training lossand validation metrics are averaged from 3 runs using dif-ferent random seeds. Across all experiments on the eightmodels, we use sliding window width 20 for estimating theextreme curvature hmax and hmin in Algorithm 2. It isselected based on the performance on PTB LSTM and CI-FAR10 ResNet model. The selected sliding window widthis directly applied to the other 6 models, including the con-volutional sequence to sequence model in Section 3.3, aswell as the ResNext and Tied LSTM in Appendix G.3.

5.1 Synchronous experiments

We tune Adam and momentum SGD on learning rate gridswith prescribed momentum 0.9 for SGD. We fix the param-eters of Algorithm 1 in all experiments, i.e. YELLOWFINruns without any hand tuning. We provide full specifica-tions, including the learning rate (grid) and the number ofiterations we train on each model in Appendix F. For visual-ization purposes, we smooth training losses with a uniformwindow of width 1000. For Adam and momentum SGD oneach model, we pick the configuration achieving the lowestaveraged smoothed loss. To compare two algorithms, werecord the lowest smoothed loss achieved by both. Then thespeedup is reported as the ratio of iterations to achieve thisloss. We use this setup to validate our claims.

Page 9: YellowFin and the Art of Momentum Tuning - MLSys · 2019. 6. 15. · Accelerated forms of stochastic gradient descent (SGD), pioneered byPolyak(1964) andNesterov(1983), are the de-facto

YELLOWFIN and the Art of Momentum Tuning

0k 5k 10k 15k 20k

Iterations

1

1.5

2T

rain

ing

loss YellowFin

YF mom.=0.0YF mom.=0.9YF rescaling

0k 30k 60k 90k

Iterations

100

101

Tra

inin

glo

ss YellowFinYF mom.=0.0YF mom.=0.9YF rescaling

0k 5k 10k 15k 20k

Iterations

1

1.5

2

Tra

inin

glo

ss Momentum SGDVanilla SGDYellowFinYF rescaling

Figure 7. The importance of adaptive momentum: The training loss comparison between YELLOWFIN with adaptive momentum andYELLOWFIN with fixed momentum values; this comparison is conducted on TS LSTM (left) and CIFAR100 ResNet (middle). Learningrate scaling based on YELLOWFIN tuned momentum can match the performance of full YELLOWFIN on the TS LSTM(right). Howeverwithout the YELLOWFIN tuned momentum, hand-tuned Vanilla SGD demonstrates observably larger training loss than momentum basedmethods, including full YELLOWFIN, YELLOWFIN learning rate rescaling and hand-tuned momentum SGD (with the same learning ratesearch grid as with Vanilla SGD).

Table 2. The speedup of YELLOWFIN and tuned momentum SGDover tuned Adam on ResNet and LSTM models.

CIFAR10 CIFAR100 PTB TS WSJ

Adam 1x 1x 1x 1x 1xmom. SGD 1.71x 1.87x 0.88x 2.49x 1.33x

YF 1.93x 1.38x 0.77x 3.28x 2.33x

Momentum SGD is competitive with adaptive methodsIn Table 2, we compare tuned momentum SGD and tunedAdam on ResNets with training losses shown in Figure 9 inAppendix D. We can observe that momentum SGD achieves1.71x and 1.87x speedup to tuned Adam on CIFAR10 andCIFAR100 respectively. In Figure 8 and Table 2, with theexception of PTB LSTM, momentum SGD also producesbetter training loss, as well as better validation perplexityin language modeling and validation F1 in parsing. For theparsing task, we also compare with tuned Vanilla SGD andAdaGrad, which are used in the NLP community. Figure 8(right) shows that fixed momentum 0.9 can already speedupVanilla SGD by 2.73x, achieving better validation F1.

YELLOWFIN can match hand-tuned momentum SGDand can outperform hand-tuned Adam In our experi-ments, YELLOWFIN, without any hand-tuning, yields train-ing loss matching hand-tuned momentum SGD for all theResNet and LSTM models in Figure 8 and 9 (AppendixD). When comparing to tuned Adam in Table 2, except be-ing slightly slower on PTB LSTM, YELLOWFIN achieves1.38x to 3.28x speedups in training losses on the other fourmodels. More importantly, YELLOWFIN consistently showsbetter validation metrics than tuned Adam in Figure 8. Itdemonstrates that YELLOWFIN can match tuned momen-tum SGD and outperform tuned state-of-the-art adaptiveoptimizers. In Appendix G.3, we show YELLOWFIN furtherspeeding up with finer-grain manual learning rate tuning.

Importance of adaptive momentum in YELLOWFINIn Definition 4, we noticed that the optimally tuned µ∗ ishighly objective-dependent. Empirically, we indeed observethe momentum values chosen by YF range from smallerthan 0.03 in the PTM LSTM to 0.89 for ResNext. Weperform an ablation study to validate the importance ofobjective-dependent momentum adaptivity of YELLOWFINon CIFAR100 ResNet and TS LSTM. In the experiments,YELLOWFIN tunes the learning rate. Instead of also usingthe momentum tuned by YF, we continuously feed objective-agnostic prescribed momentum value 0.0 and 0.9 to the un-derlying momentum SGD optimizer which YF is tuning. InFigure 7, when comparing to YELLOWFIN with prescribedmomentum 0.0 or 0.9, YELLOWFIN with adaptively tunedmomentum achieves observably faster convergence on bothTS LSTM and CIFAR100 ResNet.

In Figure 8 (bottom right) and Figure 7 (right), we also ob-serve that hand-tuned vanilla SGD, typically does not matchthe performance of momentum based methods (includingYELLOWFIN and momentum SGD hand-tuned using thesame learning rate grid as with vanilla SGD). However,we can rescale the learning rate based on the YELLOWFINtuned momentum µt, and use 0 momentum in the modelupdates to match the performance of momentum based meth-ods. Specifically, we rescale the YELLOWFIN tuned learn-ing rate αt with 1/(1 − µt)

4. Model updates with thisrescaled learning rate and 0 momentum can demonstratetraining loss closely matching those of YELLOWFIN andhand-tuned momentum SGD for WSJ LSTM in Figure 8(bottom right) and TS LSTM in Figure 7 (right).

5.2 Asynchronous experiments

In this section, we evaluate closed-loop YELLOWFIN withfocus on the number of iterations to reach a certain solu-

4Let vt = xt − xt−1 be the model update, this rescaling ismotivated with the fact that vt+1 = µtvt − αt∇f(xt). Assumingthe vt evolves smoothly, we have vt ≈ αt/(1− µt)∇f(xt).

Page 10: YellowFin and the Art of Momentum Tuning - MLSys · 2019. 6. 15. · Accelerated forms of stochastic gradient descent (SGD), pioneered byPolyak(1964) andNesterov(1983), are the de-facto

YELLOWFIN and the Art of Momentum Tuning

0k 5k 10k 15k 20k 25k 30k

Iterations

3.5

4

5

6

7

Tra

inin

glo

ssMomentum SGDAdamYellowFin

0k 5k 10k 15k 20k

Iterations

1

1.5

2

Tra

inin

glo

ss

Momentum SGDAdamYellowFin

0k 30k 60k 90k 120k

Iterations

1.5

2.0

2.5

Tra

inin

glo

ss

Vanilla SGDMomentum SGDAdamAdagradYellowFin

0k 5k 10k 15k 20k 25k 30k

Iterations

102

103

Valid

atio

npe

rple

xity

Momentum SGDAdamYellowFin

0k 5k 10k 15k 20k

Iterations

4.5

5

6

7

Valid

atio

npe

rple

xity

Momentum SGDAdamYellowFin

0k 30k 60k 90k 120k

Iterations

88.0

88.5

89.0

89.5

90.0

90.5

91.0

91.5

Valid

atio

nF

1

Momentum SGDAdamYellowFinAdagradVanilla SGD

Figure 8. Training loss and validation metrics on (left to right) word-level language modeling with PTB, char-level language modelingwith TS and constituency parsing on WSJ. The valid. metrics are monotonic as we report the best values up to each number of iterations.

tion. To that end, we run 16 asynchronous workers on asingle machine and force them to update the model in around-robin fashion, i.e. the gradient is delayed for 15 it-erations. Figure 1 (right) presents training losses on theCIFAR100 ResNet, using YELLOWFIN in Algorithm 1,closed-loop YELLOWFIN in Algorithm 5 and Adam withthe learning rate achieving the best smoothed loss in Sec-tion 5.1. We can observe closed-loop YELLOWFIN achieves20.1x speedup to YELLOWFIN, and consequently a 2.69xspeedup to Adam. This demonstrates that (1) closed-loopYELLOWFIN accelerates by reducing algorithmic momen-tum to compensate for asynchrony and (2) can converge inless iterations than Adam in asynchronous-parallel training.

6 RELATED WORKMany techniques have been proposed on tuning hyperpa-rameters for optimizers. General hyperparameter tuningapproaches, such as random search (Bergstra & Bengio,2012) and Bayesian approaches (Snoek et al., 2012; Hutteret al., 2011), can directly tune optimizers. As another trend,adaptive methods, including AdaGrad (Duchi et al., 2011),RMSProp (Tieleman & Hinton, 2012) and Adam (Kingma& Ba, 2014), uses per-dimension learning rate. Schaulet al. (2013) use a noisy quadratic model similar to oursto tune the learning rate in Vanilla SGD. However theydo not use momentum which is essential in training mod-ern neural nets. Existing adaptive momentum approacheither consider the deterministic setting (Graepel & Schrau-dolph, 2002; Rehman & Nawi, 2011; Hameed et al., 2016;Swanston et al., 1994; Ampazis & Perantonis, 2000; Qiuet al., 1992) or only analyze stochasticity with O(1/t) learn-

ing rate (Leen & Orr, 1994). In contrast, we aim at practicalmomentum adaptivity for stochastically training neural nets.

7 DISCUSSIONWe presented YELLOWFIN, the first optimization methodthat automatically tunes momentum as well as the learningrate of momentum SGD. YELLOWFIN outperforms the state-of-the-art adaptive optimizers on a large class of modelsboth in synchronous and asynchronous settings. It estimatesstatistics purely from the gradients of a running system, andthen tunes the hyperparameters of momentum SGD basedon noisy, local quadratic approximations. As future work,we believe that more accurate curvature estimation methods,like the bbprop method (Martens et al., 2012) can furtherimprove YELLOWFIN. We also believe that our closed-loopmomentum control mechanism in Section 4 could accelerateother adaptive methods in asynchronous-parallel settings.

ACKNOWLEDGEMENTSWe are grateful to Christopher Re for his valuable guidanceand support. We thank Bryan He, Paroma Varma, Chris DeSa, Tri Dao, Albert Gu, Fred Sala, Alex Ratner, TheodorosRekatsinas, Olexa Bilaniuk and Avner May for helpful dis-cussions and feedback. We gratefully acknowledge thesupport of the D3M program under No. FA8750-17-2-0095,the FRQNT new researcher program (2019-NC-257943),a grant by IVADO and a Canada CIFAR AI chair. Anyopinions, findings, and conclusions or recommendationsexpressed in this material are those of the authors and donot necessarily reflect the views of DARPA, or the Canadianor U.S. governments.

Page 11: YellowFin and the Art of Momentum Tuning - MLSys · 2019. 6. 15. · Accelerated forms of stochastic gradient descent (SGD), pioneered byPolyak(1964) andNesterov(1983), are the de-facto

YELLOWFIN and the Art of Momentum Tuning

REFERENCES

Ampazis, N. and Perantonis, S. J. Levenberg-marquardtalgorithm with adaptive momentum for the efficient train-ing of feedforward networks. In Neural Networks, 2000.IJCNN 2000, Proceedings of the IEEE-INNS-ENNS In-ternational Joint Conference on, volume 1, pp. 126–131.IEEE, 2000.

Bengio, Y. Practical recommendations for gradient-basedtraining of deep architectures. In Neural networks: Tricksof the trade, pp. 437–478. Springer, 2012.

Bengio, Y. et al. Deep learning of representations for unsu-pervised and transfer learning. ICML Unsupervised andTransfer Learning, 27:17–36, 2012.

Bergstra, J. and Bengio, Y. Random search for hyper-parameter optimization. Journal of Machine LearningResearch, 13(Feb):281–305, 2012.

Bottou, L. Stochastic gradient descent tricks. In Neuralnetworks: Tricks of the trade, pp. 421–436. Springer,2012.

Chen, D., Bolton, J., and Manning, C. D. A thoroughexamination of the cnn/daily mail reading comprehensiontask. arXiv preprint arXiv:1606.02858, 2016.

Choe, D. K. and Charniak, E. Parsing as language modeling.

Duchi, J. Fisher information., 2016. URLhttps://web.stanford.edu/class/stats311/Lectures/lec-09.pdf.

Duchi, J., Hazan, E., and Singer, Y. Adaptive subgradientmethods for online learning and stochastic optimization.Journal of Machine Learning Research, 12(Jul):2121–2159, 2011.

Foucart, S. University Lecture, 2012. URLhttp://www.math.drexel.edu/˜foucart/TeachingFiles/F12/M504Lect6.pdf.

Gehring, J., Auli, M., Grangier, D., Yarats, D., and Dauphin,Y. N. Convolutional sequence to sequence learning. arXivpreprint arXiv:1705.03122, 2017.

Goodfellow, I., Bengio, Y., and Courville, A. DeepLearning. MIT Press, 2016. http://www.deeplearningbook.org.

Graepel, T. and Schraudolph, N. N. Stable adaptive momen-tum for rapid online learning in nonlinear systems. InInternational Conference on Artificial Neural Networks,pp. 450–455. Springer, 2002.

Hadjis, S., Zhang, C., Mitliagkas, I., Iter, D., and Re, C.Omnivore: An optimizer for multi-device deep learningon cpus and gpus. arXiv preprint arXiv:1606.04487,2016.

Hameed, A. A., Karlik, B., and Salman, M. S. Back-propagation algorithm with variable adaptive momentum.Knowledge-Based Systems, 114:79–87, 2016.

He, K., Zhang, X., Ren, S., and Sun, J. Deep residual learn-ing for image recognition. In Proceedings of the IEEEConference on Computer Vision and Pattern Recognition,pp. 770–778, 2016.

Hutter, F., Hoos, H. H., and Leyton-Brown, K. Sequentialmodel-based optimization for general algorithm configu-ration. LION, 5:507–523, 2011.

Karimi, H., Nutini, J., and Schmidt, M. Linear conver-gence of gradient and proximal-gradient methods underthe polyak-łojasiewicz condition. In Joint European Con-ference on Machine Learning and Knowledge Discoveryin Databases, pp. 795–811. Springer, 2016.

Karpathy, A., Johnson, J., and Fei-Fei, L. Visualizingand understanding recurrent networks. arXiv preprintarXiv:1506.02078, 2015.

Kingma, D. and Ba, J. Adam: A method for stochasticoptimization. arXiv preprint arXiv:1412.6980, 2014.

Krizhevsky, A., Nair, V., and Hinton, G. The cifar-10 dataset,2014.

Leen, T. K. and Orr, G. B. Optimal stochastic search andadaptive momentum. In Advances in neural informationprocessing systems, pp. 477–484, 1994.

Lessard, L., Recht, B., and Packard, A. Analysis and de-sign of optimization algorithms via integral quadraticconstraints. SIAM Journal on Optimization, 26(1):57–95,2016.

Marcus, M. P., Marcinkiewicz, M. A., and Santorini, B.Building a large annotated corpus of english: The penntreebank. Computational linguistics, 19(2):313–330,1993.

Martens, J. New insights and perspectives on the naturalgradient method. arXiv preprint arXiv:1412.1193, 2014.

Martens, J., Sutskever, I., and Swersky, K. Estimating thehessian by back-propagating curvature. arXiv preprintarXiv:1206.6464, 2012.

Mitliagkas, I., Zhang, C., Hadjis, S., and Re, C. Asynchronybegets momentum, with an application to deep learning.arXiv preprint arXiv:1605.09774, 2016.

Page 12: YellowFin and the Art of Momentum Tuning - MLSys · 2019. 6. 15. · Accelerated forms of stochastic gradient descent (SGD), pioneered byPolyak(1964) andNesterov(1983), are the de-facto

YELLOWFIN and the Art of Momentum Tuning

Nesterov, Y. A method of solving a convex programmingproblem with convergence rate o (1/k2). In Soviet Mathe-matics Doklady, volume 27, pp. 372–376, 1983.

Nesterov, Y. Introductory lectures on convex optimization:A basic course, volume 87. Springer Science & BusinessMedia, 2013.

Niu, F., Recht, B., Re, C., and Wright, S. Hogwild: A lock-free approach to parallelizing stochastic gradient descent.In Advances in Neural Information Processing Systems,pp. 693–701, 2011.

Orr, G. B. and Muller, K.-R. Neural networks: tricks of thetrade. Springer, 2003.

Pascanu, R. and Bengio, Y. Revisiting natural gradient fordeep networks. arXiv preprint arXiv:1301.3584, 2013.

Pascanu, R., Mikolov, T., and Bengio, Y. On the difficultyof training recurrent neural networks. In InternationalConference on Machine Learning, pp. 1310–1318, 2013.

Polyak, B. T. Some methods of speeding up the convergenceof iteration methods. USSR Computational Mathematicsand Mathematical Physics, 4(5):1–17, 1964.

Press, O. and Wolf, L. Using the output embedding to im-prove language models. arXiv preprint arXiv:1608.05859,2016.

Qiu, G., Varley, M., and Terrell, T. Accelerated training ofbackpropagation networks by using adaptive momentumstep. Electronics letters, 28(4):377–379, 1992.

Reddi, S. J., Kale, S., and Kumar, S. On the convergence ofadam and beyond. 2018.

Rehman, M. Z. and Nawi, N. M. The effect of adaptivemomentum in improving the accuracy of gradient descentback propagation algorithm on classification problems. InInternational Conference on Software Engineering andComputer Systems, pp. 380–390. Springer, 2011.

Roux, N. L., Manzagol, P.-A., and Bengio, Y. Topmoumouteonline natural gradient algorithm. In Advances in neuralinformation processing systems, pp. 849–856, 2008.

Schaul, T., Zhang, S., and LeCun, Y. No more pesky learn-ing rates. ICML (3), 28:343–351, 2013.

Snoek, J., Larochelle, H., and Adams, R. P. Practicalbayesian optimization of machine learning algorithms.In Advances in neural information processing systems,pp. 2951–2959, 2012.

Sutskever, I., Martens, J., Dahl, G., and Hinton, G. On theimportance of initialization and momentum in deep learn-ing. In Proceedings of the 30th international conferenceon machine learning (ICML-13), pp. 1139–1147, 2013.

Swanston, D., Bishop, J., and Mitchell, R. J. Simpleadaptive momentum: new algorithm for training multi-layer perceptrons. Electronics Letters, 30(18):1498–1500,1994.

Szegedy, C., Zaremba, W., Sutskever, I., Bruna, J., Erhan,D., Goodfellow, I., and Fergus, R. Intriguing properties ofneural networks. arXiv preprint arXiv:1312.6199, 2013.

Tieleman, T. and Hinton, G. Lecture 6.5-rmsprop: Dividethe gradient by a running average of its recent magnitude.COURSERA: Neural networks for machine learning, 4(2), 2012.

Wilson, A. C., Roelofs, R., Stern, M., Srebro, N., and Recht,B. The marginal value of adaptive gradient methodsin machine learning. arXiv preprint arXiv:1705.08292,2017.

Xie, S., Girshick, R., Dollar, P., Tu, Z., and He, K. Aggre-gated residual transformations for deep neural networks.arXiv preprint arXiv:1611.05431, 2016.

Zhang, C. and Re, C. Dimmwitted: A study of main-memory statistical analytics. PVLDB, 7(12):1283–1294, 2014. URL http://www.vldb.org/pvldb/vol7/p1283-zhang.pdf.

Zhu, C., Han, S., Mao, H., and Dally, W. J. Trained ternaryquantization. arXiv preprint arXiv:1612.01064, 2016.

Page 13: YellowFin and the Art of Momentum Tuning - MLSys · 2019. 6. 15. · Accelerated forms of stochastic gradient descent (SGD), pioneered byPolyak(1964) andNesterov(1983), are the de-facto

YELLOWFIN and the Art of Momentum Tuning

A PROOF OF LEMMA 3To prove Lemma 3, we first prove a more generalized ver-sion in Lemma 7. By restricting f to be a one dimensionalquadratics function, the generalized curvature ht itself isthe only eigenvalue. We can prove Lemma 3 as a straight-forward corollary. Lemma 7 also implies, in the multi-ple dimensional correspondence of (4), the spectral radiusρ(At) =

õ if the curvature on all eigenvector directions

(eigenvalue) satisfies (6).Lemma 7. Let the gradients of a function f be describedby

∇f(x t) = H (x t)(x t − x ∗), (19)

with H (xt) ∈ Rn 7→ Rn×n. Then the momentum updatecan be expressed as a linear operator:(

y t+1

y t

)=

(I − αH (x t) + µI −µI

I 0

)(y t

y t−1

)=At

(y t

y t−1

),

(20)

where y t , x t − x ∗. Now, assume that the followingcondition holds for all eigenvalues λ(H (xt)) of H (xt):

(1−√µ)2α

≤ λ(H (xt)) ≤(1 +

õ)2

α. (21)

then the spectral radius of At is controlled by momentumwith ρ(At) =

õ.

Proof. Let λt be an eigenvalue of matrix At, it givesdet (At − λtI ) = 0. We define the blocks in At asC = I − αH t + µI − λtI , D = −µI , E = I andF = −λtI which gives

det (At − λtI ) = detF det(C −DF−1E

)= 0

assuming generally F is invertible. Note we useH t , H (x t) for simplicity in writing. The equationdet(C −DF−1E

)= 0 implies that

det(λ2t I − λtM t + µI

)= 0 (22)

with M t = (I − αH t + µI ). In other words, λt satis-fied that λ2t − λtλ(M t) + µ = 0 with λ(M t) being oneeigenvalue of Mt . I.e.

λt =λ(M t)±

√λ(M t)2 − 4µ

2(23)

On the other hand, (21) guarantees that (1 − αλ(H t) +µ)2 ≤ 4µ. We know both H t and I − αH t + µI aresymmetric. Thus for all eigenvalues λ(M t) of M t, we haveλ(M t)

2 = (1 − αλ(H t) + µ)2 ≤ 4µ which guarantees|λt| = √µ for all λt. As the spectral radius is equal tothe magnitude of the largest eigenvalue of At, we have thespectral radius of At being

õ.

B PROOF OF LEMMA 5We first prove Lemma 8 and Lemma 9 as preparation for theproof of Lemma 5. After the proof for one dimensional case,we discuss the trivial generalization to multiple dimensionalcase.

Lemma 8. Let the h be the curvature of a one dimensionalquadratic function f and xt = Ext. We assume, withoutloss of generality, the optimum point of f is x? = 0. Thenwe have the following recurrence

(xt+1

xt

)=

(1− αh+ µ −µ

1 0

)t(x1x0

)(24)

Proof. From the recurrence of momentum SGD, we have

Ext+1 =E[xt − α∇fSt(xt) + µ(xt − xt−1)]=Ext [xt − αESt∇fSt(xt) + µ(xt − xt−1)]=Ext [xt − αhxt + µ(xt − xt−1)]=(1− αh+ µ)xt − µxt−1

By putting the equation in to matrix form, (24) is a straight-forward result from unrolling the recurrence for t times.Note as we set x1 = x0 with no uncertainty in momentumSGD, we have [x0, x1] = [x0, x1].

Lemma 9. Let Ut = E(xt − xt)2 and Vt = E(xt −

xt)(xt−1 − xt−1) with xt being the expectation of xt. Forquadratic function f(x) with curvature h ∈ R, We have thefollowing recurrence

Ut+1

UtVt+1

= (I −B>)(I −B)−1

α2C00

(25)

where

B =

(1− αh+ µ)2 µ2 −2µ(1− αh+ µ)1 0 0

1− αh+ µ 0 −µ

(26)

and C = E(∇fSt(xt)−∇f(xt))2 is the variance of gradi-ent on minibatch St.

Proof. We prove by first deriving the recurrence for Ut andVt respectively and combining them in to a matrix form. For

Page 14: YellowFin and the Art of Momentum Tuning - MLSys · 2019. 6. 15. · Accelerated forms of stochastic gradient descent (SGD), pioneered byPolyak(1964) andNesterov(1983), are the de-facto

YELLOWFIN and the Art of Momentum Tuning

Ut, we have

Ut+1 =E(xt+1 − xt+1)2

=E(xt − α∇fSt(xt) + µ(xt − xt−1)− (1− αh+ µ)xt + µxt−1)

2

=E(xt − α∇f(xt) + µ(xt − xt−1)− (1− αh+ µ)xt + µxt−1

+ α(∇f(xt)−∇fSt(xt)))2

=E((1− αh+ µ)(xt − xt)− µ(xt−1 − xt−1))2

+ α2E(∇f(xt)−∇fSt(xt))2

=(1− αh+ µ)2E(xt − xt)2− 2µ(1− αh+ µ)E(xt − xt)(xt−1 − xt−1)+ µ2E(xt−1 − xt−1)2 + α2C

(27)where the cross terms cancels due to the fact ESt [∇f(xt)−∇fSt(xt)] = 0 in the third equality.

For Vt, we can similarly derive

Vt =E(xt − xt)(xt−1 − xt−1)=E((1− αh+ µ)(xt−1 − xt−1)− µ(xt−2 − xt−2)

+ α(∇f(xt)−∇fSt(xt)))(xt−1 − xt−1)=(1− αh+ µ)E(xt−1 − xt−1)2− µE(xt−1 − xt−1)(xt−2 − xt−2)

(28)Again, the term involving ∇f(xt) − ∇fSt(xt) cancels inthe third equality as a results of ESt [∇f(xt)−∇fSt(xt)] =0. (27) and (28) can be jointly expressed in the followingmatrix formUt+1

UtVt+1

=B

UtUt−1Vt

+

α2C00

=t−1∑i=0

B i

α2C00

+B t

U1

U0

V1

=(I −B t)(I −B)−1

α2C00

.

(29)

Note the second term in the second equality is zero becausex0 and x1 are deterministic. Thus U1=U0=V1=0.

According to Lemma 8 and 9, we have E(xt − x∗)2 =(e>1 A

t[x1, x0]>)2 and E(xt−xt)2 = α2Ce>1 (I−B t)(I−

B)−1e1 where e1 ∈ Rn has all zero entries but the firstdimension. Combining these two terms, we prove Lemma 5.Though the proof here is for one dimensional quadratics,it trivially generalizes to multiple dimensional quadratics.Specifically, we can decompose the quadratics along theeigenvector directions, and then apply Lemma 5 to each

eigenvector direction using the corresponding curvature h(eigenvalue). By summing quantities in (11) for all eigen-vector directions, we can achieve the multiple dimensionalcorrespondence of (11).

C PROOF OF LEMMA 6Again we first present a proof of a multiple dimensionalgeneralized version of Lemma 6. The proof of Lemma 6 isa one dimensional special case of Lemma 10. Lemma 10also implies that for multiple dimension quadratics, thecorresponding spectral radius ρ(B) = µ if (1−√µ)2

α ≤ h ≤(1+√µ)2

α on all the eigenvector directions with h being theeigenvalue (curvature).

Lemma 10. Let H ∈ Rn×n be a symmetric matrix andρ(B) be the spectral radius of matrix

B =

M>M µ2I −2µMI 0 0M 0 −µI

(30)

where M = I − αH + µI . We have ρ(B) = µ if alleigenvalues λ(H ) of H satisfies

(1−√µ)2α

≤ λ(H ) ≤ (1 +√µ)2

α. (31)

Proof. Let λ be an eigenvalue of matrix B , it givesdet (B − λI ) = 0 which can be alternatively expressedas

det (B − λI ) = detF det(C −DF−1E

)= 0 (32)

assuming F is invertible, i.e. λ+ µ 6= 0, where the blocksin B

C =

(M>M − λI µ2I

I −λI

),D =

(−2µM

0

),

E =

(M0

)>,F = −µI − λI

with M = I − αH + µI . (32) can be transformed usingstraight-forward algebra as

det

((λ− µ)M>M − (λ+ µ)λI (λ+ µ)µ2I

(λ+ µ)I −(λ+ µ)λI

)= 0

(33)Using similar simplification technique as in (32), we canfurther simplify into

(λ− µ) det((λ+ µ)2I − λM>M

)= 0 (34)

if λ 6= µ, as (λ+µ)2I−λM>M is diagonalizable, we have(λ+ µ)2 − λλ(M )2 = 0 with λ(M ) being an eigenvalue

Page 15: YellowFin and the Art of Momentum Tuning - MLSys · 2019. 6. 15. · Accelerated forms of stochastic gradient descent (SGD), pioneered byPolyak(1964) andNesterov(1983), are the de-facto

YELLOWFIN and the Art of Momentum Tuning

of symmetric M . The analytic solution to the equation canbe explicitly expressed as

λ =λ(M )2 − 2µ±

√(λ(M )2 − 2µ)2 − 4µ2

2. (35)

When the condition in (31) holds, we have λ(M)2 = (1−αλ(H ) + µ)2 ≤ 4µ. One can verify that

(λ(M )2 − 2µ)2 − 4µ2

= (λ(M )2 − 4µ)λ(M )2

=((1− αρ(H ) + µ)2 − 4µ

)λ(M )2

≤ 0

(36)

Thus the roots in (35) are conjugate with |λ| = µ. In conclu-sion, the condition in (31) can guarantee all the eigenvaluesof B has magnitude µ. Thus the spectral radius of B iscontrolled by µ.

D PRACTICAL IMPLEMENTATION

In Section 3.2, we discuss estimators for learning rate andmomentum tuning in YELLOWFIN. In our experiment prac-tice, we have identified a few practical implementation de-tails which are important for improving estimators. Zero-debias is proposed by Kingma & Ba (2014), which accel-erates the process where exponential average adapts to thelevel of original quantity in the beginning. We applied zero-debias to all the exponential average quantities involved inour estimators. In some LSTM models, we observe thatour estimated curvature may decrease quickly along theoptimization process. In order to better estimate extremalcurvature hmax and hmin with fast decreasing trend, we ap-ply zero-debias exponential average on the logarithmic ofhmax,t and hmin,t, instead of directly on hmax,t and hmin,t.Except from the above two techniques, we also implementedthe slow start heuristic proposed by (Schaul et al., 2013).More specifically, we use α = min{αt, t · αt/(10 · w)} asour learning rate with w as the size of our sliding window inhmax and hmin estimation. It discount the learning rate inthe first 10 ·w steps and helps to keep the learning rate smallin the beginning when the exponential averaged quantitiesare not accurate enough.

E MODEL SPECIFICATION

The model specification is shown in Table 3 for all theexperiments in Section 5. CIRAR10 ResNet uses the regularResNet units while CIFAR100 ResNet uses the bottleneckunits. Only the convolutional layers are shown with filtersize, filter number as well as the repeating count of theunits. The layer counting for ResNets also includes batchnormalization and Relu layers. The LSTM models are also

diversified for different tasks with different vocabulary sizes,word embedding dimensions and number of layers.

F SPECIFICATION FOR SYNCHRONOUSEXPERIMENTS

In Section 5.1, we demonstrate the synchronous experimentswith extensive discussions. For the reproducibility, we pro-vide here the specification of learning rate grids. The num-ber of iterations as well as epochs, i.e. the number of passesover the full training sets, are also listed for completeness.For YELLOWFIN in all the experiments in Section 5, weuniformly use sliding window size 20 for extremal curvatureestimation and β = 0.999 for smoothing. For momentumSGD and Adam, we use the following configurations.

• CIFAR10 ResNet

– 40k iterations (∼114 epochs)– Momentum SGD:

learning rates {0.001, 0.01(best), 0.1, 1.0},momentum 0.9

– Adam:learning rates {0.0001, 0.001(best), 0.01, 0.1}

• CIFAR100 ResNet

– 120k iterations (∼341 epochs)– Momentum SGD:

learning rates {0.001, 0.01(best), 0.1, 1.0},momentum 0.9

– Adam:learning rates {0.00001, 0.0001(best), 0.001, 0.01}

• PTB LSTM

– 30k iterations (∼13 epochs)– Momentum SGD:

learning rates {0.01, 0.1, 1.0(best), 10.0},momentum 0.9

– Adam:learning rates {1e-4, 0.001(best), 0.01, 0.1}

• TS LSTM

– ∼21k iterations (50 epochs)– Momentum SGD:

learning rates {0.05, 0.1, 0.5, 1.0(best), 5.0},momentum 0.9

– Adam:learning rates {5e-4, 0.001, 0.005(best), 0.01, 0.05}

– Decrease learning rate by factor 0.97 every epochfor all optimizers, following the design by Karpathyet al. (2015).

• WSJ LSTM

Page 16: YellowFin and the Art of Momentum Tuning - MLSys · 2019. 6. 15. · Accelerated forms of stochastic gradient descent (SGD), pioneered byPolyak(1964) andNesterov(1983), are the de-facto

YELLOWFIN and the Art of Momentum Tuning

network # layers Conv 0 Unit 1s Unit 2s Unit 3s

CIFAR10 ResNet 110[3× 3, 4

] [3× 3, 43× 3, 4

]× 6

[3× 3, 83× 3, 8

]× 6

[3× 3, 163× 3, 16

]× 6

CIFAR100 ResNet 164[3× 3, 4

] 1× 1, 163× 3, 161× 1, 64

× 6

1× 1, 323× 3, 321× 1, 128

× 6

1× 1, 643× 3, 641× 1, 256

× 6

network # layers Word Embed. Layer 1 Layer 2 Layer 3

TS LSTM 2 [65 vocab, 128 dim] 128 hidden units 128 hidden units –

PTB LSTM 2 [10000 vocab, 200 dim] 200 hidden units 200 hidden units –

WSJ LSTM 3 [6922 vocab, 500 dim] 500 hidden units 500 hidden units 500 hidden units

Table 3. Specification of ResNet and LSTM model architectures.

– ∼120k iterations (50 epochs)

– Momentum SGD:learning rates {0.05, 0.1, 0.5(best), 1.0, 5.0},momentum 0.9

– Adam:learning rates {1e-4, 5e-4, 0.001(best), 0.005, 0.01}

– Vanilla SGD:learning rates {0.05, 0.1, 0.5, 1.0(best), 5.0}

– Adagrad:learning rates {0.05, 0.1, 0.5(best), 1.0, 5.0}

– Decrease learning rate by factor 0.9 every epochsafter 14 epochs for all optimizers, following thedesign by Choe & Charniak.

G ADDITIONAL EXPERIMENT RESULTS

G.1 The importance of adaptive momentum

In Section 5.1, we discussed the importance of adaptive mo-mentum by demonstrating the training loss on the TS LSTMand CIFAR100 ResNet models. In Figure 9, we furthervalidate the importance of adaptive momentum by demon-strating the corresponding validation/test performance onthe PSTM LSTM and CIFAR100 ResNet models. Particu-larly in Figure 7 (left and middle), similar to our observationon training loss comparison, we can also see that neitherprescribed momentum 0.0 or 0.9 can match the performanceof YELLOWFIN with adaptive momentum across the twotasks. Furthermore, in Figure 7 (right), hand-tuned VanillaSGD without momentum decreases the validation perplexityin TS LSTM more slowly than momentum based methods.However by dynamically rescaling the Vanilla SGD learningrate based on YellowFin tuned momentum, it demonstratesa validation perplexity decreasing speed matching that ofmomentum based methods.

G.2 Training loss and test accuracy on CIFAR10 andCIFAR100 ResNet

In Figure 10, we demonstrate the training loss on CI-FAR10 ResNet and CIFAR100 ResNet. Specifically, YEL-LOWFIN can match the performance of hand-tuned mo-mentum SGD, and achieves 1.93x and 1.38x speedup com-paring to hand-tuned Adam respectively on CIFAR10 andCIFAR100 ResNet. In Figure 11, we show the test accuracycurves corresponding to the curves in Figure 10. We canobserve that YELLOWFIN can have matching or better train-ing loss at the end of training than hand-tuned momentumSGD, while the test accuracy is worse (e.g. CIFAR100);this phenomenon where better training loss does not guaran-tee better generalization is often observed in deep learningresults.

G.3 Tuning momentum can improve Adam inasynchronous-parallel setting

We conduct experiments on PTB LSTM with 16 asyn-chronous workers using Adam using the same protocol asin Section 5.2. Fixing the learning rate to the value achiev-ing the lowest smoothed loss in Section 5.1, we sweep thesmoothing parameter β1 (Kingma & Ba, 2014) of the first or-der moment estimate in grid {−0.2, 0.0, 0.3, 0.5, 0.7, 0.9}.β1 serves the same role as momentum in SGD and we callit the momentum in Adam. Figure 12 shows tuning momen-tum for Adam under asynchrony gives measurably bettertraining loss. This result emphasizes the importance of mo-mentum tuning in asynchronous settings and suggests thatstate-of-the-art adaptive methods can perform sub-optimallywhen using prescribed momentum.

G.4 Accelerating YELLOWFIN with finer grainlearning rate tuning

As an adaptive tuner, YELLOWFIN does not involve manualtuning. It can present faster development iterations on model

Page 17: YellowFin and the Art of Momentum Tuning - MLSys · 2019. 6. 15. · Accelerated forms of stochastic gradient descent (SGD), pioneered byPolyak(1964) andNesterov(1983), are the de-facto

YELLOWFIN and the Art of Momentum Tuning

0k 5k 10k 15k 20k

Iterations

1.5

1.6

1.7

1.8

1.9

2.0Va

lidat

ion

perp

lexi

tyYellowFinYF mom.=0.0YF mom.=0.9YF rescaling

0k 30k 60k 90k

Iterations

0.1

0.2

0.3

0.4

0.5

0.6

0.7

Test

accu

racy

YellowFinYF mom.=0.0YF mom.=0.9YF rescaling

0k 5k 10k 15k 20k

Iterations

1.5

1.6

1.7

1.8

1.9

2.0

Valid

atio

npe

rple

xity

Momentum SGDVanilla SGDYellowFinYF rescaling

Figure 9. Importance of adaptive momentum: The validation/test performance comparison between YELLOWFIN with adaptive momentumand YELLOWFIN with fixed momentum values; this comparison is conducted on TS LSTM (left) and CIFAR100 ResNet (middle).Prescribed momentum values do not match the performance of YELLOWFIN with adaptive momentum across the two tasks. An adaptivelearning rate for SGD based on YELLOWFIN tuned momentum, can match the performance of momentum based methods on the TSLSTM(right).

0k 10k 20k 30k 40kIterations

10−1

100

Tra

inin

glo

ss

Momentum SGDAdamYellowFin

0k 30k 60k 90k 120kIterations

100

101

Tra

inin

glo

ss

Momentum SGDAdamYellowFin

Figure 10. The best training loss for the 100-layer CIFAR10 ResNet (left) and 164-layer CIFAR100 bottleneck ResNet (right).

architectures than grid search on optimizer hyperparameters.In deep learning practice for computer vision and naturallanguage processing, after fixing the model architecture, ex-tensive optimizer tuning (e.g. grid search or random search)can further improve the performance of a model. A naturalquestion to ask is can we also slightly tune YELLOWFIN toaccelerate convergence and improve the model performance.Specifically, we can manually multiply a positive number,the learning rate factor, to the auto-tuned learning rate inYELLOWFIN to further accelerate.

In this section, we empirically demonstrate the effec-tiveness of learning rate factor on a 29-layer ResNext(2x64d) (Xie et al., 2016) on CIFAR10 and a TiedLSTM model (Press & Wolf, 2016) with 650 dimen-sions for word embedding and two hidden units layerson the PTB dataset. When running YELLOWFIN,we search for the optimal learning rate factor in grid{ 13 , 0.5, 1, 2(best for ResNext), 3(best for Tied LSTM), 10}.Similarly, we search the same learning rate factor grid forAdam, multiplying the factor to its default learning rate0.001. To further strengthen the performance of Adam as abaseline, we also run it on conventional logarithmic learningrate grid {5e−5, 1e−4, 5e−4, 1e−3, 5e−3} for ResNext and{1e−4, 5e−4, 1e−3, 5e−3, 1e−2} for Tied LSTM. We report

the best metric from searching the union of learning ratefactor grid and logarithmic learning rate grid as searchedAdam results. Recently, AMSGrad (AMSG) (Reddi et al.,2018) is proposed as an variant of Adam to correct theconvergence issue on certain convex problems. To provide acomplete comparison, we additionally perform learning ratefactor search with grid {0.1, 13 , 0.5, 1, 2, 3, 10} for AMSG.Empirically, we observe Adam and AMSG have similarconvergence behavior with same leraning rate factors, andlearning factor 1

3 and 1.0 work best for Adam/AMSGrespectively on ResNext and Tied LSTM.

As shown in Figure 13, with the searched best learning ratefactor, YELLOWFIN can improve validation perplexity onTied LSTM from 88.7 to 80.5, an improvement of morethan 9%. Similarly, the searched learning rate factor canimprove test accuracy from 92.63 to 94.75 on ResNext.More importantly, we can observe, with learning rate factorsearch on the two models, YELLOWFIN can achieve bettervalidation metric than the searched Adam and AMSG results.It demonstrates that finer-grain learning rate tuning, i.e. thelearning rate factor search, can be effectively applied onYELLOWFIN to improve the performance of deep learningmodels.

Page 18: YellowFin and the Art of Momentum Tuning - MLSys · 2019. 6. 15. · Accelerated forms of stochastic gradient descent (SGD), pioneered byPolyak(1964) andNesterov(1983), are the de-facto

YELLOWFIN and the Art of Momentum Tuning

0k 10k 20k 30k 40kIterations

0.80

0.82

0.84

0.86

0.88

0.90

Test

accu

racy

Momentum SGDAdamYellowFin

0k 30k 60k 90kIterations

0.50

0.55

0.60

0.65

0.70

Test

accu

racy

Momentum SGDAdamYellowFin

Figure 11. Test accuracy for ResNet on 100-layer CIFAR10 ResNet (left) and 164-layer CIFAR100 bottleneck ResNet. The test accuracycurves corresponds to the training loss curves in Figure 10

0k 5k 10k 15k 20k 25k 30kIterations

3

4

5

6

7

Tra

inin

glo

ss

β1 = −0.2

β1 = 0.0

β1 = 0.3

β1 = 0.5

β1 = 0.7

β1 = 0.9

Figure 12. Hand-tuning Adam’s momentum under asynchrony.

0 5 10 15 20 25 30 35 40

Epochs

70

90

110

Valid

atio

npe

rple

xity

YellowFinAdam defaultAMSG defaultYF searchedAdam searchedAMSG searched

0 50 100 150 200

Epochs

80

85

90

95

Valid

atio

nac

cura

cy

Figure 13. Validation perplexity on Tied LSTM and validation accuracy on ResNext. Learning rate fine-tuning using grid-searched factorcan further improve the performance of YELLOWFIN in Algorithm 1. YELLOWFIN with learning factor search can outperform hand-tunedAdam on validation metrics on both models.