NeurIPS 2026 · Sydney

Generalization at the Edge of Stability

1 INRIA, CNRS, École Normale Supérieure 2 Imperial College London

*,† Equal contribution

Conceptual diagram of stochastic optimization at the Edge of Stability: trajectories in R^d enter a lower-dimensional random attractor with expanding and contracting directions, governed by the Sharpness Dimension SD < d.
Figure 1 — Generalization at the Edge of Stability (EoS). Modeling stochastic optimization as a random dynamical system (RDS), at EoS the leading sharpness satisfies \(\lambda_1 > 0\) (local expansion along at least one direction), while contraction in the remaining directions confines trajectories to a fractal attractor with intrinsic dimension \(\mathrm{SD} < d\).
TL;DR

At the Edge of Stability, stochastic optimizers do not converge to a single point—they explore a lower-dimensional random pullback attractor. We introduce the Sharpness Dimension (\(\mathrm{SD}\)), a Lyapunov-inspired measure built from the full Hessian spectrum, prove that it bounds the worst-case generalization gap over the attractor, and validate it across MLPs, modular-arithmetic grokking, and 124M-parameter GPT-2.

Abstract

Training modern neural networks often relies on large learning rates, operating at the edge of stability, where the optimization dynamics exhibit oscillatory and chaotic behavior. Empirically, this regime often yields improved generalization performance, yet the underlying mechanism remains poorly understood. In this work, we represent stochastic optimizers as random dynamical systems, which often converge to a fractal attractor set (rather than a point) with a smaller intrinsic dimension. Building on this connection and inspired by Lyapunov dimension theory, we introduce a novel notion of dimension, coined the sharpness dimension, and prove a generalization bound based on this dimension. Our results show that generalization in the chaotic regime depends on the complete Hessian spectrum and the structure of its partial determinants, highlighting a complexity that cannot be captured by the trace or spectral norm considered in prior work. Experiments across various MLPs and transformers validate our theory while also providing new insights into the recently observed phenomenon of grokking.

Interactive: From Hessian Spectrum to Sharpness Dimension

Explore how the full Hessian spectrum \(\{\alpha_i\}_{i=1}^d\) and learning rate \(\eta\) determine the ordered one-step Jacobian log-singular values \(\lambda_k = \ln |1 - \eta \alpha_{\pi(k)}|\), the partial sums \(S_i = \sum_{k=1}^i \lambda_k\), and the Sharpness Dimension \(\dim_{\mathrm{S}}\mathcal{A}\).

Spectrum preset — determines (1) Hessian eigenvalues \(\{\alpha_i\}_{i=1}^d\)

Each preset chooses the Hessian spectrum \(\{\alpha_i\}\) in Panel (1); the sliders below push it through \(\lambda_k = \ln|1 - \eta\alpha_{\pi(k)}|\) in Panel (2) and its cumulative sum in Panel (3).

0.080
36.0
0.75
Stability threshold \(2/\eta\) 25.00
Top RDS sharpness \(\lambda_1\) +0.631
Hessian trace \(\mathrm{tr}(H)\) 182.4
Transition index \(j^*\) 7
Sharpness Dimension \(\dim_{\mathrm{S}}\mathcal{A}\) 14.94 / 24
Dynamical regime Edge of Stability

1. Hessian Eigenvalues \(\alpha_i\)

Expanding if \(\alpha_i > 2/\eta\) or \(\alpha_i < 0\)

2. Ordered RDS Sharpness \(\lambda_k\)

\(\lambda_k = \ln |1 - \eta \alpha_{\pi(k)}|\), sorted descending

3. Partial Sums \(S_i = \sum_{k=1}^i \lambda_k\)

Zero crossing gives \(\dim_{\mathrm{S}}\mathcal{A} = j^* + \frac{S_{j^*}}{|\lambda_{j^*+1}|}\)

Geometric intuition (Ellipsoid covering)

One step of \(I - \eta H\) maps a ball \(B(0, R)\) to an ellipsoid with semi-axes \(R\sigma_1 \ge \dots \ge R\sigma_d\). Covering it with balls of radius \(R\sigma_{j^*+1}\) turns the volume product \(\prod_{k=1}^{j^*} \sigma_k\) into the partial sum \(S_{j^*}\), giving \(\dim_{\mathrm{S}}\mathcal{A}\) as the exact scale where \(j\)-volumes stop expanding.

Interactive: Pullback Attraction at the Edge of Stability

Visualizing Definition 2.2 on \(L(x) = \frac{1}{2}\|x\|^2 - 2\cos(4x_1)\cos(4x_2)\). Three disjoint initial sets \(B_1, B_2, B_3\) share a fixed noise history \(\omega\). Increasing the pullback horizon \(t\) (starting earlier at \(-t\) and evolving to present time \(0\)) collapses all three initializations onto the same stationary snapshot attractor \(\mathcal{A}(\omega)\).

\(B_1\) \(B_2\) \(B_3\) Fixed target \(\mathcal{A}(\omega)\) at \(t_{\text{now}}=0\)
Pullback horizon t = 24 Ergodic 2D SD: —

Attraction Mode & Parameters

24

In Pullback mode, \(B_1, B_2, B_3\) converge onto one fixed snapshot \(\mathcal{A}(\omega)\). In Forward mode, the attractor drifts as fresh noise arrives.

0.074
0.32
Hausdorff \(\mathrm{dist}(B_1, B_2)\) —
Ergodic 2D \(\mathrm{SD}\) (last 15 steps) —
Snapshot 2D \(\mathrm{SD}\) (step \(t\)) —
Ergodic \(\bar{\lambda}_1,\; \bar{\lambda}_2\) —

