$\boldsymbol{\mu}\mathbf{P^2}$: Effective Sharpness Aware Minimization Requires Layerwise Perturbation Scaling

Moritz Haas, Jin Xu, Volkan Cevher, Leena Chennuru Vankadara

Sharpness Aware Minimization (SAM) has become a go-to technique for researchers looking to squeeze extra generalization performance out of neural networks. By seeking out "flat" regions of the loss landscape, SAM helps models avoid overfitting and improves robustness. But as we move toward the era of massive foundation models, a critical question arises: How does SAM behave when we scale up the width of a network?

A recent paper from researchers at the University of Tübingen, Oxford, EPFL, and Amazon reveals a startling finding: in very wide networks, standard SAM effectively "breaks," only perturbing the very last layer of the model. To fix this, they introduce $\mu P^2$ (Maximal Update and Perturbation Parameterization), a framework that ensures SAM remains effective across all layers, regardless of model size.

The Problem: Hyperparameter Tuning and the "Vanishing Act"

In deep learning, "scaling laws" are the current north star. To avoid the massive computational cost of tuning hyperparameters (like learning rate $\eta$ or perturbation radius $\rho$) on giant models, researchers use the Maximal Update Parameterization ($\mu P$). $\mu P$ allows practitioners to find the best settings on a small proxy model and "transfer" them directly to a much larger one.

However, SAM adds a unique "ascent" step where weights are perturbed before the actual gradient update. The authors discovered that under standard scaling rules, as the network width approaches infinity, the influence of these perturbations in the hidden layers drops to zero. If the perturbations vanish, the inductive bias that makes SAM useful disappears. This makes hyperparameter tuning for SAM a moving target as models grow.

Methods: Deriving $\mu P^2$

The authors utilize the Tensor Programs framework—a mathematical toolset for analyzing the infinite-width limit of neural networks—to diagnose and solve this issue.

  1. The "bcd-parameterization": They extend the existing $abc$-parameterization (which handles initialization and learning rates) by adding new scaling factors specifically for the SAM perturbation radius.
  2. Defining "Effective" Perturbations: A perturbation is defined as "effective" only if its impact on the model's output remains constant as the width increases.
  3. Layerwise Scaling Rules: By analyzing the forward and backward passes of the SAM update, they derived a unique set of layerwise scaling rules. While a naive global scaling might use a single factor like $\rho \cdot n^{-1/2}$, $\mu P^2$ requires different exponents for the input, hidden, and output layers to keep the "perturbation signal" balanced.
  4. Spectral Condition: They provide a simple heuristic: for SAM to be stable and effective, weight perturbations should scale exactly like weight updates in $\mu P$.

Key Insights and Ideas

  • The Vanishing Act: In wide networks, standard SAM is essentially "Last-Layer SAM." Hidden layers become "lazy" regarding the perturbation, meaning they don't inherit SAM’s benefits (like lower Hessian spectral norms).
Layerwise perturbation effects across network widths.
  • Hyperparameter Transfer is Possible: The most significant breakthrough is that $\mu P^2$ is the unique parameterization that achieves joint transfer of both the learning rate ($\eta$) and the perturbation radius ($\rho$).
  • Four Regimes of Scaling: The paper categorizes perturbation scaling into four distinct regimes: Unstable (outputs blow up), Vanishing (perturbations disappear, collapsing to standard SGD), Nontrivial (unbalanced effects), and Effective (the "Goldilocks" zone where every layer contributes to the sharpness-aware objective).

Key Results

The researchers validated their theory across several standard benchmarks, including MLPs on CIFAR-10, ResNet-18, and Vision Transformers (ViT) on ImageNet-1K.

  • Joint Transfer: In experiments with MLPs, the "island" of optimal test accuracy for $(\eta, \rho)$ remained perfectly stationary across widths ranging from 256 to 4096 when using $\mu P^2$. In contrast, global scaling caused the optimum to shift significantly, breaking the transferability.
Hyperparameter transfer comparison between global scaling and $\mu P^2$.
  • Performance Gains: $\mu P^2$ doesn't just make tuning easier; it improves absolute results. On ResNet-18 (CIFAR-10), the SAM-ON variant in $\mu P^2$ achieved 97.34% accuracy, outperforming standard parameterizations.
  • ViT Scaling: On ImageNet-1K, training a Vision Transformer from scratch with $\mu P^2$ showed clear $\rho$-transfer and substantial improvements over the standard AdamW baseline.

Limitations and Future Work

While $\mu P^2$ solves the width-scaling problem for SAM, open questions remain. The current theory focuses strictly on the infinite-width limit; a formal theory for scaling depth alongside width is still needed. Furthermore, while the paper explains how to scale SAM to maintain its properties, it doesn't fully solve the theoretical mystery of why SAM generalizes better than SGD in the first place. Finally, the authors noted that some standard parameterizations showed unexpected hyperparameter stability after many epochs, suggesting that the interaction between long training times and model scale requires deeper investigation.

Summary updated

BibTeX
@inproceedings{haas2024boldsymbol,
  author = {Moritz Haas and Jin Xu and Volkan Cevher and Leena Chennuru Vankadara},
  title = {{$\textbackslash\{\}boldsymbol\{\textbackslash\{\}mu\}\textbackslash\{\}mathbf\{P^2\}$: Effective Sharpness Aware Minimization Requires Layerwise Perturbation Scaling}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=pR5g1bBqoV},
}
Figure