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

Why Does Sharpness-Aware Minimization Generalize Better Than SGD?

Zixiang Chen, Junkai Zhang, Yiwen Kou, Xiangning Chen, Cho-Jui Hsieh, Quanquan Gu

Abstract

Sharpness-Aware Minimization (SAM) has emerged as a powerful optimizer for improving the generalization of deep neural networks, yet a rigorous theoretical understanding of its advantage over Stochastic Gradient Descent (SGD) has been limited—particularly for non-smooth architectures like those using ReLU activations. This paper provides a formal analysis of SAM’s success, demonstrating that it acts as an early-stage "noise filter." By utilizing a signal-noise decomposition framework on a two-layer convolutional neural network (CNN), we show that SAM prevents the memorization of noisy labels by deactivating noise-sensitive neurons during its adversarial perturbation step. Our findings reveal a fundamental separation: while SGD requires signal strength to scale with data dimensionality to avoid harmful overfitting, SAM achieves benign overfitting even with constant signal strength. These theoretical insights are supported by empirical evidence across synthetic datasets, CIFAR-10/100, and ImageNet.

1. Introduction

Modern deep learning relies on overparameterized models that possess the capacity to perfectly fit training data, including mislabeled or noisy samples. This susceptibility to overfitting is a primary challenge in model training. While Stochastic Gradient Descent (SGD) is the standard optimization tool, Sharpness-Aware Minimization (SAM) has consistently demonstrated superior generalization by seeking "flat" regions in the loss landscape.

Existing explanations for SAM’s efficacy often rely on the Hessian—a measure of curvature that assumes a smooth loss landscape. However, real-world networks typically employ ReLU activations, which result in non-smooth landscapes where Hessian-based analysis fails. This paper addresses this gap by analyzing SAM’s behavior in non-smooth, two-layer CNNs, focusing on how the optimizer distinguishes between true features and random noise.

2. Theoretical Framework and Methodology

To compare SGD and SAM, the authors analyze a two-layer convolutional ReLU network trained on a binary classification task. The data model utilizes a "patch-based" structure: each input contains one patch representing the actual signal (the feature) and multiple patches containing random Gaussian noise. To simulate real-world imperfections, label noise (randomly flipped labels) is introduced.

2.1 Signal-Noise Decomposition

The core of the analysis is a signal-noise decomposition technique. This allows for the mathematical tracking of weight growth, separating the components of the network that learn the true feature from those that memorize noise. Unlike previous theories, this approach focuses on the "activation patterns" of neurons—specifically, which neurons fire during the perturbation step that SAM performs. This bypasses the need for smoothness assumptions and provides a direct look at how SAM influences the model's internal representations.

3. Key Insights: SAM as a Noise Filter

3.1 The Denoising Property

The most significant finding is SAM’s ability to act as a filter during the early stages of training. When a neuron begins to adapt to a noise pattern (memorizing a specific noisy sample), SAM’s adversarial perturbation step is likely to deactivate that neuron. By shifting the weights in a direction that increases loss, SAM effectively "tests" the stability of a neuron's contribution. If a neuron is only firing for a specific noisy outlier, the perturbation disrupts its activation, preventing the model from committing to that noise.

3.2 The Phase Transition and Dimensionality

The authors identify a formal separation between the two optimizers based on data dimensionality ($d$):

  • SGD’s Limitation: SGD is subject to a "phase transition" where it falls into harmful overfitting unless the signal strength is at least $\Theta(d^{1/4})$. In high-dimensional spaces, the signal must be quite strong for SGD to ignore the noise.
  • SAM’s Advantage: In contrast, SAM is effectively "dimension-free." It can achieve benign overfitting—fitting the training data while maintaining high test accuracy—even when the signal strength is a constant $\Omega(1)$, regardless of the dimensionality of the data.

4. Empirical Results

The theoretical predictions were validated through several experiments:

  • Synthetic Data: Heatmaps of test error on synthetic data confirmed the theoretical separation. In regimes with high dimensionality and weak signals, SGD exhibited high test error, while SAM maintained low test error across nearly the entire parameter space.
  • Benchmark Datasets: On CIFAR-10 and CIFAR-100, SAM showed significantly higher robustness against added Gaussian noise compared to SGD.
  • ImageNet and Training Dynamics: Using a ResNet-50 on ImageNet, the authors investigated the timing of SAM updates. They found that applying SAM early in the training process is critical for final performance. This supports the hypothesis that SAM’s primary role is preventing the initial "memorization phase" of noise, allowing the model to focus on learning robust features.

5. Discussion and Limitations

While this work provides a breakthrough in understanding SAM for non-smooth networks, several areas remain for future exploration. The current theoretical proof is focused on two-layer CNNs; extending this to deeper architectures like ResNet-50 remains a mathematical challenge. Additionally, the analysis does not yet fully incorporate other common regularization techniques such as weight decay or momentum. Finally, while the patch-based data model is a powerful abstraction, it is simpler than the complex hierarchical structures found in natural image data.

6. Conclusion

This paper clarifies why SAM generalizes better than SGD by highlighting its role as an early-training noise filter. By preventing neurons from latching onto noisy labels in high-dimensional settings, SAM ensures that the model prioritizes generalizable features. This "denoising" mechanism provides a robust explanation for SAM's success in modern, non-smooth neural network architectures.

Summary updated

BibTeX
@inproceedings{chen2023why,
  author = {Zixiang Chen and Junkai Zhang and Yiwen Kou and Xiangning Chen and Cho-Jui Hsieh and Quanquan Gu},
  title = {{Why Does Sharpness-Aware Minimization Generalize Better Than SGD?}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=3WAnGWLpSQ},
}
Figure