Near minima \(\alpha_{\max} = 33\), so \(\eta < 2/33 \approx 0.061\) is contractive (\(\mathrm{SD}=0\)). Above EoS, the single-step Snapshot SD can briefly dip to \(0\) when noise pushes particles onto the fold \(\sigma \approx 0\), whereas the time-averaged Ergodic SD estimates the expectation \(\mathbb{E}[\cdot]\) in Def. 3.1.

Main Theoretical Result

Modeling a stochastic optimizer as a random dynamical system \((\Omega, \mathcal{F}, \mathbb{P}, \theta, \phi)\) with one-step Jacobian singular values \(\sigma_1(\omega, w) \ge \dots \ge \sigma_d(\omega, w)\), we define the RDS Sharpness of Order \(k\) as \(\lambda_k := \mathbb{E}[\sup_{w \in \mathcal{A}(\omega)} \ln \sigma_k(\omega, w)]\). Letting \(j^* := \max\{ i : \sum_{k=1}^i \lambda_k \ge 0\}\), the Sharpness Dimension is

$$\dim_{\mathrm{S}}\mathcal{A} := j^* + \frac{\sum_{i=1}^{j^*} \lambda_i}{|\lambda_{j^*+1}|} \quad (1 \le j^* < d),$$

with \(\dim_{\mathrm{S}}\mathcal{A} = 0\) when \(\lambda_1 < 0\) and \(\dim_{\mathrm{S}}\mathcal{A} = d\) when \(j^* = d\). Using iterative ellipsoid covering, exterior-power subadditivity, and Birkhoff's ergodic theorem, we prove \(\overline{\dim}_M(\mathcal{A}(\omega)) \le \dim_{\mathrm{S}}\mathcal{A}\) almost surely, yielding our generalization bound over the entire random pullback attractor \(\mathcal{A}_S(\omega)\):

Theorem 3.4 — Generalization via Sharpness Dimension

Under standard boundedness (\(B\)), \(L\)-Lipschitz continuity, and regular random dynamics assumptions (Assump. B.1–B.3), with probability at least \(1 - \zeta - \gamma\) over \((S, \omega)\), for sufficiently small \(\delta > 0\),

$$\sup_{w \in \mathcal{A}_S(\omega)} \big(\mathcal{R}(w) - \widehat{\mathcal{R}}_S(w)\big) \;\le\; 2L\delta + 2B\sqrt{\frac{4\,\dim_{\mathrm{S}}\mathcal{A}_S \,\log(1/\delta)}{n}} + \frac{I_\infty(\mathcal{A}_S(\omega), S) + \log(1/\zeta)}{\sqrt{n}} + \frac{CB^2}{\sqrt{n}}.$$

We also provide a mutual-information-free version via random set stability (Theorem C.6) and a scalable estimator via minibatch Stochastic Lanczos Quadrature (SLQ), reducing memory from \(\Theta(N^2)\) to \(\Theta(mN)\).

Empirical Highlights

MNIST MLPs (3- & 5-Layer)

Across a \(5\times 5\) learning-rate / batch-size grid, trajectory-based PH-Dim and top sharpness \(\lambda_1\) fail at EoS, whereas full-spectrum SD (\(\tau = \mathbf{0.76}\)) and SD-SLQ (\(\tau = \mathbf{0.61}\)) strongly track the generalization gap.

SD (Exact)
+0.76
SD-SLQ
+0.61
\(E_\alpha\) (\(\|\cdot\|_2\))
+0.34
RDS-Sharp. \(\lambda_1\)
−0.16
PH-Dim (\(\rho\))
−0.40

Grokking (Mod 97)

On modular addition \((a + b) \bmod 97\), SD achieves up to \(\tau = \mathbf{0.88}\) using only single-checkpoint weights—matching trajectory-based \(E_\alpha\) without storing training trajectories.

In 3-layer ReLU grokking without momentum, classical sharpness and \(\mathrm{tr}(H)\) decay monotonically, while SD rises before grokking and drops sharply across the sudden generalization phase transition.

GPT-2 (124M) on WikiText-2

Trained from scratch across SGD, SGD+Momentum, and AdamW hyperparameter grids, classical sharpness fails and correlates negatively with the loss gap under AdamW (\(\tau = -0.88\)).

Our smoothed SLQ estimators remain consistently positive across all three optimizers, with pseudo-spectrum SD-PS reaching \(\tau \approx \mathbf{0.51}\) (SGD+Mom.) and \(\tau \approx \mathbf{0.69}\) (AdamW).

Citation

@inproceedings{tuci2026generalization,
  title         = {Generalization at the Edge of Stability},
  author        = {Tuci, Mario and Korkmaz, Caner and
                   {\c{S}}im{\c{s}}ekli, Umut and Birdal, Tolga},
  booktitle     = {Advances in Neural Information Processing Systems (NeurIPS)},
  year          = {2026},
  eprint        = {2604.19740},
  archivePrefix = {arXiv},
  primaryClass  = {cs.LG},
  url           = {https://arxiv.org/abs/2604.19740}
}

Acknowledgments

T. B. was supported by a UKRI Future Leaders Fellowship (MR/Y018818/1). The authors acknowledge support from the UK AI Research Resource (AIRR Isambard AI) through grant 0251-4584-0945-1 — TopoFound. U. Ş. is partially supported by the French government under the management of Agence Nationale de la Recherche as part of the “Investissements d’avenir” program, reference ANR-19-P3IA-0001 (PRAIRIE 3IA Institute). M. T. and U. Ş. are partially supported by the European Research Council Starting Grant DYNASTY — 101039676.