Momentum

Dive into Deep Learning · §9.4

Momentum and Nesterov Accelerated Gradient
velocity recursion · effective step size · memory timescale · critical damping & √κ acceleration · Nesterov look-ahead

Why Memoryless Gradient Descent Struggles on Valleys

Motivation

  • Memoryless O(\kappa) bottleneck: On f(\mathbf{x}) = 0.1x_1^2 + 2x_2^2 (\kappa = 20), plain GD takes 47 steps to 1\% error (139 steps to 10^{-6}) because it ignores temporal gradient alignment:
    • Along the flat floor (x_1): Gradients point persistently in the same direction.
    • Across the steep walls (x_2): Gradients alternate in sign on every step.
  • Polyak’s heavy-ball idea (1964): Accumulate an exponentially decaying velocity sum so floor gradients reinforce and wall oscillations cancel.

Heavy-Ball Momentum: The Velocity Recursion

Update Equations

  • Velocity update (\beta \in [0, 1), \mathbf{v}_0 = \mathbf{0}): \mathbf{v}_t = \beta\,\mathbf{v}_{t-1} + \mathbf{g}_t, \qquad \mathbf{x}_{t+1} = \mathbf{x}_t - \eta\,\mathbf{v}_t
  • Unrolled geometric history: \mathbf{v}_t = \sum_{k=0}^{t-1} \beta^k \mathbf{g}_{t-k}
  • Physical analogy: A heavy ball rolling down f(\mathbf{x}) with inertia \beta and viscous friction 1 - \beta over memory window \tau = \frac{1}{1-\beta}.

Momentum Stabilizes a Divergent Learning Rate (η = 0.6)

Valley Trajectory

  • At \eta = 0.6 > 2/\lambda_2 = 0.5, plain gradient descent diverges violently across the steep wall because x_2 multiplies by 1 - 4(0.6) = -1.4 on every step (1.4^{20} \approx 837).
  • Adding heavy-ball momentum with \beta = 0.5 at the exact same \eta = 0.6 damps the transverse wall oscillation and drives both coordinates within 1\% of the origin in 20 steps.
  • Apparent paradox: Summing past gradients increases total step length along the valley floor—how does it stabilize the steep wall at the same time?
step 20, x1: 0.007188, x2: 0.002553

Persistent Amplification vs. Alternating Cancellation

The Effective Step Size

  • Persistent floor mode (\mathbf{g}_{t-k} \approx \mathbf{g}): Geometric sum \sum_{k \ge 0}\beta^k = \frac{1}{1-\beta} yields effective step \eta_{\text{eff}} = \frac{\eta}{1-\beta} (1.2 at \eta=0.6, \beta=0.5).
  • Alternating wall mode (\mathbf{g}_{t-k} \approx (-1)^k\mathbf{g}): Alternating sum \sum_{k \ge 0}(-\beta)^k = \frac{1}{1+\beta} damps step to \eta_{\text{alt}} = \frac{\eta}{1+\beta} (0.4 < 0.5, stable).
  • Expanded stability ceiling: \eta\lambda_{\max} < 2(1+\beta), unlocking \frac{1+\beta}{1-\beta} times larger floor steps than plain GD.

How Momentum Expands the Stability Ceiling

Stability & Maximum Speedup

Because a sign-flipping mode x_t \propto (-1)^t experiences the damped step size \frac{\eta}{1+\beta}, the stability threshold \frac{\eta}{1+\beta}\lambda < 2 rises by a factor of 1 + \beta:

Optimizer Sign-Flipping Step Size Stability Ceiling for Curvature \lambda Ceiling on Valley (\lambda_{\max} = 4) Maximum Stable Floor Step \eta_{\text{eff}}
Plain Gradient Descent (\beta = 0) \eta \eta\lambda < 2 \eta < 0.50 0.50
Heavy-Ball Momentum (\beta) \frac{\eta}{1 + \beta} \eta\lambda < 2(1 + \beta) \eta < 0.75 (at \beta = 0.5) \frac{2(1+\beta)}{(1-\beta)\lambda_{\max}} = 1.50 (at \beta = 0.5)
  • At \beta = 0.5, momentum can take an effective step along the valley floor up to \frac{1+\beta}{1-\beta} = 3\times larger than the maximum stable step of plain gradient descent.

The Memory Timescale and Half-Life of β

