Introduction
In deep learning, "flat" minima—regions of the loss landscape where the error remains stable under slight weight perturbations—are strongly associated with better generalization on unseen data. Sharpness-Aware Minimization (SAM) is an optimization technique designed to explicitly seek out these flat regions. While highly effective, SAM is computationally expensive, requiring two gradient computations per update and effectively doubling training time.
Furthermore, the "implicit bias" of SAM—why and how it navigates the loss landscape to find these flatter regions compared to standard Stochastic Gradient Descent (SGD)—has remained a subject of theoretical debate. Recent research investigates the training dynamics of SAM to understand when it is most effective, revealing that its computational overhead can be drastically reduced without sacrificing performance.
The Switching Method
To isolate the effects of different optimizers at various stages of training, researchers introduced a Switching Method. This approach compares models trained entirely with one optimizer (Full SGD or Full SAM) against models that switch optimizers mid-training. The primary focus is on the SGD $\to$ SAM trajectory: training with standard SGD for $t$ epochs, and then switching to SAM for the remainder of the training process.
The Dynamics of Late-Stage SAM
The most significant finding is that the late phase of training is decisive. The final properties of a neural network solution, including its sharpness and generalization capabilities, are primarily determined by the optimization algorithm used at the very end of training.
When switching from SGD to SAM late in the process, the optimizer does not merely drift slowly. Instead, it undergoes a rapid, two-phase transition:
- Phase I (Escape): SAM quickly identifies that the current minimum found by SGD is "too sharp" and escapes it exponentially fast.
- Phase II (Convergence): It then rapidly converges to a much flatter minimum located within the same broad "valley" of the loss landscape.
Interestingly, using SAM early in training provides almost no benefit if the model is switched back to SGD for the final phase. Without SAM actively maintaining flatness at the end, the "Edge of Stability" effect in SGD tends to push the model back toward sharper regions.
Efficiency and Sharpness Reduction
This late-phase efficiency translates to massive computational savings. On CIFAR-10 using a WideResNet-16-8 architecture, applying SAM for only the last 5 epochs (out of 200) achieved a test error of ~3.4%. This nearly matches the ~3.2% error of full SAM training, while standard SGD lagged behind at ~4.4%.
As illustrated above, the sharpness of the solution (measured by the spectral norm of the Hessian) drops dramatically the moment SAM is introduced, even if the model has already "converged" under SGD. A very small proportion of SAM training at the end is sufficient to close the generalization gap.
Broader Implications
This "late phase efficiency" is not unique to SAM. Researchers found a similar pattern in Adversarial Training (AT). Applying AT only at the tail end of training (e.g., at epoch 180 out of 200) causes the robust error to drop sharply, matching the performance of a model trained with AT from the very beginning.
While current theoretical models rely on certain simplifications (like assuming a constant perturbation radius or using squared loss), the empirical evidence is clear: late-phase switching offers a powerful way to achieve the generalization benefits of specialized optimizers like SAM while bypassing their steep computational costs.
Summary updated