ZO-SAM: Zero-Order Sharpness-Aware Minimization for Efficient Sparse Training

Jie Ji, Gen Li, Kaiyuan Deng, Fatemeh Afghah, Xiaolong Ma

TL;DR

ZO-SAM is a new optimization framework that brings the generalization benefits of Sharpness-Aware Minimization (SAM) to sparse neural network training without the usual 100% computational overhead. By replacing the first of SAM's two backpropagation steps with a "zero-order" gradient estimation (using only forward passes), ZO-SAM cuts the extra training cost in half while significantly improving the accuracy and robustness of sparse models.

What Problem Does This Paper Address?

Sparse neural networks—where a large majority of weights are set to zero—are essential for deploying AI on edge devices with limited memory and power. However, training these models is notoriously difficult. As sparsity increases, the "loss landscape" becomes jagged and steep, leading to chaotic, noisy gradient signals that hinder convergence and hurt the model's ability to generalize to new data.

Sharpness-Aware Minimization (SAM) is a popular technique designed to find "flat minima" (broad valleys in the loss landscape), which typically leads to better generalization. The catch? SAM requires two backpropagation passes per update, effectively doubling the training time. In resource-constrained sparse training scenarios, this "SAM tax" is often too expensive to pay.

Methods

The authors introduce ZO-SAM (Zero-Order Sharpness-Aware Minimization). To understand how it works, we have to look at the two steps of standard SAM:

  1. Perturbation Step: Calculate a gradient to find the "worst-case" nearby direction to perturb the weights.
  2. Update Step: Calculate the gradient at that perturbed location to perform the actual weight update.

ZO-SAM’s "aha!" moment is realizing that the first step doesn't need perfect precision. Instead of a full backpropagation pass, ZO-SAM uses Random Gradient Estimation (RGE)—a zero-order method. RGE estimates the gradient by slightly tweaking the weights in a few random directions and measuring the change in loss using only forward passes.

By using zero-order estimation for the perturbation and reserving the precise first-order backpropagation for the final update, ZO-SAM achieves the "flatness" benefits of SAM with only a single backpropagation pass per iteration.

Datasets

The researchers evaluated ZO-SAM across a wide range of benchmarks:

  • Image Classification: CIFAR-10, CIFAR-100, and the large-scale ImageNet-1K.
  • Robustness: CIFAR-10-C (a version of CIFAR-10 with 19 different types of corruptions like blur and noise).
  • Architectures: ResNet-32, ResNet-50, WideResNet-28-10, and Vision Transformers (DeiT-Tiny and DeiT-Small).

Key Insights and Ideas

  • Precision Trade-off: The paper demonstrates that "minor inaccuracies" in the perturbation direction are tolerable. This allows for the use of cheaper zero-order estimates in the first step without sacrificing the final model quality.
  • Stabilizing Sparse Training: Sparse training often suffers from "turbulent" gradients. ZO-SAM acts as a stabilizer, smoothing out the optimization trajectory.
  • Efficiency is King: In sparse training, the goal is efficiency. ZO-SAM achieves ~76% of the throughput of standard SGD, whereas traditional SAM drops to ~47%.
  • Visual Proof: The authors provide loss surface visualizations showing that ZO-SAM successfully transforms steep, narrow "pits" into wide, stable "basins," even at 95% sparsity.

Key Results

  • Accuracy Gains: ZO-SAM consistently outperformed standard sparse training methods (like RigL, SNIP, and MEST). On ResNet-32 (CIFAR-100), it improved accuracy by up to 2.54%.
  • Faster Convergence: Models trained with ZO-SAM reached 90% accuracy significantly faster than those trained with SGD. For example, at 90% sparsity, ZO-SAM reached the target in 70 epochs, compared to 104 for SGD.
  • Superior Robustness: On the corrupted CIFAR-10-C dataset, ZO-SAM improved accuracy by 3.10% over the baseline, proving that "flat minima" really do help models handle real-world noise better.
  • Transformer Success: The method isn't just for CNNs; it improved DeiT-Small performance on ImageNet-1K by 1.17% at 70% sparsity.

Limitations and Future Work

While ZO-SAM is highly effective, the authors note a few areas for further exploration:

  • Hyperparameter Tuning: Like standard SAM, ZO-SAM introduces a perturbation radius ($\rho$) that may require tuning for different tasks.
  • Scaling to LLMs: While the paper mentions Large Language Models (LLMs) in the context of zero-order optimization, the experiments in this paper focus on computer vision. Testing ZO-SAM on massive generative models remains a promising future direction.
  • Optimal 'm': The number of random directions ($m$) used for the zero-order estimate affects the trade-off between speed and accuracy; finding an automated way to set this could further optimize the process.

Summary updated

Abstract

Deep learning models, despite their impressive achievements, suffer from high computational costs and memory requirements, limiting their usability in resource-constrained environments. Sparse neural networks significantly alleviate these constraints by dramatically reducing parameter count and computational overhead. However, existing sparse training methods often experience chaotic and noisy gradient signals, severely hindering convergence and generalization performance, particularly at high sparsity levels. To tackle this critical challenge, we propose Zero-Order Sharpness-Aware Minimization (ZO-SAM), a novel optimization framework that strategically integrates zero-order optimization within the SAM approach. Unlike traditional SAM, ZO-SAM requires only a single backpropagation step during perturbation, selectively utilizing zero-order gradient estimations. This innovative approach reduces the backpropagation computational cost by half compared to conventional SAM, significantly lowering gradient variance and effectively eliminating associated computational overhead. By harnessing SAM's capacity for identifying flat minima, ZO-SAM stabilizes the training process and accelerates convergence. These efficiency gains are particularly important in sparse training scenarios, where computational cost is the primary bottleneck that limits the practicality of SAM. Moreover, models trained with ZO-SAM exhibit improved robustness under distribution shift, further broadening its practicality in real-world deployments.
BibTeX
@misc{ji2026zo,
  author = {Jie Ji and Gen Li and Kaiyuan Deng and Fatemeh Afghah and Xiaolong Ma},
  title = {{ZO-SAM: Zero-Order Sharpness-Aware Minimization for Efficient Sparse Training}},
  year = {2026},
  eprint = {2603.13115},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.13115},
}
Figure