Exponential Horizon

  • Because the geometric weights 1, \beta, \beta^2, \ldots sum to \frac{1}{1-\beta}, the velocity averages gradients over a characteristic memory window: \tau = \frac{1}{1 - \beta} \text{ steps}
  • Half-life: A gradient’s weight \beta^k drops to 0.5 after k_{1/2} = \frac{\ln 0.5}{\ln\beta} \approx 0.693\,\tau steps, and the first \tau steps always capture 1 - \beta^{1/(1-\beta)} \approx 1 - e^{-1} \approx 63\text{--}75\% of the total weight.
  • Shifting \beta from 0.9 \to 0.99 expands both \tau and \eta_{\text{eff}} tenfold (10 \to 100 steps).
beta   window   half-life   weight inside the window
 0.5        2         1.0                       0.75
 0.9       10         6.6                       0.65
0.99      100        69.0                       0.63

Momentum Under Minibatch Noise: Same Noise Floor

Interaction with Stochastic Noise

  • Integrated impulse of a single noise kick \boldsymbol{\xi}_t: Persists in \mathbf{v}_{t+k} with weight \beta^k, contributing total cumulative displacement: -\eta\,(1 + \beta + \beta^2 + \cdots)\,\boldsymbol{\xi}_t = -\frac{\eta}{1 - \beta}\,\boldsymbol{\xi}_t = -\eta_{\text{eff}}\,\boldsymbol{\xi}_t
  • No free noise-ball reduction at matched \eta_{\text{eff}}: Momentum spreads each noise kick across \tau = \frac{1}{1-\beta} steps, settling into the same stationary variance as plain SGD at step size \eta_{\text{eff}}.
  • Tuning rule: When enabling \beta = 0.9 in a noise-limited run, scale \eta down by 1 - \beta = 0.1.

Optimal Quadratic Acceleration: From O(κ) to O(√κ)

Polyak’s Acceleration Law

  • Polyak’s optimal tuning (1964): \eta^\star = \frac{4}{\left(\sqrt{\lambda_{\max}} + \sqrt{\lambda_{\min}}\right)^2}, \qquad \beta^\star = \left(\frac{\sqrt{\kappa} - 1}{\sqrt{\kappa} + 1}\right)^2
  • From O(\kappa) to O(\sqrt{\kappa}) steps: Contraction improves from \frac{\kappa-1}{\kappa+1} \approx 1 - \frac{2}{\kappa} (plain GD) to \sqrt{\beta^\star} = \frac{\sqrt{\kappa}-1}{\sqrt{\kappa}+1} \approx 1 - \frac{2}{\sqrt{\kappa}} (37\times fewer steps at \kappa = 1{,}400).
  • Why \sqrt{\beta}? For \beta \ge \beta_{\text{c}}(\lambda) = (1-\sqrt{\eta\lambda})^2, characteristic roots z_1, z_2 are complex conjugates with z_1 z_2 = \beta \implies |z| = \sqrt{\beta}.

Second-Order Recurrence and the √β Complex-Root Law

Why Contraction Equals √β

Why do all intermediate eigenmodes contract at the exact same rate \sqrt{\beta^\star} independent of their curvature \lambda?

  • Along an eigenvector of curvature \lambda (g_t = \lambda x_t), substituting \eta v_{t-1} = x_{t-1} - x_t into x_{t+1} = x_t - \eta(\beta v_{t-1} + \lambda x_t) yields a second-order linear recurrence: x_{t+1} - (1 + \beta - \eta\lambda)\,x_t + \beta\,x_{t-1} = 0
  • Characteristic polynomial: Trying x_t = z^t gives z^2 - (1 + \beta - \eta\lambda)z + \beta = 0, whose two roots satisfy Vieta’s product formula z_1 z_2 = \beta.
  • The complex-conjugate regime: Whenever the discriminant \Delta = (1 + \beta - \eta\lambda)^2 - 4\beta \le 0 (which holds for all \beta \ge \beta_{\text{c}}(\lambda) = (1 - \sqrt{\eta\lambda})^2), the roots z_1, z_2 = z_1^* are complex conjugates with identical modulus: |z_1| = |z_2| = \sqrt{z_1 z_2} = \sqrt{\beta}

Overdamped, Critically Damped, and Underdamped Modes

