Sharpness-aware Minimization for Worst Case Optimization

Taero Kim, Sungjun Lim, Kyungwoo Song · OpenReview

Abstract

Improvement of worst group performance and generalization performance are core problems of current machine learning. There are diverse efforts to increase performance, such as weight norm penalty and data augmentation, but the improvements are limited. Recently, there have been two promising approaches to increase the worst group performance and generalization performance, respectively. Distributionally robust optimization (DRO) focuses on the worst or hardest group to improve the worst-group performance. Besides, sharpness-aware minimization (SAM) finds the flat minima to increase the generalization ability on an unseen dataset. They show significant performance improvements on the worst-group dataset and unseen dataset, respectively. However, DRO does not guarantee flatness, and SAM does not guarantee the worst group performance improvement. In other words, DRO and SAM may fail to increase the worst group performance when the training and test dataset shift occurs. In this study, we propose a new approach, the sharpness-aware group distributionally robust optimization (SGDRO). SGDRO finds the flat-minima that generalizes well on the worst group dataset. Different from DRO and SAM, SGDRO contributes to improving the generalization ability even the distribution shift occurs. We validate that SGDRO shows the smaller maximum eigenvalue and improved performance in the worst group.

The Challenge of Distribution Shift

In real-world applications, machine learning models often encounter "distribution shift," where test data differs significantly from training data. To combat this, researchers typically aim to learn "invariant features"—characteristics like the shape of an object that remain constant across different environments.

However, a critical flaw exists in current methodologies: models often stop once they find a single, easily accessible invariant feature. If this specific feature is obscured in the test set (for example, a bird’s feet being hidden underwater), the model's performance collapses. This paper argues that true robustness requires learning a sufficient set of diverse invariant features—a redundant system that ensures the model remains functional even when some features are missing.

Conceptual illustration of Sufficient Invariant Learning. While standard invariant features might be obscured (e.g., feet underwater), a sufficient set of features (tail, beak, feet) provides redundancy for robustness.

Methods: Sufficient Invariant Learning (SIL)

To address this, the authors introduce the Sufficient Invariant Learning (SIL) framework and a corresponding algorithm: Adaptive Sharpness-aware Group Distributionally Robust Optimization (ASGDRO). This approach merges two powerful concepts:

  1. Group DRO (GDRO): Minimizes loss for the worst-performing group to prevent reliance on spurious correlations (e.g., background color).
  2. Sharpness-aware Minimization (SAM): Seeks "flat minima" in the loss landscape, where small weight perturbations do not significantly increase error, enhancing generalization.

The Geometry of Diversity

The theoretical core of ASGDRO is that finding a common flat minimum across all training environments forces the model to distribute its reliance across multiple invariant features. While spurious features often lead to sharp minima, the demand for flatness incentivizes the discovery of a wider variety of stable, reliable signals. By optimizing for the geometry of the loss surface, the model naturally avoids "shortcuts" and builds a more diverse feature portfolio.

Loss landscapes for Invariant vs. Sufficient Invariant objectives. ASGDRO finds a common flat minimum that balances multiple features, whereas other methods may fall into sharp minima or fail to find the optimal point.

Experimental Evaluation

The paper evaluates ASGDRO across several rigorous benchmarks:

  • H-CMNIST (Heterogeneous ColoredMNIST): A new benchmark designed to test if a model can learn "hard" invariant features (digit shape) when "easy" ones (color) are present.
  • Subpopulation Shift: Standard tests including Waterbirds, CelebA, and CivilComments.
  • Real-world Shifts: The Wilds benchmark (e.g., medical imaging in Camelyon17) and DomainBed for domain generalization.

Key Results

  • Benchmark Performance: On the H-CMNIST challenge, ASGDRO achieved 69.17% accuracy on the most difficult test bed, significantly outperforming standard GDRO (61.44%) and ERM (57.41%).
  • State-of-the-Art Generalization: Combined with DPLCLIP on the DomainBed benchmark, ASGDRO reached an average accuracy of 74.0%, surpassing the standard DPLCLIP baseline of 72.6%.
  • Feature Diversity: Grad-CAM visualizations confirmed that while baseline models focused narrowly on single attributes, ASGDRO-trained models simultaneously attended to multiple parts of an object (e.g., a bird's head, body, and feet).

Conclusion and Future Work

ASGDRO demonstrates that redundancy is a key component of robustness. By leveraging the geometry of the loss landscape, models can be forced to look beyond the easiest invariant features. The primary trade-off is computational; ASGDRO requires two forward and backward passes per iteration, doubling training time. Future research will focus on improving the efficiency of this approach and developing more complex "sufficient" benchmarks for real-world datasets.

Summary updated

BibTeX
@inproceedings{kim2025sharpness,
  author = {Taero Kim and Sungjun Lim and Kyungwoo Song},
  title = {{Sharpness-aware Minimization for Worst Case Optimization}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.00467},
}
Figure