Gradient Descent and Curvature

Dive into Deep Learning · §35.1

Gradient Descent and Curvature
steepest descent · L-smoothness · descent lemma · condition number · heavy-ball & Nesterov momentum

One Downhill Direction, Three Step Lengths

Motivation

On f(x, y) = \tfrac12(x^2 + 10y^2) from \mathbf{x}_0 = (2, 1) (f = 7, \nabla f = (2, 10)), -\nabla f fixes the direction while \eta sets the step length:

  • Too timid (\eta = 0.01): Moves to (1.98, 0.90) with f = 6.01—safe but painfully slow.
  • Just right (\eta = 0.10 = 1/L): Eliminates the steep y-mode in one step (f = 1.62), while the flat x-mode creeps at 0.9\times per step.
  • Too aggressive (\eta = 0.25 > 2/L): Overshoots the steep wall to (1.50, -1.50) (f = 12.38) and diverges.

First-Order Taylor Model and Descent Directions

Steepest Descent

Expanding f around \mathbf{x} along a unit vector \|\mathbf{d}\| = 1 for small \eta > 0:

f(\mathbf{x} + \eta\,\mathbf{d}) = f(\mathbf{x}) + \eta\,\nabla f(\mathbf{x})^\top \mathbf{d} + o(\eta)

  • Descent half-space: Any direction with \nabla f(\mathbf{x})^\top \mathbf{d} < 0 lowers f for sufficiently small \eta > 0.
  • Cauchy–Schwarz optimality: \nabla f(\mathbf{x})^\top \mathbf{d} \ge -\|\nabla f(\mathbf{x})\|, attained uniquely by \mathbf{d}^\star = -\nabla f(\mathbf{x}) / \|\nabla f(\mathbf{x})\|.

Comparing Directional Slopes Over Finite Steps

Steepest Descent

On f(x, y) = \tfrac12(x^2 + 10y^2) at (2, 1), the normalized negative gradient is (-0.196, -0.981) with directional slope -\|\nabla f\| = -10.198. Over a short step \eta = 0.01, actual loss changes track \eta \nabla f^\top \mathbf{d} within 1\%:

steepest -grad/|grad|:  slope = -10.1980,  f(x + eta d) - f(x) = -0.101498
diagonal -(1,1)/sqrt(2):  slope =  -8.4853,  f(x + eta d) - f(x) = -0.084578
axis     (-1,0):  slope =  -2.0000,  f(x + eta d) - f(x) = -0.019950
uphill   +(1,1)/sqrt(2):  slope =  +8.4853,  f(x + eta d) - f(x) = +0.085128

Differentiability alone guarantees descent only for infinitesimally small steps. To certify a finite step size \eta > 0, we must bound how rapidly the gradient itself can change along the step.

L-Smoothness and the Global Quadratic Ceiling

Smoothness

A differentiable function f is L-smooth if its gradient is L-Lipschitz (\|\nabla f(\mathbf{x}) - \nabla f(\mathbf{y})\| \le L\|\mathbf{x} - \mathbf{y}\|):

f(\mathbf{y}) \le f(\mathbf{x}) + \nabla f(\mathbf{x})^\top(\mathbf{y} - \mathbf{x}) + \tfrac{L}{2}\|\mathbf{y} - \mathbf{x}\|^2

  • Hessian test: For C^2 functions, L-smoothness holds iff all eigenvalues of \nabla^2 f(\mathbf{x}) lie in [-L, L].
  • Geometric guarantee: The graph of f never rises above its tangent plane by more than the isotropic parabola \tfrac{L}{2}\|\mathbf{y} - \mathbf{x}\|^2.

The Descent Lemma and the 2/L Step Ceiling

Smoothness

Substituting the gradient descent update \mathbf{x}_{k+1} = \mathbf{x}_k - \eta\,\mathbf{g}_k (where \mathbf{g}_k = \nabla f(\mathbf{x}_k)) into the quadratic ceiling yields the descent lemma:

f(\mathbf{x}_{k+1}) \le f(\mathbf{x}_k) - \eta\,\|\mathbf{g}_k\|^2 + \tfrac{L}{2}\eta^2\|\mathbf{g}_k\|^2 = f(\mathbf{x}_k) - \eta\left(1 - \tfrac{L\eta}{2}\right)\|\mathbf{g}_k\|^2

  • Linear gain vs. curvature penalty: The first-order drop -\eta\|\mathbf{g}_k\|^2 dominates for small \eta, while the worst-case curvature penalty +\tfrac{L}{2}\eta^2\|\mathbf{g}_k\|^2 grows quadratically in \eta.
  • Strict descent window: The factor \eta(1 - L\eta/2) is strictly positive if and only if 0 < \eta < 2/L. At \eta = 2/L, the linear gain and curvature penalty cancel completely.
  • Optimal worst-case step: Minimizing the quadratic ceiling selects \eta = 1/L, certifying a per-step decrease of at least f(\mathbf{x}_{k+1}) \le f(\mathbf{x}_k) - \tfrac{1}{2L}\|\mathbf{g}_k\|^2.

Visualizing the Quadratic Ceiling Along a Step

Smoothness

On f(x,y) = \tfrac12(x^2 + 10y^2) from (2, 1), we have L = 10 and \|\mathbf{g}_0\|^2 = 104:

eta = 0.01:  bound  6.0120,  actual  6.0102
eta = 0.10:  bound  1.8000,  actual  1.6200
eta = 0.25:  bound 13.5000,  actual 12.3750
  • At \eta = 1/L = 0.1, the ceiling guarantees f \le 1.8 and the step achieves 1.62.
  • Beyond 2/L = 0.2, the ceiling exceeds f(\mathbf{x}_0) = 7 and at \eta = 0.25 the actual loss climbs to 12.375.
image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/

Finding Stationary Points Without Convexity

Nonconvex Guarantees

Even on nonconvex landscapes, the descent lemma alone prevents the gradient norm from staying large indefinitely when f is bounded below by f_{\mathrm{low}}:

  • Telescoping the per-step drops: At \eta = 1/L, rearrange the descent lemma as \|\mathbf{g}_k\|^2 \le 2L\big(f(\mathbf{x}_k) - f(\mathbf{x}_{k+1})\big) and sum over k = 0, \ldots, K-1: \sum_{k=0}^{K-1} \|\nabla f(\mathbf{x}_k)\|^2 \le 2L\big(f(\mathbf{x}_0) - f(\mathbf{x}_K)\big) \le 2L\big(f(\mathbf{x}_0) - f_{\mathrm{low}}\big)
  • Sublinear stationarity rate: Because the minimum over K steps is at most the average, \min_{0 \le k < K} \|\nabla f(\mathbf{x}_k)\|^2 \le \frac{2L\big(f(\mathbf{x}_0) - f_{\mathrm{low}}\big)}{K}

Among the first K iterates, at least one has gradient norm \|\nabla f(\mathbf{x}_k)\| = O(1/\sqrt{K}), requiring only L-smoothness and a lower bound on the objective.

Why Stationarity Does Not Guarantee a Minimum

Nonconvex Pitfalls

Without convexity, \nabla f(\mathbf{x}) = \mathbf{0} cannot distinguish a minimum from a saddle point:

  • Saddle trap: f(x, y) = \tfrac12 x^2 + \cos y is bounded below by -1 and is globally 1-smooth (\nabla^2 f = \mathrm{diag}(1, -\cos y)).
  • One-step halt: From (1, 0) with \eta = 1/L = 1, gradient descent steps directly to (0, 0) where \nabla f(0, 0) = \mathbf{0}.
  • Suboptimal plateau: GD freezes permanently at the saddle f(0, 0) = +1, two units above the global minimum f(0, \pi) = -1.
  • A measure-zero accident: Only starts on the line y = 0 end here; from any small y_0 \neq 0, GD escapes to a minimum.

Backtracking Line Search and the Armijo Rule

Adaptive Step Sizes

When L is unknown or varies locally (e.g., f(x) = \tfrac14 x^4), backtracking line search halves a trial step \eta \leftarrow \eta/2 until the Armijo condition holds (c \in (0, 1)):

