| Curvature | |
|---|---|
| the model's weights | |
| the training loss at weights | |
| the Hessian , the matrix of second derivatives of the training loss | |
| sharpness, the top eigenvalue of the Hessian (the course's assignment and quiz write ); gradient descent with step size holds it near | |
| the top eigenvector of the Hessian , the direction along which the iterate oscillates | |
| the center of the oscillation, with the weights written as | |
| the displacement of the weights along the top Hessian eigenvector , with | |
| preconditioned sharpness, top eigenvalue of , with AdamW's small constant | |
| AdamW's diagonal preconditioner and its bias-corrected second-moment estimate | |
| Optimizers | |
| training step (or continuous time in the central flow) | |
| batch size (number of training sequences per update) | |
| learning rate (step size) | |
| gradient at a step | |
| heavy-ball momentum buffer, | |
| heavy-ball momentum coefficient, in , | |
| Adam's first-moment (momentum) decay, 0.9 in the note's example | |
| RMSProp's running squared gradient, in the scalar version, or kept per coordinate with each coordinate's squared gradient | |
| decay of RMSProp's running squared gradient ; a high makes respond slowly | |
| RMSProp's preconditioner ; RMSProp is gradient descent preconditioned by | |
| the time average of RMSProp's preconditioner at the edge of stability | |
| weight-decay coefficient (.1 by default in d8) | |
| Central flow | |
| the central flow, the time-averaged iterate, which follows | |
| , the variance of the oscillation along , set so that stays at | |
| projection onto the directions orthogonal to (or to ) | |
| Model and SAM | |
| d8's language-model head matrix; the logits depend on it only through | |
| d8's final RMSNorm gain vector, which the default weight-decay mask leaves undecayed; the logits depend on it only through | |
| positive rescaling factor in the head-and-gain symmetry | |
| SAM radius, the size of the ball around the weights over which SAM takes the worst loss | |
| SAM's weight perturbation, approximated to first order by | |
| coefficient of the ordinary L2 penalty in SAM's objective | |
| sub-batch size on which SAM's perturbation is computed | |
Context. On a quadratic , gradient descent with step size multiplies by each step, so it converges only while . In many dimensions, every Hessian eigenvalue must stay below . Classical theory therefore expects training to keep the sharpness, the largest eigenvalue of the Hessian of the training loss at the weights : the curvature along the steepest direction below . Cohen et al. (2021) found that full-batch gradient descent on neural networks breaks this expectation. Sharpness rises to and hovers there while the loss keeps falling unevenly, a regime called the edge of stabilitythe regime in which training holds the sharpness at the largest value the step size tolerates, for gradient descent, since on a quadratic with curvature the iterates diverge once (Cohen et al., 2021). Reading note: bubbleforce: the edge of stability for Muon. Lecture 6 of Hashimoto and Kotha's Stanford course CS 312 Deep Learning Alchemy (Fall 2026) follows Cohen and Damian's central flows tutorial. It covers how training regulates itself at the edge, how adaptive optimizers behave there, and whether flat minima improve generalization. The speedrun section covers the analogous threshold for momentum optimizers such as Muonan optimizer that replaces each weight matrix's momentum by the nearest matrix with all singular values equal to 1, for momentum . Reading note: Muon.
Oscillating across the sharpest direction pushes sharpness back down, so gradient descent regulates its own curvature right at the stability threshold. Averaging over the oscillation gives the central flow: gradient flow plus a sharpness penalty that holds at . Equivalently, it follows gradient flow with the sharpening direction projected out. In scalar RMSProp, the same self-regulation makes the effective step size track without computing ; larger oscillations then steer training into flatter regions where larger steps stay stable. Whether flatness helps generalization is less clear. Sharpness correlates weakly with test performance and changes arbitrarily under reparameterization, while sharpness-aware minimization: training on the worst loss in a small ball around the weights, which pushes toward flat regions; in practice the inner maximum is approximated by one step and the gradient is taken at (Foret et al., 2021) pays off mainly under label noise.
Setting. The theory starts from full-batch training of small networks (Cohen et al., 2021; Cohen, Damian et al., 2024) and extends to momentum, minibatches, and RMSProp. Assignment 3 tests these ideas on the course's d8 model organism, an 8-block transformer pretrained on about 614M tokens. It estimates top Hessian eigenvalues from Hessian-vector products with Lanczos iterationa Krylov method that builds the subspace spanned by from Hessian-vector products alone; the eigenvalues of restricted to that subspace approximate its extreme eigenvalues, and the Hessian itself is never formed. The experiments cover both full-batch gradient descent on the first training sequences and ordinary minibatch AdamW, where preconditioned sharpnessthe top eigenvalue of , with the Hessian and built from AdamW's bias-corrected second-moment estimate and its small constant governs stability.
What it changes in practice. Because the learning rate sets the sharpness where training settles, sharpness comparisons make sense only at matched learning rates and parameterizations. In an adaptive optimizer, the learning rate still matters despite step normalization. A larger rate drives larger oscillations and pushes training into flatter regions where the effective step size grows larger. A smoothed training loss sits above the loss at the time-averaged weights by an oscillation penalty. An EMA or cooldown removes that penalty, matching Lecture 5's river-valley picture. Sharpness is an unreliable proxy for generalization, and sharpness-aware minimization costs a second gradient per step. It pays off mainly under noisy labels or when a pretrained model must resist forgetting during later fine-tuning.
Full-batch gradient descent sharpens to and stays there. In Cohen et al.'s runs, sharpness first rises steadily (progressive sharpeningthe steady rise of the sharpness during training while it is below the threshold; observed widely, with no accepted explanation) until it crosses . The loss then spikes and the iterate oscillates along the top Hessian eigenvector, just as on a quadratic. Instead of diverging, sharpness drops back and hovers near while the loss keeps falling non-monotonically. Halving doubles the plateau. Several top eigenvalues reach in sequence and oscillate there together. Minibatch SGD plateaus at a lower level (Jastrzebski et al., 2018), and Cohen et al. observe stronger progressive sharpening in narrower networks, deeper networks, and larger datasets.
On d8, full-batch runs resemble the edge of stability without matching it exactly. Full-batch gradient descent on training sequences at first crosses at update 375. With the cross-entropy loss, however, overshoots above 2, and changing shifts the plateau level. Sample size and step size control when the run reaches the edge and how long it stays there. Once the small set of sequences is memorized, the run falls off the edge.
Oscillation along the top eigenvector lowers the sharpness. Unlike a quadratic, a network's curvature varies with the weights, so bouncing along the top eigenvector pushes curvature down. Write , where is the oscillation center, is the unit top Hessian eigenvector, and is the scalar displacement along . For a simple top eigenvalue, expanding the gradient to second order in (third order in the loss) gives The middle term pushes back along and flips the sign of at each step, as on a quadratic. Because curvature along is , its gradient is , so the quadratic term adds a descent step of size on sharpness at every update. Stronger oscillations push down harder until drops below 2 and the bounce decays; progressive sharpening then lifts back to the edge. Damian et al. (2023) analyze this self-stabilization mechanism, the same one examined in the speedrun section's note on Muon's edge of stability.
Averaging out the oscillation gives the central flow. Plain gradient flow, , tracks gradient descent only until hits , after which it keeps sharpening and diverges from the discrete trajectory. Cohen, Damian et al. (2024) instead track the time-averaged iterate . Averaging the expansion above over the oscillation kills the zero-mean middle term and leaves where is the oscillation variance along . Holding the sharpness on the edge imposes , a linear equation in with the unique solution Substituting back gives , gradient flow with the component along projected out, using the orthogonal projection , the projection onto the directions orthogonal to . Because must be nonnegative, this flow holds only under progressive sharpening, . Whenever gradient flow itself lowers sharpness, the run leaves the edge and resumes plain gradient flow. The central flow tracks gradient descent over thousands of steps and predicts the measured variance . With several simultaneous edge eigenvalues, a covariance matrix replaces .
The central flow separates the iterate's loss from the averaged weights' loss. Expanding the loss to second order around and averaging gives . Substituting at the edge yields A smoothed training curve plots the left side; an EMA of the weights or a learning-rate cooldown reveals the lower loss at the averaged weights. Lecture 6 connects this directly to Lecture 5's river valley: the central flow runs along the river floor while the iterate bounces from wall to wall. The bounce height rises and falls as the sharpness oscillates.
Momentum and minibatch noise shift the stability threshold in opposite directions. Under heavy-ball momentum, and , full-batch training on a quadratic stays stable while . At the edge, successive gradients along the top eigenvector alternate in sign. Momentum sums a fixed-size alternating gradient to , damping the bounce and raising the tolerated sharpness by . For Adam with and a frozen preconditioner, the analogous preconditioned threshold is . With small minibatches, noise makes consecutive gradients nearly independent instead of alternating. Momentum then adds their variances by rather than canceling an alternating signal, lowering the sharpness where training settles (Andreyev et al., 2026).
Scalar RMSProp holds its effective sharpness at 2. Scalar RMSProp drops momentum and divides all coordinates by one running root-mean-square gradient norm: With actual step size , stability along the top direction depends on the effective sharpness, the sharpness times RMSProp's actual step size , where is the running average of the squared gradient norm; the optimizer is stable along the top direction when it is below 2, as gradient descent is when , which settles at 2 in the lecture's runs. Oscillation holds it there both by lowering , as in gradient descent, and by inflating the gradient norm to raise . A larger slows 's response, pushing more regulation onto so that both and settle lower at the same effective sharpness of 2.
At the edge, scalar RMSProp takes steps of size , with acting through the sharpness penalty. Repeating the central-flow averaging with the time-averaged squared gradient norm driving gives On the edge of stability, effective sharpness equals 2, so and the weight flow simplifies to The optimizer takes the largest stable step without computing . Meanwhile, the penalty steers training into flatter regions and thus larger steps; removing it in the paper's ablation slows training. Although drops out of the prefactor , still depends on and . Raising enlarges the oscillations, strengthens sharpness reduction, and ultimately increases .
Coordinatewise RMSProp solves a convex program that mixes a Newton-like goal with a brake. Keeping per coordinate gives and , gradient descent preconditioned by . Even while individual coordinates oscillate, the loss curve looks smooth and the top eigenvalues of the effective Hessian sit at 2. At the edge, once has settled at its stationary value for the current weights (as observed in the paper's runs), the time-averaged preconditioner solves where . The constraint enforces local stability. Minimizing , the sum of inverse effective step sizes, maximizes step sizes subject to stability. Without the diagonal restriction, it yields the scaled Newton matrix for positive semidefinite . By contrast, the second term is proportional to the loss-decrease rate under the preconditioned flow, so minimizing it slows training. In the paper's comparison, the preconditioner that drops that term trains faster, which Lecture 6 flags as a potentially suboptimal feature of RMSProp.
On d8, weight decay shifts sharpness along a head-and-gain rescaling symmetry. Weight decay moves final sharpness dramatically while leaving validation loss nearly unchanged. The default mask decays hidden and readout matrices, including the language-model head , while leaving embeddings and RMSNorm gains undecayed, including the final gain vector . Logits depend on and only through . Scaling and therefore preserves the function while multiplying curvature with respect to by . Stronger decay shrinks , undecayed grows to compensate, and head sharpness climbs. Weight decay 0, .1, and .3 give final sharpnesses of 2.55, 5.95, and 14.9. Over that range, the top eigenvector moves from 70% in RMSNorm gains (24% in the head) at 0, to the head at .1, and to 94% in the head at .3.
In d8, updates barely lie in the top-10 Hessian eigenspace. A second experiment checks Gur-Ari et al.'s (2018) claim that gradients live mainly inside the span of the top few Hessian eigenvectors. Starting from an SGD-with-momentum checkpoint at 100M tokens, projecting the top-10 eigenspace out of each update costs nothing over 300 steps. Keeping only the top-10 component makes no progress. In these runs, the update's projection onto those ten directions is tiny, so progress happens in the remaining directions and training along the top ten alone stalls.
Sharpness is a weak, parameterization-dependent predictor of generalization. When data rather than compute limits training, as with repeated epochs, training and validation loss diverge. That gap motivates the claim that flat minima generalize better (Hochreiter and Schmidhuber, 1997; Keskar et al., 2017 on large-batch minima). Across 2,187 models, Jiang et al. (2019) find that most generalization metrics correlate poorly; a sharpness-based metric scores highest at 0.516, against 0.147 for final cross-entropy and −0.15 for parameter count. Later studies report weak and often negative correlations (Andriushchenko et al., 2023). Dinh et al. (2017) show why raw sharpness cannot be trusted. Rescaling layers of a ReLU network preserves the function while making a minimum arbitrarily sharp, the same type of symmetry seen in d8's head and final gain.
loss_fn(model(x), y).backward() # gradient at w
norm = 0.0
for p in params:
norm = norm + (p.grad ** 2).sum()
eps = []
with torch.no_grad():
for p in params:
e = rho * p.grad / norm.sqrt()
p.add_(e) # move to w + eps
eps.append(e)
model.zero_grad()
loss_fn(model(x), y).backward() # gradient at w + eps
with torch.no_grad():
for i in range(len(params)):
params[i].sub_(eps[i]) # back to w
optimizer.step() # step with the SAM gradientSAM helps most under label noise, and its effective target depends on sub-batch size. On WRN-28-10 trained for 200 epochs with basic augmentation, SAM trims test error from 3.5% to 2.7% on CIFAR-10 and from 18.8% to 16.5% on CIFAR-100. Its largest payoff comes under label noise: on CIFAR-10 with 80% flipped labels, a ResNet-32 reaches 77.9% clean test accuracy with SAM against 26.2% with SGD. Computing separately on small sub-batches of size beats using the full batch. At , analysis shows SAM minimizes average-case sharpness, the expected loss over random perturbations in the ball. Flatter pretrained models, whether from SAM or higher pretraining learning rates, also forget less during later fine-tuning (sharpness-aware pretraining).
Caveats. Edge-of-stability and central-flow descriptions are least reliable for cross-entropy loss, stochastic minibatches, adaptive optimizers such as AdamW, and very high learning rates. Progressive sharpening itself still lacks an accepted explanation. The full-batch d8 runs illustrate the gap: they look like the edge of stability without matching it cleanly. On generalization, Lecture 6 concludes that sharpness may or may not help in data-limited regimes and that what SAM actually minimizes remains unclear. It treats sharpness mainly as a design intuition for settings such as fine-tuning.
Terms
- edge of stability
- sharpness rises to and hovers there while the loss keeps falling unevenly
- progressive sharpening
- rise of the sharpness during training below the threshold; unexplained
- self-stabilization
- the term of the gradient: oscillation descends the sharpness
- central flow
- with ; gradient flow with projected out
- time-averaged loss
- : the smoothed curve sits above the loss at the averaged weights
- momentum threshold
- full batch, heavy ball: ; with noisy small batches momentum lowers the plateau
- effective sharpness
- for scalar RMSProp; settles at 2, so the step is
- stationary preconditioner
- argmin of over diagonal with
- head/gain symmetry
- , keeps the model, multiplies head curvature by
- Dinh et al.
- rescaling layers keeps the function and changes the sharpness at will
- SAM
- gradient at ; two gradients per step; strongest under label noise
Sources
Lecture 6, “Loss Landscapes Part 2: Edge of Stability” (Oct 15, 2026), of Stanford CS 312 Deep Learning Alchemy, Fall 2026. Taught by Tatsunori Hashimoto and Suhas Kotha; course staff Kaiyue Wen and Tristan Thrush (CAs).
Course site Lecture slides Online quiz Quiz answers Assignment Assignment code
The lessons, experiments, figures and quiz problems in this note are the course's, shown here with the instructors' permission.
- Tatsunori Hashimoto and Suhas Kotha. CS 312 Deep Learning Alchemy, Lecture 6: Loss Landscapes Part 2: Edge of Stability. Stanford, Fall 2026.
- Tatsunori Hashimoto and Suhas Kotha. CS 312 Deep Learning Alchemy, Quiz 3: Optimization 2 (with answer slides). Stanford, Fall 2026.
- Tatsunori Hashimoto and Suhas Kotha. CS 312 Deep Learning Alchemy, Assignment 3: Optimization 2. Stanford, Fall 2026.
- Jeremy M. Cohen et al. Gradient Descent on Neural Networks Typically Occurs at the Edge of Stability. ICLR, 2021.
- Jeremy M. Cohen et al. Understanding Optimization in Deep Learning with Central Flows. ICLR, 2025.
- Pierre Foret et al. Sharpness-Aware Minimization for Efficiently Improving Generalization. ICLR, 2021.
Connected notes
- Understanding deep learning requires rethinking generalizationGeneralization bounds · Implicit bias of the optimizer
SGD started at zero stays in the row space of the data, so on a linear model it returns the minimum-norm interpolant, which reaches 1.2% test error on raw MNIST with no regularization.
- The information exponentHigh-dimensional SGD · Abrupt transitions at a critical ratio
Online SGD's overlap with a hidden direction grows at the rate signal/noise, which is tiny near a random start, so escaping takes about samples for information exponent (the order of the first nonzero Hermite term) and almost all the samples are used up before the overlap grows.
- Transformers Learn In-Context by Gradient DescentIn-context learning · Hyperparameters set what the loss leaves free
In one-layer linear self-attention, the loss depends only on the product and leaves the scale split between the label-value scalar and the key-query matrix free; gradient flow conserves , which pins the limit on the hyperbola of equivalent global minima.
- Double descentBenign overfitting · Implicit bias of the optimizer
Past the interpolation threshold every model fits the data, so the test risk is set by which interpolant is chosen, and the minimum-norm one spreads the noise over more directions as features are added, which gives the second descent.