Surrogate Gap Minimization Improves Sharpness-Aware Training

Juntang Zhuang, Boqing Gong, Liangzhe Yuan, Yin Cui, Hartwig Adam, Nicha C. Dvornek, Sekhar Tatikonda, James S. Duncan, Ting Liu

TL;DR

Researchers have developed GSAM (Surrogate Gap Guided Sharpness-Aware Minimization), a new optimization technique that significantly boosts how well neural networks generalize to new data. By specifically minimizing the "surrogate gap"—the difference between a model's normal loss and its worst-case neighborhood loss—GSAM finds flatter minima in the loss landscape more effectively than previous methods like SAM, leading to record-breaking accuracies on benchmarks like ImageNet.

What Problem Does This Paper Address?

In deep learning, we don't just want a model that performs well on training data; we want one that generalizes to the real world. A long-standing theory suggests that "flat" minima (regions where the loss doesn't change much if you wiggle the parameters) generalize better than "sharp" minima.

Recently, Sharpness-Aware Minimization (SAM) became popular by trying to minimize the "perturbed loss"—the maximum loss within a small radius of the current parameters. The idea is: if the worst-case scenario nearby is good, the region must be flat.

However, this paper points out a critical flaw: SAM can be "tricked." A very sharp minimum with a low base loss might still have a lower "worst-case" loss than a slightly flatter minimum with a higher base loss. In other words, SAM doesn't always prefer the flattest path.

Illustration of the surrogate gap $h(w)$ across different minima.

Methods

The authors introduce GSAM, which builds on SAM but adds a clever "side-step" to the optimization process to explicitly target flatness.

  1. The Surrogate Gap ($h$): They define the surrogate gap as the difference between the perturbed loss ($f_p$) and the original loss ($f$). Mathematically, they prove this gap is a proxy for the "sharpness" (specifically, the dominant eigenvalue of the Hessian matrix) of the loss surface.
  2. Gradient Decomposition: This is the "secret sauce." During an update, GSAM calculates two gradients: one for the perturbed loss and one for the original loss. It then decomposes the original loss gradient into two parts: one parallel to the SAM update and one orthogonal (perpendicular) to it.
Gradient decomposition in GSAM showing the orthogonal step.
  1. The Two-Step Update:
    • Step 1: Perform a standard SAM-like descent to minimize the perturbed loss.
  2. Step 2: Perform an "ascent" step along that orthogonal direction. Because this step is perpendicular to the SAM update, it reduces the surrogate gap (making the landscape flatter) without undoing the progress made in reducing the overall loss.

This allows the optimizer to simultaneously seek low loss and high flatness without the two goals "fighting" each other.

Key Insights and Ideas

  • SAM’s Blind Spot: The paper visually and mathematically demonstrates that SAM can settle into sharp valleys if the bottom of the valley is deep enough.
  • Sharpness is Measurable (Cheaply): Calculating the full Hessian matrix (to find sharpness) is computationally impossible for giant models. The "surrogate gap" provides a "poor man's Hessian" that is remarkably accurate and nearly free to compute.
  • Orthogonal Optimization: By using gradient decomposition, the authors solve a multi-objective optimization problem (low loss + low sharpness) more efficiently than simply adding the two terms together, which often leads to conflicting gradients.

Key Results

GSAM consistently outperformed both standard optimizers (AdamW, SGD) and the original SAM across various architectures on datasets like ImageNet-1k, CIFAR, and robustness benchmarks (ImageNet-C, ImageNet-R):

  • Vision Transformers (ViT): On ViT-B/32, GSAM improved Top-1 accuracy by +5.4% over AdamW and +3.2% over the original SAM.
  • MLP-Mixers: On Mixer-B/32, it saw a massive +11.1% jump over AdamW.
  • Robustness: GSAM models were significantly more resilient to image corruptions and style changes, proving that flatter minima do indeed lead to more robust features.
  • Efficiency: Despite the extra math, GSAM adds negligible computation overhead compared to SAM, as it mostly involves simple vector projections.

Limitations and Future Work

  • Two Passes Required: Like SAM, GSAM requires two forward and backward passes per update (to calculate the two different gradients). This makes it roughly twice as slow as standard SGD or Adam per epoch, though it often converges in fewer steps or reaches much higher final performance.
  • Hyperparameter Sensitivity: GSAM introduces a new parameter, $\alpha$, to control the strength of the "flatness" step. While the authors provide suggested ranges, finding the perfect $\alpha$ might require some tuning for new, niche architectures.
  • Beyond Vision: The paper focuses entirely on computer vision. Exploring GSAM's impact on Large Language Models (LLMs) or Reinforcement Learning remains an open and promising frontier.

Summary updated

BibTeX
@inproceedings{zhuang2022surrogate,
  author = {Juntang Zhuang and Boqing Gong and Liangzhe Yuan and Yin Cui and Hartwig Adam and Nicha C. Dvornek and Sekhar Tatikonda and James S. Duncan and Ting Liu},
  title = {{Surrogate Gap Minimization Improves Sharpness-Aware Training}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=WhKohGc8G7},
}
Figure