Skip to content

Momentum and Nesterov acceleration

How momentum retains gradient history, how buffer conventions change learning-rate scaling, and how Nesterov evaluates a lookahead gradient.

Momentum is an optimisation method that carries information from earlier gradients into the next parameter update. It extends gradient descent: a parameter moves according to accumulated gradient history rather than the current gradient alone. For a quant fitting a volatility forecaster, this changes the training path and makes the saved optimiser state part of a reproducible experiment. It is separate from a trading strategy that buys recent market winners.

What the buffer remembers

Let θt−1\theta_{t-1} be the parameter vector before update tt, and let gtg_t be the gradient of the training loss function at that point, possibly estimated from a mini-batch. One classical momentum convention is
vt=βvt−1+gt,θt=θt−1−ηvt,v_t=\beta v_{t-1}+g_t, \qquad \theta_t=\theta_{t-1}-\eta v_t,
where v0=0v_0=0, 0≤β<10\leq\beta<1 and η>0\eta>0. Here vtv_t is a gradient buffer, with the learning rate applied outside it. This is the undampened momentum form documented by PyTorch SGD, with weight decay and Nesterov disabled.

Expanding the recurrence shows precisely what “memory” means:

vt=gt+βgt−1+β2gt−2+⋯+βt−1g1.v_t=g_t+\beta g_{t-1}+\beta^2g_{t-2}+\cdots+\beta^{t-1}g_1.

Gradients pointing in a similar direction reinforce one another. Opposing contributions partly cancel. The buffer does not know whether a direction is economically useful; it remembers gradients of the chosen training objective.

Take an illustrative scalar parameter with θ0=1\theta_0=1, β=0.9\beta=0.9, η=0.1\eta=0.1, and two stipulated gradient observations, g1=g2=2g_1=g_2=2.

UpdateBuffer calculationParameter after update
1v1=2v_1=2θ1=1−0.1(2)=0.8\theta_1=1-0.1(2)=0.8
2v2=0.9(2)+2=3.8v_2=0.9(2)+2=3.8θ2=0.8−0.1(3.8)=0.42\theta_2=0.8-0.1(3.8)=0.42

The second move has magnitude 0.380.38, even though the fresh gradient is unchanged. These are stipulated gradients, not a claim that every loss produces that sequence. If the next gradient were zero, the buffer would still be v3=3.42v_3=3.42, moving the parameter to 0.0780.078. A zero current gradient does not immediately stop an optimiser with nonzero memory.

Illustrative scalar momentum updates. Gradients 2 and 2 produce buffers 2 and 3.8 and parameters 0.8 and 0.42. A hypothetical third gradient of zero retains a buffer of 3.42 and moves the parameter to 0.078.
Illustrative scalar momentum updates. Gradients 2 and 2 produce buffers 2 and 3.8 and parameters 0.8 and 0.42. A hypothetical third gradient of zero retains a buffer of 3.42 and moves the parameter to 0.078.
Carried gradient history and the new observation contribute separately to each buffer. The third step illustrates retained motion after the current gradient becomes zero.

A learning rate needs its convention

Another convention uses an exponential moving average:

mt=βmt−1+(1−β)gt.m_t=\beta m_{t-1}+(1-\beta)g_t.

With both buffers initially zero and the same constant β\beta, algebra gives mt=(1−β)vtm_t=(1-\beta)v_t. To reproduce the preceding parameter updates using θt=θt−1−ηEMAmt\theta_t=\theta_{t-1}-\eta_{\mathrm{EMA}}m_t, set

ηEMA=η1−β.\eta_{\mathrm{EMA}}=\frac{\eta}{1-\beta}.

Thus the example's raw-buffer learning rate of 0.10.1 corresponds to an EMA-buffer learning rate of 11. Copying the same numerical learning rate between these formulas changes the algorithm's step sizes.

There is another distinction: some implementations store the signed parameter displacement, dt=βdt−1−ηgtd_t=\beta d_{t-1}-\eta g_t, then add it to the parameter. With a constant learning rate, dt=−ηvtd_t=-\eta v_t translates between these two forms. If the learning rate changes, old gradients in the displacement state retain their earlier learning-rate scaling; the raw-buffer form scales the whole current buffer by the new learning rate. PyTorch's implementation note explicitly distinguishes these conventions. Record the update rule, schedule and state initialisation when comparing implementations.

Nesterov moves the point where you ask for a gradient

In the signed-displacement notation, a lookahead form of Nesterov accelerated gradient is
yt=θt−1+βdt−1,dt=βdt−1−η∇L(yt),θt=θt−1+dt.\begin{aligned} y_t&=\theta_{t-1}+\beta d_{t-1},\\ d_t&=\beta d_{t-1}-\eta\nabla L(y_t),\\ \theta_t&=\theta_{t-1}+d_t. \end{aligned}
Classical momentum evaluates the gradient at θt−1\theta_{t-1}; Nesterov evaluates it at the projected point yty_t. The lookahead lets the gradient correction respond to where the retained motion is taking the parameter. This is the formulation in Sutskever and co-authors, Section 2; framework parameterisations must be checked before equating their stored states.

A separate toy loss makes the difference visible. For L(θ)=θ2/2L(\theta)=\theta^2/2, start at 11 with zero displacement, learning rate 0.10.1 and momentum 0.90.9. Both methods first reach 0.90.9, with displacement −0.1-0.1. On update two, classical momentum reads the gradient 0.90.9 and reaches 0.720.72. Nesterov reads the gradient at 0.9+0.9(−0.1)=0.810.9+0.9(-0.1)=0.81 and reaches 0.7290.729. The methods already differ after two updates; this short example is not a performance ranking.

Faster fitting is a claim to test

Polyak's original two-step analysis explains the appeal of inertia in poorly conditioned problems, while also noting that the objective need not decrease on every iteration. Its nonlinear convergence results are local, under stated assumptions. See Polyak, Sections 1–2. Those results do not guarantee acceleration for an arbitrary nonconvex market model or convergence to its global optimum.
For a financial prediction experiment, tune learning rate and momentum together, preserve chronological validation, and compare validation performance as well as training loss. More rapid loss reduction alone does not establish a better trading signal or a particular explanation about the shape of the fitted minimum. The loss-curve diagnosis lesson develops experiment logging and model-selection discipline; its preview is public and the full lesson requires membership. Adam adds adaptive coordinate scaling to gradient memory, so it is a further method rather than another name for classical momentum.

Sources

Last updated
  • machine learning
  • optimisation
  • momentum
  • nesterov
  • gradient descent
← Back to the glossaryBack to top ↑