9  Optimization Algorithms

Every model in this book has used an optimizer to update its parameters once per minibatch. This chapter examines the principles behind those updates. An optimization algorithm makes three related choices: the descent direction, the step size and its variation over time, and the treatment of noise in minibatch gradients. The appropriate descent direction depends on how the size of an update is measured; the step size must account for curvature and training time; and the gradient variance depends on batching and averaging.

Two properties of the loss surface make the decisions consequential. The first is curvature: a deep network’s loss rises steeply along some directions of parameter space and slowly along others. A single step size must serve both, so a large step causes oscillation in steep directions while a small step makes slow progress in flat directions. The second is noise: an exact gradient costs a full pass over the dataset, so scalable methods use minibatch estimates whose variance depends on the batch size. Section 9.1 introduces these properties. The next five sections develop gradient descent and preconditioning (Section 9.2), stochastic gradients and learning-rate decay (Section 9.3), the computational effects of minibatching (Section 9.4), momentum for ill-conditioned objectives (Section 9.5), and per-coordinate scaling from AdaGrad through RMSProp to Adam (Section 9.6). The Adam section also builds the tiny transformer language model used in later experiments.

The second half removes simplifying assumptions from this progression. AdamW separates shrinkage from adaptive preconditioning, and learning-rate schedules vary the step over time. Muon changes the geometry used to choose matrix updates. Batch-size experiments connect gradient variance to parallel compute, while scaling and practice address hyperparameter transfer, clipping, weight averaging, and matched comparisons.

This chapter emphasizes computations and controlled experiments. The mathematical appendix (Chapter 26) proves the descent lemma, the condition-number law, momentum’s \(\sqrt{\kappa}\) acceleration, the Robbins–Monro conditions, and Adam’s bias correction under explicit assumptions. The two treatments can be read in either order.

Several methods in the second half are recent, and their relative performance remains protocol-dependent. The comparisons therefore tune each optimizer under the same budget and distinguish evidence from small testbeds, public benchmarks, and reported production runs.

Resources and Further Reading

The references below cover convex foundations, classical methods, current optimizers, and tuning. All are freely accessible online except where noted. The optimization chapter of the mathematical appendix (Chapter 26) keeps its own resource list for the theory side — convex-optimization texts and courses with proofs — and we do not repeat those entries here.

Books

Courses and video lectures

Foundational and current papers

Tutorials, notes, and interactive