Critical Damping Geometry

  • Three damping regimes for a mode of curvature \lambda:
    • Overdamped (\beta < \beta_{\text{c}}): Two distinct real roots; the larger root creeps slowly toward zero without oscillating.
    • Critically damped (\beta = \beta_{\text{c}} = (1 - \sqrt{\eta\lambda})^2): Roots collide at z_1 = z_2 = \sqrt{\beta_{\text{c}}}, giving the fastest possible contraction for that mode.
    • Underdamped (\beta > \beta_{\text{c}}): Complex roots oscillate and decay at envelope rate \sqrt{\beta}.
  • Polyak’s optimal tuning (\eta^\star, \beta^\star) equates the critical thresholds of \lambda_{\min} and \lambda_{\max}: (1 - \sqrt{\eta^\star\lambda_{\min}})^2 = (\sqrt{\eta^\star\lambda_{\max}} - 1)^2 = \beta^\star.

Quantitative Verification on the κ = 20 Valley

40 Steps vs. 139 Steps

  • On our valley (\lambda_1 = 0.2, \lambda_2 = 4.0, \kappa = 20):
    • Optimal tuning gives \eta^\star \approx 0.668 and \beta^\star \approx 0.403.
    • The per-step contraction factor drops from 0.905 (plain GD) to \sqrt{\beta^\star} \approx 0.635.
    • Steps to reach 10^{-6} relative error fall 3.5\times from 139 steps to 40 steps.
  eta   beta   factor   steps to 1%   steps to 1e-6
0.476  0.000    0.905            47             139
0.600  0.500    0.707            16              42
0.668  0.403    0.635            18              40
0.300  0.800    0.894            42             126

Underdamped Ringing When β Exceeds Critical Damping

Overshoot Hazard

  • What happens if we set \beta = 0.8 at \eta = 0.3—well above the critical damping thresholds of both coordinates (\beta_{\text{c}}(\lambda_1) = 0.57, \beta_{\text{c}}(\lambda_2) = 0.01)?
  • Both coordinates lie deep in the underdamped complex-root regime with modulus \sqrt{0.8} \approx 0.894 (barely faster than plain GD’s 0.905).
  • Because the velocity remembers \tau = \frac{1}{1-0.8} = 5 steps of downhill push, the iterate overshoots the origin and rings back and forth along both axes.

step 20, x1: 0.195696, x2: -0.249649

Two Regimes on Real Data: Curvature vs. Noise

Empirical Test on Fashion-MNIST

Our theory predicts two contrasting outcomes when comparing \beta = 0 and \beta = 0.9 on Fashion-MNIST:

  • 1. Curvature-limited (full-batch softmax regression, b = 60{,}000): Exact gradients, ill-conditioned pixel covariance. Adding \beta = 0.9 raises the optimal effective step 32\times (\eta_{\text{eff}}: 0.125 \to 4.0) and cuts steps to loss 0.5 by 6.25\times (625 \to 100 steps).
  • 2. Noise-limited (FashionCNN, small batch b = 32): Optimal \eta drops by \sim 10\times (0.2 \to 0.02) to preserve \eta_{\text{eff}} = \frac{\eta}{1-\beta}, finishing at comparable step counts and losses.
softmax regression  beta=0.0  best lr 0.125  steps to 0.5: 625  final loss 0.472
softmax regression  beta=0.9  best lr 0.4    steps to 0.5: 100  final loss 0.365
FashionCNN          beta=0.0  best lr 0.2    steps to 0.3: 1550  final loss 0.293
FashionCNN          beta=0.9  best lr 0.02   steps to 0.3: 1425  final loss 0.280

Nesterov Accelerated Gradient: Look-Ahead Correction

Anticipatory Damping

  • Why did underdamped heavy-ball momentum overshoot? Because it evaluated \nabla f(\mathbf{x}_t) at the current position rather than where the momentum step -\eta\beta\mathbf{v}_{t-1} was about to carry it.
  • Nesterov momentum (1983) evaluates the gradient at the look-ahead point \tilde{\mathbf{x}}_t = \mathbf{x}_t - \eta\beta\,\mathbf{v}_{t-1}: \mathbf{v}_t = \beta\,\mathbf{v}_{t-1} + \nabla f(\mathbf{x}_t - \eta\beta\,\mathbf{v}_{t-1})
  • Look-ahead curvature evaluation brakes the velocity before the overshoot occurs and, with the schedule \beta_t = (t-1)/(t+2), achieves the optimal O(1/t^2) rate on general smooth convex functions.

