In the world of deep learning, Adam is the undisputed king of optimizers for Transformers, while SGD (Stochastic Gradient Descent) remains the go-to for Convolutional Neural Networks (CNNs). This "generalization gap"—where adaptive methods like Adam fail to match SGD's performance on vision tasks—has long puzzled researchers.
A new paper from the 41st International Conference on Machine Learning (ICML 2024) suggests the culprit might be hiding in plain sight: the square root.
TL;DR
By removing the square root from the preconditioner of adaptive gradient methods (like RMSProp and Adam), researchers found they could close the generalization gap with SGD on CNNs while keeping their edge on Transformers. Furthermore, this "square-root-free" approach enables a new class of matrix-based optimizers that are twice as fast and far more stable in low-precision (BFP-16) training.
What Problem Does This Paper Address?
Standard adaptive optimizers (Adam, RMSProp) work by scaling the gradient by the square root of a running average of squared gradients. While this is often motivated as an approximation of "second-order" optimization (like Newton’s method), the square root actually represents a significant departure from true second-order theory.
This heuristic has two major downsides:
- The Generalization Gap: Adaptive methods tend to perform worse than SGD on CNNs. Some hypothesize this is because the square root makes the optimizer behave like "sign descent," which doesn't generalize well on certain architectures.
- Computational Complexity: For "full-matrix" adaptive methods (like Shampoo), calculating matrix square roots (e.g., $S^{-1/4}$) is numerically unstable and computationally expensive, especially in half-precision (FP16/BFP16) which is standard for modern large-scale training.
Methods
The authors propose Square-Root-Free (RF) adaptive methods. To make this theoretically sound, they introduce several key innovations:
- A New Second-Order Perspective: They reinterpret the gradient outer product not just as a heuristic, but as a specific type of "empirical Fisher" matrix. This allows them to justify removing the root while maintaining "scale invariance" (the property that ensures the optimizer doesn't care if you average or sum your loss).
- RF-RMSProp: A diagonal optimizer that removes the root from the denominator.
- IF-Shampoo (Inverse-Free Shampoo): A sophisticated matrix optimizer that avoids both square roots and matrix inversions. It uses a technique called "preconditioner invariance" to update the optimizer's state using simple matrix multiplications, making it compatible with low-precision hardware.
Datasets
The researchers tested their methods across a diverse range of architectures and benchmarks:
- CNNs: ResNet34, VGG16, and DenseNet121 on CIFAR-100.
- Transformers & Mambas: SwinViT, FocalNet, GCViT, and VMamba on ImageWoof10.
- RNNs: 3-layer LSTM on PenTree.
- GNNs: Graph MLP with attention on OgbnProducts.
- Convex/Regression: Logistic regression on BreastCancer and linear regression on BostonHousing.
Key Insights and Ideas
- The Root is a Relic: The square root was originally introduced to stabilize training in "outdated" pipelines (e.g., constant learning rates). In modern training with learning rate schedules and heavy hyperparameter tuning, the root is no longer necessary for stability.
- Disentangling Sign Descent: Removing the root effectively "turns off" the sign-descent behavior of Adam. The fact that RF methods match SGD on CNNs suggests that sign-descent—not adaptivity itself—is what causes the generalization gap.
- Numerical Stability in Half-Precision: Matrix roots (like the 4th root used in Shampoo) are notoriously "fussy" in low precision. By removing the root and the inverse, the authors created an optimizer (IF-Shampoo) that is robust enough to run entirely in BFP-16 without crashing.
Key Results
- Closing the Gap: As shown in the figure above, on ResNet34 (CIFAR-100), RF-RMSProp achieved a test error of 21.25%, nearly matching SGD (20.91%) and significantly beating standard AdamW (24.85%).
- Universal Performance: Unlike SGD, which struggles on Transformers, the RF methods performed excellently across both CNNs and Transformers (e.g., SwinViT and FocalNet), making them a more "universal" choice for mixed-architecture pipelines.
- Speed and Efficiency: Their IF-Shampoo optimizer ran twice as fast as standard Shampoo and used less memory, all while maintaining the superior convergence speed that matrix methods are known for.
Limitations and Future Work
The authors acknowledge that in the specific, older training contexts where Adam was first developed (fixed learning rates, zero-initialization), the square root does help. The success of RF methods depends on modern training strategies like learning rate decay.
Future work could involve scaling these root-free matrix methods to even larger models (like LLMs) and exploring whether "preconditioner invariance" can be used to develop even more efficient sparse-matrix optimizers.
Paper Citation: Wu Lin, Felix Dangel, Runa Eschenhagen, Juhan Bae, Richard E. Turner, Alireza Makhzani. "Can We Remove the Square-Root in Adaptive Gradient Methods? A Second-Order Perspective." Proceedings of the 41st International Conference on Machine Learning (ICML), 2024.
Summary updated