The Crucial Role of Normalization in Sharpness-Aware Minimization

Yan Dai, Kwangjun Ahn, Suvrit Sra

TL;DR

This paper reveals that the often-ignored normalization factor in Sharpness-Aware Minimization (SAM) is not just a mathematical detail, but a fundamental driver of the algorithm's success. By comparing SAM to an "un-normalized" version (USAM), the authors demonstrate that normalization is essential for stabilizing training and enabling the optimizer to "drift" along manifolds of minima to find flatter, better-generalizing solutions.

What Problem Does This Paper Address?

Sharpness-Aware Minimization (SAM) has become a go-to optimizer for improving the generalization of deep neural networks. It works by seeking parameters that lie in "flat" regions of the loss landscape. The standard SAM update involves a small perturbation step that is normalized by the gradient's magnitude:

$$w_{t+1} = w_t - \eta \nabla L \left( w_t + \rho \frac{\nabla L(w_t)}{\|\nabla L(w_t)\|} \right)$$

However, many theoretical researchers have recently started analyzing an "Un-normalized SAM" (USAM) variant for the sake of mathematical simplicity, assuming the normalization factor $1/\|\nabla L(w_t)\|$ is negligible. This paper asks a critical question: Is this simplification justified? The authors argue that it is not, and that removing normalization fundamentally changes—and often breaks—the algorithm's behavior.

Methods

The authors employ a two-pronged approach:

  1. Theoretical Analysis: They characterize the dynamics of SAM vs. USAM across several settings:
  2. Strongly Convex & Smooth Losses: Proving that SAM stays within a stable neighborhood of the minimum, while USAM can easily diverge.
  3. Non-Convex Scalar Factorization: A toy model used to show how SAM robustly finds the origin while USAM is unstable.
  4. Single-Neuron Linear Models: Used to study "drifting" behavior near a continuum of minima.
  5. Empirical Validation: They test their findings on:
  6. Matrix Sensing: An over-parameterized problem to observe stability and drifting.
  7. Deep Learning Benchmarks: Training ResNet18 and Fully Connected Networks (FCNs) on CIFAR-10.
  8. Sparse Coding: A case study on learning specific network structures (threshold neurons).

Datasets

  • CIFAR-10: Standard image classification dataset used for ResNet18 and FCN experiments.
  • Synthetic Data: Custom-generated datasets for the matrix sensing and sparse coding experiments to isolate specific mathematical behaviors.

Key Insights and Ideas

  • The Stability Anchor: Normalization acts as a stabilizer. In the early stages of training, gradients are large. In USAM, this leads to massive, aggressive perturbation steps that cause the optimizer to diverge. SAM’s normalization keeps the perturbation radius constant ($\rho$), ensuring it doesn't blow up.

    Figure 1: Role of normalization for stabilizing algorithms (η = 0.05).
  • The "Drift" Mechanism: The most profound insight is how normalization affects behavior near minima. As an optimizer approaches a minimum, the gradient $\|\nabla L(w_t)\|$ shrinks.

  • In USAM, the perturbation also shrinks, causing the algorithm to get stuck at the first minimum it finds.
  • In SAM, the normalization ensures the perturbation remains at magnitude $\rho$ even as the gradient vanishes. This "kicks" the optimizer along the manifold of minima, allowing it to keep moving until it finds a region with lower "sharpness."

    Figure 2: SAM continues to drift along the manifold of minima to reduce test loss, while USAM and GD get stuck.
  • Hyperparameter Robustness: Because normalization decouples the perturbation from the gradient magnitude, the perturbation radius $\rho$ can be tuned independently of the learning rate $\eta$. This makes SAM a robust "add-on" for existing optimizers, whereas USAM requires delicate joint tuning of $\eta$ and $\rho$.

Key Results

  • Stability Proofs: Theorem 1 shows that for $\beta$-smooth losses, SAM converges to a neighborhood of the minimum for any $\eta < 2/\beta$, whereas USAM diverges if $\eta$ is even slightly larger than a much stricter threshold.
  • Drifting Dynamics: In the single-neuron model, the authors prove that SAM always approaches the origin (the "best" minimum), while USAM gets trapped at suboptimal points depending on its initialization.
  • Sparse Coding Success: In the sparse coding task, SAM consistently learns the desired negative bias structure across different learning rates. USAM, like standard Gradient Descent, fails to learn this structure unless the learning rate is tuned to the "edge of stability," which is difficult to do in practice.

Limitations and Future Work

  • Simplified Models: Much of the rigorous theory relies on simplified models (scalar factorization, single neurons). While these capture the essence of the dynamics, extending these proofs to deep, multi-layer architectures remains a challenge.
  • Stochasticity: The paper primarily focuses on full-batch gradient descent. The interaction between normalization and the noise inherent in Stochastic Gradient Descent (SGD) is a promising area for future research.
  • Alternative Normalizations: Future work could investigate if other forms of normalization (e.g., layer-wise or parameter-wise) offer even better stability or drifting properties.

Summary updated

Abstract

Sharpness-Aware Minimization (SAM) is a recently proposed gradient-based optimizer (Foret et al., ICLR 2021) that greatly improves the prediction performance of deep neural networks. Consequently, there has been a surge of interest in explaining its empirical success. We focus, in particular, on understanding the role played by normalization, a key component of the SAM updates. We theoretically and empirically study the effect of normalization in SAM for both convex and non-convex functions, revealing two key roles played by normalization: i) it helps in stabilizing the algorithm; and ii) it enables the algorithm to drift along a continuum (manifold) of minima -- a property identified by recent theoretical works that is the key to better performance. We further argue that these two properties of normalization make SAM robust against the choice of hyper-parameters, supporting the practicality of SAM. Our conclusions are backed by various experiments.
BibTeX
@inproceedings{dai2023crucial,
  author = {Yan Dai and Kwangjun Ahn and Suvrit Sra},
  title = {{The Crucial Role of Normalization in Sharpness-Aware Minimization}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=zq4vFneRiA},
}
Figure