Optimization Algorithms

Dive into Deep Learning · §9

Optimization Algorithms: Geometry, Stochasticity, and Scaling
ill-conditioning · gradient noise · momentum · AdamW & Muon · schedules · critical batch size · μP

Two Obstacles Limit Every Deep Learning Optimizer

The Central Problem

  • Obstacle 1 — Ill-Conditioning (\kappa = \lambda_{\max}/\lambda_{\min} \gg 1):
    • On f(\mathbf{x}) = 0.1x_1^2 + 2x_2^2 (\lambda_1 = 0.2, \lambda_2 = 4, \kappa = 20), stability along x_2 caps \eta < 2/\lambda_2 = 0.5, forcing x_1 to shrink by <10\% per step (47 steps to 1\% error).
  • Obstacle 2 — Minibatch Gradient Noise (\operatorname{tr}(\boldsymbol{\Sigma})/b):
    • Sampling b examples traps constant-rate iterates inside a stationary noise ball of variance \eta\sigma^2 / (2\lambda b).
  • Chapter thesis: Every modern optimizer lever attacks one of these two bottlenecks.

Three Design Levers of a Modern Training Recipe

Architectural Framework

  • 1. Step Direction & Preconditioning (§§9.4–9.6):
    • Replace -\nabla f(\mathbf{x}) with momentum velocity (\mathbf{v}_t), per-coordinate RMS normalization (AdamW), or spectral orthogonalization (\mathbf{U}\mathbf{V}^\top, Muon).
  • 2. Step-Size Schedule \eta_t (§9.7):
    • Ramp \eta_t during warmup to steer below 2/\eta_0, hold a high travel budget B_T = \sum_t \eta_t, and decay \eta_T \to 0.
  • 3. Batch Size, Width Scaling & Guards (§§9.8–9.10):
    • Match b to b_{\text{noise}}, transfer LRs across widths via \mu\text{P} (\eta/m), and guard with global-norm clipping and weight EMA.

From Exact Analytical Models to Neural Benchmarks

Pedagogical Methodology

  • Analytical quadratics & linear data (§§9.1–9.2):
    • Solve exact stability ceilings, \sqrt{\kappa} critical damping, and excess loss \frac{\eta\operatorname{tr}\boldsymbol{\Sigma}}{4b} on the \kappa=20 valley and NASA airfoil dataset (n=1{,}500, d=6).
  • Two complementary neural networks (§§9.3–9.10):
    • FashionCNN (421\text{K} params): Multi-epoch image classification (8.5 epochs in 2{,}000 steps at b = 256) with held-out test accuracy.
    • TinyLM (471\text{K} / 3.3\text{M} params): Single-pass byte-level Transformer on WikiText-103 (40\times layer gradient spread).

Chapter 9 Roadmap: Sections and Core Invariants

Chapter Map

  • Foundations & Benchmarks (§§9.1–9.3):
    • Stability \eta < 2/\lambda_{\max}, edge of stability \lambda_{\max} \approx 2/\eta, noise ball \frac{\eta\sigma^2}{2\lambda b}, count landmarks, and 3\times multi-seed thresholds.
  • Preconditioned Directions (§§9.4–9.6):
    • Momentum \eta_{\text{eff}} = \frac{\eta}{1-\beta} (O(\sqrt{\kappa})), AdamW timescale \tau = \frac{1}{\eta\lambda}, and Muon 5-step Newton–Schulz orthogonalization -\eta\mathbf{U}\mathbf{V}^\top.
  • Schedules, Scaling & Operations (§§9.7–9.10):
    • Warmup + WSD/cosine budget B_T, critical batch size b_{\text{noise}} = \frac{\operatorname{tr}\boldsymbol{\Sigma}}{\|\nabla f\|^2}, \mu\text{P} hidden LR \eta/m, clipping (\theta=1), and weight EMA.

How to Navigate Chapter 9 and the Math Appendix

Study Guide

  • Core practitioner sequence (§9.1–§9.5, §9.7–§9.8, §9.10):
    • Master the two bottlenecks (§9.1–§9.2), experimental benchmarking (§9.3), momentum and AdamW (§9.4–§9.5), learning-rate schedules (§9.7), critical batch size (§9.8), and production diagnostics (§9.10).
  • Advanced scaling & matrix methods (§9.6, §9.9):
    • Study §9.6 (Muon) for spectral-norm steepest descent via Newton–Schulz polynomials and §9.9 (Scaling Up) for zero-shot learning-rate transfer across widths via \mu\text{P}.
  • Connection to subsequent chapters & proofs:
    • TinyLM, its WikiText-103 byte loader, and its AdamW/schedule harness return in the chapters on Attention, Transformers, State Space Models, and Performance.
    • Concise derivations that directly guide hyperparameter choices appear inline; full convergence proofs and convex analysis live in Chapter 35 (Mathematics for Deep Learning: Optimization).

Up next (§9.1 Landscapes and Gradient Descent): How directional curvature and the condition number \kappa = \lambda_{\max}/\lambda_{\min} determine the maximum stable step size and the edge of stability.