Skip to main content
QUICK REVIEW

[Paper Review] Towards Efficient and Scalable Sharpness-Aware Minimization

Yong Liu, Siqi Mai|arXiv (Cornell University)|Mar 5, 2022
Advanced Neural Network ApplicationsComputer Science5 citations
TL;DR

This paper proposes LookSAM, a computationally efficient variant of Sharpness-Aware Minimization (SAM) that periodically computes the inner gradient ascent step, reusing the sharpness-promoting direction across iterations. The method achieves SAM-level generalization performance with first-order optimizer-like efficiency, enabling training Vision Transformers at 64k batch size in under an hour—setting a new speed record for ViT training.

ABSTRACT

Recently, Sharpness-Aware Minimization (SAM), which connects the geometry of the loss landscape and generalization, has demonstrated significant performance boosts on training large-scale models such as vision transformers. However, the update rule of SAM requires two sequential (non-parallelizable) gradient computations at each step, which can double the computational overhead. In this paper, we propose a novel algorithm LookSAM - that only periodically calculates the inner gradient ascent, to significantly reduce the additional training cost of SAM. The empirical results illustrate that LookSAM achieves similar accuracy gains to SAM while being tremendously faster - it enjoys comparable computational complexity with first-order optimizers such as SGD or Adam. To further evaluate the performance and scalability of LookSAM, we incorporate a layer-wise modification and perform experiments in the large-batch training scenario, which is more prone to converge to sharp local minima. We are the first to successfully scale up the batch size when training Vision Transformers (ViTs). With a 64k batch size, we are able to train ViTs from scratch in minutes while maintaining competitive performance.

Motivation & Objective

  • To reduce the computational overhead of SAM, which doubles training time due to two sequential gradient computations per step.
  • To maintain SAM’s generalization benefits while significantly improving training efficiency for large-scale models like Vision Transformers.
  • To scale SAM to large-batch training, a regime prone to sharp minima and non-uniform instability across layers.
  • To develop a layer-wise adaptation of LookSAM (Look-LayerSAM) that enables stable and efficient training at extremely high batch sizes.
  • To establish a new training speed record for Vision Transformers by achieving 8× speedup over prior state-of-the-art settings.

Proposed method

  • LookSAM reuses the sharpness-promoting direction from previous iterations instead of recomputing the inner gradient ascent at every step.
  • The method decomposes SAM’s update into components parallel and orthogonal to the standard SGD direction, with the orthogonal component being reused when stable.
  • A reuse frequency hyperparameter $k$ controls how often the inner gradient ascent is recomputed, balancing speed and accuracy.
  • Look-LayerSAM applies layer-wise scaling to the weight perturbation in LookSAM, improving stability in large-batch training.
  • The algorithm uses a gradient reuse weight $\alpha$ and perturbation intensity $\rho$ to fine-tune the trade-off between generalization and efficiency.
  • Empirical validation is conducted on ViT-B-16 using ImageNet-1k, with ablation studies on $k$, $\alpha$, and $\rho$.
Figure 1 : Accuracy of SAM-5, SAM and vanilla ViT on ImageNet-1k. SAM-5 indicates the method that calculating SAM gradients every 5 steps.
Figure 1 : Accuracy of SAM-5, SAM and vanilla ViT on ImageNet-1k. SAM-5 indicates the method that calculating SAM gradients every 5 steps.

Experimental results

Research questions

  • RQ1Can the computational cost of SAM be reduced without sacrificing generalization performance?
  • RQ2How does periodic reuse of the sharpness-promoting direction affect model accuracy and training speed?
  • RQ3Can LookSAM be scaled to extremely large batch sizes (e.g., 64k) while maintaining competitive performance?
  • RQ4How does layer-wise perturbation scaling improve training stability in large-batch settings?
  • RQ5What hyperparameter settings ($k$, $\alpha$, $\rho$) yield optimal trade-offs between speed and accuracy?

Key findings

  • LookSAM achieves 79.8% validation accuracy on ViT-B-16 with a reuse frequency $k=5$, matching the performance of vanilla SAM.
  • With $k=5$, LookSAM increases throughput from 12,800 to 19,051 samples per second, significantly improving training speed.
  • At $k=10$, throughput reaches 20,480 samples per second, with only a minor drop in accuracy to 78.7%.
  • Look-LayerSAM achieves 78.4% accuracy on 16,384 batch size and 77.1% on 32,768 batch size with $\alpha=0.7$ and $\rho=1.0$, demonstrating robustness.
  • The method enables training ViT-B-16 from scratch with a 64k batch size in under an hour, achieving 75%+ accuracy.
  • Look-LayerSAM achieves approximately 8× speedup over the training setup in [10], completing ViT-B-16 training in 0.7 hours—setting a new speed record.
Figure 2 : Difference of gradients between every 5 steps for $\boldsymbol{g_{s}}$ , $\boldsymbol{g_{h}}$ , and $\boldsymbol{g_{v}}$ (i.e., $||g_{s}^{t}-g_{s}^{t+k}||$ ) . $\boldsymbol{g_{v}}$ that leads to a smoother region changes much slower than $\boldsymbol{g_{s}}$ and $\boldsymbol{g_{h}}$ .
Figure 2 : Difference of gradients between every 5 steps for $\boldsymbol{g_{s}}$ , $\boldsymbol{g_{h}}$ , and $\boldsymbol{g_{v}}$ (i.e., $||g_{s}^{t}-g_{s}^{t+k}||$ ) . $\boldsymbol{g_{v}}$ that leads to a smoother region changes much slower than $\boldsymbol{g_{s}}$ and $\boldsymbol{g_{h}}$ .

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.