↑↓ move Enter open ⌘K find from any page 256 of 256 tabs
Loading the recording…

Sharpness and the 2/η rule

Near a minimum, a loss looks like a bowl that is steep in some directions and flat in others. Its curvature is the Hessian, the matrix of second derivatives , and the curvature of its steepest direction, the largest eigenvalue , is called the sharpness.

Gradient descent with learning rate takes . On a one-dimensional quadratic that is

so the distance to the bottom shrinks only while , that is while . Past that, each step overshoots the bottom by more than it started from, the iterate flips from side to side and grows. Classical optimization reads this as a rule: keep the sharpness below , or gradient descent diverges. The question this tab answers by measuring is what the sharpness actually does while a network trains.

The runs

The page follows Cohen et al.'s setup: the first 5,000 CIFAR-10 training images, each colour channel standardized, a fully connected network with tanh between the layers (656,810 parameters, PyTorch's default initialization, seed 0) and the squared loss against one-hot targets. Full-batch gradient descent means every step uses all 5,000 images, so there is no minibatch noise and no momentum: each step is exactly . Four runs start from the same weights with = 100, 150, 200 and 400.

The sharpness of a 656,810-parameter model cannot come from writing down. A Hessian–vector product costs about two gradients (differentiate once more), and Lanczos's method builds, from 20 of them, a small tridiagonal matrix whose largest eigenvalues match 's. Every 20 steps the runs measure the top three eigenvalues this way, warm-starting from the last top eigenvector . At the start the sharpness is 82.4, below every run's .

Progressive sharpening, then the edge

The Sharpness panel shows the same story four times. The sharpness first dips, to about 73 within a few hundred steps, and then climbs steadily: progressive sharpening. It crosses at step 860 for , at step 2,220 for 150 and at step 4,000 for 200, later for smaller learning rates because each step moves the weights less (in units of steps, 17.2, 29.6 and 40.0).

Then it stops climbing. After the crossing each run's sharpness stays near its own : between 94 and 113 (mean 106.8) for 100, 143 to 163 (mean 157.2) for 150 and 193 to 214 (mean 207.4) for 200, a few per cent above the line each time. Cohen et al. called this the edge of stability: the sharpness rises until gradient descent is just unstable along one direction and hovers there, instead of staying safely below as the classical rule assumes, or diverging as the quadratic picture predicts.

Measured against steps instead of steps, the runs share one sharpening curve until each meets its edge: about 77.6 at 8, 97.5 at 16, 126.8 at 24 and 161.8 at 32 for every run not yet at its edge. The run with never gets there in 8,000 steps; its sharpness is still rising at the end, at 199.7 by steps , the point where the run met its own edge. It is the reference the others leave: what the sharpness would do if the learning rate let it.

The bounce

What happens at the edge is visible in the Up close panel, which plots the gradient's component along the top eigenvector, , step by step. Before the crossing it is tiny: for it is below until step 940. Once the sharpness exceeds 100 the quadratic picture applies along : each step multiplies that component by , a number below , so it flips sign and grows. Between steps 960 and 990 it grew by a factor of 1.15 to 1.19 per step, while for the sharpness measured there (107 to 109) is 1.15 to 1.17. By step 1,010 it is 2.3, and the gradient points almost entirely along .

The Along the sharpest direction panel draws the loss along through the current weights, , with the bottom of the parabola and where one step lands. At step 0, with , the step overshoots the bottom and lands 0.65 of the way back on the other side, : the flips shrink. At step 986, with , it lands 1.18 times as far out: the flips grow.

The growth does not run away. In this first burst the loss rose from 0.307 at step 1,000 to 0.333 at step 1,011 and the sharpness fell from 109.8 to 93.6 by step 1,020, back below ; then progressive sharpening resumed and the cycle repeated. Damian et al. explain this as self-stabilization: moving along changes the curvature itself, and the bounce pushes the weights towards regions where the sharpness is lower.

The loss keeps falling, not monotonically

In none of the runs did the loss rise even once before the sharpness crossed , and in the run, which never crossed, it never rose once in 8,000 steps. After it, the loss went up on 886 of the 2,139 remaining steps for , 1,169 of 2,779 for 150 and 1,236 of 2,999 for 200: on roughly two steps in five. Yet over the longer run it keeps falling. The Training loss panel shows it going from 0.599 at the start to 0.202, 0.181 and 0.150 at the ends of the three runs (3,000, 5,000 and 7,000 steps), with training accuracy rising from 12.7 % to 90.7 %, 92.4 % and 95.7 %.

So a learning rate that a quadratic analysis calls too large is not one that fails: training sits at the boundary of stability and still makes progress, through a sequence of short-lived instabilities rather than a steady descent. This is also why the minibatch picture of the WSD tab, a high learning rate bouncing across a valley and a decay that settles it, is not only about noise.

Where it came from

Jastrzębski et al. found that the learning rate and batch size limit how sharp the regions SGD visits can be (the break-even point). Cohen et al. measured full-batch gradient descent across architectures and losses and found the same pattern everywhere: progressive sharpening up to and then the edge of stability; this tab reproduces their fully connected tanh network on 5,000 CIFAR-10 images. Damian et al. gave the self-stabilization mechanism, and Cohen et al. later showed that adaptive optimizers such as Adam sit at an edge of their own, for the preconditioned sharpness. Measuring a Hessian's top eigenvalues relies on Pearlmutter's exact Hessian–vector products and Lanczos's method, as Ghorbani et al. used for whole spectra of network Hessians. The AdamW tab trains with one of those adaptive optimizers; the Init & norm tab shows the instabilities a deep network can have before training starts.

Papers

  1. Gradient Descent on Neural Networks Typically Occurs at the Edge of Stability Jeremy M. Cohen et al. · ICLR 2021 Measures the sharpness of full-batch gradient descent and finds it rising to 2/η and hovering there; the runs here use its fully connected tanh network on 5,000 CIFAR-10 images.
  2. Self-Stabilization: The Implicit Bias of Gradient Descent at the Edge of Stability Alex Damian et al. · ICLR 2023 Explains why the bounce along the top eigenvector does not diverge: it lowers the sharpness back below 2/η.
  3. The Break-Even Point on Optimization Trajectories of Deep Neural Networks Stanisław Jastrzębski et al. · ICLR 2020 Shows early in training that the learning rate and batch size cap the sharpness SGD reaches.
  4. Adaptive Gradient Methods at the Edge of Stability Jeremy M. Cohen et al. · arXiv 2022 Finds the same edge for Adam and other adaptive optimizers, in terms of the preconditioned sharpness.
  5. An Investigation into Neural Net Optimization via Hessian Eigenvalue Density Behrooz Ghorbani et al. · ICML 2019 Estimates whole Hessian spectra of large networks with Lanczos on Hessian–vector products, as the sharpness here is measured.
  6. Fast Exact Multiplication by the Hessian Barak A. Pearlmutter · Neural Computation 1994 Computes Hessian–vector products exactly at the cost of a few gradients, which makes the sharpness measurable.
  7. An iteration method for the solution of the eigenvalue problem of linear differential and integral operators Cornelius Lanczos · Journal of Research of the National Bureau of Standards 1950 The Lanczos method: the largest eigenvalues of a symmetric matrix from a few matrix–vector products.

See also