NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Towards Understanding Sharpness-Aware Minimization

Maksym Andriushchenko, Nicolas Flammarion

Sharpness-Aware Minimization (SAM) has rapidly become a go-to optimizer for boosting the generalization capabilities of neural networks. However, despite its widespread empirical success, its theoretical foundations have remained somewhat shaky. This paper bridges the gap between SAM's practical performance and our theoretical understanding, demonstrating that SAM’s success isn't solely about finding "flat" minima. Instead, it introduces a powerful implicit bias—specifically a sparsity-inducing effect—and provides the first rigorous convergence guarantees for SAM in stochastic, non-convex settings.

The Problem: Flatness, Sharpness, and Generalization

In the era of overparametrized deep learning, models can easily achieve zero training error across many different sets of weights. Yet, some of these "global minima" generalize well to unseen data, while others fail miserably.

SAM was designed to address this by seeking out "flat" minima—regions in the loss landscape where the loss doesn't change significantly if you perturb the weights. While SAM works exceptionally well in practice, existing justifications (like PAC-Bayesian bounds) are often loose. More importantly, they fail to explain a crucial empirical fact: SAM works best when the "sharpness" is calculated over small mini-batches ($m$-SAM) rather than the full dataset ($n$-SAM). Furthermore, the common intuition that "flatter is always better" has known counterexamples.

Key Insights and Discoveries

The authors tackle the mechanics of SAM through three main lenses: implicit bias analysis, trajectory analysis, and convergence theory.

The Power of Small Batches ($m$-SAM)

A central finding of the paper is that calculating the worst-case perturbation on small batches is essential for SAM's success. Full-batch SAM ($n$-SAM) barely improves over standard Empirical Risk Minimization (ERM/SGD). In contrast, mini-batch SAM (like 128-SAM) provides a massive boost in generalization.

Comparison of weight perturbation methods on CIFAR-10 and CIFAR-100. Only low-m SAM (128-SAM) shows significant gains.

As shown in the CIFAR-10 and CIFAR-100 benchmarks above, 128-SAM achieves roughly 20% test error on CIFAR-100 with a ResNet-34, while $n$-SAM and standard ERM hover around 23-24%.

Sparsity as a Proxy for Generalization

To understand why $m$-SAM works so well, the authors theoretically analyze SAM in the context of diagonal linear networks—a simplified model used to study feature selection. They prove that SAM biases the optimization toward solutions with smaller $L_1$-norms (sparsity).

This "implicit bias" pushes the model toward simpler, sparser solutions that generalize better, rather than just "flat" ones. Crucially, this sparsity-inducing effect is significantly stronger for $m$-SAM than for $n$-SAM.

Implicit bias of SAM variants showing suboptimality factor across different batch sizes.

This challenges the simplistic "flat = good" mantra. The authors even demonstrate that a model found by SAM with a large batch size can technically be "flatter" than one found by ERM with a small batch size, yet the ERM model might still generalize better.

SAM as a "Late-Stage" Refiner

Through "switching" experiments—starting training with standard SGD and switching to SAM late in the process, and vice versa—the authors uncover a surprising operational detail: you don't need SAM for the entire training run.

Enabling SAM for just the last 10% of epochs can "rescue" a model from a poorly-generalizing minimum found by standard SGD. This suggests SAM can effectively navigate "connected valleys" of minima to find better, more robust spots. This finding is highly practical, as it demonstrates that fine-tuning a pre-trained ERM model with SAM leads to significant generalization improvements, offering a computationally cheaper way to reap SAM's benefits.

Convergence Guarantees

Finally, the paper fills a major gap in the optimization literature by providing a formal proof that SAM converges to stationary points in non-convex landscapes when using stochastic gradients. The authors prove that SAM converges at a rate of $O(1/\sqrt{T})$ for non-convex objectives, matching the standard convergence rate of SGD.

Limitations and Future Directions

While this paper makes significant strides in demystifying SAM, open questions remain:

  • Linear vs. Non-Linear: The implicit bias results are mathematically rigorous for diagonal linear networks, but extending these proofs to deep, non-linear architectures remains a theoretical challenge.
  • Label Noise: SAM can eventually overfit to noisy labels, just like SGD. Early stopping is still necessary in those scenarios.
  • Computational Cost: SAM inherently requires two gradient computations per update. While late-stage fine-tuning is a viable workaround, making the full training process more efficient is an ongoing area of research.

Ultimately, this work provides a much-needed theoretical foundation for one of modern deep learning's most effective optimizers, proving that SAM's magic lies not just in finding flat valleys, but in its implicit push toward simpler, sparser representations.

Summary updated

BibTeX
@inproceedings{andriushchenko2022towards,
  author = {Maksym Andriushchenko and Nicolas Flammarion},
  title = {{Towards Understanding Sharpness-Aware Minimization}},
  booktitle = {International Conference on Machine Learning},
  year = {2022},
  url = {https://openreview.net/forum?id=_dRrY5HdSq},
}
Figure