Overview
While Sharpness-Aware Minimization (SAM) is a go-to technique for improving model generalization, the underlying reasons for its success—and why it sometimes fails to find the flattest possible minima—have remained partially obscured. This paper reveals that SAM’s effectiveness hinges on a "hidden" alignment between its perturbation vector and the Hessian matrix's top eigenvector. By introducing Eigen-SAM, the authors explicitly enforce this alignment, consistently outperforming standard SAM across various deep learning benchmarks.
The Gap Between SAM Theory and Practice
In deep learning, "flat" minima (regions where the loss doesn't change much if parameters are slightly perturbed) generally generalize better than "sharp" ones. SAM attempts to find these flat regions by minimizing the maximum loss within a small neighborhood of the current parameters.
However, there is a notable gap between theory and practice. Theoretical models often assume SAM perfectly minimizes "sharpness" (measured by the top eigenvalue of the Hessian matrix), but empirical evidence shows SAM doesn't always reduce this value as much as expected. The authors identify a core bottleneck: for SAM to effectively regularize sharpness, the perturbation it applies must align with the direction of maximum curvature (the top eigenvector of the Hessian). In real-world training, this alignment is often surprisingly poor, limiting SAM's efficiency.
Introducing Eigen-SAM
The authors tackle this problem through rigorous mathematical modeling and a novel algorithmic approach:
- Third-Order SDE Analysis: They derive a third-order Stochastic Differential Equation (SDE) to model SAM’s training dynamics. Unlike previous second-order models, this higher-order approach captures how SAM implicitly regularizes the Hessian. It reveals that SAM's "drift" toward flatter regions is directly proportional to how well the gradient aligns with the top Hessian eigenvector.
- Eigen-SAM Algorithm: To fix the alignment issue, they propose a modified algorithm. Every $p$ steps (e.g., every 100 mini-batches), Eigen-SAM uses a power iteration to estimate the top eigenvector of the Hessian.
- Explicit Alignment: Instead of relying on the raw gradient for the perturbation, Eigen-SAM decomposes the estimated top eigenvector and adds its orthogonal component to the perturbation vector. This explicitly steers the optimization toward directions that reduce the largest eigenvalue of the Hessian.
Key Insights and Empirical Results
The authors validated their approach on standard computer vision tasks, including CIFAR-10/100, Fashion-MNIST, SVHN, and fine-tuning a ViT-B-16 pre-trained on ImageNet-1K.
- The Alignment Gap: Standard SAM relies on the gradient to "guess" the direction of maximum sharpness. As shown in the left panel of the figure below, this guess is often mediocre, with alignment scores frequently hovering between 0.4 and 0.6.
- Flatter Minima: Eigen-SAM maintains a significantly lower top Hessian eigenvalue throughout training compared to both SGD and standard SAM (right panel), confirming that the explicit regularization works as intended.
- Generalization Boost: On CIFAR-100 with a ResNet18, Eigen-SAM achieved 78.3% accuracy, compared to SAM's 77.4% and SGD's 74.6%. Across various architectures (ResNet18, ResNet50, WideResNet-28-10), Eigen-SAM consistently provided a 0.3% to 0.9% accuracy bump over standard SAM.
Limitations and Future Work
The primary trade-off of Eigen-SAM is computational overhead. Estimating the top eigenvector requires Hessian-vector products. While the authors mitigate this by only performing the estimation intermittently (every $p$ steps), it still adds memory and time requirements beyond standard SAM. Future research may focus on improving the efficiency of these eigenvector estimations to make Eigen-SAM practical for massive-scale models, or exploring the regularization of the entire Hessian spectrum rather than just the top eigenvalue.
Summary updated