SS-SAM : Stochastic Scheduled Sharpness-Aware Minimization for Efficiently Training Deep Neural Networks

Yang Zhao, Hao Zhang, Xiuyuan Hu

Abstract

By driving models to converge to flat minima, sharpness-aware learning algorithms (such as SAM) have shown the power to achieve state-of-the-art performances. However, these algorithms will generally incur one extra forward-backward propagation at each training iteration, which largely burdens the computation especially for scalable models. To this end, we propose a simple yet efficient training scheme, called Randomized Sharpness-Aware Training (RST). Optimizers in RST would perform a Bernoulli trial at each iteration to choose randomly from base algorithms (SGD) and sharpness-aware algorithms (SAM) with a probability arranged by a predefined scheduling function. Due to the mixture of base algorithms, the overall count of propagation pairs could be largely reduced. Also, we give theoretical analysis on the convergence of RST. Then, we empirically study the computation cost and effect of various types of scheduling functions, and give directions on setting appropriate scheduling functions. Further, we extend the RST to a general framework (G-RST), where we can adjust regularization degree on sharpness freely for any scheduling function. We show that G-RST can outperform SAM in most cases while saving 50% extra computation cost.

Introduction

In the pursuit of high-performance deep neural networks, the geometry of the loss surface has emerged as a critical factor for generalization. Models that converge to "flat" minima—regions where the loss remains relatively stable under small weight perturbations—typically exhibit superior performance on unseen data compared to those trapped in "sharp" minima.

Sharpness-Aware Minimization (SAM) was introduced to explicitly steer optimizers toward these desirable flat regions. Despite its success, SAM imposes a significant computational penalty: it requires two forward-backward propagation passes per iteration (one to identify the sharpest nearby point and another to update weights). This effectively doubles the training time compared to standard Stochastic Gradient Descent (SGD), creating a massive burden for training modern, large-scale architectures.

Methodology: Randomized Sharpness-Aware Training (RST)

To mitigate the overhead of SAM, we propose Randomized Sharpness-Aware Training (RST), also referred to as Stochastic Scheduled SAM (SS-SAM). Rather than executing the expensive SAM update at every step, the optimizer performs a Bernoulli trial at each iteration $t$ with a probability $p(t)$ defined by a scheduling function.

  • With probability $p(t)$, the model performs a full SAM update (two passes).
  • With probability $1 - p(t)$, the model performs a standard SGD update (one pass).

By adjusting $p(t)$, we can control the "extra expected propagation count." As shown in Figure 1, the actual wall-clock time overhead scales linearly with this expected count across different architectures like ResNet-18 and WideResNet-28-10, confirming that the randomized approach provides a direct and predictable reduction in training time.

Figure 1: Extra wall time scales linearly with the expected propagation count, confirming the efficiency gains of the randomized approach.

To further refine this approach, we introduce G-RST (General RST). Because reducing the frequency of SAM updates naturally lowers the total sharpness regularization, G-RST allows for increasing the intensity of the perturbation during the active SAM steps. This ensures a consistent "regularization budget" is maintained throughout the training process.

Experimental Evaluation

We validated the RST framework across a wide variety of standard benchmarks and architectures:

  • Datasets: CIFAR-10, CIFAR-100, and the large-scale ImageNet.
  • Models: Traditional Convolutional Neural Networks (VGG16, ResNet-18/50/101, WideResNet-28-10, PyramidNet) and modern Vision Transformers (ViT-Ti, ViT-S, ViT-B).

Results and Discussion

Our empirical analysis yielded several key insights:

  • Efficiency and Speedup: G-RST (with a 50% SAM frequency) saves roughly 50% of the extra computation time required by SAM. For a model like ResNet-101 on ImageNet, this represents a massive reduction in wall-clock time.
  • Superior Performance: Surprisingly, G-RST often outperforms full SAM. For example, on WideResNet-28-10 (CIFAR-100), G-RST achieved a 16.19% error rate, beating SAM’s 16.53% while being significantly faster. As illustrated in Figure 2, the testing error rate often reaches a minimum before the 100% propagation mark, suggesting that the stochastic nature of RST may provide an additional regularizing effect.
  • Scheduling Insights: While complex linear and piecewise schedules were tested, a constant probability (e.g., $p=0.5$) is remarkably effective. However, the "end-game" matters; avoiding standard SGD near the end of training is crucial to prevent the model from drifting away from flat minima.
Figure 2: Testing error rates on CIFAR-10 (left) and CIFAR-100 (right) as a function of extra computation. Optimal performance is often reached before 100% extra propagation.

Conclusion

RST and its generalized counterpart G-RST offer a simple, universal upgrade to the SAM framework. By leveraging stochastic scheduling, we can achieve state-of-the-art generalization while significantly reducing the computational cost. Future work will explore the interaction between RST and other efficiency tricks like gradient clipping or specialized learning rate cyclic schedules.

Summary updated

Abstract

By driving models to converge to flat minima, sharpness-aware learning algorithms (such as SAM) have shown the power to achieve state-of-the-art performances. However, these algorithms will generally incur one extra forward-backward propagation at each training iteration, which largely burdens the computation especially for scalable models. To this end, we propose a simple yet efficient training scheme, called Randomized Sharpness-Aware Training (RST). Optimizers in RST would perform a Bernoulli trial at each iteration to choose randomly from base algorithms (SGD) and sharpness-aware algorithms (SAM) with a probability arranged by a predefined scheduling function. Due to the mixture of base algorithms, the overall count of propagation pairs could be largely reduced. Also, we give theoretical analysis on the convergence of RST. Then, we empirically study the computation cost and effect of various types of scheduling functions, and give directions on setting appropriate scheduling functions. Further, we extend the RST to a general framework (G-RST), where we can adjust regularization degree on sharpness freely for any scheduling function. We show that G-RST can outperform SAM in most cases while saving 50\% extra computation cost.
BibTeX
@inproceedings{zhao2023ss,
  author = {Yang Zhao and Hao Zhang and Xiuyuan Hu},
  title = {{SS-SAM : Stochastic Scheduled Sharpness-Aware Minimization for Efficiently Training Deep Neural Networks}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=8foynpwwRb},
}
Figure