Introduction
In the landscape of deep learning optimization, practitioners often face a dilemma. Adaptive optimizers, such as Adam, provide rapid convergence but frequently fall short in generalization compared to Stochastic Gradient Descent (SGD). Conversely, second-order methods that leverage Hessian (curvature) information are theoretically superior but computationally expensive, making them impractical for large-scale models.
Presented at NeurIPS 2023, researchers from Ant Group introduced AGD (Auto-switchable optimizer using Stepwise Gradient Difference). AGD is designed to bridge this gap, offering the convergence speed of adaptive methods, the generalization capabilities of SGD, and the curvature-awareness of second-order methods—all while maintaining a computational footprint similar to Adam.
The Optimization Challenge
The primary hurdle in deep learning optimization is determining an effective "preconditioning matrix" to scale gradients across different dimensions.
- First-order methods (SGD) apply uniform scaling, which is stable but often slow to converge.
- Adaptive methods (Adam, AdaBelief) scale updates based on historical gradient magnitudes or variances. While fast, this can lead to sub-optimal generalization.
- Second-order methods (e.g., AdaHessian) utilize the Hessian matrix to account for the loss landscape's curvature. However, the direct calculation or approximation of the Hessian is typically too memory-intensive for modern architectures.
AGD addresses these issues by capturing curvature information efficiently and implementing a mechanism to decide when to employ adaptive scaling versus reliable SGD-style updates.
Methodology
AGD introduces two core innovations:
1. Gradient Difference for Preconditioning
Instead of relying on squared gradients or variance, AGD utilizes the difference between gradients from successive steps. Mathematically, this difference serves as an approximation of the inner product between Hessian row vectors and the change in parameters. This allows the optimizer to incorporate second-order curvature information using only first-order data, avoiding the heavy lifting of Hessian computation.
2. The Auto-Switch Mechanism
Traditional adaptive optimizers use a small constant ($\epsilon$) for numerical stability. AGD replaces this with a tunable threshold hyperparameter, $\delta$. This parameter enables a per-parameter "auto-switch": if the calculated adaptive scaling falls below $\delta$, the optimizer reverts to an SGD-with-momentum mode. This allows the model to remain adaptive in complex regions of the landscape while maintaining the stability of SGD in flat or noisy areas.
Experimental Evaluation
The authors validated AGD across several domains to demonstrate its versatility, including Natural Language Processing (Penn TreeBank, IWSLT14), Computer Vision (CIFAR-10, ImageNet), and Recommendation Systems (Avazu, Criteo).
Key Insights
- Robustness to Hyperparameters: A critical finding is AGD's stability. Unlike AdaBelief, whose performance can degrade significantly with poor $\epsilon$ tuning, AGD remains consistent across a broad range of $\delta$ values.
- Dynamic Adaptivity: Analysis indicates that AGD naturally mimics SGD during the early, noisy stages of training and transitions to more aggressive adaptive updates as training progresses and the landscape becomes more defined.
Performance Results
AGD consistently met or exceeded the performance of state-of-the-art (SOTA) optimizers:
- NLP: On the Penn TreeBank dataset, AGD achieved superior perplexity (PPL) results across various LSTM architectures.
- Computer Vision: On ImageNet, AGD reached a top-1 accuracy of 70.35%, surpassing both SGD (69.94%) and AdamW (69.11%).
- Computational Efficiency: AGD maintains high efficiency. In Transformer model tests, it was only 7% slower than AdamW, whereas the second-order AdaHessian was nearly three times slower.
Conclusion
AGD represents a significant step toward a "best-of-all-worlds" optimizer. While it introduces the $\delta$ hyperparameter, its stability makes it a practical choice for large-scale training. Future work may involve testing AGD on billion-parameter Large Language Models (LLMs) and further refining the theoretical bounds of its convergence under varied architectural conditions.
Summary updated