A Single-Step, Sharpness-Aware Minimization is All You Need to Achieve Efficient and Accurate Sparse Training

Jie Ji, Gen Li, Jingjing Fu, Fatemeh Afghah, Linke Guo, Xiaoyong Yuan, Xiaolong Ma

Training massive Deep Neural Networks (DNNs) is an expensive endeavor, both in terms of electricity and hardware. Sparse training—the practice of training a network where most of the weights are zero—is a promising solution to reduce this "parameter footprint." However, there’s a catch: sparse networks are notoriously difficult to train and often fail to generalize as well as their "dense" counterparts.

In a new paper presented at NeurIPS 2024, researchers introduce $S^2$-SAM (Single-step Sharpness-Aware Minimization). This novel optimizer bridges the gap between efficiency and accuracy, offering the generalization benefits of sharpness-aware optimization with zero extra computational cost.

TL;DR

$S^2$-SAM is a "plug-and-play" optimization technique that improves the accuracy and robustness of sparse neural networks. By using gradient information from the previous training step to approximate the local "sharpness" of the loss landscape, it finds flatter, more stable minima without the 2x computational overhead required by traditional Sharpness-Aware Minimization (SAM).

What Problem Does This Paper Address?

The core challenge in sparse training is the generalization gap. Even when a sparse network achieves low error on training data, it often performs poorly on new, unseen data.

The authors identify the culprit by visualizing the loss surface—a mathematical "map" of how a network's error changes as its weights are adjusted. They discovered that as a network becomes sparser, its loss surface becomes increasingly chaotic and sharp.

Loss surfaces of dense vs. sparse networks. The sparse network exhibits a much sharper, more chaotic landscape.

Imagine trying to find the bottom of a valley that is full of jagged, narrow crevices; it’s easy to get stuck in a "saddle point" that looks like a minimum but isn't the optimal solution. While a technique called Sharpness-Aware Minimization (SAM) exists to smooth out these surfaces by seeking "flat" minima, it requires two forward and backward passes per training step. For researchers using sparse training to save resources, doubling the training time is a dealbreaker.

Methods: Sharpness for Free

The authors propose $S^2$-SAM, a streamlined version of SAM tailored specifically for the efficiency goals of sparse training.

  • The Standard SAM Approach: To find a flat minimum, SAM first takes a "lookahead" step to find a nearby point where the loss is highest (the sharpest direction) and then updates the weights based on the gradient at that perturbed point. This requires two full gradient computations.
  • The $S^2$-SAM Innovation: The researchers realized that in a chaotic loss landscape, the gradient from the previous iteration ($g_{t-1}$) is actually a very good proxy for a "sharp" direction. Instead of performing a new computation to find the perturbation, $S^2$-SAM uses the prior gradient to shift the weights before the current step's calculation.

By recycling old information, $S^2$-SAM achieves the smoothing effect of SAM in a single step, maintaining the same training speed as standard Stochastic Gradient Descent (SGD).

Key Insights and Ideas

  • Sparsity Breeds Sharpness: The paper provides quantitative proof (using the $Ra$ coefficient) that higher sparsity directly correlates with a steeper, more jagged loss landscape. This explains why sparse models are so sensitive to hyperparameter settings.
At 98% sparsity, the loss landscape becomes extremely sharp (Ra = 2.487), illustrating the difficulty of finding stable minima.
  • The "Prior Gradient" Heuristic: The most surprising insight is that "stale" gradient information is sufficient to approximate local sharpness. This suggests that the trajectory of the optimizer itself carries enough information about the landscape's geometry to guide it toward flatter regions.
  • Universal Compatibility: $S^2$-SAM isn't a standalone training method; it’s an optimizer. The authors showed it could be "plugged into" almost any existing sparse training algorithm—whether static (like the Lottery Ticket Hypothesis) or dynamic (like RigL or MEST)—and consistently improve results.

Key Results

The authors validated $S^2$-SAM across a wide range of standard benchmarks, including CIFAR-10/100, ImageNet-1K, and ImageNet-C (for robustness).

  • Zero Overhead: Throughput tests on NVIDIA A6000 GPUs confirmed that $S^2$-SAM trains at virtually the same speed as standard methods, whereas original SAM was nearly 50% slower.
  • Significant Accuracy Boosts: On CIFAR-100 with 98% sparsity, $S^2$-SAM improved the accuracy of the "MEST" training method by 1.97%. On ImageNet-1K, it consistently boosted top-1 accuracy by 0.4% to 1.1% across different sparsity levels.
  • Enhanced Robustness: Models trained with $S^2$-SAM were significantly more resilient to image corruptions. On ImageNet-C, the robust accuracy improved by an average of 3.23%, proving that flatter minima lead to more reliable models in real-world conditions.

Limitations and Future Work

While $S^2$-SAM is highly effective for sparse training, the authors note that its benefits are most pronounced when the loss surface is chaotic. In very low-sparsity or dense regimes where the landscape is already relatively smooth, the gains are more modest.

Future research could explore applying $S^2$-SAM to even larger architectures, such as Vision Transformers (ViTs) or Large Language Models (LLMs), where the efficiency-accuracy trade-off is even more critical. Additionally, further theoretical work could refine how the "perturbation" parameter ($\rho$) should be scheduled over time for different types of data.

Check out the code: https://github.com/jjsrf/SSAM-NEURIPS2024

Summary updated

BibTeX
@inproceedings{ji2024single,
  author = {Jie Ji and Gen Li and Jingjing Fu and Fatemeh Afghah and Linke Guo and Xiaoyong Yuan and Xiaolong Ma},
  title = {{A Single-Step, Sharpness-Aware Minimization is All You Need to Achieve Efficient and Accurate Sparse Training}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=MJgMMqMDu4},
}
Figure