Sam Babichenko

Reading notes / Deep Learning Alchemy

The edge of stability, central flows and flat minima

From Lecture 6 of Stanford CS 312 Deep Learning Alchemy (Fall 2026), taught by Tatsunori Hashimoto and Suhas Kotha

slides quiz answers assignment code

Curvature
wwthe model's weights
L(w)L(w)the training loss at weights ww
HHthe Hessian H=∇2L(w)H=\nabla^2L(w), the matrix of second derivatives of the training loss
S(w)S(w)sharpness, the top eigenvalue of the Hessian HH (the course's assignment and quiz write λmax⁡\lambda_{\max}); gradient descent with step size η\eta holds it near 2/η2/\eta
uuthe top eigenvector of the Hessian HH, the direction along which the iterate oscillates
wˉ\bar wthe center of the oscillation, with the weights written as w=wˉ+xuw=\bar w+xu
xxthe displacement of the weights along the top Hessian eigenvector uu, with w=wˉ+xuw=\bar w+xu
SpreS_{\mathrm{pre}}preconditioned sharpness, top eigenvalue of D−1/2HD−1/2D^{-1/2}HD^{-1/2}, D=v^+ϵD=\sqrt{\hat v}+\epsilon with AdamW's small constant ϵ\epsilon
D,D, v^\hat vAdamW's diagonal preconditioner D=v^+ϵD=\sqrt{\hat v}+\epsilon and its bias-corrected second-moment estimate v^\hat v
Optimizers
tttraining step (or continuous time in the central flow)
NNbatch size (number of training sequences per update)
η\etalearning rate (step size)
gggradient ∇L(wt)\nabla L(w_t) at a step
vtv_theavy-ball momentum buffer, vt+1=βvt+∇L(wt)v_{t+1}=\beta v_t+\nabla L(w_t)
β\betaheavy-ball momentum coefficient, in vt+1=βvt+∇L(wt)v_{t+1}=\beta v_t+\nabla L(w_t), wt+1=wt−ηvt+1w_{t+1}=w_t-\eta v_{t+1}
β1\beta_1Adam's first-moment (momentum) decay, 0.9 in the note's example
νt\nu_tRMSProp's running squared gradient, νt=β2νt−1+(1−β2)∥∇L(wt)∥2\nu_t=\beta_2\nu_{t-1}+(1-\beta_2)\|\nabla L(w_t)\|^2 in the scalar version, or kept per coordinate with each coordinate's squared gradient
β2\beta_2decay of RMSProp's running squared gradient νt\nu_t; a high β2\beta_2 makes νt\nu_t respond slowly
PPRMSProp's preconditioner P=diag(νt)/ηP=\mathrm{diag}(\sqrt{\nu_t})/\eta; RMSProp is gradient descent preconditioned by PP
Pˉ\bar Pthe time average of RMSProp's preconditioner P=diag(νt)/ηP=\mathrm{diag}(\sqrt{\nu_t})/\eta at the edge of stability
ω\omegaweight-decay coefficient (.1 by default in d8)
Central flow
w(t)w(t)the central flow, the time-averaged iterate, which follows dw/dt=−η[∇L+12σ2∇S]dw/dt=-\eta[\nabla L+\tfrac12\sigma^2\nabla S]
σ2(t)\sigma^2(t)σ2(t)=E[xt2]\sigma^2(t)=\mathbb E[x_t^2], the variance of the oscillation along uu, set so that SS stays at 2/η2/\eta
Πv⊥,\Pi^\perp_v, Π∇S⊥\Pi^\perp_{\nabla S}projection I−vv⊤/∥v∥2I-vv^\top/\|v\|^2 onto the directions orthogonal to vv (or to ∇S\nabla S)
Model and SAM
WWd8's language-model head matrix; the logits depend on it only through W diag(γ)W\,\mathrm{diag}(\gamma)
γ\gammad8's final RMSNorm gain vector, which the default weight-decay mask leaves undecayed; the logits depend on it only through W diag(γ)W\,\mathrm{diag}(\gamma)
ccpositive rescaling factor in the head-and-gain symmetry W→W/c, γ→cγW\to W/c,\ \gamma\to c\gamma
ρ\rhoSAM radius, the size of the ball ∥ϵ∥2≤ρ\|\epsilon\|_2\le\rho around the weights over which SAM takes the worst loss
ϵ,\epsilon, ϵ^\hat\epsilonSAM's weight perturbation, approximated to first order by ϵ^=ρ∇L(w)/∥∇L(w)∥\hat\epsilon=\rho\nabla L(w)/\|\nabla L(w)\|
λ\lambdacoefficient of the ordinary L2 penalty λ∥w∥2\lambda\|w\|^2 in SAM's objective
mmsub-batch size on which SAM's perturbation is computed

Context. On a quadratic 12Sx2\tfrac12Sx^2, gradient descent with step size η\eta multiplies xx by 1−ηS1-\eta S each step, so it converges only while S<2/ηS\lt 2/\eta. In many dimensions, every Hessian eigenvalue must stay below 2/η2/\eta. Classical theory therefore expects training to keep the S(w)S(w), the largest eigenvalue of the Hessian ∇2L(w)\nabla^2L(w) of the training loss at the weights ww: the curvature along the steepest direction SS below 2/η2/\eta. Cohen et al. (2021) found that full-batch gradient descent on neural networks breaks this expectation. Sharpness rises to 2/η2/\eta and hovers there while the loss keeps falling unevenly, a regime called the the regime in which training holds the sharpness at the largest value the step size tolerates, S≈2/ηS\approx2/\eta for gradient descent, since on a quadratic with curvature SS the iterates diverge once ηS>2\eta S\gt 2 (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 an optimizer that replaces each weight matrix's momentum by the nearest matrix with all singular values equal to 1, UV⊤UV^\top for momentum UΣV⊤U\Sigma V^\top. 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 SS at 2/η2/\eta. Equivalently, it follows gradient flow with the sharpening direction projected out. In scalar RMSProp, the same self-regulation makes the effective step size track 2/S2/S without computing SS; 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 min⁡wmax⁡∥ϵ∥≤ρL(w+ϵ)\min_w\max_{\|\epsilon\|\le\rho}L(w+\epsilon): 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 ϵ=ρ∇L/∥∇L∥\epsilon=\rho\nabla L/\|\nabla L\| and the gradient is taken at w+ϵw+\epsilon (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 a Krylov method that builds the subspace spanned by v,Hv,H2v,…v,Hv,H^2v,\dots from Hessian-vector products alone; the eigenvalues of HH 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 NN training sequences and ordinary minibatch AdamW, where the top eigenvalue of D−1/2HD−1/2D^{-1/2}HD^{-1/2}, with HH the Hessian and D=v^+ϵD=\sqrt{\hat v}+\epsilon built from AdamW's bias-corrected second-moment estimate v^\hat v and its small constant ϵ\epsilon SpreS_{\mathrm{pre}} 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 2/η2/\eta and stays there. In Cohen et al.'s runs, sharpness first rises steadily (the steady rise of the sharpness during training while it is below the threshold; observed widely, with no accepted explanation) until it crosses 2/η2/\eta. 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 2/η2/\eta while the loss keeps falling non-monotonically. Halving η\eta doubles the plateau. Several top eigenvalues reach 2/η2/\eta 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 N=32N=32 training sequences at η=.01\eta=.01 first crosses ηS=2\eta S=2 at update 375. With the cross-entropy loss, however, ηS\eta S overshoots above 2, and changing η\eta 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 w=wˉ+xuw=\bar w+xu, where wˉ\bar w is the oscillation center, uu is the unit top Hessian eigenvector, and xx is the scalar displacement along uu. For a simple top eigenvalue, expanding the gradient to second order in xx (third order in the loss) gives ∇L(wˉ+xu)≈∇L(wˉ)+x S(wˉ) u+12x2 ∇S(wˉ).\begin{aligned}\nabla L(\bar w+xu)&\approx\nabla L(\bar w)+x\,S(\bar w)\,u\\&\quad+\tfrac12x^2\,\nabla S(\bar w).\end{aligned} The middle term pushes back along uu and flips the sign of xx at each step, as on a quadratic. Because curvature along uu is u⊤Hu=Su^\top Hu=S, its gradient is ∇S\nabla S, so the quadratic term adds a descent step of size 12ηx2\tfrac12\eta x^2 on sharpness at every update. Stronger oscillations push SS down harder until ηS\eta S drops below 2 and the bounce decays; progressive sharpening then lifts SS 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, dw/dt=−η∇L(w)dw/dt=-\eta\nabla L(w), tracks gradient descent only until SS hits 2/η2/\eta, after which it keeps sharpening and diverges from the discrete trajectory. Cohen, Damian et al. (2024) instead track the time-averaged iterate w(t)w(t). Averaging the expansion above over the oscillation kills the zero-mean middle term and leaves dwdt=−η[∇L(w)+12σ2(t) ∇S(w)],\frac{dw}{dt}=-\eta\Big[\nabla L(w)+\tfrac12\sigma^2(t)\,\nabla S(w)\Big], where σ2(t)=E[xt2]\sigma^2(t)=\mathbb E[x_t^2] is the oscillation variance along uu. Holding the sharpness on the edge S(w(t))=2/ηS(w(t))=2/\eta imposes dS/dt=⟨∇S,dw/dt⟩=0dS/dt=\langle\nabla S,dw/dt\rangle=0, a linear equation in σ2\sigma^2 with the unique solution σ2(t)=2 ⟨∇S(w),−∇L(w)⟩∥∇S(w)∥2.\sigma^2(t)=\frac{2\,\langle\nabla S(w),-\nabla L(w)\rangle}{\|\nabla S(w)\|^2}. Substituting σ2\sigma^2 back gives dw/dt=−η Π∇S⊥∇Ldw/dt=-\eta\,\Pi^\perp_{\nabla S}\nabla L, gradient flow with the component along ∇S\nabla S projected out, using the orthogonal projection I−vv⊤/∥v∥2I-vv^\top/\|v\|^2, the projection onto the directions orthogonal to vv. Because σ2\sigma^2 must be nonnegative, this flow holds only under progressive sharpening, ⟨∇S,−∇L⟩>0\langle\nabla S,-\nabla L\rangle\gt 0. 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 σ2\sigma^2. With several simultaneous edge eigenvalues, a covariance matrix replaces σ2\sigma^2.

The central flow separates the iterate's loss from the averaged weights' loss. Expanding the loss to second order around w(t)w(t) and averaging gives E L(wt)≈L(w(t))+12S σ2(t)\mathbb E\,L(w_t)\approx L(w(t))+\tfrac12 S\,\sigma^2(t). Substituting S=2/ηS=2/\eta at the edge yields E L(wt)≈L(w(t))+σ2(t)/η.\mathbb E\,L(w_t)\approx L(w(t))+\sigma^2(t)/\eta. A smoothed training curve plots the left side; an EMA of the weights or a learning-rate cooldown reveals the lower loss L(w(t))L(w(t)) 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, vt+1=βvt+∇L(wt)v_{t+1}=\beta v_t+\nabla L(w_t) and wt+1=wt−ηvt+1w_{t+1}=w_t-\eta v_{t+1}, full-batch training on a quadratic stays stable while ηS<2(1+β)\eta S\lt 2(1+\beta). At the edge, successive gradients along the top eigenvector alternate in sign. Momentum sums a fixed-size alternating gradient gg to g−βg+β2g−⋯=g/(1+β)g-\beta g+\beta^2g-\cdots=g/(1+\beta), damping the bounce and raising the tolerated sharpness by 1+β1+\beta. For Adam with β1=0.9\beta_1=0.9 and a frozen preconditioner, the analogous preconditioned threshold is ηSpre<2(1+β1)/(1−β1)=38\eta S_{\mathrm{pre}}\lt 2(1+\beta_1)/(1-\beta_1)=38. With small minibatches, noise makes consecutive gradients nearly independent instead of alternating. Momentum then adds their variances by ∑iβ2i=1/(1−β2)\sum_i\beta^{2i}=1/(1-\beta^2) 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: νt=β2νt−1+(1−β2)∥∇L(wt)∥2,wt+1=wt−ηνt∇L(wt).\begin{aligned}\nu_t&=\beta_2\nu_{t-1}+(1-\beta_2)\|\nabla L(w_t)\|^2,\\w_{t+1}&=w_t-\frac{\eta}{\sqrt{\nu_t}}\nabla L(w_t).\end{aligned} With actual step size η/νt\eta/\sqrt{\nu_t}, stability along the top direction depends on the ηS/ν\eta S/\sqrt{\nu}, the sharpness SS times RMSProp's actual step size η/ν\eta/\sqrt{\nu}, where ν\nu 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 ηS<2\eta S\lt 2 ηS/ν\eta S/\sqrt{\nu}, which settles at 2 in the lecture's runs. Oscillation holds it there both by lowering SS, as in gradient descent, and by inflating the gradient norm to raise ν\nu. A larger β2\beta_2 slows ν\nu's response, pushing more regulation onto SS so that both SS and ν\nu settle lower at the same effective sharpness of 2.

At the edge, scalar RMSProp takes steps of size 2/S2/S, with η\eta acting through the sharpness penalty. Repeating the central-flow averaging with the time-averaged squared gradient norm ∥∇L∥2+σ2S2\|\nabla L\|^2+\sigma^2S^2 driving ν\nu gives dwdt=−ην[∇L+12σ2∇S],dνdt=1−β2β2[∥∇L∥2+σ2S2−ν].\begin{aligned}\frac{dw}{dt}&=-\frac{\eta}{\sqrt\nu}\Big[\nabla L+\tfrac12\sigma^2\nabla S\Big],\\\frac{d\nu}{dt}&=\frac{1-\beta_2}{\beta_2}\big[\|\nabla L\|^2+\sigma^2S^2-\nu\big].\end{aligned} On the edge of stability, effective sharpness equals 2, so ν=ηS/2\sqrt\nu=\eta S/2 and the weight flow simplifies to dwdt=−2S(w)[∇L(w)+12σ2∇S(w)].\frac{dw}{dt}=-\frac2{S(w)}\Big[\nabla L(w)+\tfrac12\sigma^2\nabla S(w)\Big]. The optimizer takes the largest stable step 2/S2/S without computing SS. Meanwhile, the 12σ2∇S\tfrac12\sigma^2\nabla S penalty steers training into flatter regions and thus larger steps; removing it in the paper's ablation slows training. Although η\eta drops out of the prefactor 2/S2/S, σ2\sigma^2 still depends on η\eta and β2\beta_2. Raising η\eta enlarges the oscillations, strengthens sharpness reduction, and ultimately increases 2/S2/S.

Coordinatewise RMSProp solves a convex program that mixes a Newton-like goal with a brake. Keeping νt\nu_t per coordinate gives νt=β2νt−1+(1−β2)∇L(wt)⊙2\nu_t=\beta_2\nu_{t-1}+(1-\beta_2)\nabla L(w_t)^{\odot2} and wt+1=wt−η ∇L(wt)/νtw_{t+1}=w_t-\eta\,\nabla L(w_t)/\sqrt{\nu_t}, gradient descent preconditioned by P=diag(νt)/ηP=\mathrm{diag}(\sqrt{\nu_t})/\eta. Even while individual coordinates oscillate, the loss curve looks smooth and the top eigenvalues of the effective Hessian P−1HP^{-1}H sit at 2. At the edge, once ν\nu has settled at its stationary value for the current weights (as observed in the paper's runs), the time-averaged preconditioner Pˉ\bar P solves Pˉ=argmin⁡P diag, P⪰0 tr(P)+1η2∥∇L∥P−12such that H⪯2P,\begin{aligned}\bar P=\operatorname*{argmin}_{P\ \mathrm{diag},\ P\succeq0}\ &\mathrm{tr}(P)+\tfrac1{\eta^2}\|\nabla L\|^2_{P^{-1}}\\\text{such that}\ &H\preceq2P,\end{aligned} where ∥g∥P−12=g⊤P−1g\|g\|^2_{P^{-1}}=g^\top P^{-1}g. The constraint enforces local stability. Minimizing tr(P)\mathrm{tr}(P), the sum of inverse effective step sizes, maximizes step sizes subject to stability. Without the diagonal restriction, it yields the scaled Newton matrix P=12HP=\tfrac12H for positive semidefinite HH. 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 WW, while leaving embeddings and RMSNorm gains undecayed, including the final gain vector γ\gamma. Logits depend on WW and γ\gamma only through W diag(γ)W\,\mathrm{diag}(\gamma). Scaling W→W/cW\to W/c and γ→cγ\gamma\to c\gamma therefore preserves the function while multiplying curvature with respect to WW by c2c^2. Stronger decay shrinks WW, undecayed γ\gamma 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.

Sharpness-aware minimization targets the worst loss in a local ball. Foret et al. (2021) optimize the worst loss inside a ball of radius ρ\rho around ww, min⁡w max⁡∥ϵ∥2≤ρL(w+ϵ)+λ∥w∥2,\min_w\ \max_{\|\epsilon\|_2\le\rho}L(w+\epsilon)+\lambda\|w\|^2, with ordinary L2 penalty λ\lambda. Linearizing the inner maximum gives ϵ^=ρ ∇L(w)/∥∇L(w)∥\hat\epsilon=\rho\,\nabla L(w)/\|\nabla L(w)\|. Dropping second-order derivatives, SAM updates with the gradient at w+ϵ^w+\hat\epsilon, which costs two backward passes per step:
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 gradient

SAM 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 ϵ^\hat\epsilon separately on small sub-batches of size mm beats using the full batch. At m=1m=1, 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 2/η2/\eta and hovers there while the loss keeps falling unevenly
progressive sharpening
rise of the sharpness during training below the threshold; unexplained
self-stabilization
the 12x2∇S\tfrac12x^2\nabla S term of the gradient: oscillation descends the sharpness
central flow
dw/dt=−η[∇L+12σ2∇S]dw/dt=-\eta[\nabla L+\tfrac12\sigma^2\nabla S] with σ2=2⟨∇S,−∇L⟩/∥∇S∥2\sigma^2=2\langle\nabla S,-\nabla L\rangle/\|\nabla S\|^2; gradient flow with ∇S\nabla S projected out
time-averaged loss
L(w(t))+σ2/ηL(w(t))+\sigma^2/\eta: the smoothed curve sits above the loss at the averaged weights
momentum threshold
full batch, heavy ball: ηS<2(1+β)\eta S\lt 2(1+\beta); with noisy small batches momentum lowers the plateau
effective sharpness
ηS/ν\eta S/\sqrt\nu for scalar RMSProp; settles at 2, so the step is 2/S2/S
stationary preconditioner
argmin of trP+∥∇L∥P−12/η2\mathrm{tr}P+\|\nabla L\|^2_{P^{-1}}/\eta^2 over diagonal PP with H⪯2PH\preceq2P
head/gain symmetry
W→W/cW\to W/c, γ→cγ\gamma\to c\gamma keeps the model, multiplies head curvature by c2c^2
Dinh et al.
rescaling layers keeps the function and changes the sharpness at will
SAM
gradient at w+ρ∇L/∥∇L∥w+\rho\nabla L/\|\nabla L\|; 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.

Connected notes

  • 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.

  • Online SGD's overlap with a hidden direction grows at the rate signal2^2/noise, which is tiny near a random start, so escaping takes about dk⋆−1d^{k^\star-1} samples for information exponent k⋆k^\star (the order of the first nonzero Hermite term) and almost all the samples are used up before the overlap grows.

  • In one-layer linear self-attention, the loss depends only on the product V=u−1U11V=u_{-1}U_{11} and leaves the scale split between the label-value scalar and the key-query matrix free; gradient flow conserves u−12=∥U11∥F2u_{-1}^2=\|U_{11}\|_F^2, which pins the limit on the hyperbola of equivalent global minima.

  • 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.

Threads