Generalization at the Edge of Stability

Mario Tuci, Caner Korkmaz, Umut Simsekli, Tolga BirdalNeurIPS 2026

TL;DR

When we train modern neural networks with large learning rates, they don't quietly settle into a single optimal point; instead, they bounce around chaotically at the "edge of stability." Rather than treating this chaos as an optimization bug, this paper models the optimizer as a random dynamical system that settles onto a lower-dimensional fractal attractor. By measuring the intrinsic geometry of this entire attractor—via a new metric called the Sharpness Dimension—the authors explain why models operating on the brink of instability generalize so remarkably well.

What Problem Does This Paper Address?

Classical optimization textbooks tell us that if your learning rate ($\eta$) is too large relative to the curvature of the loss landscape (specifically, when the largest eigenvalue of the Hessian exceeds $2/\eta$), gradient descent becomes unstable and diverges. Yet, modern deep learning routinely violates this rule. Networks frequently train right at or above this threshold—a regime known as the Edge of Stability (EoS)—oscillating chaotically while training loss still decreases and test performance improves.

Historically, researchers tried to explain generalization by looking at the local curvature ("flatness" or "sharpness") of a single final weight vector. However, flat minima can generalize poorly, sharp minima can generalize well, and—most importantly—at the EoS, the optimizer never settles on a single point anyway! How do we explain generalization when the training trajectory is locally unstable, chaotic, and perpetually wandering?

Methods

The authors shift the focus from isolated parameter vectors to the geometry of the entire set of solutions the optimizer explores over time.

Figure 1: Generalization at the Edge of Stability (EoS). Modeling stochastic optimization as a random dynamical system (RDS), we show that at EoS the leading sharpness satisfies λ1 > 0, implying expansion along at least one direction. The fundamental balance between expansion and contraction implies that the effective dimensionality of the dynamics, measured by our Sharpness Dimension (SD), is strictly smaller than the ambient parameter space: SD < d. We prove that the worst-case generalization error is governed by SD rather than the parameter count.
  • Random Dynamical Systems (RDS) & Pullback Attractors: They formalize stochastic optimizers (like mini-batch SGD) as discrete-time RDS. Because fresh minibatch noise is injected at every step, trajectories don't converge forward in time; instead, they are analyzed via a pullback random attractor—a compact, often fractal set representing a noise-conditioned snapshot of where past trajectories settle.
  • RDS Sharpness & Sharpness Dimension (SD): Inspired by Lyapunov exponents (which measure how fast nearby chaotic trajectories diverge), the authors define RDS Sharpness using the singular values of the optimizer's one-step Jacobian across the attractor. Combining these values yields the Sharpness Dimension (SD): a measure of the effective number of expanding directions on the attractor before contracting directions take over and squash the volume.
  • Scalable Estimation (SLQ): Computing the full Hessian spectrum for millions of parameters is intractable with standard SVD. To compute SD in practice without needing the training trajectory, the authors adapt Stochastic Lanczos Quadrature (SLQ)—probing Hessian-vector products across independent minibatches to approximate the full eigenvalue density.

Datasets

No new benchmarks are introduced; the authors validate their theory across standard vision, algorithmic, and language modeling tasks:

  • MNIST: Used to train 3-layer and 5-layer MLPs across grids of learning rates and batch sizes.
  • Modular Arithmetic (Addition modulo 97): A classic synthetic task (using a 40%/60% train/test split of the $97^2$ pairs) used to induce and study grokking (sudden, delayed generalization).
  • WikiText-2: Used to train 124M-parameter GPT-2 transformers from scratch using SGD, SGD with momentum, and AdamW.

Key Insights and Ideas

  • Chaos compresses dimensionality: At the Edge of Stability, there is at least one expanding direction ($\lambda_1 > 0$), creating chaotic oscillations. However, because the vast majority of directions in parameter space are strongly contracting, the resulting fractal attractor has an effective dimension strictly smaller than the ambient parameter count ($\text{SD} < d$). Generalization is governed by this smaller intrinsic dimension, not the raw number of weights.
  • The entire spectrum matters: Prior metrics rely on the Hessian's trace or its single largest eigenvalue. SD reveals that generalization in chaotic regimes depends on the delicate tug-of-war between all expanding and contracting directions across the complete Hessian spectrum.
  • Trajectory-free dynamical insight: Unlike topological data analysis (TDA) baselines that require saving thousands of late-stage weight checkpoints to measure the trajectory's shape, SD extracts dynamical attractor properties directly from the local spectrum of a single model checkpoint.
  • Grokking is a spectral phase transition: During grokking, SD tracks the sudden jump in test accuracy—even rising before generalization and dropping sharply right at the grokking transition—confirming that delayed generalization coincides with a structural reorganization of the Hessian spectrum.

Key Results

Across scales, SD and its scalable approximations (SD-SLQ, SD-KDE, SD-PS) consistently correlate with the empirical generalization gap better than classical sharpness or trajectory-based persistent homology (PH) dimensions.

Figure 2: Correlations between various general- ization indices and the empirical generalization gap on our small 3-layer MLP trained on the MNIST dataset. The region indicated in green shows that our proposed Sharpness Dimension (SD) better predicts generalization.
  • MLPs on MNIST: On the 3-layer MLP, exact SD achieves a 0.76 Kendall correlation with the generalization gap (and 0.83 with the loss gap), while SLQ-approximated SD reaches 0.61. Meanwhile, PH dimensions and top RDS-sharpness alone show negative correlations (-0.16 to -0.40). On the 5-layer MLP, SD-SLQ achieves the highest overall Kendall's $\tau$ across the hyperparameter grid.
  • GPT-2 (124M) on WikiText-2: Under AdamW, classical sharpness fails dramatically, showing a strong negative correlation (-0.63 to -0.68) with loss gaps. Conversely, smoothed SD variants (SD-KDE and SD-PS) maintain positive, informative correlations across SGD, Momentum, and AdamW (reaching up to 0.75 with the loss gap under AdamW).
  • Runtime: Spectral estimation via SLQ takes ~5 minutes for a 3-layer MLP, ~1 hour for a 5-layer MLP, and ~3 hours per model for GPT-2.

Limitations and Future Work

  • Computational Bottleneck: Even with SLQ approximations, estimating the entire Hessian spectrum remains computationally heavy (~3 hours for a 124M GPT-2 model), making scaling to multi-billion-parameter LLMs challenging without coarser approximations.
  • Theoretical Assumptions & Optimizers: The theoretical generalization bounds rely on smoothness and boundedness assumptions and primarily model simpler stochastic dynamics; extending the rigorous RDS theory to adaptive optimizers (like AdamW, where it already works empirically) and weaker regularity conditions remains open.
  • Analytical Characterization: Future work aims to analytically derive how specific data distributions and optimizer choices shape SD in simplified theoretical models.

Summary updated

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 behaviour*. 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.
BibTeX
@inproceedings{tuci2026generalization,
  author = {Mario Tuci and Caner Korkmaz and Umut Simsekli and Tolga Birdal},
  title = {{Generalization at the Edge of Stability}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=9UYTAT1rtr},
}
Figure