ADAHESSIAN: An Adaptive Second Order Optimizer for Machine Learning

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

Abstract

Deep learning models are predominantly trained using first-order optimizers like SGD and Adam, which often require extensive hyperparameter tuning due to the ill-conditioned nature of loss landscapes. Second-order methods, while theoretically superior in convergence, are computationally prohibitive for large-scale models. This paper introduces ADAHESSIAN, a novel second-order stochastic optimizer that approximates the Hessian diagonal with minimal overhead. By incorporating Hutchinson’s method, spatial averaging, and Hessian momentum, ADAHESSIAN achieves state-of-the-art performance across computer vision, NLP, and recommendation system benchmarks with a computational cost comparable to first-order methods.

Introduction

The training of modern neural networks relies heavily on first-order optimization. However, these methods only consider the gradient (slope) of the loss function, ignoring the curvature (Hessian). In ill-conditioned landscapes—where some directions are flat and others are sharp—first-order methods can struggle, necessitating careful "babysitting" of learning rates and schedules.

Second-order methods like Newton’s method adjust step sizes based on local curvature, allowing for faster and more robust convergence. Historically, the $O(d^3)$ complexity of computing and inverting the full Hessian matrix for $d$ parameters has made these methods impractical. ADAHESSIAN addresses this by providing a scalable, adaptive second-order framework.

Comparison of convergence paths for Gradient Descent and ADAHESSIAN on a loss landscape.

Methodology

ADAHESSIAN bridges the efficiency of Adam with the power of second-order optimization through three primary innovations:

1. Fast Hessian Approximation

Instead of the full Hessian, ADAHESSIAN estimates only the diagonal elements. It utilizes Hutchinson’s method, a "Hessian-free" approach that approximates the diagonal using a single extra backpropagation step to compute Hessian-vector products. This reduces the per-iteration complexity significantly.

2. Spatial Averaging

Curvature estimates can be noisy at the individual parameter level. To stabilize updates, ADAHESSIAN employs "block diagonal averaging." It averages Hessian estimates across local parameter groups, such as 3x3 convolution kernels, which reduces variance and improves training stability.

3. Hessian Momentum

Similar to the first-order momentum in Adam, ADAHESSIAN maintains a root-mean-square exponential moving average of the Hessian diagonal. This temporal smoothing helps the optimizer focus on the global geometry of the loss landscape rather than local fluctuations.

Visualization of loss landscapes, gradients, and the Hessian matrix across different layers of a neural network.

Experimental Results

The authors evaluated ADAHESSIAN across diverse benchmarks:

  • Computer Vision: On ImageNet, ADAHESSIAN achieved 70.08% accuracy, significantly outperforming Adam (64.53%) and AdamW (67.41%), and matching heavily tuned SGD.
  • Natural Language Processing: For Transformer models on WMT14 and IWSLT14, and language modeling on Wikitext-103, ADAHESSIAN consistently outperformed AdamW, achieving lower perplexity (19.9 vs 20.9 on Wikitext-103).
  • Recommendation Systems: ADAHESSIAN showed strong performance on DLRM models using the Criteo dataset.

Robustness and Efficiency

A key finding is ADAHESSIAN's robustness to hyperparameter choices. It maintains high performance even when the learning rate is scaled by 10x, whereas AdamW often diverges. While theoretically requiring 2x the FLOPs of SGD, practical overhead on modern GPUs is approximately 2.42x. This can be further reduced to 1.25x by periodically skipping Hessian updates with minimal impact on accuracy.

Conclusion

ADAHESSIAN demonstrates that second-order optimization is viable for large-scale deep learning. By intelligently approximating the Hessian diagonal and applying spatial and temporal smoothing, it offers the convergence benefits of second-order methods with manageable computational costs. Future work will focus on optimizing low-level kernels for Hessian-vector products to further reduce wall-clock time overhead.

Summary updated

BibTeX
@inproceedings{yao2021adahessian,
  author = {Zhewei Yao and Amir Gholami and Sheng Shen 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