9 Optimization Algorithms
Every deep network in the preceding chapters was trained with a standard recipe—such as minibatch SGD with momentum \(0.9\), or AdamW with linear warmup and cosine decay (Section 7.6). When a training run diverges to nan, we lower the learning rate; when progress stalls, we adjust the schedule or batch size. This chapter opens the black box of the optimizer to answer three practical questions: what determines the largest safe learning rate and the speed of convergence below it, how does each component of a modern training recipe reshape the update step, and how must those hyperparameters scale as models and batch sizes grow?
Gradient descent itself predates modern computing: Augustin-Louis Cauchy proposed it in 1847 to compute planetary orbits, and in 1951 Herbert Robbins and Sutton Monro analyzed root-finding under noisy observations with decaying step sizes. Across both classical and modern settings, two fundamental obstacles limit any gradient-based optimizer:
- Ill-conditioning (uneven curvature): When the loss surface curves sharply in some directions and gently in others, a learning rate small enough to remain stable along the steepest direction makes painfully slow progress along the flattest directions.
- Gradient noise: Because gradients are estimated from finite minibatches rather than the full dataset, every update carries sampling variance that prevents constant-step-size iterates from settling at a minimum.
Figure 9.1 shows both obstacles on the same two-dimensional valley. Every design choice in a modern optimizer targets one of them through three levers:
- Step direction: Momentum (Section 9.4), adaptive coordinate-wise methods such as Adam and AdamW (Section 9.5), and matrix-level orthogonalized methods such as Muon (Section 9.6) replace the raw gradient with a preconditioned or smoothed direction that travels faster along ill-conditioned valleys.
- Step-size schedule: Learning-rate warmup, cosine or linear decay, and warmup–stable–decay (WSD) schedules (Section 9.7) navigate the trade-off between rapid early traversal and low final noise.
- Minibatch size and scaling: The critical batch size (Section 9.8) determines when larger minibatches stop reducing the number of optimization steps, while Maximal Update Parametrization (\(\mu\text{P}\), Section 9.9) allows learning rates tuned on a small proxy model to transfer directly to much wider networks.
We develop each method by pairing an analytical model—a two-dimensional quadratic valley with condition number \(\kappa = 20\)—with systematic empirical measurements on two neural network benchmarks introduced in Section 9.3: the convolutional classifier FashionCNN and the byte-level Transformer language model TinyLM. Finally, Section 9.10 combines gradient clipping, weight averaging, and hyperparameter scaling into an end-to-end protocol for configuring and diagnosing large-scale training runs.
This chapter assumes familiarity with gradients, eigenvalues of symmetric matrices, and basic minibatch SGD (Section 2.1.2.3). We give concise derivations where they directly guide hyperparameter choices and defer longer mathematical proofs to Chapter 35. Annotated references to textbooks, papers, and practitioner playbooks are collected in Section 9.11.