ADAHESSIAN: An Adaptive Second Order Optimizer for Machine Learning

Zhewei Yao, Amir Gholami, Sheng Shen, Mustafa Mustafa, Kurt Keutzer, Michael W. Mahoney

Introduction

Deep learning models are predominantly trained using first-order optimizers like Stochastic Gradient Descent (SGD) or Adam. While these methods are computationally efficient, they only utilize the "slope" (gradient) of the loss landscape, ignoring the "curvature" (Hessian). This often necessitates extensive hyperparameter tuning to achieve convergence. Second-order methods, such as Newton’s method, incorporate curvature information to provide more robust and faster convergence per iteration. However, the quadratic computational and memory costs ($O(d^2)$) of calculating the full Hessian matrix have historically made them impractical for large-scale deep learning.

ADAHESSIAN addresses this challenge by introducing a practical stochastic second-order optimizer. It incorporates curvature information with a computational cost comparable to standard first-order methods, achieving state-of-the-art results across various domains including Natural Language Processing (NLP), Computer Vision (CV), and Recommendation Systems.

Methodology

ADAHESSIAN makes second-order optimization feasible through three primary innovations:

  1. Diagonal Approximation via Hutchinson’s Method: Instead of the full Hessian, ADAHESSIAN approximates only the diagonal elements. It employs a "Hessian-free" approach where the Hessian-vector product is computed via backpropagation, maintaining a linear cost ($O(d)$) relative to the parameter count.
  2. Spatial Averaging: To mitigate noise in the Hessian diagonal, the authors apply spatial averaging across neighboring coordinates (e.g., within convolutional kernels). This variance reduction technique helps the optimizer perceive a smoother loss landscape.
  3. Temporal Smoothing (Hessian Momentum): Similar to Adam's moving average of gradients, ADAHESSIAN maintains a root-mean-square exponential moving average of the Hessian. This "Hessian momentum" stabilizes updates against local ruggedness in the loss surface.

The resulting update rule resembles Adam, but uses a preconditioner derived from the estimated Hessian rather than squared gradients.

Algorithm 1: The ADAHESSIAN optimization procedure.

Experimental Evaluation

The authors evaluated ADAHESSIAN on several industry-standard benchmarks across NLP, Computer Vision, and Recommendation Systems.

Key Results

ADAHESSIAN consistently matched or outperformed heavily tuned first-order baselines. In NLP tasks, it improved BLEU scores for translation and reduced perplexity for language modeling. In vision tasks, it achieved significantly higher accuracy on ResNet architectures compared to Adam (e.g., +5.55% on ImageNet with ResNet18).

Performance comparison on NLP translation tasks (BLEU scores) showing ADAHESSIAN's superiority.

Beyond raw performance, a critical advantage of ADAHESSIAN is its robustness. It demonstrates significantly higher resilience to learning rate variations compared to AdamW, remaining stable even when the learning rate is scaled by 10x or 20x. While the theoretical overhead is $2\times$ that of SGD, practical wall-clock time is currently around $2.42\times$ slower in PyTorch, though this can be reduced by updating the Hessian less frequently.

Discussion and Future Work

ADAHESSIAN represents a significant step toward making second-order optimization a standard tool. While current deep learning frameworks are primarily optimized for first-order gradients, future optimizations for Hessian-vector products could further close the speed gap. The optimizer's robustness to hyperparameters suggests it could significantly reduce the time researchers spend on manual tuning, making it a powerful alternative for training complex modern architectures.

Summary updated

BibTeX
@inproceedings{yao2021adahessian,
  author = {Zhewei Yao and Amir Gholami and Sheng Shen and Mustafa Mustafa and Kurt Keutzer and Michael W. Mahoney},
  title = {{ADAHESSIAN: An Adaptive Second Order Optimizer for Machine Learning}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2021},
  doi = {10.1609/aaai.v35i12.17275},
}
Figure