MLRG Deep Curvature

Diego Granziol, Xingchen Wan, Timur Garipov, Dmitry P. Vetrov, Stephen RobertsarXiv 2019

MLRG Deep Curvature: Bridging the Curvature Gap in Deep Learning

The MLRG Deep Curvature suite is an open-source PyTorch package designed to make the "black box" of neural network curvature accessible. By leveraging the Lanczos algorithm and efficient Hessian-vector products, it allows researchers to visualize loss landscapes and analyze the spectral density of massive models without the prohibitive $O(P^2)$ memory costs of traditional methods.

The Curvature Gap

In deep learning, the "loss surface"—the high-dimensional landscape the optimizer navigates—is central to understanding model behavior. The curvature of this surface, represented by the Hessian matrix, dictates training speed and generalization. However, for modern networks with millions of parameters ($P$), the Hessian's $P^2$ entries make direct computation impossible. This "Curvature Gap" often leads researchers to rely on inaccurate diagonal approximations, which this research proves can be wildly misleading.

Methodology: Lanczos and Moment Matching

The MLRG Deep Curvature package bridges this gap using the Lanczos algorithm. Instead of computing the full Hessian, it utilizes Hessian-vector products via "Pearlmutter’s trick," requiring only a slightly more expensive version of standard backpropagation. This iterative approach builds a small tridiagonal matrix that shares the same "moments" as the full Hessian, enabling accurate estimation of the spectral density (eigenvalue distribution) with minimal memory overhead.

Figure 3: Lanczos stem plots compared to true eigenvalue histograms for synthetic benchmarks, demonstrating high accuracy in spectral density estimation even with few iterations.

As shown in Figure 3, the Lanczos method (represented by stem plots) accurately captures the theoretical distribution as the number of parameters $P$ increases, even with a limited number of iterations ($m=30$). This confirms that Lanczos is not just for finding top eigenvalues but is a robust tool for capturing the overall shape of the entire spectrum.

Practical Performance and Optimization

The package supports the Generalized Gauss-Newton (GGN) matrix, a popular positive-definite approximation. The authors evaluate the practical impact of these curvature-aware methods on architectures like VGG-16 and ResNet-110 trained on CIFAR datasets.

Figure 1: Training error across epochs for various optimizers, including Adam, SGD, and Gauss-Newton (GN) at different learning rates.

Figure 1 illustrates the training dynamics of different optimizers. The package allows for a detailed comparison of standard methods like SGD and Adam against second-order approximations like GN, helping researchers understand how curvature influences convergence and training stability.

Key Insights

  • The Diagonal Delusion: Diagonal approximations often fail to capture the true spectral support, missing directions of extreme curvature that are critical for optimization.
  • Hessian vs. GGN: While GGN is a useful surrogate, it is blind to negative curvature. In VGG-16 experiments, the Hessian was found to have significant spectral mass (~37%) on the negative axis, which the GGN completely ignores.
  • Efficiency: For a VGG-16 model (15M+ parameters), the package can perform a Lanczos iteration in roughly 26–28 seconds on a single NVIDIA 1080 Ti, using less than 3GB of VRAM.

Conclusion

The MLRG Deep Curvature suite provides a powerful toolset for demystifying the geometry of neural network loss landscapes. By making high-dimensional curvature analysis computationally feasible, it opens new avenues for designing better normalization techniques and more robust second-order optimizers that can account for the complex curvature found in modern deep models.

Summary updated

BibTeX
@misc{granziol2019mlrg,
  author = {Diego Granziol and Xingchen Wan and Timur Garipov and Dmitry P. Vetrov and Stephen Roberts},
  title = {{MLRG Deep Curvature}},
  year = {2019},
  eprint = {1912.09656},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1912.09656},
}
Figure