f\big(\mathbf{x}_k - \eta\,\nabla f(\mathbf{x}_k)\big) \le f(\mathbf{x}_k) - c\,\eta\,\|\nabla f(\mathbf{x}_k)\|^2

  • Sufficient decrease: Accepts \eta as soon as actual loss reduction reaches fraction c of the linear Taylor drop.
  • Automatic termination: Guaranteed to pass once \eta \le 2(1-c)/L_{\mathrm{loc}}, returning \eta \ge \min(\eta_0, (1-c)/L_{\mathrm{loc}}) without knowing L_{\mathrm{loc}}.

Backtracking vs. Fixed Step on a Quartic Bowl

Adaptive Step Sizes

On f(x) = \tfrac14 x^4 from x_0 = 3 with c = \tfrac12, the update x \mapsto x(1 - \eta x^2) contracts |x| if and only if \eta x_0^2 < 2 (\eta < 2/9 \approx 0.22), whereas local curvature at x_0 = 3 is f''(3) = 27:

fixed eta = 0.3 from x0 = 3:  |x_6| = 6.52e+103  (diverged)
accepted steps: [0.03125 0.0625  0.125   0.25    0.5     1.      1.      1.     ] ...
backtracking from x0 = 3:  f(x_25) = 1.09e-04  (monotone descent)

A fixed step \eta = 0.3 (safe near the origin) explodes to 6.5 \times 10^{103} in 6 steps from x_0 = 3. Backtracking starts at \eta = 0.031 < 1/27 and automatically doubles \eta as the iterate enters flatter regions near zero.

The Quadratic Model and the Condition Number

Quadratic Geometry

Near any strict local minimizer \mathbf{x}^\star with positive-definite Hessian \mathbf{A} = \nabla^2 f(\mathbf{x}^\star) \succ \mathbf{0}, shifting \mathbf{x}^\star to the origin yields the canonical quadratic model:

f(\mathbf{x}) = \tfrac12\,\mathbf{x}^\top \mathbf{A}\,\mathbf{x}

  • Spectrum: 0 < \lambda_{\min} = \lambda_1 \le \cdots \le \lambda_d = \lambda_{\max} = L.
  • Condition number: \kappa = \lambda_{\max} / \lambda_{\min} \ge 1 measures the ratio of steepest to flattest curvature (\kappa = 10 on our gentle bowl, \kappa = 1000 on the chapter benchmark).
image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/

Spectral Decoupling into Scalar Recursions

Quadratic Geometry

Because \nabla f(\mathbf{x}) = \mathbf{A}\mathbf{x}, gradient descent applies the linear operator \mathbf{x}_{k+1} = (\mathbf{I} - \eta\mathbf{A})\mathbf{x}_k. Expanding \mathbf{x}_k in the orthonormal eigenbasis of \mathbf{A} with coordinates u_i^{(k)} decouples the d variables completely:

u_i^{(k+1)} = (1 - \eta\lambda_i)\,u_i^{(k)} \implies u_i^{(k)} = (1 - \eta\lambda_i)^k\,u_i^{(0)}

  • Exact stability ceiling: Every mode contracts if and only if |1 - \eta\lambda_i| < 1 for all i, which requires 0 < \eta < 2/\lambda_{\max} = 2/L. Thus the descent lemma’s sufficient threshold 2/L is also strictly necessary on quadratics.
  • Spectral radius governs speed: The worst-case error norm decays as \rho(\eta)^k, where \rho(\eta) = \max_i |1 - \eta\lambda_i| = \max\big(|1 - \eta\lambda_{\min}|,\, |1 - \eta\lambda_{\max}|\big) is determined by the two extreme eigenvalues.

Sweeping Step Sizes Across the Stability Limit

Quadratic Geometry

On \mathbf{A} = \mathrm{diag}(1, 10) from \mathbf{x}_0 = (1, 1), the stability ceiling is 2/\lambda_{\max} = 0.20:

 eta    |1-eta*1|  |1-eta*10|  spectral radius   |x_60|