Nesterov Look-Ahead Suppresses Underdamped Ringing

Heavy-Ball vs. Nesterov

  • Running Nesterov momentum at the exact same underdamped hyperparameters (\eta = 0.3, \beta = 0.8) on the valley demonstrates immediate anticipatory damping:
    • Steep wall oscillation along x_2 decays below |x_2| < 10^{-4} within 20 steps (versus -0.25 under heavy-ball).
    • Longitudinal overshoot along x_1 is reduced by nearly half.
  • In practice, \beta = 0.9 (with heavy-ball or Nesterov look-ahead) is a standard default, tuned via \eta_{\text{eff}} = \frac{\eta}{1-\beta}.

step 20, x1: 0.217791, x2: -0.000070

Concept Check: Effective Step, Timescales, and √κ

Check Your Understanding

Work out the quantitative answer for each momentum scenario:

  1. Adjusting \eta when changing \beta: A minibatch SGD run trains well at \eta = 0.02 with \beta = 0.9. If you increase momentum to \beta = 0.98, what learning rate \eta preserves the effective step size \eta_{\text{eff}} and stationary noise ball, and how does the memory window \tau change?
  2. \sqrt{\kappa} acceleration: For a quadratic with condition number \kappa = 10{,}000, what is the optimal momentum \beta^\star, and by what factor does optimal momentum reduce the steps needed to shrink error by 10^{-2} compared to optimal plain gradient descent?
  3. Batch size transition: Why did adding \beta = 0.9 cut the step count by 6\times on full-batch softmax regression (b = 60{,}000) but not on FashionCNN at b = 32?

Concept Check: Effective Step, Timescales, and √κ (answers)

Check Your Understanding

Answers:

  1. At \beta = 0.9, \eta_{\text{eff}} = \frac{0.02}{1 - 0.9} = 0.2 and \tau = 10 steps. At \beta = 0.98 (1 - \beta = 0.02), keeping \eta_{\text{eff}} = 0.2 requires \eta = 0.2 \times 0.02 = 0.004 (5\times smaller), while the memory window expands 5\times from 10 \to 50 steps.
  2. Since \sqrt{\kappa} = 100, \beta^\star = (99/101)^2 \approx 0.9608, reducing the required step count by \frac{\kappa}{\sqrt{\kappa}} = \sqrt{\kappa} = 100\times (\approx 230 steps vs. 23{,}000 steps).
  3. At b = 32, training is noise-limited (b \ll b_{\text{crit}}), so \eta_{\text{eff}} is capped by the noise ball; at full batch (b = 60{,}000), gradient noise is zero and training is curvature-limited, unlocking momentum’s 32\times larger \eta_{\text{eff}}.

Summary: Heavy-Ball and Nesterov Momentum

Key Takeaways

Concept / Rule Mathematical Expression Key Property Practical Guideline
Heavy-Ball Velocity \mathbf{v}_t = \beta\mathbf{v}_{t-1} + \mathbf{g}_t,\; \mathbf{x}_{t+1} = \mathbf{x}_t - \eta\mathbf{v}_t Unrolls to \sum_{k=0}^{t-1} \beta^k \mathbf{g}_{t-k} Default \beta = 0.9; adds 1 state buffer per parameter
Effective Step & Window \eta_{\text{eff}} = \frac{\eta}{1-\beta},\quad \tau = \frac{1}{1-\beta} Damps alternating steps to \frac{\eta}{1+\beta}; ceiling \eta\lambda < 2(1+\beta) Scale \eta \propto (1-\beta) when changing \beta under noise
Critical Damping & \sqrt{\kappa} \beta_{\text{c}}(\lambda) = (1 - \sqrt{\eta\lambda})^2,\; \rho^\star = \frac{\sqrt{\kappa}-1}{\sqrt{\kappa}+1} Complex roots for \beta \ge \beta_{\text{c}} have modulus |z| = \sqrt{\beta} Cuts curvature-limited step complexity from O(\kappa) to O(\sqrt{\kappa})
Nesterov Look-Ahead \mathbf{v}_t = \beta\mathbf{v}_{t-1} + \nabla f(\mathbf{x}_t - \eta\beta\mathbf{v}_{t-1}) Evaluates curvature at predicted position \tilde{\mathbf{x}}_t Suppresses underdamped ringing; forms the base of Muon (§9.6)