TL;DR
Domain-Inspired Sharpness-Aware Minimization (DISAM) is a new optimization algorithm designed to fix a major flaw in Sharpness-Aware Minimization (SAM) when dealing with multiple data sources. By forcing different domains to converge at a consistent rate through a domain-loss variance constraint, DISAM prevents optimization bias and achieves significantly better generalization on unseen data than standard SAM or Empirical Risk Minimization (ERM).
What Problem Does This Paper Address?
In deep learning, we often seek "flat minima"—regions of the loss landscape where small changes in model weights don't cause the error to spike. Flat minima are known to generalize better to new data. Sharpness-Aware Minimization (SAM) has become a popular tool for finding these regions by simultaneously minimizing loss and loss sharpness.
However, SAM was built on the assumption that training data is "Independent and Identically Distributed" (i.e., it all comes from the same bucket). In the real world—and specifically in Domain Generalization (DG)—we train on multiple distinct domains (e.g., photos, sketches, and cartoons) to prepare the model for an unseen domain (e.g., oil paintings).
The authors discovered that under these "domain shifts," standard SAM actually struggles. Because different domains have different levels of difficulty or amounts of data, they converge at different speeds. SAM’s perturbation step gets "distracted" by the domains that haven't converged yet (which have large gradients), leading to a biased estimation of sharpness. This inconsistency can actually make SAM perform worse than basic training (ERM) in some scenarios, as seen in the TerraIncognita benchmark.
The DISAM Method
To address this, the authors propose DISAM, which introduces a "domain-level convergence consistency" constraint into the SAM framework.
- Standard SAM: Works by taking a small "adversarial" step in the direction of the steepest gradient (the perturbation), calculating the loss there, and then updating the weights to minimize that perturbed loss.
- The DISAM Twist: During the perturbation generation phase, DISAM adds a penalty for the variance of the losses across different domains.
- Elastic Gradient Calibration: This variance constraint acts as an automatic balancer. If one domain is "too far ahead" (low loss), the algorithm increases the perturbation pressure on it. If a domain is "lagging behind" (high loss), the perturbation is weakened.
Technically, this is achieved by modifying the gradient used for the perturbation step. It requires almost no extra memory and adds negligible computational overhead (roughly 0.01s per step) compared to vanilla SAM.
Datasets and Evaluation
The researchers evaluated DISAM using the DomainBed benchmark, the gold standard for domain generalization. The datasets included PACS, VLCS, OfficeHome, TerraIncognita, and DomainNet. They tested these using both a standard ResNet50 backbone and a large-scale pretrained CLIP model (ViT-B/16).
Key Insights
- The "Aha" Moment: SAM's failure in DG isn't about the final loss; it's about the path taken. Inconsistent convergence across domains creates a "misdirected" perturbation that pushes the model toward sharp, non-generalizable minima for the "harder" domains.
- Fairness in Optimization: By minimizing domain-loss variance, DISAM essentially enforces "fairness" across domains during the sharpness estimation. This ensures the model finds a location in the weight space that is flat for all domains simultaneously.
- Stability Allows for Aggression: Because DISAM is more stable than SAM, it can handle a larger perturbation radius ($\rho$). In optimization, a larger $\rho$ usually leads to even flatter minima and better generalization, but it often causes standard SAM to crash or fail to converge. DISAM bypasses this trade-off.
Key Results
- State-of-the-Art Performance: DISAM consistently outperformed ERM, SAM, and other advanced variants like GSAM and SAGM. On the difficult TerraIncognita dataset, DISAM improved out-of-domain accuracy by over 3% compared to standard SAM.
- CLIP & Fine-Tuning: When used for parameter-efficient fine-tuning of CLIP, DISAM showed a remarkable ability to prevent "representation collapse." In "open-class" settings (where the model must generalize to entirely new categories), DISAM outperformed the previous best method (CLIPOOD) by 3.1%.
- Faster Convergence: Empirically, DISAM reaches a lower loss on unseen test domains much faster than standard SAM.
Limitations and Future Work
While DISAM is efficient compared to SAM, it still requires two forward/backward passes per iteration, making it twice as slow as standard ERM. Additionally, the algorithm introduces a new hyperparameter, $\lambda$ (the weight of the variance constraint). While $\lambda = 0.1$ is a stable default, extreme values can lead to over-conditioning.
Future work may explore applying DISAM’s principle of "convergence consistency" to other areas beyond domain shifts, such as Multi-Task Learning (MTL), where different tasks often compete for the optimizer's attention.
Summary updated