0.020     0.980      0.800         0.980       3.0e-01
0.100     0.900      0.000         0.900       1.8e-03
0.182     0.818      0.818         0.818       8.3e-06
0.190     0.810      0.900         0.900       1.8e-03
0.200     0.800      1.000         1.000       1.0e+00
0.210     0.790      1.100         1.100       3.0e+02
  • At \eta = 0.10 = 1/L, the stiff mode vanishes in 1 step (1 - 10\eta = 0), but the slow mode crawls at 1 - \eta = 0.90.
  • At \eta = 2/11 \approx 0.182, both modes contract by 9/11 \approx 0.818 (+9/11 and -9/11), cutting the 60-step error by two orders of magnitude.

The Optimal Fixed Step Balances Extreme Modes

Quadratic Geometry

Because \lambda \mapsto |1 - \eta\lambda| is V-shaped on [\lambda_{\min}, \lambda_{\max}], \rho(\eta) is minimized by equalizing the contraction magnitudes at the two endpoints:

1 - \eta^\star\lambda_{\min} = \eta^\star\lambda_{\max} - 1 \implies \eta^\star = \frac{2}{\lambda_{\min} + \lambda_{\max}}

  • Optimal contraction rate: \rho(\eta^\star) = \frac{\kappa - 1}{\kappa + 1} \approx 1 - \frac{2}{\kappa}
  • Linear iteration complexity: Reaching \|\mathbf{x}_k\| \le \epsilon\|\mathbf{x}_0\| takes k \approx \frac{\kappa}{2}\log\frac{1}{\epsilon} steps (69 at \kappa=10, 6{,}908 at \kappa=1000).
image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/

Neural Network Training at the Edge of Stability

Deep Learning Dynamics

  • Progressive sharpening: During full-batch GD on deep networks, top Hessian sharpness \lambda_{\max}(\nabla^2 f(\mathbf{x}_k)) rises until it hits the stability limit 2/\eta and hovers there.
  • Why loss spikes occur: Once \lambda_{\max} > 2/\eta, the top mode multiplier 1 - \eta\lambda_{\max} < -1 oscillates with growing amplitude.
  • Self-stabilization beyond quadratics: Third-order Taylor terms couple the oscillation to changing curvature, steering the iterate toward flatter regions where \lambda_{\max} \approx 2/\eta.

How Convexity Upgrades Convergence Guarantees

Rate Hierarchy

Adding structural assumptions on f upgrades gradient descent (\eta = 1/L) from local stationarity to global optimality and geometric convergence:

Objective Class Mathematical Assumption Guaranteed Rate at \eta = 1/L Steps for Accuracy \epsilon
Smooth Nonconvex \nabla f is L-Lipschitz, f \ge f_{\mathrm{low}} \min_{k < K}\|\nabla f(\mathbf{x}_k)\|^2 \le \frac{2L(f_0 - f_{\mathrm{low}})}{K} O(1/\epsilon^2) for \|\nabla f\| \le \epsilon
Smooth Convex L-smooth and \nabla^2 f(\mathbf{x}) \succeq \mathbf{0} f(\mathbf{x}_k) - f^\star \le \frac{L\|\mathbf{x}_0 - \mathbf{x}^\star\|^2}{2k} O(1/\epsilon) for f - f^\star \le \epsilon
Strongly Convex \mu\mathbf{I} \preceq \nabla^2 f(\mathbf{x}) \preceq L\mathbf{I} (\kappa = L/\mu) f(\mathbf{x}_k) - f^\star \le (1 - 1/\kappa)^k(f_0 - f^\star) O(\kappa \log(1/\epsilon))
Quadratic at \eta^\star f(\mathbf{x}) = \tfrac12\mathbf{x}^\top\mathbf{A}\mathbf{x}, \eta^\star = \frac{2}{\mu + L} f(\mathbf{x}_k) - f^\star \le \bigl(\frac{\kappa - 1}{\kappa + 1}\bigr)^{2k}(f_0 - f^\star) \approx \frac{\kappa}{4}\log(1/\epsilon) for f - f^\star

Heavy-Ball Momentum: Velocity with Memory

Momentum

Gradient descent takes O(\kappa) steps because a memoryless step cannot damp steep oscillations without starving flat directions. Polyak’s heavy-ball momentum maintains an exponentially weighted velocity \mathbf{v}_k and updates \mathbf{x}_{k+1} = \mathbf{x}_k + \mathbf{v}_{k+1}:

\mathbf{v}_{k+1} = \beta\,\mathbf{v}_k - \eta\,\nabla f(\mathbf{x}_k)

  • Two-step recurrence: Eliminating \mathbf{v}_k = \mathbf{x}_k - \mathbf{x}_{k-1} gives \mathbf{x}_{k+1} = \mathbf{x}_k - \eta\nabla f(\mathbf{x}_k) + \beta(\mathbf{x}_k - \mathbf{x}_{k-1}).
  • Dual action: Opposite gradients along steep walls cancel; aligned gradients along the flat floor accumulate speed.
image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/

Characteristic Polynomial of a Momentum Mode

Momentum Analysis

In the eigenbasis of a quadratic \tfrac12\mathbf{x}^\top\mathbf{A}\mathbf{x}, each mode u_k with eigenvalue \lambda obeys the second-order linear recurrence u_{k+1} = (1 + \beta - \eta\lambda)u_k - \beta u_{k-1}. Substituting u_k = z^k yields the characteristic equation:

z^2 - (1 + \beta - \eta\lambda)\,z + \beta = 0

  • Complex-conjugate root regime: The discriminant (1 + \beta - \eta\lambda)^2 - 4\beta is nonpositive whenever: (1 - \sqrt{\beta})^2 \le \eta\lambda \le (1 + \sqrt{\beta})^2
  • Equalized root modulus: When the roots z, \bar{z} are complex conjugates, their product is the constant term z\bar{z} = |z|^2 = \beta, so both roots have modulus |z| = \sqrt{\beta} regardless of \lambda.
  • Endpoint double roots: At the two boundaries \eta\lambda = (1 \pm \sqrt{\beta})^2, a repeated real root z = \pm\sqrt{\beta} introduces a linear prefactor |u_k| \le C\,k\,\beta^{k/2}.

Optimal Heavy-Ball Tuning and the √κ Law

Momentum Analysis

Placing the extreme eigenvalues \lambda_{\min} and \lambda_{\max} right at the endpoints of the complex-root interval, \eta\lambda_{\min} = (1 - \sqrt{\beta})^2 and \eta\lambda_{\max} = (1 + \sqrt{\beta})^2, forces every mode onto the circle of radius \sqrt{\beta^\star} with step size \eta_{\mathrm{HB}} = 4 / (\sqrt{\lambda_{\max}} + \sqrt{\lambda_{\min}})^2:

\beta^\star = \left(\frac{\sqrt{\kappa} - 1}{\sqrt{\kappa} + 1}\right)^{\!2}

  • Accelerated contraction rate: Every mode contracts at rate \rho_{\mathrm{HB}} = \sqrt{\beta^\star} = \frac{\sqrt{\kappa} - 1}{\sqrt{\kappa} + 1} \approx 1 - \frac{2}{\sqrt{\kappa}}
  • Speedup: Iteration complexity drops from O(\kappa\log\tfrac{1}{\epsilon}) to O(\sqrt{\kappa}\log\tfrac{1}{\epsilon}).
image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/

Nesterov Acceleration and Global Guarantees

Accelerated Methods

Nesterov’s accelerated gradient evaluates \nabla f at the look-ahead point \tilde{\mathbf{x}}_k = \mathbf{x}_k + \beta\mathbf{v}_k:

\mathbf{v}_{k+1} = \beta\,\mathbf{v}_k - \eta\,\nabla f(\mathbf{x}_k + \beta\,\mathbf{v}_k)

  • Look-ahead braking: If momentum carries the iterate uphill, \nabla f(\tilde{\mathbf{x}}_k) points backward and brakes before overshooting.
  • Minimax optimal rates: Achieves O(\sqrt{\kappa}\log(1/\epsilon)) globally on all L-smooth, \mu-strongly convex objectives and O(1/k^2) on smooth convex objectives (matching the Nemirovski–Yudin lower bound).

Benchmarking Iteration Scaling Across κ

Empirical Verification

Measuring the exact number of iterations required to reach \|\mathbf{x}_k\| \le 10^{-6}\|\mathbf{x}_0\| on \mathrm{diag}(1, \kappa) from (1, 1) confirms the linear \kappa vs. \sqrt{\kappa} scaling laws:

kappa      GD   heavy ball   Nesterov     GD/kappa   HB/sqrt(kappa)
   10      69        27         43          6.9         8.5
  100     691        93        155          6.9         9.3
 1000    6908       315        508          6.9        10.0
  • Gradient descent stays pinned at k/\kappa \approx 6.9 (6{,}908 steps at \kappa = 1000).
  • Heavy ball finishes in 315 steps at \kappa = 1000; its ratio k/\sqrt{\kappa} drifts gently (8.5 \to 10.0) due to the Jordan-block double-root prefactor k\rho_{\mathrm{HB}}^k, matching k \approx \frac{\sqrt{\kappa}}{2}(\log 10^6 + \log k).

Concept Check: Step Sizes and Momentum Rates

Concept Check

Consider the quadratic objective f(x_1, x_2) = \tfrac12(x_1^2 + 100\,x_2^2) with eigenvalues \lambda_{\min} = 1, \lambda_{\max} = 100 (\kappa = 100):

  1. What is the maximum stable learning rate for gradient descent, the optimal fixed step \eta^\star, and the per-step contraction factor \rho(\eta^\star)?
  2. Roughly how many gradient descent steps are needed to shrink \|\mathbf{x}_k\| by 10^{-6}?
  3. What contraction factor \rho_{\mathrm{HB}} does tuned heavy-ball momentum achieve, and roughly how many steps does it need (including the double-root logarithmic term)?

Answers: (1) Stability ceiling: 2/L = 0.02. Optimal step: \eta^\star = 2/(1 + 100) = 2/101 \approx 0.0198. Contraction factor: \rho(\eta^\star) = 99/101 \approx 0.9802. (2) \log(10^6)/\log(101/99) \approx \frac{100}{2}\ln(10^6) \approx 691 steps. (3) With \sqrt{\kappa} = 10, \rho_{\mathrm{HB}} = (10 - 1)/(10 + 1) = 9/11 \approx 0.818. Pure geometric decay predicts 69 steps, and the double-root factor k\rho_{\mathrm{HB}}^k adds \frac{\sqrt{\kappa}}{2}\ln k \approx 24 steps, matching the measured 93 steps.

Summary: First-Order Methods and Curvature

Key Takeaways

Method / Concept Step Rule / Formula Contraction / Guarantee Core Takeaway
Descent Lemma \mathbf{x}_{k+1} = \mathbf{x}_k - \eta\mathbf{g}_k, 0 < \eta < 2/L \Delta f \le -\eta(1 - L\eta/2)\|\mathbf{g}_k\|^2 Steepest curvature L caps the safe step at 2/L
Backtracking (Armijo) Halve \eta until f(\mathbf{x} - \eta\mathbf{g}) \le f(\mathbf{x}) - c\eta\|\mathbf{g}\|^2 Finds \eta \ge \min(\eta_0, (1-c)/L_{\mathrm{loc}}) Adapts to local curvature without knowing L
Optimal Fixed-Step GD \eta^\star = \frac{2}{\lambda_{\min} + \lambda_{\max}} \rho_{\mathrm{GD}} = \frac{\kappa - 1}{\kappa + 1} \approx 1 - \frac{2}{\kappa} Iteration count scales linearly with \kappa = L/\mu
Heavy-Ball Momentum \mathbf{v}_{k+1} = \beta^\star\mathbf{v}_k - \eta_{\mathrm{HB}}\mathbf{g}_k \rho_{\mathrm{HB}} = \frac{\sqrt{\kappa} - 1}{\sqrt{\kappa} + 1} \approx 1 - \frac{2}{\sqrt{\kappa}} Complex roots equalize all modes at modulus \sqrt{\beta^\star}
Nesterov Look-Ahead \mathbf{v}_{k+1} = \beta\mathbf{v}_k - \frac{1}{L}\nabla f(\mathbf{x}_k + \beta\mathbf{v}_k) \rho_{\mathrm{NAG}} = 1 - \frac{1}{\sqrt{\kappa}} (O(1/k^2) if \mu=0) Achieves optimal O(\sqrt{\kappa}) globally beyond quadratics