Abstract
Modern neural architectures like Transformers and Graph Neural Networks (GNNs) rely heavily on weight-sharing, yet second-order optimization methods like Kronecker-Factored Approximate Curvature (K-FAC) have historically lacked a unified framework for these structures. This paper introduces a formalization of linear weight-sharing layers and identifies two distinct settings: "expand" and "reduce." We propose K-FAC-reduce, a computationally efficient variant that maintains theoretical exactness for specific architectures while significantly reducing memory and time overhead compared to the standard "expand" approach.
Introduction
Training state-of-the-art deep learning models is computationally intensive. While first-order optimizers like Adam or SGD are standard, they only utilize gradient information. Second-order methods, which account for the curvature of the loss landscape via the Fisher Information Matrix, offer the potential for much faster convergence. K-FAC is a leading second-order method that makes these computations tractable through Kronecker-product approximations. However, its application to modern architectures with complex weight-sharing (e.g., tokens in a Transformer) has remained ad-hoc and often inefficient.
The Weight-Sharing Framework
The authors formalize modern layers as linear weight-sharing operations. The critical insight is that weight-sharing occurs in two primary modes based on how the loss function interacts with shared dimensions:
1. The Expand Setting
In the "expand" setting, the loss is calculated for every shared element. A classic example is language modeling, where a loss is computed for every token in a sequence. Here, shared dimensions act like additional batch samples. The standard approach, K-FAC-expand, is theoretically exact in this context.
2. The Reduce Setting
In the "reduce" setting, shared dimensions are aggregated (e.g., summed or averaged) before the loss is computed. This is common in image classification with Vision Transformers (ViTs), where a sequence of patches is reduced to a single class prediction. The authors introduce K-FAC-reduce, which aggregates statistics before performing expensive Kronecker operations.
Key Insights and Efficiency
The choice between "expand" and "reduce" flavors is not merely a matter of implementation but of mathematical alignment with the architecture's loss structure.
Computational Gains: K-FAC-reduce avoids "unfolding" large tensors, leading to significant savings. In Transformer models like nanoGPT, K-FAC-reduce requires only ~70% of the time per step compared to the expand version. Furthermore, it is more memory-efficient; in Wide ResNet experiments, K-FAC-expand encountered out-of-memory (OOM) errors at large batch sizes (e.g., 2048), while K-FAC-reduce operated smoothly.
Automatic Hyperparameter Tuning: The efficiency of K-FAC-reduce enables advanced use cases like automatic weight decay selection via marginal likelihood optimization. This process was found to be roughly twice as fast using the reduce variant.
Experimental Results
The framework was evaluated across diverse benchmarks including CIFAR-10 (Wide ResNet), ogbg-molpcba (GNNs), ImageNet (ViTs), and DART (nanoGPT).
- Convergence Speed: K-FAC reached validation targets in 50-75% of the steps required by highly tuned first-order optimizers like NAdamW.
- Wall-Clock Performance: Despite the per-step overhead of second-order statistics, the reduction in total steps led to overall wall-clock speedups.
- Optimization Quality: Interestingly, both K-FAC versions showed similar "steps to convergence" on GNNs and ViTs, suggesting that the computational savings of K-FAC-reduce come with no penalty to optimization performance.
Conclusion and Limitations
This work provides the necessary theoretical and practical tools to apply K-FAC to modern architectures. By matching the K-FAC flavor to the weight-sharing structure, practitioners can achieve faster training and more efficient hyperparameter tuning.
However, challenges remain. Implementation complexity is higher than for first-order methods, and numerical stability in low-precision (FP16) environments can be an issue. Additionally, while K-FAC-reduce is more efficient, it still carries a memory overhead for storing Kronecker factors compared to standard SGD or Adam. Future work may explore "inverse-free" methods to further improve stability and scalability.
Summary updated