HesScale: Scalable Computation of Hessian Diagonals

Mohamed Elsayed, A. Rupam Mahmood · DOI

Introduction

Deep learning optimization primarily relies on first-order methods like SGD and Adam due to their computational efficiency. However, these methods often struggle in "ill-conditioned" loss landscapes where curvature information—captured by the Hessian matrix—could significantly accelerate convergence. While second-order methods like Newton’s method utilize this curvature, calculating the full Hessian is computationally prohibitive ($O(n^2)$). Common proxies, such as the "empirical Fisher" (squared gradients used in Adam), often fail to accurately represent true curvature. HesScale addresses this gap by providing a deterministic, $O(n)$ method to approximate the Hessian diagonal with high accuracy.

Methodology: The HesScale Approach

HesScale introduces a recursive backpropagation rule for Hessian diagonals that maintains linear complexity. Its primary innovation lies in the treatment of the final layer.

Exact Last-Layer Curvature

Unlike previous methods (e.g., the BL89 method) that approximate curvature throughout the entire network, HesScale computes the exact Hessian diagonal for the output layer (e.g., Softmax with Cross-Entropy). This precise initialization prevents the accumulation of approximation errors that typically plague backpropagated curvature estimates. The authors demonstrate that this "small" change drastically improves the approximation quality for all preceding layers.

Linear Backpropagation and AdaHesScale

The authors derive a recursive rule to propagate this curvature information backward through the network in $O(n)$ time and memory—the same scaling as standard backpropagation. This approximation is integrated into the AdaHesScale optimizer, which replaces the squared gradient term in Adam with the HesScale diagonal estimate. A variant, HesScaleGN, approximates the Generalized Gauss-Newton (GGN) matrix by omitting second-order activation terms, ensuring a positive semi-definite matrix for increased stability.

Experimental Results

Approximation Accuracy

HesScale demonstrates superior accuracy in estimating the true Hessian diagonal. As shown in the comparison below, the normalized $L^1$ error for HesScale is significantly lower than that of AdaHessian, KFAC, or the empirical Fisher ($g^2$). Notably, the layer-wise analysis reveals that starting with exact output curvature keeps the error low across all preceding layers, whereas other methods see error accumulation.

Hessian diagonal approximation accuracy.

Computational Efficiency and Scaling

A critical requirement for any modern optimizer is scalability. HesScale achieves a "holy grail" in optimization: providing second-order benefits while maintaining the same computational scaling as first-order methods. Empirically, an AdaHesScale update is approximately 2x the cost of an Adam update, whereas AdaHessian is roughly 3x. As illustrated in the scaling plots, HesScale maintains linear time complexity relative to the number of parameters, making it viable for large-scale models.

Computational scaling of HesScale.

Training Performance

Evaluated on the DeepOBS benchmark (MNIST, CIFAR-10, CIFAR-100), AdaHesScale consistently outperformed Adam and SGD. On the All-CNN-C architecture for CIFAR-100, it reached higher test accuracy in fewer epochs and showed better stability across different learning rates compared to standard first-order heuristics.

Discussion and Future Work

While HesScale offers a significant step forward, it currently focuses on standard classification and regression loss functions. Extending these derivations to more complex layers, such as Attention mechanisms in Transformers, remains an area for future research. Additionally, the 2x overhead relative to Adam, while efficient for a second-order method, may still be a consideration for compute-constrained environments. Beyond optimization, the high-quality curvature estimates provided by HesScale could enhance neural network pruning and mitigate catastrophic forgetting in continual learning, where knowing the "importance" of specific weights is critical.

Summary updated

BibTeX
@misc{elsayed2022hesscale,
  author = {Mohamed Elsayed and A. Rupam Mahmood},
  title = {{HesScale: Scalable Computation of Hessian Diagonals}},
  year = {2022},
  eprint = {2210.11639},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2210.11639},
}
Figure