Practical Sharpness-Aware Minimization Cannot Converge All the Way to Optima

Dongkuk Si, Chulhee Yun

Introduction

Sharpness-Aware Minimization (SAM) has emerged as a cornerstone optimizer for modern deep learning, particularly for training high-performance models like Vision Transformers. By seeking "flat" minima—regions where the loss remains relatively stable under small perturbations—SAM effectively improves model generalization. However, a significant discrepancy exists between the theoretical ideal of SAM and its practical implementation. While mathematical proofs often assume a decaying perturbation size ($\rho$) or unnormalized gradients, practitioners typically use a constant $ ho$ and normalized gradients for the ascent step.

This paper investigates whether the version of SAM used in the real world actually converges to the global optimum. The findings reveal a fundamental limitation: practical SAM often fails to reach the true optimum, instead hitting an "error floor" or becoming trapped in suboptimal regions of the loss landscape.

The Virtual Loss Framework

To analyze SAM's behavior, the authors introduce the concept of a Virtual Loss ($J_f$). They demonstrate that running SAM on a target function $f$ is mathematically equivalent to performing standard Gradient Descent on this virtual landscape.

The critical insight is that the stationary points of $J_f$ do not necessarily coincide with the stationary points of the original loss $f$. If the virtual loss landscape is shifted or distorted relative to the original, the optimizer will naturally gravitate toward the minimum of $J_f$, effectively drifting away from the true optimum of $f$. For example, in simple 1D quadratic functions, the virtual loss can become non-smooth, preventing the rapid exponential convergence typically seen with standard optimizers.

Convergence Analysis Across Function Classes

The research categorizes SAM into two primary operational modes: Deterministic SAM (using full-batch gradients) and Stochastic SAM (using mini-batches). Stochastic SAM is further divided into n-SAM (using independent samples for ascent and descent) and m-SAM (using the same sample for both, which is the standard practice).

1. The $O(\rho^2)$ Error Floor

In nearly all stochastic and nonconvex settings, the authors prove that SAM suffers from an unavoidable additive error term proportional to the square of the perturbation size ($O(\rho^2)$). While the optimizer can approach the vicinity of the optimum, it cannot "touch" it; the constant perturbation size creates a fundamental limit on precision.

2. The Trap of m-SAM

The practical version of stochastic SAM (m-SAM) is particularly susceptible to failure. Because it reuses the same data sample for both the ascent and descent steps, local concavity in individual component functions can create "attracting basins" within the virtual loss. These basins can trap the optimizer in regions with high loss values indefinitely, regardless of how many iterations are performed.

3. Strong Convexity and Sublinear Rates

Even in the most favorable scenario—deterministic SAM on strongly convex functions—the optimizer underperforms compared to standard Gradient Descent. While it can converge to the true optimum in this specific case, it does so at a sublinear rate of $\tilde{O}(1/T^2)$. This is significantly slower than the exponential (linear) convergence rate expected from standard GD on smooth, strongly convex objectives.

Key Results and Lower Bounds

The paper establishes several rigorous bounds for SAM's performance:

  • Deterministic Strongly Convex: Achieves a rate of $\tilde{O}(\exp(-T) + 1/T^2)$. The $1/T^2$ term is a fundamental lower bound.
  • Stochastic Convex: For m-SAM, the authors constructed smooth convex functions where the suboptimality gap remains arbitrarily large, independent of the size of $\rho$.
  • Nonconvex: Even in deterministic settings, SAM only converges to a neighborhood of a stationary point, with a gradient norm error of $O(\rho^2)$.

Conclusion and Future Directions

This work highlights that the generalization benefits of SAM come at the cost of optimization precision. Practical SAM is not a perfect minimizer but rather an optimizer of a "virtual" landscape that prioritizes flatness over absolute convergence.

Future research may focus on identifying definitive counter-examples for deterministic SAM on smooth convex functions or refining the constants related to smoothness and strong convexity in existing bounds. For now, practitioners should be aware that the "flatness" sought by SAM may inherently prevent the model from reaching the lowest possible point on the original loss training curve.

Summary updated

BibTeX
@inproceedings{si2023practical,
  author = {Dongkuk Si and Chulhee Yun},
  title = {{Practical Sharpness-Aware Minimization Cannot Converge All the Way to Optima}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=nijJN0LHqM},
}
Figure