Ginger: An Efficient Curvature Approximation with Linear Complexity for General Neural Networks

Yongchang Hao, Yanshuai Cao, Lili MouarXiv 2024

Abstract

Second-order optimization approaches like the generalized Gauss-Newton method are considered more powerful as they utilize the curvature information of the objective function with preconditioning matrices. Albeit offering tempting theoretical benefits, they are not easily applicable to modern deep learning. The major reason is due to the quadratic memory and cubic time complexity to compute the inverse of the matrix. These requirements are infeasible even with state-of-the-art hardware. In this work, we propose Ginger, an eigendecomposition for the inverse of the generalized Gauss-Newton matrix. Our method enjoys efficient linear memory and time complexity for each iteration. Instead of approximating the conditioning matrix, we directly maintain its inverse to make the approximation more accurate. We provide the convergence result of Ginger for non-convex objectives. Our experiments on different tasks with different model architectures verify the effectiveness of our method.

Introduction

Training modern deep learning models typically relies on first-order optimizers like SGD or Adam due to their computational efficiency. However, these methods often struggle with "ill-conditioned" loss landscapes where gradients do not point directly toward the minimum. Second-order methods, such as Newton’s method, leverage curvature information (the Hessian matrix) to navigate more efficiently. However, for a model with $d$ parameters, the Hessian requires $O(d^2)$ memory to store and $O(d^3)$ time to invert, making it impractical for modern deep learning architectures.

This paper introduces GINGER (General Inverse Gauss-Newton with Eigendecomposition and Rank-reduction), a novel second-order optimization method designed to bring the benefits of curvature-aware training to large-scale neural networks without prohibitive computational costs. GINGER achieves linear time and memory complexity by directly maintaining a low-rank eigendecomposition of the inverse preconditioning matrix.

Methodology

GINGER addresses the "inversion trap" where small errors in approximating a preconditioning matrix can lead to massive errors once that matrix is inverted. Its key innovations include:

  1. Direct Inverse Modeling: Instead of approximating the Generalized Gauss-Newton (GGN) matrix and then inverting it, GINGER directly models the inverse of a damped GGN matrix.
  2. Low-Rank Spectral Decomposition: It represents the preconditioning matrix as a sum of a diagonal matrix (damping) and a low-rank component ($U \Sigma U^\top$). This allows the optimizer to capture the most significant "directions" of curvature using a small rank $\tau$.
  3. Efficient SVD Updates: To update the optimizer state at each step, GINGER uses the Woodbury matrix identity and a specialized, efficient Singular Value Decomposition (SVD) algorithm. This keeps the computational complexity at $O(d\tau^2)$, which is linear with respect to the number of parameters $d$.
  4. Architecture Agnostic: Unlike methods like K-FAC, GINGER does not rely on specific layer types and can be applied to any neural network.

Experimental Setup

The authors evaluated GINGER on two primary benchmarks:

  • CIFAR-100: A standard image classification dataset used with ResNet-18 and ResNet-50 architectures.
  • XSUM: A large-scale text summarization dataset used to fine-tune a T5-small Transformer model, testing both full-parameter fine-tuning and Low-Rank Adaptation (LoRA).

Results and Discussion

GINGER demonstrates superior performance across both vision and language tasks. On CIFAR-100 with ResNet-50, GINGER achieved a validation accuracy of 75.83%, significantly higher than Adam (71.59%) and the previous state-of-the-art linear second-order method, QNG (75.12%).

Performance comparison on CIFAR-100 with ResNet architectures. GINGER consistently achieves higher accuracy and lower validation loss compared to first-order and other second-order baselines.

In the XSUM summarization task, GINGER reached lower training losses and better ROUGE scores than Adam and Momentum, particularly in full-parameter fine-tuning scenarios.

Results on the XSUM dataset for both LoRA and full-parameter fine-tuning. GINGER shows competitive ROUGE scores and lower training loss while maintaining manageable FLOPs and memory overhead.

Efficiency and Complexity

While GINGER requires more FLOPs and memory than Adam (roughly 1.5x to 3x depending on the rank $\tau$), it remains well within the limits of modern GPUs. By using spectral decomposition, GINGER leverages the Eckart–Young theorem, ensuring that its low-rank component captures the most useful curvature information available within its memory budget.

Conclusion and Future Work

GINGER provides a general-purpose, accurate, and linear-complexity alternative to existing optimizers. While it is computationally heavier than first-order methods, its superior convergence properties offer a better performance-per-epoch trade-off. Future work will focus on further optimizing implementation to reduce constant factors in complexity and establishing specific asymptotic convergence rates for non-convex objectives.

Summary updated

BibTeX
@misc{hao2024ginger,
  author = {Yongchang Hao and Yanshuai Cao and Lili Mou},
  title = {{Ginger: An Efficient Curvature Approximation with Linear Complexity for General Neural Networks}},
  year = {2024},
  eprint = {2402.03295},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.03295},
}
Figure