ML Systems Lab Open interactive version →
Advanced 45 min read newtonhessianl-bfgscurvaturequasi-newton

Second-Order Methods

Newton's method, why the Hessian is impractical, and when L-BFGS is used.

Gradient descent uses only the first derivative of the loss: which direction is downhill from here. It does not know how steep that downhill is or how quickly it levels off — it cannot see curvature.

This is why the learning rate must be tuned so carefully: it is a proxy for curvature information the optimizer does not have. Newton's method has that information. The Hessian H is the matrix of second derivatives — it encodes the curvature in every parameter direction simultaneously. Newton's step θ ← θ − H^{-1}·∇L is the exact minimizer of the local quadratic approximation of the loss. For a perfectly quadratic loss, one Newton step lands at the minimum. For smooth strongly convex functions, convergence is quadratic — the error roughly doubles the number of correct digits at each step.

The fundamental problem is scale: the Hessian of a network with n parameters is n×n. For n=10^6, the Hessian has 10^12 entries requiring 4 TB of memory, and inverting it requires 10^18 floating-point operations. At the compute capacity of a modern GPU (about 10^14 FLOP/s), one Newton step takes on the order of three hours — before any training has occurred. Quasi-Newton methods approximate the inverse Hessian from gradient information across recent steps rather than computing it exactly. L-BFGS builds a low-rank approximation using the last m gradient pairs at O(mn) cost. It is the right tool when n is small enough (below roughly 10^5 parameters) and full-batch gradient evaluation is affordable — scientific computing, physics simulations, hyperparameter optimization inner loops. At the scale of deep learning, it is not used in production because the cost of even an approximate Hessian exceeds the cost of many gradient steps.


Raw Newton overshoots: line search and trust regions

The clean "one step to the minimum" story only holds for a *truly quadratic* loss. Real losses aren't quadratic, so the full Newton step H⁻¹∇L can badly overshoot — the local quadratic model is only accurate near the current point. So practical second-order methods never take the raw step. They add a line search (compute the Newton *direction*, then search along it for a step length that actually decreases the loss) or a trust region (only trust the quadratic model within a bounded radius, and cap the step to that region, shrinking it when the model proves inaccurate). Newton without damping or line search is a good way to diverge.


The Hessian can point the wrong way

Newton's method assumes the Hessian is positive definite (the loss curves *up* in every direction, a bowl). In the non-convex landscapes of deep nets that's often false: at a saddle point the Hessian is indefinite (curves up some ways, down others). Then H⁻¹∇L can point *toward* the saddle or even a local *maximum* rather than a minimum — the raw Newton step actively moves the wrong way. This is why non-convex second-order methods must modify the Hessian (add damping λI to make it positive definite, or flip negative curvature) before inverting. Raw Newton is a convex-optimisation tool.


What ML actually uses: Gauss-Newton and the Fisher

Because the true Hessian is expensive *and* can be indefinite, ML rarely uses it directly. Two better-behaved substitutes dominate. The Gauss-Newton matrix approximates the Hessian using only first-derivative (Jacobian) information and is guaranteed positive semi-definite — no wrong-way steps. The closely-related Fisher information matrix underlies natural gradient methods (and K-FAC), which precondition the gradient by the Fisher instead of the Hessian. Both give curvature-aware steps without the true Hessian's indefiniteness — which is why "second-order in ML" almost always means Gauss-Newton / Fisher / natural-gradient, not literal Newton.


Where L-BFGS shines — and where it doesn't

Sharpen the use-map. L-BFGS is excellent for small, deterministic, full-batch objectives: classical ML models (logistic regression, CRFs), scientific/physics optimisation, style-transfer-style problems, and small full-batch fine-tuning where you can afford exact gradients. It is a poor fit for noisy, large-scale mini-batch deep learning, because batch noise corrupts the gradient-difference curvature estimates (they can go indefinite and point uphill), and full-batch gradients over millions of examples cost as much as many SGD steps. Rule of thumb: L-BFGS when the gradient is exact and parameters are modest; SGD/Adam when the gradient is a noisy mini-batch estimate.


Adam is not literally diagonal Newton

A common over-statement: "Adam is a diagonal approximation to the Hessian." Be precise — Adam divides by the running second moment of the *gradients* (E[g²]), which is *not* the diagonal of the Hessian (that would be second *derivatives*). It's better described as curvature-*like* adaptive preconditioning: dividing by the gradient's recent magnitude gives each parameter its own effective step, which *behaves* somewhat like inverse-curvature scaling but isn't derived from the Hessian. Useful intuition, imprecise identity — worth stating correctly in an interview.


The optimizer decision tree (and a precision note)

Choosing among them comes down to a few axes: dataset/parameter size, gradient noise (batch vs full-batch), and objective stability. AdamW — the default for large, noisy, mini-batch deep learning (transformers, most nets). SGD+momentum — competitive/better in well-tuned vision/CNN settings. L-BFGS — small-to-medium, full-batch, deterministic objectives and classical ML. Newton / IRLS — very small, convex, well-conditioned problems (IRLS is Newton's method for logistic-regression-style GLMs). K-FAC / natural gradient — when the per-step second-order gain outweighs 2–5× overhead, mostly research. (One precision footnote: the "4 TB Hessian" figure assumes float32; in float64 it's 8 TB — the exact number depends on precision, but the point that it's hopeless stands either way.)

Key points

Takeaway

Second-order methods would give optimal steps if you could afford them. Newton's method converges in a handful of steps for well-conditioned problems. The Hessian for a million-parameter network requires 4 TB of memory and 10^18 operations to invert — which is why we use gradient descent. Every adaptive optimizer from AdaGrad to Adam is a practical approximation to diagonal Newton steps, not a theoretical preference for first-order methods.

Recap

Check your understanding

Q1. A 3-parameter loss function has Hessian H = [[4, 0, 0], [0, 1, 0], [0, 0, 100]] and gradient g = [2, 1, 10]. Compare the gradient descent step (α=0.01) to the Newton step. What does this reveal about condition number?

Q2. Why does L-BFGS require full-batch gradients rather than mini-batch gradients? What happens when you try to use mini-batch gradients with L-BFGS?

Q3. K-FAC achieves faster convergence in steps than SGD for ResNet training. Yet practitioners still use SGD for production ImageNet training. Why?

Q4. You implement raw Newton's method (θ ← θ − H⁻¹∇L) on a non-convex neural-net loss and it sometimes moves the loss *up* or diverges. Which two of the following correctly explain why, and how each is addressed?

Q5. An interviewer says "Adam is basically a diagonal approximation to Newton's method." How would you make that statement more precise?

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →