Skip to content
AI.info

Mathematical foundations

Gradient Methods, Conditioning, and Preconditioning

Connect gradient descent, step size, curvature, condition numbers, momentum, and preconditioning through the geometry of quadratic objectives.

By the end you can

Visual

Gradient descent on an ellipsoidal bowl

For f(x)=½xᵀHx with positive definite H, each Hessian eigen-direction evolves on its own. The error along the eigenvector belonging to λᵢ is multiplied by 1−ηλᵢ at every step, so the method converges along that direction only while that factor stays inside the convergent range. That puts a ceiling on η, set by the largest eigenvalue, at the curvature 2/(step size).

The ceiling is not a safety margin that real training respects from below. Full-batch gradient descent on neural networks has been measured against it, by Cohen and four co-authors, at ICLR in 2021. The sharpness climbs until it reaches the threshold and then balances there: “In this regime, the maximum eigenvalue of the training loss Hessian hovers just above the numerical value 2 / (step size), and the training loss behaves non-monotonically over short timescales, yet consistently decreases over long timescales.”

A separate group restated the same regime independently at ICML in 2022 — “sharpness stabilizes around 2/LR and loss goes up and down across iterations, yet still with an overall downward trend” — and proved that two GD variants provably enter it.

The quadratic model is not being contradicted here. Training walks to the edge the quadratic model draws and then hovers just above it, where the quadratic model predicts divergence and the loss keeps falling anyway.

FigureProcess · 5 steps
  1. 1. Decompose the error

    Express x in Hessian eigenvector coordinates.

  2. 2. Apply the update

    Each coordinate is multiplied by 1−ηλᵢ.

  3. 3. Check stability

    All factors must remain within the convergent range.

  4. 4. Compare rates

    Small and large eigenvalues decay at different speeds.

  5. 5. Improve geometry

    Rescale or precondition to reduce the spread.

The Hessian spectrum predicts stability and convergence speed, and real training runs sit just above the threshold it predicts rather than safely below it.

The negative gradient is local, not strategic

Gradient descent updates x ← x−η∇f(x). The gradient gives the steepest local Euclidean decrease, while η decides how far the method trusts that direction. On a curved landscape, the best step can differ sharply across directions. A single scalar learning rate must compromise between steep and shallow axes. Conditioning measures this imbalance. Poor conditioning creates zig-zag paths, slow progress, and sensitivity to step size even on a simple convex quadratic.

The price of that compromise has been measured, and it is not small. Take a large image classifier, leave the architecture and the objective alone, and change only the scale of the inputs each layer sees, by normalizing them. Ioffe and Szegedy did that in 2015, and their abstract reports the result: “Applied to a state-of-the-art image classification model, Batch Normalization achieves the same accuracy with 14 times fewer training steps, and beats the original model by a significant margin.” An ensemble of batch-normalized networks reached 4.9% top-5 validation error on ImageNet, and 4.8% test error, given as 4.82% in the ICML version.

The same abstract records the mechanical symptom. The method “allows us to use much higher learning rates” — which is what a step size looks like once it is no longer held hostage by the steepest direction in the problem.

Ioffe and Szegedy attributed the gain to reduced internal covariate shift. A paper at NeurIPS in 2018 showed that explanation does not hold, and that batch normalization instead makes the optimization landscape significantly smoother. The fourteenfold saving stands under either reading. What it buys is geometry, not capacity.

Many optimization difficulties come from mismatched geometry rather than mysterious nonconvexity.

Case

Polyak's heavy ball, 1964, and the speedup measured in the condition number

Momentum is old. Boris Polyak published the heavy-ball method in 1964. Four authors restated the result at ICML in 2013, and stated the size of the gain in the only unit that matters here: “Polyak (1964) showed that CM can considerably accelerate convergence to a local minimum, requiring √R-times fewer iterations than steepest descent to reach the same level of accuracy, where R is the condition number of the curvature at the minimum and µ is set to (√R − 1)/(√R + 1)”.

Both quantities are functions of the conditioning alone, and they move together. At R = 10 the saving is 3.2× and the constant that earns it is 0.519. At R = 100, 10.0× and 0.818. At R = 1,000, 31.6× and 0.939. At R = 10,000, 100.0× and 0.980 — the constant climbing toward 1 without ever reaching it.

A 2024 paper by Wei and Chen writes the heavy-ball momentum parameter as β=((√L−√μ)/(√L+√μ))², the square of the µ quoted above, with the accelerated local rate given in terms of √ρ where ρ=μ/L=1/κ. Conditioning is not a footnote about speed here. It is the quantity in which the acceleration is measured, which is why rescaling the variables and adding momentum are different interventions with a similar symptom.

One caution: this is a result about a quadratic model of the curvature at the minimum, not a measured training run, so its speedups are derived, not measured.

FigureInteractive

Four columns evaluate Polyak's 1964 heavy-ball result at condition numbers R = 10, 100, 1,000 and 10,000, four values chosen for this figure. The speedup is √R — 3.2×, 10.0×, 31.6× and 100.0× fewer iterations to a given accuracy, all derived — and the momentum constant that buys it, (√R−1)/(√R+1), is 0.519, 0.818, 0.939 and 0.980, drawn as fills on tracks that represent the unit interval. Both quantities are functions of the conditioning alone, and the constant approaches 1 without ever reaching it. The result describes a quadratic model of the curvature at the minimum rather than a measured training run; the speedups are derived, not measured.

Momentum and conditioning are the same quantity twice: the speedup is √R and the constant that earns it is (√R−1)/(√R+1).

Comparison

Four ways to alter the optimization path

These methods may look similar in code but act through different mechanisms. The difference between the last two has now been settled on wall-clock time rather than argued from iteration counts.

MLCommons ran the inaugural AlgoPerf: Training Algorithms competition and announced the results on 1 August 2024: “The first iteration of the AlgoPerf: Training Algorithms competition attracted 18 submissions (with 15 being scorable) from 10 different teams. Scoring involved over 4000 individual training runs across the 14 workloads used in the benchmark.”

The external-tuning winner was Meta's Distributed Shampoo, which “provides an impressive 28% faster model training compared to the baseline” and took a $25,000 prize. The self-tuning winner, Schedule Free AdamW, delivered an “8% faster neural network training process”.

The competition results paper draws the conclusion: “The winning submission in the external tuning ruleset, using Distributed Shampoo, demonstrates the effectiveness of non-diagonal preconditioning over popular methods like Adam, even when compared on wall-clock runtime.” Preconditioning that models curvature across coordinates beat diagonal adaptive scaling on fixed hardware. It paid for its matrices every step and still finished first.

FigureComparison · 4 columns

Learning-rate change

Scales the entire gradient by one factor.

  • Simple global control
  • Cannot correct directional imbalance
  • Too large causes instability
  • Too small wastes iterations

Momentum

Accumulates a velocity from past gradients.

  • Damps repeated oscillation
  • Accelerates persistent directions
  • Adds state and tuning
  • Can overshoot after regime changes

Adaptive diagonal scaling

Uses coordinate-wise gradient statistics.

  • Cheap approximation to geometry
  • Sensitive to parameterization
  • May change implicit regularization
  • Does not model cross-coordinate curvature

Preconditioning

Transforms the problem or gradient with a matrix.

  • Can align updates with curvature
  • Ranges from simple scaling to second-order methods
  • Requires stable approximations
  • Aims to improve effective conditioning

Key idea

A better condition number does not guarantee a better model

Optimization geometry concerns how easily an objective is minimized. It does not determine whether the objective represents the right task, or whether the solution generalizes. That gap has been constructed on purpose and then found in the wild.

There is a linearly separable binary classification problem on which GD and SGD reach zero test error while AdaGrad, Adam and RMSProp reach test errors arbitrarily close to one half. Five authors built it, and presented it at NIPS in 2017. The methods that adapt the geometry fit the training data and predict nothing.

Across several state-of-the-art deep models they found the same direction of failure: “We observe that the solutions found by adaptive methods generalize worse (often significantly worse) than SGD, even when these solutions have better training performance.” Better training performance was the evidence, and it pointed the wrong way.

Aggressive scaling can also change implicit biases, regularization interactions, and numerical behavior. Measure both optimization progress and downstream validation. Converging faster on the wrong objective does not make the system better.

Conditioning answers how hard the chosen objective is to optimize, not whether it deserves to be optimized.

Example

A two-dimensional quadratic with a narrow valley

Let f(x,y)=½(100x²+y²). Shewchuk works the same manoeuvre on a small system in a 1994 Carnegie Mellon report. Its section on preconditioning opens: “Preconditioning is a technique for improving the condition number of a matrix.” Then it reports what the cheapest version of it actually buys.

  • Gradient: ∇f=(100x,y), so the x direction is one hundred times steeper.
  • Stable step: η must be small enough for the x direction, limiting progress in y.
  • Trajectory: Updates can alternate across the valley while moving slowly toward the minimum.
  • Rescaling: Let u=10x; the objective becomes ½(u²+y²), which is isotropic. This is diagonal, or Jacobi, preconditioning, which Shewchuk says “is equivalent to scaling the quadratic form along the coordinate axes”. On his sample problem, “The condition number has improved from 3.5 to roughly 2.8”.
  • Ceiling: With the perfect preconditioner M = A the transformed matrix “has a condition number of one, and the quadratic form is perfectly spherical, so solution takes only one iteration”. A coordinate transformation can turn a difficult search into a single step without changing the optimum.

Analogy

Steep walls make the downhill direction the wrong direction

Down a corridor that slopes gently forward between steep walls, steering directly downhill points mostly into a wall, and causes repeated corrections. Momentum remembers the forward component. Preconditioning changes the coordinate map so the corridor appears more circular.

The literature reaches for the same picture: “Intuitively, preconditioning is an attempt to stretch the quadratic form to make it appear more spherical, so that the eigenvalues are close to each other.” — Shewchuk, 1994.

The formal statement drops the corridor and keeps the guarantee. Templates for the Solution of Linear Systems, published by SIAM in 1994 and written by ten authors, puts it this way: “The convergence rate of iterative methods depends on spectral properties of the coefficient matrix. Hence one may attempt to transform the linear system into one that is equivalent in the sense that it has the same solution, but that has more favorable spectral properties. A preconditioner is a matrix that effects such a transformation.”

Equivalent in the sense that it has the same solution is the entire safety argument for the trick. It is why preconditioning is not a way of cheating on the answer. With stochastic gradients, or a landscape that shifts while it is being descended, the corridor itself appears to move.

Preconditioning changes the geometry seen by the optimizer, not the location of the desired solution.

Predict first

How much of the gradient do the steep directions carry?

The quadratic picture in this lesson has two directions, one steep and one shallow. A real image network has hundreds of thousands of parameters or more, so its Hessian has as many eigenvalues, one curvature per eigen-direction, and the step size is capped by the largest of them. Lessons 17 and 18 described the measured shape of that spectrum: a bulk of near-zero curvatures with a handful of large outliers standing apart.

Guess before reading on. The outliers are a handful of directions out of hundreds of thousands. In a network trained without batch normalization, how much of the energy of its stochastic gradients lies in those few top directions: a share about as small as their number, roughly half, or nearly all of it?

Settle on an answer, then read on — the next section is the reveal

Steps

Diagnosing slow or unstable optimization

Use targeted interventions instead of changing every hyperparameter at once. The probes below are real instruments with published readings, not metaphors.

The full Hessian spectrum of ImageNet-scale networks has been estimated with Hessian-vector products, by three authors at ICML in 2019. What they found is this lesson's anisotropy, counted: “the vast majority (> 99.99% of eigenvalues being close to 0)”, with a handful of large outliers separated from that bulk. They track the outliers with a scale-invariant ratio, ζ(t) := λ1(∇²L(θt))/λK(∇²L(θt)) — a condition number under another name — and state the consequence plainly: “For all directions where λi is small with respect to λ1, we expect convergence to be slow”.

The outliers are not a curiosity of the tail. The same authors also computed the spectrum of the gradient covariance, which shows how the energy of the mini-batch gradients is spread, for a Resnet-32 trained on CIFAR-10. Without batch normalization, “almost 99% of the energy is in the top few subspaces”, and those subspaces “mostly coincide” with the Hessian's outlier directions. Nearly all of the stochastic-gradient signal lives inside the few steep directions that already cap the step size.

Their summary carries the diagnosis and the intervention in one sentence: “in non-batch normalized networks, we observe the rapid appearance of large isolated eigenvalues in the spectrum, along with a surprising concentration of the gradient in the corresponding eigenspaces. In batch normalized networks, these two effects are almost absent.”

FigureProcess · 5 steps
  1. 1. Plot loss and gradient norms

    Separate divergence, plateaus, oscillation, and noise.

  2. 2. Inspect feature and parameter scales

    Look for orders-of-magnitude differences and saturation.

  3. 3. Probe curvature

    Use Hessian-vector products, local sweeps, or simple quadratic fits.

  4. 4. Test one geometry fix

    Try normalization, rescaling, momentum, or a preconditioner.

  5. 5. Recheck validation

    Confirm that easier optimization improves the metric and slices that matter.

Example

Standardising two features cuts the steps from 9.6 million to 109

A least-squares model with two features can be computed exactly, which makes every step checkable. The five deliveries are invented: distance 1, 2, 3, 4 and 5 km, parcel weight 500, 1,500, 1,000, 2,500 and 2,000 g, and delivery time 12, 14, 15, 22 and 19 minutes. The model predicts centred time from centred distance and weight with loss f(w) = ½ · mean squared error. Every figure below was computed in double precision.

  • 1. Plot loss and gradient norms: with the step η = 1/λmax, the loss falls from 5.98 above its minimum to 0.217 above it after 1,000 steps, and then keeps crawling. A step only 1% past 2/λmax, which is itself about 4.0 × 10⁻⁶, diverges instead. That pattern, stable but slow or fast but explosive with nothing in between, points to geometry rather than noise.
  • 2. Inspect scales: distance has a standard deviation of 1.41 km, weight 707 g, a factor of 500 between two features the model treats alike.
  • 3. Probe curvature: the Hessian is H = [[2, 800], [800, 500,000]], with eigenvalues of about 0.72 and 500,001. The condition number is about 694,000, and gradient descent at η = 1/λmax needs about 9.6 million steps to bring the weights within one part in a million of the optimum.
  • 4. Test one geometry fix: standardise both features and nothing else. The Hessian becomes [[1, 0.8], [0.8, 1]], with eigenvalues 0.2 and 1.8. The condition number drops to 9 (it is now set only by the 0.8 correlation between distance and weight), and the same tolerance takes 109 steps.
  • 5. Recheck validation: mapped back to the original units, both runs give the same weights, 0.778 minutes per km and 0.00356 minutes per gram, and the same minimum loss, 0.542. The predictions agree to within 10⁻¹⁵. Rescaling bought speed and changed nothing about the fitted model, so any change in a validation metric after such a fix has to be explained some other way.

Condition number summarizes anisotropy

In a positive definite quadratic, the spectral condition number κ=λmax/λmin compares the steepest and shallowest curvature directions. A large κ forces conservative steps for stability along the steep directions, which leaves slow movement along the shallow ones. Condition number depends on parameterization. Rescaling variables can dramatically improve optimization without changing the represented problem.

The cost of ignoring that has been audited, with certified numbers attached. In 1967 Longley appraised least-squares programs from the point of view of the user, in the Journal of the American Statistical Association, building on a macroeconomic least-squares problem whose design matrix is so collinear that regression programs disagreed on the answer. Cleve Moler records what became of it: “The Longley data set of labor statistics was one of the first used to test the accuracy of least squares computations.” The R Core Team documents the same 16 observations, taken from 1947 to 1962 on 7 variables, as “A macroeconomic data set which provides a well-known example for a highly collinear regression.”

NIST's Statistical Reference Datasets archive now certifies it: 1 response variable, 6 predictors, 16 observations, classified at the “Higher Level of Difficulty”. B0 = −3482258.63459582. Residual standard deviation 304.854073561965. R² = 0.995479004577296. The figures are published so that software can be checked against them, and the archive's stated purpose is improving “the accuracy of statistical software by providing reference datasets with certified computational results”.

A badly conditioned matrix is not an abstraction about convergence rates. It is a problem on which two correct-looking programs return different numbers, and someone had to certify which ones were right.

Case

December 1952: conjugate gradients promised a solution in n steps

Poor conditioning has been costed in machine time since 1952. Hestenes and Stiefel published the conjugate gradient method that December, in the Journal of Research of the National Bureau of Standards. The promise is the first two sentences of the abstract: “An iterative algorithm is given for solving a system Ax=k of n linear equations in n unknowns. The solution is given in n steps.”

They were writing for hardware and said so — “By a machine method, we shall mean one in which sequence-controlled machines are used.” — and the third of their five stated criteria was that “The procedure should be stable with respect to rounding-off errors.”

They survived by exploiting the spectrum rather than fighting it, and the size of that advantage is the same square root momentum earns. Shewchuk derives it in his 1994 Carnegie Mellon report, which cites the 1952 paper as reference [11]: to reduce the error by a factor ε, Steepest Descent needs roughly ½·κ·ln(1/ε) iterations and Conjugate Gradients roughly ½·√κ·ln(2/ε).

The condition number enters one linearly and the other under a square root — κ against √κ, the same law the heavy ball obeys.

Key takeaways