LLGA · Course notes

Optimization for AI

APM_52067_EP · Year 1 · Period 2

Contents

Introduction and overview

Module Optimization for AI
Code APM_52067_EP
Team and volume Official instructors (“Responsables” on the 2026–2027 sheet and on the track page): Aymeric Dieuleveut & Luiz Fernando De Oliveira Chamon (École Polytechnique, CMAP), Luiz Chamon being the head of the 2026–2027 occurrence · instructional engineering team: P. Bianchi, B. Goujaud · teaching hours: not displayed on the 2026–2027 sheet, nor in the volume column of the track page (enrollment: 1 to 80); 36 h per the LLGA curriculum wiki (all M1 courses after the refreshers) · 4.5 ECTS per the same wiki (the sheet’s assessment tab gives 4.5 ECTS for the TRAI track and 5 ECTS for the engineering cycle, the M1 MJH and the exchange programmes, but no ECTS value in its LLGA section) · from gradient descent to SGD, from Nesterov to proximal methods — the complete theory of the algorithms that train AI, with the proofs of the convergence rates.
Official sheet (SynapseS 2026-2027) Official title: “Optimization for AI” (programme d’approfondissement, applied mathematics) · period: X-3A-P2, from 04/01/2027 to 19/03/2027 · language: English · official assessment (assessment tab “Acquisition de l’UE”, section for the LLGA track, checked on 24 October 2026): written final exam without calculator, one handwritten A4 sheet allowed and to be handed in with the exam; this LLGA section gives no duration, resit rule, pass threshold or ECTS value, which the sheet lists only for other degrees (grade format of the unit: numerical out of 20, with a US letter grade) · prerequisites: not displayed · APM_52067_EP course sheet
Status in the program P2 OptionOutside recommended track

Audience: an engineer who already runs Adam or SGD and wants to know why it converges (or not). Empirical first: each topic starts from a symptom — a loss that oscillates because the step is too large, a plateau on an ill-conditioned problem — and only then names the concepts that explain it: convexity, conditioning, acceleration, proximal operators, convergence rates.

The module is the theoretical backbone reused wherever a model is trained in the program.

What you will be able to do

Official objectives and syllabus (2026-2027 catalog)

According to the APM_52067_EP — “Optimization for AI” sheet: the course introduces the fundamentals of optimization for machine learning and AI. Rather than a panorama of existing algorithms, it is organized around the workhorse of modern ML/AI — stochastic gradient descent (SGD) — and studies its extensions, such as variance reduction and adaptive methods, deriving convergence guarantees in convex and non-convex settings.

It also explores minimax optimization, in particular in the context of constrained optimization and duality, non-smooth optimization, and saddle-point methods, with an emphasis on theoretical foundations and practical applications.

The sheet publishes no session-by-session programme and no prerequisites. The LLGA section of its assessment tab gives only the exam format: a written final exam without calculator, with one handwritten A4 sheet allowed (to be handed in with the exam). The table maps every element of this description to the section that teaches it.

Element of the official description Section of the course
SGD, the workhorse of modern ML/AI ch. 5 — Stochastic gradient descent (definition 5.1, theorem 5.2, regimes, minibatching)
Extension: variance reduction ch. 6 — SAGA and SVRG (definitions 6.1–6.2, theorem 6.3)
Extension: adaptive methods ch. 10 — Adam and AdamW (recall 10.1, taught in Deep Learning ch. 3); AdaGrad and its regret bound, scale-free steps, the Adam non-convergence example (definition 10.3 – example 10.5)
Convergence guarantees, convex setting ch. 2 (theorems 2.2–2.3, proved), ch. 3 (acceleration, lower bound), ch. 4 (theorems 4.4 and 4.6), ch. 5 (theorem 5.2 and the table of rates)
Convergence guarantees, non-convex setting ch. 5 — theorem 5.5 (SGD reaches approximate stationary points, proved); ch. 10 — proposition 10.2 (why training works anyway)
Constrained optimization and duality ch. 0 (weak and strong duality) and ch. 8 (penalties, projections, multipliers, theorem 8.3)
Minimax optimization ch. 8 — section “Minimax optimization and saddle-point methods” (definition 8.6, Lagrangian games, GANs, adversarial training)
Non-smooth optimization ch. 1 (subdifferential), ch. 4 (proximal methods, ISTA/FISTA, and the subgradient method, theorem 4.6)
Saddle-point methods ch. 8 — gradient descent–ascent, extragradient (example 8.7), rates (proposition 8.8); Uzawa / primal-dual (proposition 8.2)
Theoretical foundations and practical uses proofs throughout; code labs in ch. 4 and ch. 5, training of networks in ch. 10

Complement to the official description — chapters of these materials that go beyond it: Nesterov acceleration (ch. 3), Newton and quasi-Newton (ch. 7), hyperparameter optimization (ch. 9) and the research of the course instructors (ch. 11, self-study).

Where this course fits in the program

An option of period 2 of M1, outside the recommended track. It sits in the Choose-1 group of Period 2, next to Multimodal Generative AI, Deep Learning (P2 variant), Computational Optimal Transport, Advanced Deep Learning and Image Synthesis. A student who takes it takes none of these, so this page cites their notes only as optional reading. Official prerequisites: not communicated (the “Prerequisites” tab of the SynapseS sheet is empty).

What the module assumes:

What it feeds: the mandatory Reinforcement Learning course, which runs in parallel, rests on the stochastic approximation of its section 0.2, and chapter 11 here carries duality over to constrained reinforcement learning. In Year 2, the training runs of Large Language Models (ch. 3–4) are the SGD, AdamW and schedules of chapters 5 and 10. The end-of-year projects Y1.3 (exposure constraint by stochastic primal–dual) and Y2.4 use the constraint tools of chapter 8.

Course outline

Session plan

36 h in class = 12 sessions of 3 h. The SynapseS 2026–2027 sheet displays no volume (and the volume column of the LLGA track page is empty for this unit), but the LLGA curriculum page of the programme wiki (msct.dix.polytechnique.fr/llga, last modified on 9 September 2026 by the programme director) states that “all subsequent M1 courses are 36h and will credit 4.5 ECTS”; since no session-by-session programme is published, the split below is our proposal for covering these notes in that time.

Level 1 = foundations (reviews, definitions, first worked examples), 2 = core theorems and algorithms, 3 = advanced or open questions; the level never goes down from one session to the next.

Session Hours Level Content Practice
1 3 h 1 ch. 0 Convexity, smoothness, duality; ch. 1 Training problems, subdifferential, one-dimensional LASSO Ex. 5 (soft thresholding)
2 3 h 2 ch. 2 Descent lemma, the O(1/k) rate Ex. 1
3 3 h 2 ch. 2 Linear convergence and the condition number Ex. 4
4 3 h 2 ch. 3 Lower bound, Nesterov acceleration, momentum in practice lab: GD vs Nesterov on the valley
5 3 h 2 ch. 4 Proximal operator, ISTA and FISTA (both proved); the subgradient method and its 1/\sqrt{K} rate Ex. 2, Ex. 5 (projections)
6 3 h 2 ch. 5 SGD: assumptions, constant-step plateau, minibatching; non-convex SGD and stationary points Ex. 6
7 3 h 2 ch. 6 Variance reduction: SAGA and SVRG Ex. 7
8 3 h 2 ch. 7 Newton, BFGS and L-BFGS Ex. 8
9 3 h 2 ch. 8 Constraints: penalties, projections, multipliers; minimax problems, gradient descent–ascent, extragradient Ex. 9
10 3 h 2 ch. 9 Hyperparameter optimization: random search, GP-EI, Hyperband Ex. 3
11 3 h 2 ch. 10 Adam and AdamW read with the module’s tools; schedules and large batches; AdaGrad and adaptive steps lab: diagnosing a diverging run (example 10.6)
12 3 h 3 ch. 10 Why non-convex training works anyway: overparameterization, local PL, SGD noise review of the proofs

Self-study, outside the 36 h (about 3 h in total): ch. 11 Course research notes — CMAP (Chamon, Dieuleveut) (≈ 3 h, with the two cross-cutting readings it proposes).

How to study this module

Independent note Optimization is the common grammar of AI: it connects the M2 LLMs (whose training is a vast optimization task) to distributed systems and frugal AI. The theoretical perspective gained here — knowing what an algorithm can and cannot do — distinguishes the engineer who designs from the one who configures, and is a natural prerequisite toward careers in research and large-scale ML.

Notation

The page follows the site-wide notation conventions:

Deviations, as in optimization textbooks.

0. Refresher: convexity and duality

L3 reminders — the essentials of convex analysis, complete here (first met in Machine Learning, sections 0.2 and 0.4)

  • Convexity: f\colon \mathbb{R}^d \to \mathbb{R} is convex if f(\lambda x + (1-\lambda)y) \leq \lambda f(x) + (1-\lambda) f(y) \quad \text{for all } \lambda \in [0,1]; in finite dimension with f differentiable, this is equivalent to f(y) \geq f(x) + \langle \nabla f(x), y - x \rangle \quad \text{(subgradient inequality).}
  • Strong convexity: x \mapsto f(x) - \tfrac{\mu}{2}\|x\|^2 is convex for some \mu > 0 — the subgradient inequality becomes strict by a quadratic term; this is what will yield linear (geometric) convergence.
  • Smoothness: \nabla f L-Lipschitz — that is, \|\nabla f(x) - \nabla f(y)\| \leq L \|x - y\|; equivalent to the quadratic upper bound f(y) \leq f(x) + \langle \nabla f(x), y-x\rangle + \tfrac{L}{2}\|y-x\|^2.
  • Lagrangian duality: primal problem \min f(x) subject to g_i(x) \leq 0 for i = 1, \dots, m, Lagrangian \mathcal{L}(x, \lambda) = f(x) + \sum_i \lambda_i g_i(x), dual function d(\lambda) = \inf_x \mathcal{L}(x,\lambda), dual problem \max_{\lambda \geq 0} d(\lambda).
  • KKT conditions (convex differentiable f and g_i): x^\star and \lambda^\star solve the primal and the dual with a zero gap if and only if g_i(x^\star) \leq 0, \qquad \lambda^\star \geq 0, \qquad \nabla f(x^\star) + \sum_i \lambda_i^\star \nabla g_i(x^\star) = 0, \qquad \lambda_i^\star\, g_i(x^\star) = 0 \;\; \forall i, that is primal feasibility, dual feasibility, stationarity of the Lagrangian in x, and complementary slackness (an inactive constraint has a zero multiplier).
  • Linear programs: for \min c^\top x subject to Ax \geq b, the dual function is b^\top \lambda when A^\top\lambda = c and -\infty otherwise, so the dual is again a linear program: \max_{\lambda \geq 0}\; b^\top \lambda \quad \text{subject to} \quad A^\top \lambda = c .

Proposition 0.1 — Weak duality (proved) For every feasible x and every \lambda \geq 0: d(\lambda) \leq f(x). In particular \max_\lambda d(\lambda) \leq \min_{x \text{ feasible}} f(x) : the dual always provides lower bounds.

Proof. For feasible x, g_i(x) \leq 0 and \lambda_i \geq 0 give \mathcal{L}(x, \lambda) = f(x) + \sum_i \lambda_i g_i(x) \leq f(x). Taking the infimum over x on the left and then the supremum over \lambda, we get d(\lambda) \leq f(x) for every pair, hence \sup_\lambda d(\lambda) \leq \inf_{x \text{ feasible}} f(x). ∎

Theorem 0.2 — Strong duality (Slater) If the problem is convex (functions f, g_i convex) and there exists a strictly feasible point (g_i(x_0) < 0 for every i; affine constraints only need g_i(x_0) \leq 0), then the optimal dual value equals the primal value and the maximum of the dual problem is attained. The duality gap (the difference between the two) is zero: this is the key that allows, in chapter 8, replacing a constrained problem with a sequence of unconstrained problems playing on \lambda.

Why this refresher opens the module All of supervised learning is an optimization problem: minimize an empirical risk \frac{1}{n}\sum_i \ell(f_\theta(x_i), y_i) over \theta. The three structures of the refresher — convexity, smoothness, duality — determine the choice of algorithm (chapters 2–8) and its speed. Duality will return twice: for constraints (ch. 8, and L. Chamon’s work on learning under constraints, ch. 11) and to understand what “learning” means when one imposes requirements (fairness, safety) rather than a mere average cost.

1. Optimization inside the AI loop

A fine-tuning run that “stops descending” while the gradient is not zero is usually a problem of conditioning, not a bug. Before any algorithm, this chapter writes training as an optimization problem, fixes the vocabulary, and collects the examples on which every later method is tested.

What breaks Three mistakes recur in practice: ignoring the conditioning of the problem, reading a convergence rate proved in expectation as a promise about one run, and differentiating a non-smooth regularizer instead of handling it with a proximal step (ch. 4).

The practitioner’s main enemy is conditioning; the main ally is structure (convexity, separability, sparsity).

Definition 1.1 — Training problem Given data (x_i, y_i)_{i \leq n}, a parametric model h_\theta and a loss \ell, training solves \min_{\theta \in \mathbb{R}^d}\; F(\theta) = \frac{1}{n}\sum_{i=1}^n \ell(h_\theta(x_i), y_i) \;+\; \Omega(\theta), where \Omega (penalty) encodes a prior — sparsity \Omega = \lambda\|\theta\|_1, stability \Omega = \tfrac{\lambda}{2}\|\theta\|_2^2.

Let f denote the differentiable part (the empirical risk) and g = \Omega the possibly non-differentiable part: this decomposition F = f + g structures chapters 4 and 8.

Problem f(\theta) g Structure
Least squares \frac{1}{2n}\|X\theta - y\|^2 — \mu-strongly convex if \mathrm{rank}(X)=d, L-smooth
LASSO \frac{1}{2n}\|X\theta - y\|^2 \lambda\|\theta\|_1 convex, non-differentiable at 0 (ch. 4)
Logistic regression \frac{1}{n}\sum_i \log(1+e^{-y_i \theta^\top x_i}) 0 or \lambda\|\theta\|_2^2 smooth convex; finite sum (ch. 5–6)
SVM (constrained form) \tfrac{1}{2}\|\theta\|^2 constraints 1 - y_i\theta^\top x_i \leq 0 constraints: duality (ch. 8, see ML module ch. 3)
Neural network cross-entropy over h_\theta — non-convex (ch. 10)

Definition 1.2 — Subdifferential, reference examples The subdifferential of a convex F at \theta is the set of slopes of the affine minorants that touch F at \theta: \partial F(\theta) = \{v : F(\theta') \geq F(\theta) + \langle v, \theta'-\theta\rangle \;\forall \theta'\}. It reduces to the singleton \{\nabla F(\theta)\} when F is differentiable at \theta. Examples:

  • for \theta \in \mathbb{R}, \partial |\theta| = \{\mathrm{sign}(\theta)\} if \theta \neq 0, =[-1,1] if \theta = 0;
  • \partial (\tfrac{1}{2}\|\theta\|^2) = \{\theta\};
  • \partial \max(\theta_1,\theta_2) = \{e_{i^\star}\} if a unique argmax, a segment otherwise.

Summation rule: if one of the two terms is continuous, \partial(F_1+F_2) = \partial F_1 + \partial F_2.

Proposition 1.3 — First-order optimality condition Let F be convex. Then \theta^\star minimizes F if and only if 0 \in \partial F(\theta^\star).

Proof. Both directions read definition 1.2 with v = 0: the statement 0 \in \partial F(\theta^\star) means F(\theta) \geq F(\theta^\star) + \langle 0, \theta - \theta^\star\rangle = F(\theta^\star) \quad \text{for every } \theta, which is exactly the statement that \theta^\star minimizes F. ∎

The condition does not say that the subdifferential is \{0\}: for F(\theta) = |\theta|, the minimizer 0 has \partial F(0) = [-1, 1], which contains 0. Example 1.4 uses exactly this freedom.

Example 1.4 — One-dimensional LASSO, by hand Minimize \frac{1}{2}(z - \theta)^2 + \lambda|\theta| over \theta \in \mathbb{R}, with z \in \mathbb{R} and \lambda > 0. Optimality conditions:

  • either \theta \neq 0 and \theta - z + \lambda\,\mathrm{sign}(\theta) = 0, hence \theta = z - \lambda\mathrm{sign}(\theta);
  • or \theta = 0 and -z \in [-\lambda, \lambda].

We recover soft thresholding

Key result — soft thresholding \theta^\star = \mathrm{sign}(z)\,\max(|z|-\lambda,\,0) = S_\lambda(z),

the central operation of chapter 4: sparsity comes from the fact that the optimum “sticks” to zero for all |z| \leq \lambda — which the \ell_2 penalty never does.

What the module proves, and why At the end of the module, the student must be able to prove: the O(1/k) convergence of gradient descent (ch. 2), its linear convergence under strong convexity (ch. 2), the rates of ISTA and FISTA (ch. 4), the stationary regime of constant-step SGD (ch. 5) and the local quadratic convergence of Newton (ch. 7).

The lower bound that makes the \sqrt{\kappa} factor of acceleration optimal (ch. 3) is to be stated and explained; its proof is left to the references. Each proof fits in a few lines of well-chosen inequalities — that is the point: making these rates reasonable, not esoteric.

2. Gradient descent: convergence proved

This chapter answers the first question of the module: under which assumptions does gradient descent converge, and how fast? The algorithm is the most widely used one in machine learning:

x_{k+1} = x_k - \eta\, \nabla f(x_k), \qquad \eta > 0 \text{ the step (learning rate).}

Intuition first: the step on a one-dimensional quadratic Take f(x) = \tfrac{L}{2}x^2, whose gradient Lx is exactly L-Lipschitz. One step gives x_{k+1} = (1 - \eta L)\,x_k .

  • If 0 < \eta < 2/L, then |1 - \eta L| < 1 and the iterates go to 0;
  • the choice \eta = 1/L reaches 0 in a single step;
  • if \eta > 2/L, then |1 - \eta L| > 1 and the iterates oscillate with growing amplitude.

This is the oscillating loss of the introduction, explained: a step larger than 2/L along the steepest direction makes descent diverge, whatever happens elsewhere. All the results below assume \eta \leq 1/L, which leaves a safety factor of two.

Lemma 2.1 — Guaranteed descent (descent lemma) If f is L-smooth and 0 < \eta \leq 1/L: f(x_{k+1}) \;\leq\; f(x_k) - \tfrac{\eta}{2}\,\|\nabla f(x_k)\|^2.

Proof. By the quadratic upper bound at y = x_{k+1} = x_k - \eta\nabla f(x_k): f(x_{k+1}) \leq f(x_k) + \langle\nabla f(x_k), -\eta\nabla f(x_k)\rangle + \tfrac{L}{2}\eta^2\|\nabla f(x_k)\|^2 = f(x_k) - \eta(1 - \tfrac{L\eta}{2})\|\nabla f(x_k)\|^2, and \eta(1-\tfrac{L\eta}{2}) \geq \tfrac{\eta}{2} whenever \eta \leq 1/L. ∎

Theorem 2.2 — O(1/k) convergence (smooth convex case, proved) Let f be convex and L-smooth, x^\star a minimizer, R = \|x_0 - x^\star\|, \eta = 1/L. Then f(x_{k+1}) - f(x^\star) \;\leq\; \frac{L R^2}{2\,(k+1)}.

Proof. Step 1 (three-point inequality). For every y — quadratic upper bound of f at x_k evaluated at x_{k+1}, combined with convexity f(x_k) \leq f(y) + \langle\nabla f(x_k), x_k - y\rangle —: f(x_{k+1}) \;\leq\; f(y) + \langle\nabla f(x_k), x_{k+1} - y\rangle + \frac{L}{2}\|x_{k+1} - x_k\|^2.

Step 2 (y = x^\star and polarization). With \nabla f(x_k) = L\,(x_k - x_{k+1}) and y = x^\star, then the identity \langle a, b\rangle = \tfrac12(\|a+b\|^2 - \|a\|^2 - \|b\|^2) applied to a = x_k - x_{k+1}, b = x_{k+1} - x^\star (so that \|a+b\| = \|x_k - x^\star\| = R_k): f(x_{k+1}) - f^\star \;\leq\; L\langle x_k - x_{k+1},\, x_{k+1} - x^\star\rangle + \frac{L}{2}\|x_{k+1}-x_k\|^2 \;=\; \frac{L}{2}\big(R_k^2 - R_{k+1}^2\big).

Step 3 (telescoping). Summing from 0 to T-1 and using \|x_T - x^\star\|^2 \geq 0: \sum_{k=0}^{T-1} (f(x_{k+1}) - f^\star) \leq \tfrac{L}{2}R_0^2 . Since the sequence f(x_k) is decreasing (lemma 2.1), each term is bounded by the average: f(x_T) - f^\star \leq \tfrac{L R^2}{2T}. ∎

Theorem 2.3 — Linear convergence (\mu-strongly convex case, proved) Let f be \mu-strongly convex and L-smooth, \eta = 1/L. Then, with \kappa = L/\mu the condition number:

Key result — linear convergence of gradient descent f(x_{k+1}) - f(x^\star) \;\leq\; \Big(1 - \frac{1}{\kappa}\Big)\,\big(f(x_k) - f(x^\star)\big), \qquad f(x_k) - f^\star \;\leq\; e^{-k/\kappa}\,\big(f(x_0)-f^\star\big).

Proof. Strong convexity implies the Polyak–Łojasiewicz inequality, by minimizing over x the quadratic lower bound f(x_k) + \langle\nabla f(x_k), x - x_k\rangle + \tfrac{\mu}{2}\|x - x_k\|^2 . The inequality reads: f(x_k) - f^\star \leq \tfrac{1}{2\mu}\|\nabla f(x_k)\|^2, \quad \text{i.e.} \quad \|\nabla f(x_k)\|^2 \geq 2\mu\,(f(x_k)-f^\star). Injecting into lemma 2.1: f(x_{k+1}) \leq f(x_k) - \frac{1}{2L}\|\nabla f(x_k)\|^2 \leq f(x_k) - \frac{\mu}{L}(f(x_k)-f^\star). The error decreases geometrically by the factor 1-\mu/L = 1-1/\kappa \leq e^{-1/\kappa}. ∎

Reading the two rates — what \kappa tells us

  • Merely convex: error in 1/k — to divide the error by 100, 100 more iterations.
  • Strongly convex: error in (1-1/\kappa)^k \approx e^{-k/\kappa} — to gain a factor e, \kappa iterations.

With \kappa = 10^4 (ill-conditioned regression, next chapter), it is night: the “basic” descent is exponentially penalized by the condition number.

Not optimal: for a quadratic, \eta = 2/(\mu+L) yields the factor \big(\tfrac{\kappa-1}{\kappa+1}\big)^2 on the values (exercise 4): better, but still O(\kappa). Breaking this barrier is the subject of chapter 3.

Example 2.4 — Counting iterations before running them A ridge regression has L = 10 and \mu = 0.1, so \kappa = 100. To divide the initial error f(x_0) - f^\star by 10^6, theorem 2.3 asks for e^{-k/\kappa} \leq 10^{-6}, i.e. k \geq \kappa \ln 10^6 \approx 1\,382 \text{ iterations.} Without the strong convexity (or ignoring it), theorem 2.2 only guarantees an error LR^2/(2k): with L = 10, R = 1 and a target 10^{-6}, it asks for k \geq 5 \times 10^6 \text{ iterations.} The two bounds differ by more than three orders of magnitude on the same problem, which is why identifying \mu — for instance through an explicit \ell_2 penalty — is worth the effort.

Example 2.5 — Seeing the condition number in two dimensions f(u,v) = \tfrac{1}{2}(u^2 + \kappa v^2): \kappa = L/\mu exactly, with \nabla f = (u, \kappa v). At step 1/L = 1/\kappa:

  • the steep direction v is canceled in one iteration (v_1 = v_0 - \tfrac{1}{\kappa}\kappa v_0 = 0);
  • the flat direction u decreases only by (1-1/\kappa) per step: it — the elongated valley — sets the pace (\kappa iterations).

As soon as the quadratic is rotated (axes not aligned), the trajectory zigzags across the valley. This is the plot to remember from the module: all the “loss landscape” figures of networks (see the Deep Learning module, ch. 3) show these valleys — hence momentum.

import numpy as np

def gradient_descent(grad, x0, step, n_iter=200):
    x, traj = x0.copy(), [x0.copy()]
    for _ in range(n_iter):
        x = x - step * grad(x)
        traj.append(x.copy())
    return np.array(traj)

kappa = 200.0
A = np.diag([1.0, kappa])          # L = kappa, mu = 1, condition number = kappa
grad = lambda x: A @ x
x0 = np.array([9.0, 0.0])          # start on the flat axis: the worst case
traj = gradient_descent(grad, x0, step=1.0/kappa)
err = 0.5 * np.sum(traj**2 * np.array([1.0, kappa]), axis=1)
print(err[-1] / err[0])   # (1 - 1/kappa)**400 ~ 0.135: slow!
# optimal step for a quadratic: 2/(mu + L)
traj_opt = gradient_descent(grad, x0, step=2.0/(1.0+kappa))
err_opt = 0.5 * np.sum(traj_opt**2 * np.array([1.0, kappa]), axis=1)
print(err_opt[-1] / err_opt[0])    # ((kappa-1)/(kappa+1))**400 ~ 0.018: better
# from (9, 9) instead, step 1/L kills the steep coordinate (which carries
# almost all of the initial error) in one step: the ratio then looks tiny
# (~7e-4) although the flat coordinate is just as slow

3. Conditioning and Nesterov acceleration

Gradient descent pays a factor \kappa in iterations; this chapter asks whether another first-order method can pay less. Can we go faster without second-order information (no Hessian)? Nesterov’s answer (1983): yes, by a factor \sqrt{\kappa} — and this is optimal: no first-order algorithm can do better on the class of smooth convex functions. This is one of the rare results of the discipline where optimality is known and achieved by a usable algorithm.

Theorem 3.1 — First-order lower bound (Nesterov 1983; Nemirovski–Yudin 1983) For any first-order method (having access only to gradients at the visited points), there exists a \mu-strongly convex and L-smooth function such that, after T iterations, f(x_T) - f(x^\star) \;\geq\; \Big(1 - \frac{1}{\sqrt{\kappa}}\Big)^{2T}\,\big(f(x_0)-f(x^\star)\big) \quad\text{(up to constants).} In other words: \Omega\!\big(\sqrt{\kappa}\,\log(1/\varepsilon)\big) iterations are necessary, versus \Omega(\kappa \log(1/\varepsilon)) for gradient descent; and \Omega(1/\sqrt{\varepsilon}) iterations in the general smooth convex case (vs \Omega(1/\varepsilon)).

The proofs construct a blockwise quadratic “trap function” whose information propagates only one coordinate per iteration: they can be found in Nesterov (2004, §2.1) and Bubeck (2015, §3.5).

Definition 3.2 — Accelerated scheme (Nesterov, strongly convex case) With the momentum coefficient \beta = \frac{1 - \sqrt{\mu/L}}{1 + \sqrt{\mu/L}} and step \eta = 1/L:

Key result — Nesterov acceleration y_k = x_k + \beta\,(x_k - x_{k-1}), \qquad x_{k+1} = y_k - \eta\,\nabla f(y_k),

and the initialization y_0 = x_0. Convergence is linear with factor 1 - \sqrt{\mu/L} = 1 - 1/\sqrt{\kappa} — the promised \sqrt{\kappa} factor.

“Smooth convex” variant: \beta_k = \frac{k-1}{k+2} (growing momentum), rate f(x_k) - f^\star \leq \frac{2L\|x_0-x^\star\|^2}{(k+1)^2}.

Example 3.3 — What the factor \sqrt{\kappa} buys On an ill-conditioned least-squares problem with \kappa = 10^4, dividing the error by 10^6 costs

  • gradient descent about \kappa \ln 10^6 \approx 1.4 \times 10^5 iterations (theorem 2.3),
  • the accelerated scheme about \sqrt{\kappa}\,\ln 10^6 \approx 1.4 \times 10^3:

a hundred times fewer, for the same cost per iteration (one gradient and one extra vector addition).

The gain grows with \kappa, which is exactly when it is needed. The momentum coefficient here is \beta = \frac{1 - 1/\sqrt{\kappa}}{1 + 1/\sqrt{\kappa}} \approx 0.98 : almost all of the previous displacement is kept, which is what lets the iterates build up speed along the flat direction of the valley.

Theorem 3.4 — Intuition of the proof: estimate sequences The idea (detailed in Nesterov 2004, §2.2), in the smooth convex case \mu = 0: build quadratic models \phi_k(x) = \phi_k^\star + \frac{\gamma_k}{2}\|x - v_k\|^2, \qquad \phi_0(x) = f(x_0) + \frac{L}{2}\|x - x_0\|^2, by mixing in, at each step, the linear lower bound of f at a look-ahead point y_k: \phi_{k+1}(x) = (1-\alpha_k)\,\phi_k(x) + \alpha_k\Big(f(y_k) + \langle\nabla f(y_k), x - y_k\rangle\Big). Two properties are kept along the way.

  1. The model is almost below f. With \lambda_k = \prod_{j<k}(1-\alpha_j), induction on the recursion gives, for every x, \phi_k(x) \leq (1-\lambda_k)\, f(x) + \lambda_k\, \phi_0(x).
  2. The iterate beats the model. The invariant is f(x_k) \leq \phi_k^\star, with \phi_k^\star = \min \phi_k. It is preserved when y_k is the right convex combination of x_k and v_k, and x_{k+1} = y_k - \tfrac{1}{L}\nabla f(y_k).

Taking x = x^\star in 1 and chaining with 2: f(x_k) - f^\star \;\leq\; \phi_k(x^\star) - f^\star \;\leq\; \lambda_k\big(\phi_0(x^\star) - f^\star\big) \;\leq\; \lambda_k\, L R^2 , since smoothness gives f(x_0) - f^\star \leq L R^2/2.

The curvature of the models decreases, \gamma_{k+1} = (1-\alpha_k)\gamma_k. The weight \alpha_k is the largest that the descent lemma allows: L\alpha_k^2 = \gamma_{k+1}. Since \gamma_k = L\lambda_k, this reads \alpha_k^2 = \lambda_{k+1}, which gives \alpha_k \approx 2/k and \lambda_k \leq 4/(k+2)^2, hence f(x_k) - f^\star \leq \frac{4 L R^2}{(k+2)^2} = O(L R^2/k^2). In continuous time t \approx k\sqrt{\eta} (Su, Boyd and Candès, 2016), the scheme becomes the ODE \ddot{x} + \tfrac{3}{t}\dot{x} + \nabla f(x) = 0 — a ball in the valley with vanishing friction, along which f(x(t)) - f^\star \leq 2R^2/t^2: the signature of acceleration.

Momentum in practice: from Nesterov to PyTorch

Variant Update Typical use
Heavy ball (Polyak 1964) v_{k+1} = \beta v_k - \eta\nabla f(x_k), x_{k+1} = x_k + v_{k+1} networks (SGD+momentum 0.9); optimal for quadratics, no general guarantee
Nesterov (this chapter) gradient evaluated at the future point y_k optimal guarantees, FISTA (ch. 4), convex case
Adaptive restart (O’Donoghue–Candès 2015) restart the momentum (\beta_k back to 0) when f rises practical twist: linearizes convergence of the strongly convex case without knowing \mu

The Deep Learning module (section 3.2) shows, mode by mode on a quadratic, what heavy-ball momentum changes. This chapter adds why it matters: momentum, in Nesterov’s form, is what reaches the \sqrt{\kappa} factor that theorem 3.1 proves optimal on valleys of condition number \kappa.

4. Proximal methods: ISTA and FISTA

This chapter extends gradient descent to objectives with a non-differentiable part. Gradient descent requires a gradient — impossible for F = f + \lambda\|\theta\|_1 at the points where a coordinate is zero. The proximal trick: handle the smooth part with a gradient step, the non-smooth part with an explicit operation.

Definition 4.1 — Proximal operator For g\colon \mathbb{R}^d \to \mathbb{R} \cup \{+\infty\} convex lower semi-continuous: \mathrm{prox}_{\eta g}(v) = \arg\min_x \;\Big\{ g(x) + \frac{1}{2\eta}\|x - v\|^2 \Big\}. Special cases:

  • g = 0 gives v (gradient descent);
  • g = \iota_C (indicator of a closed convex set C) gives the projection \Pi_C(v);
  • g = \lambda\|\cdot\|_1 gives componentwise soft thresholding (example 1.4).

Proposition 4.2 — Firm non-expansiveness (proved) For all v, w: \|\mathrm{prox}_{\eta g}(v) - \mathrm{prox}_{\eta g}(w)\| \;\leq\; \|v - w\|.

Proof. Write p = \mathrm{prox}_{\eta g}(v), q = \mathrm{prox}_{\eta g}(w). The optimality condition 1.3 gives 0 \in \partial g(p) + \tfrac{1}{\eta}(p - v) and 0 \in \partial g(q) + \tfrac{1}{\eta}(q-w), that is \tfrac{1}{\eta}(v - p) \in \partial g(p) and \tfrac{1}{\eta}(w-q) \in \partial g(q).

Monotonicity of the subdifferential (\langle u - u', x - x'\rangle \geq 0 for u \in \partial g(x), u' \in \partial g(x')) yields \langle (v-p) - (w-q),\, p - q\rangle \geq 0, \quad \text{i.e.} \quad \langle v - w, p - q\rangle \geq \|p-q\|^2. By Cauchy–Schwarz, \|v-w\| \geq \|p-q\|. ∎

Definition 4.3 — ISTA and FISTA (Beck–Teboulle 2009; Daubechies et al. 2004) ISTA (iterative shrinkage-thresholding):

Key result — the proximal gradient step x_{k+1} = \mathrm{prox}_{\eta g}\big(x_k - \eta\,\nabla f(x_k)\big), \qquad \eta \leq 1/L.

FISTA (fast ISTA): ISTA + the Nesterov acceleration stage — y_k = x_k + \frac{k-1}{k+2}\,(x_k - x_{k-1}), \qquad x_{k+1} = \mathrm{prox}_{\eta g}\big(y_k - \eta\,\nabla f(y_k)\big).

Theorem 4.4 — Rates of ISTA and FISTA (proved) Let F = f + g with f convex L-smooth and g convex, and let R = \|x_0 - x^\star\|. ISTA at step 1/L satisfies F(x_k) - F(x^\star) \;\leq\; \frac{L R^2}{2k}. FISTA achieves F(x_k) - F(x^\star) \leq \frac{2L R^2}{(k+1)^2} — the \sqrt{\cdot} factor gained on the iteration count, exactly as in chapter 3.

Proof. Take \eta = 1/L, set u_k = x_k - \tfrac{1}{L}\nabla f(x_k) and x_{k+1} = \mathrm{prox}_{g/L}(u_k), the minimizer of \phi(x) = g(x) + \tfrac{L}{2}\|x - u_k\|^2.

  1. Proximal inequality. The function \phi is L-strongly convex and minimized at x_{k+1}, so for every y: \phi(y) \geq \phi(x_{k+1}) + \tfrac{L}{2}\|y - x_{k+1}\|^2 . Expanding \|y - u_k\|^2 = \|y - x_k\|^2 + \tfrac{2}{L}\langle \nabla f(x_k), y - x_k\rangle + \tfrac{1}{L^2}\|\nabla f(x_k)\|^2, and the same for x_{k+1}, the gradient-norm terms cancel and we get g(x_{k+1}) \;\leq\; g(y) + \langle \nabla f(x_k),\, y - x_{k+1}\rangle + \frac{L}{2}\Big(\|y - x_k\|^2 - \|y - x_{k+1}\|^2 - \|x_{k+1} - x_k\|^2\Big).
  2. Smoothness, then convexity of f. f(x_{k+1}) \leq f(x_k) + \langle\nabla f(x_k), x_{k+1}-x_k\rangle + \tfrac{L}{2}\|x_{k+1}-x_k\|^2 \quad \text{and} \quad f(x_k) \leq f(y) + \langle \nabla f(x_k), x_k - y\rangle, whose sum is f(x_{k+1}) \leq f(y) + \langle\nabla f(x_k), x_{k+1} - y\rangle + \tfrac{L}{2}\|x_{k+1}-x_k\|^2 .
  3. Sum of 1 and 2. The inner products and the terms \|x_{k+1}-x_k\|^2 cancel: F(x_{k+1}) \;\leq\; F(y) + \frac{L}{2}\Big(\|y - x_k\|^2 - \|y - x_{k+1}\|^2\Big) \qquad \text{for every } y.
  4. Telescoping. With y = x_k this shows that F(x_k) is non-increasing. With y = x^\star and summing from 0 to k-1, the right-hand side telescopes: \sum_{j=1}^{k} \big(F(x_j) - F^\star\big) \leq \tfrac{L}{2}\|x_0 - x^\star\|^2 . Since the terms decrease, the last one is at most their average: F(x_k) - F^\star \leq \frac{LR^2}{2k} — the same telescoping as in theorem 2.2.

FISTA (Beck–Teboulle 2009, th. 4.4). Write the momentum of definition 4.3 as (t_k - 1)/t_{k+1} with t_k = (k+1)/2. The proof only uses three properties of the sequence: t_1 = 1, \qquad t_{k+1}^2 - t_{k+1} \leq t_k^2, \qquad t_k \geq \tfrac{k+1}{2}. Beck and Teboulle’s t_{k+1} = \big(1 + \sqrt{1 + 4t_k^2}\big)/2, used in the code of example 4.5, has them too.

  1. Step 3 from any point. Steps 1–3 never used that the gradient step starts at x_k. Started at y_k, as in FISTA, they give for every z: F(x_{k+1}) \;\leq\; F(z) + \frac{L}{2}\Big(\|z - y_k\|^2 - \|z - x_{k+1}\|^2\Big).
  2. A moving comparison point. Take z = (1 - 1/t_{k+1})\,x_k + x^\star/t_{k+1}. Convexity of F gives F(z) - F^\star \leq \Big(1 - \frac{1}{t_{k+1}}\Big)\big(F(x_k) - F^\star\big). Set w_k = t_k x_k - (t_k - 1)\,x_{k-1} - x^\star. The formula for y_k gives exactly z - y_k = -\frac{w_k}{t_{k+1}}, \qquad z - x_{k+1} = -\frac{w_{k+1}}{t_{k+1}}.
  3. An energy that never increases. Write \delta_k = F(x_k) - F^\star. Insert 6 into 5, multiply by t_{k+1}^2 and use t_{k+1}^2 - t_{k+1} \leq t_k^2: t_{k+1}^2\,\delta_{k+1} + \frac{L}{2}\|w_{k+1}\|^2 \;\leq\; t_k^2\,\delta_k + \frac{L}{2}\|w_k\|^2 .
  4. Conclusion. The first step starts from y_0 = x_0, and t_1 = 1 makes the comparison point z = x^\star, so step 5 gives t_1^2\,\delta_1 + \frac{L}{2}\|w_1\|^2 \leq \frac{L}{2}R^2 . The energy then never increases, so t_k^2\,\delta_k \leq LR^2/2. With t_k \geq (k+1)/2, this is the announced F(x_k) - F^\star \leq 2LR^2/(k+1)^2. ∎

Example 4.5 — LASSO: ISTA vs FISTA in practice

import numpy as np
rng = np.random.default_rng(0)
n, d, s = 60, 200, 8                       # underdetermined, sparse support
X = rng.normal(size=(n, d)); X /= np.sqrt(n)
theta_true = np.zeros(d); theta_true[:s] = rng.normal(size=s)
y = X @ theta_true + 0.05 * rng.normal(size=n)

L = np.linalg.norm(X, 2) ** 2              # Lipschitz constant of f = 0.5||Xt-y||^2
lam = 0.1 * np.linalg.norm(X.T @ y, np.inf)

def soft(v, t): return np.sign(v) * np.maximum(np.abs(v) - t, 0)

def ista(x, iters):
    for _ in range(iters):
        x = soft(x - (1/L) * X.T @ (X @ x - y), lam/L)
    return x

def fista(x, iters):
    z, t = x.copy(), 1.0
    for k in range(1, iters+1):
        xn = soft(z - (1/L) * X.T @ (X @ z - y), lam/L)
        t_next = (1 + np.sqrt(1 + 4*t*t)) / 2
        z = xn + ((t-1)/t_next) * (xn - x)   # Nesterov momentum
        x, t = xn, t_next
    return x

F = lambda th: 0.5*np.sum((X@th - y)**2) + lam*np.abs(th).sum()
x0 = np.zeros(d)
F_ref = F(fista(x0.copy(), 5000))          # reference optimal value
for it in (20, 100):
    print(it, "ISTA gap:", F(ista(x0.copy(), it)) - F_ref,
              "FISTA gap:", F(fista(x0.copy(), it)) - F_ref)
# observed: FISTA's gap is ~50x smaller at 20 iterations, ~270x at 100;
# by 1000 iterations both reach machine precision

The 1/k^2 vs 1/k factor is visible in the first hundred iterations: same computations per iteration, radically different horizons. Later both methods converge linearly, faster than either guarantee, because this LASSO is strongly convex on the support of its solution (exercise 2 exploits this with a restart). This is also the foundation of compressed sensing solvers and of large-scale LASSO (see the Machine Learning module, ch. 2).

Beyond: ADMM in one sentence When even f decomposes badly (f = f_1 + f_2 with two easy proxes but coupled variables), the ADMM method inherits O(1/k) rates and reigns over problems with massive constraints. Its principle is augmented duality:

  1. rewrite \min f_1(x) + f_2(z) subject to x = z;
  2. alternate a prox over x, a prox over z, a dual step on the multiplier.

The loop is closed with ch. 0: this is applied duality, hence the augmented Lagrangian — see ch. 8.

Non-smooth objectives without a prox: the subgradient method

The proximal methods above need g to have a computable prox. When the whole objective is non-smooth and has no easy prox — a hinge loss summed over many points, a maximum of many affine functions — the only first-order information left is a subgradient (definition 1.2). The subgradient method simply follows it: x_{k+1} = x_k - \eta_k v_k \quad \text{with} \quad v_k \in \partial F(x_k). It is not a descent method, since a subgradient step can increase F, so the analysis tracks the distance to the solution instead of the function value.

Theorem 4.6 — Rate of the subgradient method (proved) Let F be convex with subgradients bounded by G, i.e. F is G-Lipschitz: \|v\| \leq G \quad \text{for every } v \in \partial F(x). Let x^\star be a minimizer and R = \|x_0 - x^\star\|. With the constant step \eta = \frac{R}{G\sqrt{K}}, \min_{0 \leq k < K}\; F(x_k) - F(x^\star) \;\leq\; \frac{R\,G}{\sqrt{K}}. The rate 1/\sqrt{K} is much slower than the 1/K of ISTA: dividing the error by 10 costs 100 times more iterations.

It cannot be improved in general: for G-Lipschitz convex functions, no first-order method does better than order RG/\sqrt{K} when the dimension exceeds the number of iterations (Nemirovski–Yudin 1983).

Proof. Expand the square and use the subgradient inequality F(x^\star) \geq F(x_k) + \langle v_k, x^\star - x_k\rangle: \|x_{k+1} - x^\star\|^2 = \|x_k - x^\star\|^2 - 2\eta\langle v_k, x_k - x^\star\rangle + \eta^2\|v_k\|^2 \leq \|x_k - x^\star\|^2 - 2\eta\big(F(x_k) - F(x^\star)\big) + \eta^2 G^2. Summing over k = 0, \dots, K-1, the distances telescope and the last one is non-negative: 2\eta\sum_{k<K}\big(F(x_k) - F(x^\star)\big) \leq R^2 + K \eta^2 G^2 . The minimum is at most the average, so \min_k F(x_k) - F(x^\star) \leq \frac{R^2 + K \eta^2 G^2}{2\eta K}. With \eta = R/(G\sqrt{K}) both terms equal \frac{RG}{2\sqrt{K}}, which gives the bound. ∎

Example 4.7 — Why the step must shrink: F(x) = |x| Start from x_0 = 1 with the constant step \eta = 0.3. The subgradient is the sign of x, so the iterates are 0.7,\ 0.4,\ 0.1,\ -0.2,\ 0.1,\ -0.2,\ \dots They never reach 0 and oscillate forever at a distance of order \eta, with \min_k F(x_k) = 0.1.

Theorem 4.6 explains this: with a constant step, the method only reaches a neighbourhood whose size is proportional to \eta, the same phenomenon as the SGD plateau of chapter 5.

Compare the proximal point method, which applies the prox of \eta|x| (soft thresholding by \eta) at every step: 1 \to 0.7 \to 0.4 \to 0.1 \to 0, exactly 0 after four steps and forever after. Using the structure of the non-smooth term, when a prox is available, is what turns 1/\sqrt{K} into 1/K.

5. Stochastic gradient descent

This chapter analyses what happens when the gradient is replaced by a cheap, noisy estimate. When n = 10^9, computing \nabla f costs 10^9 evaluations — per iteration. The founding gesture of modern learning (Robbins–Monro, 1951): accept a noisy but cheap gradient.

Definition 5.1 — SGD and assumptions Write the objective as f = \frac{1}{n}\sum_{i=1}^n f_i, where f_i is the loss on sample i, plus the penalty when there is one, seen as a function of the parameter x. Draw an index i_k uniformly at random (or a mini-batch): x_{k+1} = x_k - \eta_k\, g_k, \qquad g_k = \nabla f_{i_k}(x_k). Assumptions:

  • (H1) unbiasedness \mathbb{E}[g_k \mid x_k] = \nabla f(x_k);
  • (H2) bounded variance \mathbb{E}\|g_k - \nabla f(x_k)\|^2 \leq \sigma^2;
  • (H3) Robbins–Monro \sum \eta_k = \infty, \sum \eta_k^2 < \infty for decreasing steps.

Theorem 5.2 — What can be proved simply (proof) Let f be convex L-smooth, (H1)–(H2), constant step \eta \leq 1/L. Then

Key result — SGD at constant step \mathbb{E}\big[f(x_{k+1})\big] \;\leq\; \mathbb{E}\big[f(x_k)\big] - \frac{\eta}{2}\,\mathbb{E}\|\nabla f(x_k)\|^2 + \frac{\eta^2 L \sigma^2}{2}.

Consequences:

  1. the gradients become small on average: \liminf \mathbb{E}\|\nabla f(x_k)\|^2 \leq L\sigma^2\eta ;
  2. if moreover f is \mu-strongly convex, at constant step SGD converges to a neighborhood of the solution, not to the solution (exercise 6): \limsup_k \mathbb{E}[f(x_k)] - f^\star \leq \frac{\eta L\sigma^2}{2\mu} = O(\eta\sigma^2).

Proof. Conditionally on x_k, the mean step equals -\eta\nabla f(x_k) (unbiasedness) and the noise \zeta_k = g_k - \nabla f(x_k) is centered. The descent lemma 2.1 applied to x_k - \eta g_k, then expanding the squares: \mathbb{E}_k[f(x_{k+1})] \leq f(x_k) - \eta\big(1 - \tfrac{L\eta}{2}\big)\|\nabla f(x_k)\|^2 + \tfrac{L\eta^2}{2}\,\mathbb{E}_k\|\zeta_k\|^2 \leq f(x_k) - \tfrac{\eta}{2}\|\nabla f(x_k)\|^2 + \tfrac{L\eta^2\sigma^2}{2}. Consequence 1 follows by summing and using the bounded decrease of the errors. Consequence 2 injects the Polyak–Łojasiewicz inequality of ch. 2, which strong convexity provides, and takes the fixed point of the resulting recursion. ∎

Regime Setting Speed Destination
decreasing \eta_k \sim 1/\sqrt{k}, averaged iterate convex; violates (H3), since \sum 1/k = \infty O(1/\sqrt{k}) on the values converges in value
decreasing \eta_k \sim 1/(\mu k) strongly convex; satisfies (H3) O(1/k) converges to x^\star
constant \eta practice (deep learning) linear until the plateau neighborhood O(\eta\sigma^2)
constant + averaging (Polyak–Ruppert), \bar{x}_k = \frac{1}{k}\sum x_j least squares O(1/k), statistically optimal converges to x^\star; otherwise to a point at distance O(\eta) (ch. 11)

Example 5.3 — The plateau computed exactly in one dimension Take f(x) = \tfrac12 x^2 (so L = \mu = 1) and a stochastic gradient g_k = x_k + \xi_k, where the noises \xi_k are independent, centred, of variance \sigma^2. Constant-step SGD reads x_{k+1} = (1 - \eta)\,x_k - \eta\,\xi_k . Taking the expectation of the square, and using that \xi_k is independent of x_k: \mathbb{E}[x_{k+1}^2] = (1-\eta)^2\,\mathbb{E}[x_k^2] + \eta^2\sigma^2. For 0 < \eta < 2 this linear recursion converges to its fixed point s = \eta^2\sigma^2/(1 - (1-\eta)^2) = \eta\sigma^2/(2 - \eta). Hence, for small \eta, \mathbb{E}[f(x_k)] \to \frac{\eta\sigma^2}{2(2-\eta)} \approx \frac{\eta\sigma^2}{4} : the plateau is proportional to the step, as theorem 5.2 announced (exercise 6 gives the general bound \frac{\eta L\sigma^2}{2\mu}, here \frac{\eta\sigma^2}{2}, larger by a factor of two only).

The transient, on the other hand, decays like (1-\eta)^{2k}: halving the step halves the plateau but doubles the number of iterations needed to reach it. Decreasing step schedules are the systematic way out of this trade-off.

Minibatching: buying variance with compute A mini-batch B of size b replaces g_k with the average over B: the variance drops to \sigma^2/b (independent draws), the cost rises to b gradients.

At a fixed compute budget, large b = less noise but fewer steps — the optimal trade-off depends on the regime: in the convex case, steps of modest size b often dominate (Bottou–Curtis–Nocedal 2018, §5.3); in deep learning, very large batches require correcting the step (LARS, ch. 10). Hence the question of the next chapter: can we kill the variance without paying b or n at every step?

Proposition 5.4 — Noise is not (only) an evil The stationary regime O(\eta\sigma^2) of theorem 5.2 has a positive side: the fluctuations around the minimum sweep the “passes” of the landscape and experience (see the Deep Learning module, ch. 3) shows that the “flat” minima found by SGD often generalize better than the narrow valleys reached by deterministic methods. The very sigma² that sets the stationary error acts as an implicit regularizer — an active research theme (see ch. 11, A. Dieuleveut’s work on constant-step SGD).

import numpy as np
rng = np.random.default_rng(1)
n, d = 20_000, 50
X = rng.normal(size=(n, d)) / np.sqrt(d)
y = (X @ rng.normal(size=d) + 0.3*rng.normal(size=n) > 0).astype(float)  # labels in {0, 1}

def sgd_logreg(eta, epochs=20, b=32):
    w = np.zeros(d); losses = []
    sig = lambda z: 1/(1+np.exp(-z))
    for ep in range(epochs):
        idx = rng.permutation(n)
        for s in range(0, n, b):
            B = idx[s:s+b]
            p = sig(X[B] @ w)
            g = X[B].T @ (p - y[B]) / b      # mini-batch gradient
            w = w - eta * g
        losses.append(np.mean(np.logaddexp(0, -(2*y-1)*(X@w))))  # full training risk
    return losses

# here L ~ 0.005 (features scaled by 1/sqrt(d)): all three steps are below 1/L
for eta in (0.1, 1.0, 100.0):
    print(eta, "->", sgd_logreg(eta)[-1])
# observed (optimal risk 0.200): 0.255 (too small, still descending),
# 0.201 (near the optimum), 0.26 (noisy plateau: the eta*sigma^2 term)

SGD without convexity: approximate stationary points

Neural network losses are not convex, so the convex rates above do not apply to them. What remains provable is weaker but useful: SGD finds a point where the gradient is small. The inequality of theorem 5.2 never used convexity — only L-smoothness, unbiasedness and bounded variance — so it can be summed directly.

Theorem 5.5 — Non-convex SGD (Ghadimi–Lan 2013, proved) Let f be L-smooth (not necessarily convex) and bounded below by f_{\inf}, let (H1)–(H2) hold and set \Delta = f(x_0) - f_{\inf}. With a constant step \eta \leq 1/L, \frac{1}{K}\sum_{k=0}^{K-1} \mathbb{E}\|\nabla f(x_k)\|^2 \;\leq\; \frac{2\Delta}{\eta K} + \eta L \sigma^2. With \eta = \min\big(1/L,\ \sqrt{2\Delta/(L\sigma^2 K)}\big), the right-hand side is at most 2\sqrt{2\Delta L\sigma^2/K} when the second term of the minimum is the active one: an iterate drawn uniformly among x_0, \dots, x_{K-1} has \mathbb{E}\|\nabla f\|^2 = O(1/\sqrt{K}).

Proof. Take the expectation of the inequality of theorem 5.2: \mathbb{E}f(x_{k+1}) \leq \mathbb{E}f(x_k) - \frac{\eta}{2}\mathbb{E}\|\nabla f(x_k)\|^2 + \frac{L\eta^2\sigma^2}{2}. Summing over k = 0, \dots, K-1, the values telescope: \frac{\eta}{2}\sum_{k<K}\mathbb{E}\|\nabla f(x_k)\|^2 \leq f(x_0) - \mathbb{E}f(x_K) + \frac{KL\eta^2\sigma^2}{2} \leq \Delta + \frac{KL\eta^2\sigma^2}{2}, since f(x_K) \geq f_{\inf}. Dividing by K\eta/2 gives the bound. For the step choice, \eta = \sqrt{2\Delta/(L\sigma^2K)} makes the two terms equal, each to \sqrt{2\Delta L\sigma^2/K}. ∎

Example 5.6 — Reading the non-convex bound Take \Delta = 1, L = 10, \sigma^2 = 1 and K = 10^4 steps. The tuned step is \eta = \sqrt{2/(10 \cdot 10^4)} \approx 4.5 \times 10^{-3}, below 1/L = 0.1, and the bound on the average squared gradient norm is 2\sqrt{2 \cdot 10/10^4} \approx 0.089 . Dividing this bound by 10 requires 100 times more steps.

Two cautions: the guarantee is on the average (or on a randomly chosen iterate), not on the last one; and a small gradient certifies a stationary point, which may be a saddle point or a poor local minimum. Chapter 10 discusses why, for neural networks, this weak guarantee is nevertheless what one observes in practice.

6. Variance reduction: SAGA and SVRG

This chapter removes the plateau of constant-step SGD without paying a full gradient at every step. Between the “complete but expensive” and the “stochastic but noisy” gradient, a third way: keep memory of past gradients to build an unbiased estimator whose variance vanishes by itself.

Definition 6.1 — SAGA (Defazio, Bach, Lacoste-Julien, 2014) One maintains a table \phi_i \approx \nabla f_i(x) of the latest gradient computed for each term, and \bar\phi = \frac{1}{n}\sum_i \phi_i. At each iteration, draw i and step with the stored \phi_i and \bar\phi: x_{k+1} = x_k - \eta\Big(\nabla f_i(x_k) - \phi_i + \bar\phi\Big); only then set \phi_i \leftarrow \nabla f_i(x_k) and update \bar\phi. The estimator is unbiased, because the stored table does not depend on the current draw; updating the table first would cancel \nabla f_i(x_k) - \phi_i and leave the biased step -\eta\bar\phi. Its variance is at most \frac{1}{n}\sum_i \|\nabla f_i(x_k) - \phi_i\|^2 \to 0 at convergence — instead of SGD’s permanent \sigma^2.

Definition 6.2 — SVRG (Johnson–Zhang, 2013) Without a table: every m steps, recompute a full gradient \tilde\nabla = \nabla f(\tilde{x}) at a “viewpoint” \tilde x (snapshot), then use x_{k+1} = x_k - \eta\Big(\nabla f_i(x_k) - \nabla f_i(\tilde x) + \tilde\nabla\Big). Also unbiased; variance \propto \|\nabla f_i(x_k) - \nabla f_i(\tilde x)\|^2, small when x_k stays near the snapshot. Memory cost: O(d) — the big industrial argument.

Theorem 6.3 — Linear convergence (statement, sketch) For f = \frac{1}{n}\sum f_i \mu-strongly convex, each f_i L-smooth, SAGA and SVRG with step \eta \asymp 1/L converge linearly:

Key result — variance reduction \mathbb{E}\big[F(x_k) - F(x^\star)\big] \;\leq\; \Big(1 - c\,\min\Big(\frac{1}{n}, \frac{\mu}{L}\Big)\Big)^{k}\,\big(F(x_0)-F(x^\star)\big),

that is O\big((n + \kappa)\log\frac{1}{\varepsilon}\big) evaluations of individual gradients — versus O(n\kappa\log\frac{1}{\varepsilon}) for deterministic descent.

For n = 10^5 examples and \kappa = 10^3, this is 1.01 \times 10^5 against 10^8 gradient evaluations per factor e of accuracy: about a thousand times fewer.

Sketch. The proof couples two recurrences: the decrease in function value (as in ch. 2, via unbiasedness) and the decrease of the estimator’s variance (extra contraction provided by the table/snapshot); the variance becoming multiplicative, it converts SGD’s O(\eta\sigma^2) plateau into a geometric contraction. ∎

Method Gradient/iteration Memory Evaluations for \varepsilon (strongly convex)
GD (ch. 2) n O(d) O(n\,\kappa \log 1/\varepsilon)
AGD (ch. 3) n O(d) O(n\,\sqrt{\kappa} \log 1/\varepsilon)
SGD (ch. 5) 1 O(d) O\big(\sigma^2/(\mu^2\varepsilon)\big) — not linear
SAGA / SVRG (this ch.) 1 (+n every m) O(nd) / O(d) O\big((n+\kappa)\log 1/\varepsilon\big)
SVRG + acceleration 1 O(d) O\big(n + \sqrt{n\kappa}\big)\log 1/\varepsilon — optimal

Where theory stops (and deep learning begins) In deep learning, f_i is not convex, the SAGA table explodes (n gradient-sized models), and SGD noise is an ally (prop. 5.4): strict variance reduction is little used there. But the structure of the trade-off — variance vs cost per iteration — governs the batch choices, step schedules and Adam variants (ch. 10). Convex theory is the compass, not the territory.

7. Newton and quasi-Newton

First-order methods pay for the condition number \kappa; this chapter buys second-order information (the Hessian) to remove it. The reward is quadratic local convergence — the number of correct digits doubles at every iteration — and the price is the cost of each iteration.

Theorem 7.1 — Local quadratic convergence (proved) Let f be twice differentiable, \mu I \preceq \nabla^2 f(x) \preceq LI everywhere (f therefore strongly convex), Hessian M-Lipschitz. Newton’s method x_{k+1} = x_k - \nabla^2 f(x_k)^{-1} \nabla f(x_k) satisfies, as soon as \|x_0 - x^\star\| \leq \mu/M:

Key result — quadratic convergence of Newton’s method \|x_{k+1} - x^\star\| \;\leq\; \frac{M}{2\mu}\,\|x_k - x^\star\|^2.

Proof. Write e_k = x_k - x^\star and expand \nabla f at x_k around x^\star (where \nabla f(x^\star) = 0): 0 = \nabla f(x^\star) = \nabla f(x_k) - \int_0^1 \nabla^2 f(x^\star + s e_k)\, e_k \, ds \;\Rightarrow\; \nabla f(x_k) = H_k e_k - \rho_k,\quad \|\rho_k\| \leq \frac{M}{2}\|e_k\|^2, where H_k = \nabla^2 f(x_k) and \rho_k = \int_0^1 (H_k - \nabla^2 f(x^\star+se_k))e_k\,ds collects the Hessian gap (\leq M \|e_k\| in operator norm, hence the \tfrac{M}{2}\|e_k\|^2 after integration). Then e_{k+1} = e_k - H_k^{-1}\nabla f(x_k) = H_k^{-1}\rho_k \;\Rightarrow\; \|e_{k+1}\| \leq \|H_k^{-1}\| \,\frac{M}{2}\|e_k\|^2 \leq \frac{M}{2\mu}\|e_k\|^2. If \|e_0\| \leq \mu/M, the error at least halves at every step — and then decreases quadratically once below 1. ∎

The price to pay — and the workaround

GD / Nesterov Newton BFGS / L-BFGS
cost per iteration (dimension d) O(d) O(d^3) (factorization) O(d^2) / O(md), m \approx 10
information gradients full Hessian approximation from gradient differences
convergence global, linear/k^2 local quadratic superlinear (in practice: fast linear)
scale invariance no (suffers from \kappa) yes (affine invariant) almost

Newton is not global: far from the minimum, the direction can be bad — hence damped Newton (step by line search) and the “self-concordant” analysis (Nesterov–Nemirovski) which gives a globally convergent version; this is the heart of interior-point LP/QP solvers (the linear programs of the Responsible AI module, ch. 4, if you took it in P1).

Definition 7.2 — BFGS in three ideas

  1. Goal: replace \nabla^2 f with B_k \succ 0 updated at cost O(d^2).
  2. Secant equation: impose B_{k+1} s_k = y_k with s_k = x_{k+1}-x_k, y_k = \nabla f(x_{k+1})-\nabla f(x_k) — the only second-order information extractable from gradients.
  3. Rank-2 update (closest to B_k in the Frobenius sense under these constraints): B_{k+1} = B_k - \frac{B_k s_k s_k^\top B_k}{s_k^\top B_k s_k} + \frac{y_k y_k^\top}{y_k^\top s_k}.

L-BFGS stores only the last m pairs (s_k, y_k) and reconstructs the product B_k^{-1}\nabla f by recursion: it is the standard weapon for smooth convex losses in high dimension (and the default solver of scipy.optimize.minimize(method="L-BFGS-B")).

Example 7.3 — Quadratic speed, experienced Minimize f(x) = x\log x on x > 0, a convex function with f'(x) = \log x + 1 and f''(x) = 1/x; the minimizer is x^\star = 1/e \approx 0.367879. The Newton step simplifies to x_{k+1} = x_k - f'(x_k)/f''(x_k) = -x_k \log x_k . From x_0 = 0.5 the errors |x_k - x^\star| are 1.3 \times 10^{-1},\quad 2.1 \times 10^{-2},\quad 6.3 \times 10^{-4},\quad 5.4 \times 10^{-7},\quad 3.9 \times 10^{-13}: the exponent roughly doubles at each step.

The ratio |e_{k+1}|/e_k^2 settles at about 1.36, which is the constant |f^{(3)}(x^\star)|/(2f''(x^\star)) = e/2 predicted by a second-order expansion — the one-dimensional version of the constant M/(2\mu) of theorem 7.1. Exercise 8 shows the counter-example: when f''(x^\star) = 0, as for x^4, the convergence is only linear.

Common mistakes with Newton’s method

  1. Inverting the Hessian explicitly: one solves the linear system \nabla^2 f(x_k)\, d = -\nabla f(x_k) by a Cholesky factorization, which is cheaper and more stable.
  2. Using the full step far from the minimum: without a line search, Newton can diverge even on a strictly convex function (try f(x) = \sqrt{1 + x^2} from x_0 = 2: the iterates are x_{k+1} = -x_k^3).
  3. Applying it to a non-convex function without safeguard: where the Hessian has negative eigenvalues, the Newton direction can point uphill.

8. Constraints in machine learning

This chapter shows how to train a model that must satisfy requirements, not only minimize an average loss. A real specification reads “error rate \leq 5\,\% and demographic disparity \leq \delta and latency \leq 100 ms”. The average loss alone cannot express such requirements; constraints are needed — and hence the duality of ch. 0, applied.

Definition 8.1 — Learning under constraints \min_{\theta}\; \frac{1}{n}\sum_i \ell(h_\theta(x_i), y_i) \quad\text{subject to}\quad \frac{1}{n}\sum_i c_j(h_\theta(x_i), x_i) \leq 0, \quad j = 1, \dots, m. Examples: demographic parity (gap of positive rates between groups), memory/latency budget at inference, false-negative rate in health. The empirical Lagrangian \mathcal{L}(\theta,\lambda) and the dual \max_{\lambda \geq 0} d(\lambda) are formed as in ch. 0.

Proposition 8.2 — Three ways to handle a constraint (compared)

Technique Problem solved Advantage Limit
quadratic penalty \min f + \tfrac{\rho}{2}\|g(\theta)_+\|^2 simple, smooth residual violation O(1/\rho); \rho \to \infty stiffens the problem
projection (ch. 4) x_{k+1} = \Pi_\mathcal{C}(x_k - \eta\nabla f(x_k)) simple constraints (boxes, balls, simplices) requires an exact projection
primal-dual (Uzawa) \theta_{k+1} minimizes \mathcal{L}(\cdot, \lambda_k); \lambda_{k+1} = [\lambda_k + \rho\, g(\theta_{k+1})]_+ general constraints, learns the price \lambda two step sizes to tune

Theorem 8.3 — Projected gradient descent (proved) For f convex L-smooth and \mathcal{C} closed convex, the iteration x_{k+1} = \Pi_\mathcal{C}(x_k - \eta\nabla f(x_k)), \qquad \eta \leq 1/L, preserves the rates of ch. 2 (O(1/k), linear under strong convexity).

Proof. Projection lemma. For every y \in \mathcal{C}, \langle x - \Pi_\mathcal{C}(x),\, y - \Pi_\mathcal{C}(x)\rangle \leq 0 : otherwise the point \Pi_\mathcal{C}(x) + \varepsilon(y - \Pi_\mathcal{C}(x)) \in \mathcal{C} (by convexity) would be closer to x for small \varepsilon > 0 — contradicting the definition of the projection.

With p_k = x_k - \eta\nabla f(x_k) and x_{k+1} = \Pi_\mathcal{C}(p_k), the same computation as in theorem 2.2 applies, the extra cross term being precisely controlled by the lemma (taken at y = x^\star). ∎

Example 8.4 — Penalty and multiplier on the simplest constrained problem Minimize \tfrac12 x^2 subject to x \geq 1, i.e. g(x) = 1 - x \leq 0; the solution is x^\star = 1.

Penalty. Minimizing \tfrac12 x^2 + \tfrac{\rho}{2}(1 - x)_+^2 gives x_\rho = \frac{\rho}{1+\rho} : the constraint is violated by \frac{1}{1+\rho}, which vanishes only as \rho \to \infty — and the curvature 1 + \rho of the penalized function grows at the same time, so the problem becomes ill-conditioned.

Multiplier (Uzawa). The Lagrangian \tfrac12 x^2 + \lambda(1 - x) is minimized at x(\lambda) = \lambda, so the dual function is d(\lambda) = \lambda - \tfrac12\lambda^2, maximized at \lambda^\star = 1, \qquad d(\lambda^\star) = \tfrac12 = f(x^\star) : no duality gap, as theorem 0.2 predicts. The Uzawa update \lambda_{k+1} = [\lambda_k + \rho\,(1 - x(\lambda_k))]_+ = [(1-\rho)\lambda_k + \rho]_+ converges to \lambda^\star = 1 for any 0 < \rho < 2, the error being multiplied by |1 - \rho| at each step; at the limit the constraint holds exactly.

The multiplier \lambda^\star = 1 is also the price of the constraint: tightening it to x \geq 1 + \delta raises the optimal value by about \lambda^\star\delta = \delta.

Example 8.5 — SVM: the constraint that becomes a penalty, that becomes a dual Hard-margin SVM (see the Machine Learning module, ch. 3): \min \tfrac12\|w\|^2 subject to y_i w^\top x_i \geq 1.

  1. The Wolfe dual is \max_\alpha -\tfrac12\|X^\top(\alpha\odot y)\|^2 + \mathbf{1}^\top\alpha \quad \text{subject to} \quad \alpha \geq 0 , whose feasible set is the non-negative orthant. Its projection clips the negative entries to 0, so projected descent (theorem 8.3) applies directly. With a bias term b in the margins, the dual gains the constraint \alpha^\top y = 0; the soft-margin SVM adds \alpha_i \leq C, which makes the feasible set a box.
  2. The regularized primal (hinge): \min \tfrac1n\sum \max(0, 1 - y_i w^\top x_i) + \lambda\|w\|^2 is a special case of the f + g form of ch. 4 — this time with a non-smooth f, solved by the subgradient method (theorem 4.6) or through its dual.

Three chapters of the module, a single problem.

Beyond the empirical optimum: “PAC” constrained learning Satisfying the constraints on average over the training set does not guarantee they will hold in test. This is the question addressed by L. Chamon (ch. 11): do generalization guarantees exist for learning under requirements? Positive answer (in the PAC framework, under conditions); and the empirical dual approaches the population dual well (empirical duality gap zero under good assumptions). Until ch. 11, remember: duality is not a computational artifact — it is what makes requirements learnable.

Minimax optimization and saddle-point methods

The Lagrangian of definition 8.1 turns a constrained problem into a game: the learner minimizes over \theta while the multiplier maximizes over \lambda \geq 0. The same min–max structure appears elsewhere in AI: generative adversarial networks (\min over the generator, \max over the discriminator) and adversarial training: \min_\theta \mathbb{E}\max_{\|\delta\| \leq \epsilon}\ell(h_\theta(x + \delta), y). This section studies the algorithms for such problems and shows that they need more care than plain gradient descent.

Definition 8.6 — Saddle point, gradient descent–ascent For \mathcal{L}(x, y), convex in x and concave in y, a saddle point (x^\star, y^\star) satisfies \mathcal{L}(x^\star, y) \leq \mathcal{L}(x^\star, y^\star) \leq \mathcal{L}(x, y^\star) \quad \text{for all } x, y : no player gains by moving alone. On compact convex sets, the minimax theorem (von Neumann, Sion) guarantees \min_x\max_y \mathcal{L} = \max_y\min_x \mathcal{L}, the game version of strong duality (theorem 0.2).

Simultaneous gradient descent–ascent (GDA) updates x_{k+1} = x_k - \eta\nabla_x\mathcal{L}(x_k, y_k), \qquad y_{k+1} = y_k + \eta\nabla_y\mathcal{L}(x_k, y_k), with a projection when y is constrained (for multipliers, y \geq 0). The primal-dual methods of proposition 8.2 are of this type, with the primal step replaced by one gradient step.

Example 8.7 — The bilinear game: GDA spirals out, extragradient converges Take \mathcal{L}(x, y) = xy on \mathbb{R} \times \mathbb{R}; its unique saddle point is (0, 0).

GDA gives x_{k+1} = x_k - \eta y_k and y_{k+1} = y_k + \eta x_k, so x_{k+1}^2 + y_{k+1}^2 = (1 + \eta^2)(x_k^2 + y_k^2) : for every step size the iterates turn around the saddle point and move away from it.

The extragradient method first takes a trial step, \tilde x = x_k - \eta y_k and \tilde y = y_k + \eta x_k, then updates from the original point with the gradient evaluated at the trial point: x_{k+1} = x_k - \eta\tilde y = (1 - \eta^2)x_k - \eta y_k, \qquad y_{k+1} = y_k + \eta\tilde x = \eta x_k + (1 - \eta^2)y_k. Now x_{k+1}^2 + y_{k+1}^2 = \big((1 - \eta^2)^2 + \eta^2\big)(x_k^2 + y_k^2) = (1 - \eta^2 + \eta^4)(x_k^2 + y_k^2), a factor strictly below 1 for 0 < \eta < 1: the iterates converge to the saddle point. The trial step anticipates the rotation that GDA undergoes.

Proposition 8.8 — What is known about saddle-point methods (statements)

  1. For \mathcal{L} convex-concave and G-Lipschitz on compact convex sets of diameter D, GDA with the step \eta \propto D/(G\sqrt{K}) and averaged iterates reaches a duality gap \max_y\mathcal{L}(\bar x_K, y) - \min_x\mathcal{L}(x, \bar y_K) = O(DG/\sqrt{K}) — the subgradient rate of theorem 4.6, the averaging being necessary (example 8.7 shows that the last iterate can diverge).
  2. If the gradient of \mathcal{L} is moreover L-Lipschitz, extragradient (the mirror-prox method of Nemirovski, 2004) with step 1/L reaches O(LD^2/K) for the averaged iterates.
  3. Without convexity-concavity, as in GANs, there is no general guarantee: GDA can cycle or diverge, which is one reason why GAN training is notoriously unstable.

9. Hyperparameter optimization

This chapter optimizes the quantities that the previous chapters took as given. The step \eta, the penalty \lambda, the batch size, the learning rate schedule: so many hyperparameters that the module has so far treated as given. Yet experience shows they are often worth more performance points than the choice of algorithm itself. The task is to optimize the optimizer itself.

Definition 9.1 — The problem (and why it is hard) \max_{h \in \mathcal{H}}\; v(h), \qquad v(h) = \text{validation score of a model trained with } h, an expensive function (each evaluation = one training run), noisy, non-convex, with no gradient available. Typically 5 to 50 dimensions, a budget of 10 to 1,000 evaluations. This is the territory of Bayesian derivative-free optimization.

Proposition 9.2 — Grid vs random (Bergstra–Bengio, argument) With a budget of B trials and p “important” hyperparameters out of d: the grid explores B^{1/d} values per dimension, random sampling explores B per dimension (but only once per draw).

If only p \ll d parameters really matter, random search hits a good combination on those p with much higher probability: in a grid, every “good” cell on the p useful axes is duplicated across the d-p useless ones — a wasted budget.

Proof. Model: a cell is “good” if its coordinates on the p useful axes are good, probability q^p per random draw (q = fraction of good values per axis) — after B draws, the probability of touching none: (1-q^p)^B . In a regular grid of m = B^{1/d} values per axis: the number of combinations explored on the useful axes is m^p = B^{p/d} \ll B . As soon as p < d, B^{p/d} < B: the grid visits fewer useful regions at equal budget. ∎

Example 9.3 — The numbers for 64 trials Two hyperparameters, of which only the learning rate matters, and good values occupying 5\% of its range (q = 0.05).

  • Grid. A grid of 8 \times 8 = 64 trials tests only 8 distinct learning rates; even with a random offset, a grid of 8 equally spaced points hits an interval of length 0.05 with probability 8 \times 0.05 = 0.4, so it misses the good region with probability 0.6.
  • Random. Sixty-four random trials test 64 distinct learning rates and miss with probability 0.95^{64} \approx 0.04.

Same budget, fifteen times fewer failures.

Definition 9.4 — Bayesian optimization (GP-EI)

  1. Model: v \sim \mathrm{GP}(0, k) over \mathcal{H}; after k evaluations, Gaussian predictions (\mu_k(h), \sigma_k(h)) at every point.
  2. Expected improvement acquisition: with v_k^\star = \max_j v(h_j), \mathrm{EI}_k(h) = \mathbb{E}\big[(v(h) - v_k^\star)_+\big] = (\mu_k(h) - v_k^\star)\,\Phi(z_k(h)) + \sigma_k(h)\,\varphi(z_k(h)), \quad z_k = \frac{\mu_k - v_k^\star}{\sigma_k}.
  3. Loop: evaluate h_{k+1} = \arg\max_h \mathrm{EI}_k(h), update the GP.

The closed-form formula shows the exploitation/exploration mechanics: \mathrm{EI} grows when \mu exceeds the record (exploit) and when \sigma is large (explore).

Multi-fidelity: Hyperband, pragmatism When the evaluation has a “quality setting” (epochs, data subsample), launching many configurations cheaply and only pursuing the promising ones often dominates pure GP: this is Successive Halving and Hyperband (Li et al., 2017), ubiquitous in practice (optuna, ray tune). The practitioner’s reference trio: random to scout, Hyperband to dig, GP-EI for the 5–10 truly sensitive parameters.

import numpy as np
rng = np.random.default_rng(0)
def train_score(lr, lam, epochs=30):          # proxy: linear reg model
    # ... real training replaced by a rugged function
    peak = 0.92 - 0.4*np.abs(np.log10(lr) + 1.5) - 0.15*np.log10(1+lam)
    return peak + 0.02*np.sin(10*lr) + 0.01*rng.standard_normal()

best_grid = max(train_score(10**e, 10**-l)
                for e in np.linspace(-4, -1, 8) for l in np.linspace(0, 3, 8))
best_rand = max(train_score(10**rng.uniform(-4, -1), 10**-rng.uniform(0, 3))
                for _ in range(64))           # same budget: 64 trials
print("grid:", round(best_grid, 4), "random:", round(best_rand, 4))
# on this type of landscape (few sensitive parameters), random almost always wins

10. Optimizing the training of networks

This chapter confronts the module with its main application. Almost everything so far assumed convexity, and training a network is not convex. Yet the recipes of deep learning are literally the objects of the previous chapters, transplanted — with adaptations that non-convexity demands.

What survives, what breaks

Module object (convex) Deep learning transplant Status
gradient descent (ch. 2) backprop + SGD (see Deep Learning, ch. 2–3) works; no global guarantee
momentum/Nesterov (ch. 3) SGD+momentum 0.9 empirically: yes, big gains
rate \kappa, linear convergence (ch. 2–3) non-convex landscape: plateaus, passes, valleys replaced by heuristics (warmup, cosine)
proximal/ISTA (ch. 4) weight decay, structured regularization first-order analogue for \ell_2 (AdamW, recall 10.1)
SGD: variance (ch. 5) batch size, grad clipping strong analogy, partial theory
hyperparameters (ch. 9) learning rate = hyperparameter #1 identical

Recall 10.1 — Adam and AdamW (taught in Deep Learning, sections 3.3 and 3.6), read with the module’s tools

Adam (Kingma–Ba, 2015) accumulates two exponential moments of the stochastic gradient g_k: m_k = \beta_1 m_{k-1} + (1-\beta_1)g_k, \qquad v_k = \beta_2 v_{k-1} + (1-\beta_2)g_k^2, and updates x_{k+1} = x_k - \eta\, \hat m_k / (\sqrt{\hat v_k} + \varepsilon).

“Module” reading:

  • m_k is heavy-ball momentum (ch. 3), an exponential average of past gradients; the Nesterov variant is NAdam;
  • 1/\sqrt{v_k} is a per-coordinate step adapted to the observed gradient scale (ch. 5: the noise is damped, not removed);
  • the bias correction \hat\cdot fixes the initialization of the moments at zero.

AdamW (Loshchilov–Hutter, 2019) takes the weight decay out of the gradient: the shrinkage x \leftarrow (1-\eta\lambda)x is applied separately, outside the adaptive scaling. It is an explicit gradient step on \tfrac{\lambda}{2}\|x\|^2, which agrees to first order in \eta\lambda with the proximal step x/(1+\eta\lambda) of ch. 4. Inside Adam, the same penalty would be divided by \sqrt{\hat v_k}, so the two choices give different trajectories.

Learning rate schedule: warmup, cosine, large batch The recipes are those of Deep Learning, section 3.4; what is new here is their reading through chapter 5.

  • Warmup: in the first iterations, the moments v_k are poorly estimated and the activations of deep networks poorly calibrated (variance that explodes with depth — see Deep Learning, ch. 1); ramping \eta linearly over 0.5–2% of the budget avoids destructive first steps.
  • Cosine / step decay: reducing \eta at the end of training shrinks the O(\eta\sigma^2) neighborhood of theorem 5.2 — exactly the Robbins–Monro logic, in practical form.
  • Large batch: with the batch multiplied by k, variance \sigma^2/k, but fewer steps per epoch; the “linear rule” (\eta \to k\eta) fails beyond a threshold; LARS/LAMB (You et al., 2017–2020) normalize the step by the per-layer weight/gradient norm — a heuristic, but the one that trained BERT and the LLMs.

Proposition 10.2 — Why it works anyway (overview) Three shock absorbers explain why non-convexity is not prohibitive:

  1. overparameterization: with more parameters than constraints, local minima become rare — all connected and of similar value;
  2. local PL inequality: along trajectories, an analogue of the Polyak–Łojasiewicz condition (ch. 2) often holds empirically, which restores local linear convergence “as if”;
  3. SGD noise: the stationary regime (prop. 5.4) sweeps narrow passes and selects flat minima that generalize better.

None of the three is a general theorem — this is precisely the research frontier of the field. Optional reading: the complexity of training seen from the efficiency side is ch. 8 of Deep Learning (P2 variant), a sibling option of the same group.

The engineer’s reflex sheet Diagnosing a diverging training run:

  1. \eta too large — divide by 10 (th. 5.2: the neighborhood grows as \eta\sigma^2);
  2. no warmup;
  3. faulty initialization/normalization (see Deep Learning, ch. 1);
  4. exploding gradient — clipping (g \mapsto \min(1, c/\|g\|)\,g, a projection of ch. 8 onto a ball).

A “flat” training run: step too small, batch too large, or missing momentum. These reflexes are chapters 2, 3 and 5.

Adaptive methods: AdaGrad, and what Adam changes

Recall 10.1 presented Adam as a recipe. Its theoretical ancestor is AdaGrad, for which a clean guarantee exists, and comparing the two shows what is gained and what is lost when the step adapts to the observed gradients.

Definition 10.3 — AdaGrad (Duchi, Hazan & Singer 2011) With g_k the stochastic gradient at step k, accumulate the squared gradients coordinate by coordinate, G_{k,i} = \sum_{j \leq k} g_{j,i}^2, and update

Key result — the AdaGrad step x_{k+1,i} = x_{k,i} - \frac{\eta}{\sqrt{G_{k,i}} + \varepsilon}\, g_{k,i}, \qquad i = 1, \dots, d.

Each coordinate receives its own step, large for coordinates whose gradients have been small or rare, small for those whose gradients have been large. RMSProp and Adam replace the sum G_{k,i} by an exponential moving average v_{k,i}, which forgets old gradients.

Theorem 10.4 — Regret of AdaGrad (Duchi, Hazan & Singer 2011, admitted) In online convex optimization (convex losses f_k revealed one at a time, iterates kept in a convex set of \ell_\infty-diameter D_\infty by projection), diagonal AdaGrad with \eta = D_\infty/\sqrt{2} satisfies \sum_{k=1}^{T}\big(f_k(x_k) - f_k(x^\star)\big) \;\leq\; \sqrt{2}\, D_\infty \sum_{i=1}^{d}\Big(\sum_{k=1}^{T} g_{k,i}^2\Big)^{1/2}. Averaging the iterates turns this into a stochastic convex rate \mathbb{E}f(\bar x_T) - f(x^\star) \leq \text{regret}/T.

In the worst case, the right-hand side is of order D_\infty G_\infty\, d\sqrt{T}, no better than tuned SGD; when most coordinates are rarely active (sparse features, as in text), it is much smaller — and it is obtained without knowing the scale of the gradients.

Example 10.5 — Scale-free steps In one dimension, suppose that every gradient equals the same constant c \neq 0. AdaGrad’s step at iteration k is, in absolute value, whatever c, \eta c/\sqrt{k c^2} = \eta/\sqrt{k} : multiplying the loss by 100 changes nothing, whereas plain SGD would need its step divided by 100. The method recovers by itself the decreasing 1/\sqrt{k} schedule of chapter 5.

For a coordinate that is non-zero only in a fraction p of the steps, with gradients of size c when active, G_{k} \approx p k c^2 and the effective step on active steps is \eta/\sqrt{pk}. Rare features get steps 1/\sqrt{p} times larger, which is why AdaGrad was first adopted for sparse linear models in language processing.

The price of forgetting: by replacing the sum with a moving average, Adam can lose this guarantee — Reddi, Kale & Kumar (ICLR 2018) build a simple convex online problem on which Adam does not converge, and propose AMSGrad, which uses the running maximum of v_k in the denominator so that the effective steps never increase.

Lab: diagnosing a diverging run

The reflex sheet above, tested on a small network. The code below trains a one-hidden-layer tanh network by full-batch gradient descent. It also measures the sharpness, the largest eigenvalue of the Hessian, by power iteration on gradient differences, without ever forming the Hessian.

Example 10.6 — Step, sharpness, clipping and warmup The one-dimensional analysis of chapter 2 predicts trouble above \eta = 2/\text{sharpness}, which here is about 0.74 at initialization.

import numpy as np
rng = np.random.default_rng(0)
n, d, h = 512, 10, 32                       # one-hidden-layer tanh network
X = rng.normal(size=(n, d))
y = np.tanh(X @ rng.normal(size=d) / 2)[:, None] + 0.1 * rng.normal(size=(n, 1))

def init():
    r = np.random.default_rng(1)
    return [r.normal(size=(d, h)) / np.sqrt(d), r.normal(size=(h, 1)) / np.sqrt(h)]

def loss_grad(P):
    W1, W2 = P
    H = np.tanh(X @ W1); err = H @ W2 - y
    g1 = X.T @ ((err @ W2.T) * (1 - H**2)) / n
    return 0.5 * np.mean(err**2), [g1, H.T @ err / n]

def sharpness(P, iters=50, eps=1e-4):
    """top Hessian eigenvalue by power iteration on gradient differences"""
    v = [np.random.default_rng(2).normal(size=p.shape) for p in P]
    g0 = loss_grad(P)[1]
    for _ in range(iters):
        nv = np.sqrt(sum((a**2).sum() for a in v)); v = [a / nv for a in v]
        g = loss_grad([p + eps * a for p, a in zip(P, v)])[1]
        Hv = [(a - b) / eps for a, b in zip(g, g0)]
        lam = sum((a * b).sum() for a, b in zip(Hv, v)); v = Hv
    return lam

def train(eta, steps=500, clip=None, warmup=0):
    P = init()
    for k in range(steps):
        loss, g = loss_grad(P)
        if not loss < 1e3:
            return f"diverged at step {k}"
        gn = np.sqrt(sum((a**2).sum() for a in g))
        if clip and gn > clip:                 # clipping = projection onto a ball (ch. 8)
            g = [a * clip / gn for a in g]
        lr = eta * min(1.0, (k + 1) / warmup) if warmup else eta
        P = [p - lr * a for p, a in zip(P, g)]
    return f"loss {loss:.4f}, sharpness {sharpness(P):.2f}"

print("threshold 2/sharpness at init:", round(2 / sharpness(init()), 2))   # 0.74
for eta in (0.5, 1.0, 1.5, 2.0):
    print(eta, "plain:", train(eta), "| clip:", train(eta, clip=1.0),
          "| warmup:", train(eta, warmup=100))

What the run shows:

  • \eta = 0.5, below the threshold, trains to a loss of about 0.004.
  • \eta = 1.0, above the threshold, still trains: the first steps carry the weights to a flatter region, where the sharpness settles near 2/\eta = 2.
  • \eta = 1.5 and \eta = 2 diverge within ten steps. Dividing the step (reflex 1) cures them.
  • Clipping the gradient norm at 1 (reflex 4) also saves both runs, and the final sharpness is again close to 2/\eta. This self-adjustment is the edge of stability of Cohen et al. (ICLR 2021).
  • A warmup of 100 steps only delays the divergence, to steps 95 and 115, when the step nears or reaches its full value. Warmup treats a badly estimated start, such as Adam’s moments; it does not cure a step that is too large for the region where training ends.

11. Course research notes — CMAP (Chamon, Dieuleveut)

The module’s two instructors are among the players in optimization theory for learning. Three axes: learning under constraints (Chamon), acceleration and the fine behavior of SGD (Dieuleveut).

Luiz Chamon (CMAP, X) — learning under requirements and duality

  • L. F. O. Chamon, A. Ribeiro, Probably Approximately Correct Constrained Learning, NeurIPS 2020 — the paper that founds the generalization theory of the constrained learning of ch. 8: under representativeness conditions, every PAC-learnable class remains so under constraints, with a dual that “learns” as well as the primal.
  • L. F. O. Chamon, S. Paternain, M. Calvo-Fullana, A. Ribeiro, The empirical duality gap of constrained statistical learning, 2020 — quantifies when the empirical dual approaches the population dual: the key for multipliers learned on the training set to remain valid in test (see note of ch. 8).
  • S. Paternain, L. Chamon, M. Calvo-Fullana, A. Ribeiro, Constrained Reinforcement Learning Has Zero Duality Gap, NeurIPS 2019 — extension of the “zero gap” to constrained control: the bridge toward the Reinforcement Learning module.

Proposed cross-cutting reading: apply ch. 8 to a fairness problem (Emerging ML module, ch. 6) while measuring the empirical duality gap of exercise 9.

Aymeric Dieuleveut (CMAP, X) — optimal speed and constant-step SGD

Proposed cross-cutting reading: connect ch. 5 to the Emerging ML module (ch. 0, SGD reminders) and to the Machine Learning module (ch. 4, massive data).

Exercises

  1. ★ Valley. For f(u,v)=\tfrac12(u^2+\kappa v^2), \kappa = 100, x_0 = (10, 1): compute the first three iterates of descent at step 1/L, plot the trajectory, and verify that the steep direction is canceled in one step while the flat direction decreases by 1 - 1/\kappa per step.

    Solution: \nabla f = (u, \kappa v), hence (10, 1) \to (9.9,\, 0) \to (9.801,\, 0) \to (9.703,\, 0) — v_1 = 0 but u_k = 10\,(1-1/\kappa)^k; to compare with Nesterov (\beta = \tfrac{1-1/\sqrt\kappa}{1+1/\sqrt\kappa}) which reaches the target accuracy in \sqrt\kappa steps.

  2. ★ ISTA/FISTA in practice. Take up the code of ch. 4: plot F(x_k)-F(x^\star) (reference: 5,000 FISTA iterations, as in the code) on a log scale for ISTA, FISTA and FISTA+adaptive restart (reset the momentum to zero when F(x_{k+1}) > F(x_k)). Measure the experimental slopes and compare with 1/k and 1/k^2.

    Expected: FISTA+restart beats FISTA as soon as the solution is sparse (local strong convexity).

  3. ★ Random search. Reproduce proposition 9.2: build a dummy function in d = 6 dimensions of which only p = 2 matter, compare a truncated exhaustive 8^6 grid at equal budget vs random draws, over 20 repetitions; plot the distribution of the best score.

    Then test skopt.gp_minimize (GP-EI) at small budget: when does it beat random?

  4. ★★ Optimal step on a quadratic. Show that for f(x) = \tfrac12 x^\top A x with eigenvalues in [\mu, L], the constant step minimizing the contraction factor \rho(\eta) = \max_i |1 - \eta\lambda_i| equals \eta = 2/(\mu+L) and gives \rho = \frac{\kappa-1}{\kappa+1} — in x, hence \big(\tfrac{\kappa-1}{\kappa+1}\big)^2 on the values of f.

    Verify that this factor equals 1 - \frac{2}{\kappa+1} and conclude that descent cannot beat O(\kappa) on this class.

  5. ★★ Soft thresholding. Prove the formula (use example 1.4) \mathrm{prox}_{\lambda|\cdot|}(z) = \mathrm{sign}(z)\max(|z|-\lambda, 0), then compute the \mathrm{prox} of the indicator of [a,b], of the \ell_2 ball, and of the probability simplex (algorithm of Duchi et al., 2008).

  6. ★★ SGD neighborhood. Prove consequence 2 of theorem 5.2: at constant step \eta, under strong convexity, \limsup \mathbb{E}[f(x_k)] - f^\star \leq \frac{\eta L\sigma^2}{2\mu}.

    Hint: combine theorem 5.2 with the Polyak–Łojasiewicz inequality f - f^\star \leq \frac{1}{2\mu}\|\nabla f\|^2 to get \mathbb{E}[f(x_{k+1})] - f^\star \leq (1 - \eta\mu)\big(\mathbb{E}[f(x_k)] - f^\star\big) + \frac{\eta^2 L\sigma^2}{2}, then take the fixed point of this recursion. Check the bound against the exact computation of example 5.3. Simulate with the code of ch. 5, at its steps \eta \in \{0.1; 1; 100\}.

  7. ★★ Minimum viable SAGA. Implement SAGA (table of n gradients) for \ell_2-regularized logistic regression, n = 1\,000, d = 50, \mu chosen so that \kappa = 100.

    Plot the variance of the estimator \|g_k - \nabla f(x_k)\|^2 along the iterations and compare it with that of SGD; verify the linear convergence of theorem 6.3 (slope in log).

    Pitfall: the average \bar\phi must be maintained incrementally, not recomputed.

  8. ★★ Quadratic Newton. For f(x) = \frac{x^4}{4} (convex, f'(x) = x^3, f''(x) = 3x^2): show that x_{k+1} = x_k - \tfrac{x_k}{3} = \tfrac23 x_k , a linear convergence, not a quadratic one — which assumption of theorem 7.1 fails at x^\star = 0?

    Then show that for f(x)=\frac{x^2}{2}+e^{-x} (minimizer x^\star \approx 0.567, the solution of x = e^{-x}) the convergence is quadratic once the iterate is close to x^\star.

    Compare scipy.optimize.minimize (Newton-CG, BFGS, L-BFGS-B) on the smoothed LASSO of ch. 4 in d = 200: iteration count, time, final accuracy.

  9. ★★ Constraints: penalty vs duality. Solve \min \tfrac12\|x\|^2 subject to Ax = b in two ways, then compare them.

      1. Quadratic penalty \tfrac{\rho}{2}\|Ax-b\|^2, \rho \to \infty.
      1. Uzawa \lambda_{k+1} = \lambda_k + \rho(Ax_{k+1}-b) with x_{k+1} minimizing the Lagrangian.
      1. Show that the penalized problem has Hessian I + \rho A^\top A, whose condition number is 1 + \rho\|A\|^2 when A has more columns than rows, while its violation \|Ax_\rho - b\| only decreases like O(1/\rho).
      1. Show that the dual function is concave with a \|A\|^2-Lipschitz gradient, so that Uzawa converges for 0 < \rho < 2/\|A\|^2 (example 8.4 is essentially the case A = 1, b = 1).

    Conclude on the superiority of the multiplier (which “remembers” the constraint) over the penalty (which forgets it).

Projects and assessment

The assessment tab (“Acquisition de l’UE”) of the SynapseS 2026–2027 sheet APM_52067_EP gives, in its section for the LLGA track, a single line: a “written final exam without calculator, one handwritten A4 sheet allowed and to be handed in with the exam” (our translation). That section shows no duration, resit rule, pass threshold or ECTS value; the sheet states resit rules only for other degrees. The unit’s grade format is a numerical mark out of 20. The exam proposal below keeps the stated format; its duration and questions are ours.

The projects are proposals of these notes, for practice or for a continuous-assessment part if the instructors choose to add one; they replace nothing on the sheet. They exercise objective O1 (ML and DL foundations) throughout and O7 (hands-on practice) in every subject, with O8 (trustworthy AI) and O4 (graphs) in group project 1 and O3 (large language models) in group project 2. Group project 1 rehearses, on a classifier, the stochastic primal–dual method that the optimization option of the end-of-year project Y1.3 applies to an exposure constraint on a ranking.

Solo projects

  1. [Solo · ≈ 20 h] Rates in the wild. Do the proved rates predict what one measures, and where do the gaps come from?
    • Implement: in NumPy, gradient descent, Nesterov with adaptive restart, ISTA, FISTA, the subgradient method, SGD, SAGA and SVRG; L-BFGS from scipy.optimize. The instances are ridge regressions with \kappa \in \{10, 10^2, 10^4\}, set by rescaling the features, a LASSO, and an \ell_2-regularized logistic regression.
    • Data: synthetic Gaussian designs, and the a9a version of UCI Adult (Kohavi, 1996) in the LIBSVM collection: 32,561 samples, 123 binary features.
    • Deliverables: code with a test that each method decreases its objective, a 5-page report with one log-scale plot per theorem tested, a 10-minute talk.
    • Chapters: ch. 2–7.
    • Success: the iterations needed to divide the error by 10^6 grow like \kappa for gradient descent and like \sqrt{\kappa} for Nesterov (log-log slopes 1 and 1/2, within 10 %); the gaps of ISTA and FISTA stay below the bounds of theorem 4.4 at every iteration; each other deviation (local strong convexity, constants, noise floor) is explained by a named result.
  2. [Solo · ≈ 20 h] Paper study: the non-convergence of Adam (Reddi, Kale & Kumar, ICLR 2018). When does an adaptive method fail on a convex problem, and does the fix matter in practice?
    • Paper: S. J. Reddi, S. Kale, S. Kumar, On the Convergence of Adam and Beyond, ICLR 2018.
    • Implement: AdaGrad (definition 10.3), RMSProp, Adam and AMSGrad from scratch. Reproduce the online counter-example of the paper’s theorem 1: on [-1, 1], a linear loss pays Cx once every three steps and -x otherwise, with C > 2, and Adam uses the theorem’s hyperparameters, \beta_1 = 0 and \beta_2 = 1/(1 + C^2). Then compare the four methods on the logistic regression of solo project 1 and on a small CNN trained on CIFAR-10 (Krizhevsky, 2009).
    • Deliverables: code, a 4-page report, a 10-minute talk.
    • Chapters: ch. 5, 10 (theorem 10.4, example 10.5).
    • Success: on the counter-example, Adam’s iterate goes to the worst point x = +1 while AdaGrad and AMSGrad reach the minimizer x = -1, with an average regret that vanishes only for them; a measured answer, over 3 seeds, on whether AMSGrad changes the test accuracy of the two real tasks.
  3. [Solo · ≈ 20 h] Games that spiral: gradient descent–ascent versus extragradient. When does a saddle-point method converge, and should one output the last iterate or the average?
    • Implement: simultaneous and alternating GDA, extragradient and optimistic GDA on the bilinear game of example 8.7 (unconstrained, then restricted to [-1, 1]^2 by projection), on the Lagrangian game of example 8.4, and on a 2-D GAN fitting a mixture of 8 Gaussians on a circle.
    • Paper: G. Gidel, H. Berard, G. Vignoud, P. Vincent, S. Lacoste-Julien, A Variational Inequality Perspective on Generative Adversarial Networks, ICLR 2019. The student reproduces its bilinear experiment, then applies its extragradient and averaging methods to the mixture.
    • Deliverables: code, a 4-page report with phase portraits, a 10-minute talk.
    • Chapters: ch. 0, 8 (definition 8.6, example 8.7, proposition 8.8).
    • Success: the measured growth factors on the bilinear game match 1 + \eta^2 and 1 - \eta^2 + \eta^4 to three digits; on the box, the duality gap |\bar x_K| + |\bar y_K| of the averaged GDA iterate decays at least like 1/\sqrt{K} (proposition 8.8) while the last iterate keeps cycling; the number of modes each method covers, over 5 seeds.

Group projects

  1. [Group of 3 · ≈ 30 h each] Fair classifiers by duality. Does a fairness constraint satisfied on the training set still hold on the test set, and which of penalty, Uzawa and stochastic primal–dual gets there best?
    • Implement: a classifier under a demographic-parity constraint, a gap of positive-prediction rates between two groups at most \delta (with a smooth surrogate of the rates), solved three ways (proposition 8.2): quadratic penalty, Uzawa with an exact inner minimization, and stochastic primal–dual with one SGD step per dual step.
    • Data: UCI Adult (sensitive attribute: sex) for logistic regression, and the Pokec-z social graph of Dai & Wang (WSDM 2021; sensitive attribute: region) for a GNN node classifier.
    • Paper: L. F. O. Chamon, A. Ribeiro, Probably Approximately Correct Constrained Learning, NeurIPS 2020 (ch. 11). The group measures the empirical duality gap and the train–test gap of the constraint that the paper bounds.
    • Split: member A the penalty and Uzawa solvers, with the duality-gap measurement; member B the stochastic primal–dual method and the train–test study; member C the GNN variant, built on Graph ML, ch. 5.
    • Deliverables: a repository, a 6-page report, a 15-minute talk.
    • Chapters: ch. 0, 5, 8, 11.
    • Success: a table of accuracy, train and test violation and empirical duality gap per method over 5 seeds; the multiplier \lambda^\star read as a price, the training loss saved per unit increase of \delta, and checked against a finite difference in \delta as in example 8.4.
  2. [Group of 3 · ≈ 30 h each] Anatomy of a transformer training run. Which results of the module explain the plateaus, the divergences and the noise floor of a real training run?
    • Implement: a decoder-only transformer of about 10 M parameters, trained on TinyStories (Eldan & Li, 2023) at a fixed token budget on a free GPU tier, with SGD + momentum, AdaGrad, Adam and AdamW (recall 10.1). The sweeps cover warmup length and cosine decay, batch size with the linear scaling rule, and gradient clipping; the sharpness of example 10.6 is logged along training.
    • Split: member A the optimizers and the weight-decay study; member B the schedules, batch sizes and clipping; member C a hyperparameter search, random search against Hyperband (ch. 9) at equal compute.
    • Deliverables: a repository with tracked runs, a 6-page report, a 15-minute talk, and an evidence-backed version of the reflex sheet of ch. 10.
    • Chapters: ch. 3, 5, 9, 10. It builds on Deep Learning, ch. 3 and 6 and prepares the pre-training chapter of Large Language Models.
    • Success: every reflex of the sheet is backed by one run that triggers the problem and one that cures it; the loss noise floor shrinks when the step decays, as theorem 5.2 predicts; random search and Hyperband are compared over at least 3 seeds.

Written exam (proposal)

Format: as in the LLGA section of the sheet’s assessment tab, a written final exam without calculator, with one handwritten A4 sheet allowed and handed in with the copy; the duration is not displayed, and 2 hours are proposed. Four exercises, 20 points.

  1. Question (5 points). Duality. (a) For \min f(x) subject to g_i(x) \leq 0, define the Lagrangian and the dual function, and prove weak duality. (b) State Slater’s condition and the KKT conditions. (c) For \min \tfrac12 x^2 subject to x \geq 1, compute the dual function and the optimal multiplier, and check the zero gap and complementary slackness.

    Expected:

    • (a) \mathcal{L} = f + \sum_i \lambda_i g_i and d(\lambda) = \inf_x \mathcal{L}(x, \lambda); for feasible x and \lambda \geq 0, \mathcal{L}(x, \lambda) \leq f(x), then take the infimum and the supremum (proposition 0.1) (2 points).
    • (b) A convex problem with a strictly feasible point has a zero gap and an attained dual (theorem 0.2); KKT: primal and dual feasibility, stationarity, complementary slackness (1.5 points).
    • (c) \mathcal{L} is minimized at x = \lambda, so the dual function is d(\lambda) = \lambda - \tfrac12\lambda^2, maximized at \lambda^\star = 1. Then d(\lambda^\star) = \tfrac12 = f(1): zero gap. The constraint is active at the solution, so complementary slackness holds with a positive multiplier (1.5 points).
  2. Question (6 points). Take f(u, v) = \tfrac12(u^2 + 25 v^2). (a) Give the constants of smoothness and strong convexity, and the condition number. (b) Run two steps of gradient descent at step 1/L from (1, 1). (c) Which constant step minimizes the contraction factor of exercise 4, and what is the factor? (d) Give the momentum coefficient \beta of definition 3.2. (e) About how many iterations divide the error by e^{10}, for gradient descent (theorem 2.3) and for the accelerated scheme?

    Expected:

    • (a) L = 25, \mu = 1, \kappa = 25 (1 point).
    • (b) With \nabla f = (u, 25v), the iterates are (0.96, 0), then (0.9216, 0): the steep direction is gone after one step (1.5 points).
    • (c) \eta = 2/(\mu + L) = 1/13, with factor (\kappa - 1)/(\kappa + 1) = 12/13 on both eigen-directions (1.5 points).
    • (d) \beta = (1 - 1/5)/(1 + 1/5) = 2/3 (1 point).
    • (e) e^{-k/\kappa} \leq e^{-10} gives k = 250; with the factor 1 - 1/\sqrt{\kappa} \leq e^{-1/5}, k = 50 is enough (1 point).
  3. Question (5 points). Let F be convex with subgradients bounded by G, x^\star a minimizer and R = \|x_0 - x^\star\|. Prove that the subgradient method at constant step \eta satisfies \min_{k < K} F(x_k) - F(x^\star) \leq \frac{R^2 + K\eta^2 G^2}{2\eta K}, choose \eta to get a 1/\sqrt{K} rate, and explain example 4.7.

    Expected:

    • Expand \|x_{k+1} - x^\star\|^2 and use the subgradient inequality, as in theorem 4.6 (2 points).
    • Telescope over k < K, drop the last distance, and bound the minimum by the average (1.5 points).
    • \eta = R/(G\sqrt{K}) gives RG/\sqrt{K} (1 point).
    • For a fixed step the bound tends to \eta G^2/2, here 0.15 for |x| with \eta = 0.3. The iterates of example 4.7 cycle at a minimum value of 0.1, under that floor, and never reach 0 (0.5 point).
  4. Question (4 points). Take \mathcal{L}(x, y) = xy. (a) Give its saddle point. (b) Show that simultaneous GDA multiplies x^2 + y^2 by 1 + \eta^2. (c) Show that extragradient multiplies it by 1 - \eta^2 + \eta^4, and give the steps for which it converges. (d) What does averaging change for GDA?

    Expected:

    • (a) (0, 0), since \mathcal{L}(0, y) = 0 = \mathcal{L}(x, 0) (0.5 point).
    • (b) With x_{k+1} = x_k - \eta y_k and y_{k+1} = y_k + \eta x_k, the cross terms cancel (1 point).
    • (c) The update of example 8.7 gives (1 - \eta^2)^2 + \eta^2, which is below 1 exactly when 0 < \eta < 1 (1.5 points).
    • (d) On compact sets, with a step of order 1/\sqrt{K}, the averaged iterates reach a duality gap O(1/\sqrt{K}) (proposition 8.8), although the last iterate spirals out (1 point).

Grading rubric (proposal)

Criterion Weight What earns the marks
Correctness of code and proofs 25 % each method is tested on an instance with a known solution; every proof step is justified
Rates against theory 25 % each measured rate is set against the theorem it tests, with slopes and constants; every gap is explained
Experimental protocol 15 % several seeds, equal compute budgets, baselines, reproducible runs
Report and figures 20 % 4–6 pages, log-scale plots with labelled axes, assumptions and limits stated
Talk and questions 15 % 10–15 minutes; every member can explain every part of the work

References