Kronecker-Factored Approximate Curvature (K-FAC) and Shampoo: How Kronecker Preconditioning Scales Second-Order Optimization
Standard deep neural network pre-training relies almost exclusively on first-order stochastic gradient methods. Optimizers such as AdamW maintain running averages of individual parameter gradients and uncentered second moments, applying a coordinate-wise diagonal preconditioner. While computationally efficient, diagonal scaling ignores off-diagonal cross-layer and intra-layer parameter correlations. When loss surfaces exhibit high anisotropy (narrow, ill-conditioned valleys with extreme curvature variation), diagonal first-order methods require thousands of micro-steps to navigate terrain that second-order methods could traverse in far fewer iterations.
Exact second-order methods, such as classical Newton-Raphson or Natural Gradient Descent, scale quadratically in memory and cubically in compute with respect to parameter count. For modern neural networks spanning billions of parameters, calculating, storing, and inverting the full Hessian or Fisher Information Matrix is intractable.
Kronecker-factored methods solve this computational barrier. By exploiting the Kronecker product structure inherent in neural network layer gradients, algorithms such as K-FAC (Martens & Grosse, 2015) and Shampoo (Gupta et al., 2018; Anil et al., 2020) approximate full-matrix curvature using compact block factors. This architecture enables tractable second-order preconditioning at scale.
1. The Second-Order Bottleneck
In standard optimization, minimizing a scalar empirical risk over parameters via Newton's method employs the update rule:
where is the Hessian matrix of second derivatives.
In probabilistic models optimized via log-likelihood objectives, Natural Gradient Descent (Amari, 1998) replaces the parameter-space Euclidean metric with the Riemannian metric tensor defined by the Fisher Information Matrix (FIM) :
For negative log-likelihood loss functions, the expected Fisher matrix is mathematically equivalent to the Generalized Gauss-Newton (GGN) matrix, providing a positive semi-definite curvature approximation that avoids negative curvature instabilities.
+-------------------------------------------------------------------------+
| The Second-Order Computational Ceiling |
+-------------------------------------------------------------------------+
| Model Parameter Count (N) | Hessian/Fisher Memory | Inversion Cost |
| | O(N^2) Elements (FP32) | O(N^3) FLOPs |
+-----------------------------+-------------------------+-----------------+
| 100 Million (Small Model) | 40,000 Terabytes | ~10^24 FLOPs |
| 1 Billion (Medium Model) | 4 Exabytes | ~10^27 FLOPs |
| 70 Billion (LLM Scale) | 19.6 Zettabytes | ~3.4x10^32 FLOPs|
+-------------------------------------------------------------------------+Because full-matrix representation is impossible at these dimensions, practitioners historically chose between two extremes:
- Diagonal Approximations (Adam, RMSProp): Retain only the diagonal elements of curvature. Memory drops to and inversion to , but all parameter cross-talk is discarded.
- Hessian-Free / Krylov Subspace Methods: Compute Hessian-vector products iteratively using automatic differentiation without materializing (Martens, 2010). While memory-efficient, obtaining an accurate descent direction requires dozens of conjugate gradient iterations per parameter update step, resulting in prohibitive per-iteration wall-clock overhead.
2. K-FAC: Kronecker-Factored Approximate Curvature
K-FAC (Martens & Grosse, 2015) introduces a structured structural approximation that bridges diagonal and full-matrix preconditioning. It operates on two foundational structural insights: layer-wise block diagonalization and the Kronecker decomposition of layer Fisher blocks.

The Layer Gradient Outer Product
Consider a standard fully connected layer computing activations:
where is the input activation vector, is the weight matrix, and is the pre-activation vector.
Let denote the loss gradient with respect to pre-activations. By the chain rule, the gradient with respect to the weight matrix is the outer product:
Vectorizing this gradient using the column-stacking operator yields:
where denotes the Kronecker product.
The Expectation Decoupling Assumption
The exact Fisher Information block $F_l \in \mathbb{R}^{(d_{\text{in}} d_{\text{out}}) \times (d_{\text{in}} d_{\text{out}})}$ corresponding to layer is the expected outer product of vectorized gradients:
The exact expectation of a Kronecker product couples activations and output gradients. K-FAC makes the core approximation of factoring the expectation of the product into the product of expectations:
where:
- $A_{l-1} = \mathbb{E}[a_{l-1} a_{l-1}^T] \in \mathbb{R}^{d_{\text{in}} \times d_{\text{in}}}$ is the uncentered covariance matrix of incoming activations.
- $S_l = \mathbb{E}[g_l g_l^T] \in \mathbb{R}^{d_{\text{out}} \times d_{\text{out}}}$ is the uncentered covariance matrix of pre-activation derivatives.
Inversion via Kronecker Algebra
The computational advantage of K-FAC stems from the algebraic property of Kronecker products: the inverse of a Kronecker product equals the Kronecker product of the individual inverses:
Using the standard vectorization identity , the natural gradient update direction $\tilde{\nabla}_{W_l} L = \text{vec}^{-1}(\hat{F}_l^{-1} \text{vec}(\nabla_{W_l} L))$ simplifies directly to matrix multiplication:
+-------------------------------------------------------------------------+
| K-FAC Complexity Reduction (d_in x d_out) |
+-------------------------------------------------------------------------+
| Operation | Full Block Matrix | K-FAC Factorization |
+--------------------------+-----------------------+----------------------+
| Matrix Storage | O(d_in^2 * d_out^2) | O(d_in^2 + d_out^2) |
| Matrix Inversion | O(d_in^3 * d_out^3) | O(d_in^3 + d_out^3) |
| Preconditioning Step | O(d_in^2 * d_out^2) | O(d_in * d_out * |
| | | (d_in + d_out)) |
+-------------------------------------------------------------------------+For a typical linear layer with and :
- Exact block inversion requires inverting a matrix, taking approximately FLOPs and 1.1 petabytes of memory.
- K-FAC inverts two matrices, taking approximately FLOPs and 134 megabytes of memory. This represents a compute reduction exceeding 10 orders of magnitude.
Tikhonov Damping
In practice, curvature estimates require regularization to ensure positive definiteness and bound step sizes. Standard damping adds a diagonal term . However, adding a diagonal directly breaks the Kronecker product factorization because $(A \otimes S + \gamma I)^{-1} \neq (A + \gamma_1 I)^{-1} \otimes (S + \gamma_2 I)^{-1}$.
K-FAC resolves this by distributing damping across factors using a scalar factor $\pi_l = \sqrt{\frac{\text{Tr}(A_{l-1}) / d_{\text{in}}}{\text{Tr}(S_l) / d_{\text{out}}}}$:
This formulation guarantees that the Kronecker structure is strictly preserved during matrix inversion.
3. Shampoo: Preconditioned Stochastic Tensor Optimization
While K-FAC is derived from the Fisher Information Matrix in feed-forward layers, Shampoo (Gupta et al., 2018; Anil et al., 2020) generalizes full-matrix AdaGrad to arbitrary tensor parameters using multidimensional Kronecker preconditioning.
Tensor Preconditioning Formulation
For a parameter matrix with stochastic gradient at step , full-matrix AdaGrad maintains an covariance matrix and applies .
Shampoo replaces the tensor with two separate covariance matrices along the row and column dimensions:
The preconditioned descent direction is computed by applying symmetric fractional matrix inverse roots:
For a general order- tensor parameter , Shampoo constructs preconditioner matrices by contracting the outer product of gradients along all modes except mode :
The tensor update applies the -th power along each respective tensor mode:
+-------------------------------------------------------------------------+
| Mathematical Comparison: K-FAC vs. Shampoo |
+-------------------------------------------------------------------------+
| Dimension | K-FAC | Shampoo |
+--------------------------+---------------------------+------------------+
| Theoretical Origin | Fisher Information (GGN) | Full-Matrix |
| | Natural Gradient | AdaGrad / Tensor |
| Factor Construction | Activations (A) and | Row/Column outer |
| | Gradients (S) | products of G |
| Matrix Powers | A^-1 and S^-1 | L^-1/4 and R^-1/4|
| | (Standard Inverses) | (Inverse Roots) |
| Scope | Neural layer architectures| Arbitrary tensor |
| | (MLP, Conv, Attention) | shapes |
+-------------------------------------------------------------------------+4. Computing Matrix Inverse Roots at Scale
Evaluating and efficiently and stably is the primary algorithmic challenge in Shampoo. Three main numerical approaches exist:
1. Symmetric Eigendecomposition (SVD)
Compute the spectral decomposition , where is orthogonal and . The inverse root is:
- Pros: Exact and numerically stable even for ill-conditioned matrices.
- Cons: High computational latency on modern GPU tensor cores, which are optimized for dense GEMM (General Matrix Multiply) operations rather than sequential LAPACK tridiagonalization routines.
2. Coupled Newton-Schulz Iterations
To leverage tensor core hardware acceleration, modern distributed implementations (Anil et al., 2020) use iterative polynomial expansions that rely solely on matrix multiplications.
To compute the -th inverse root (where for 2D Shampoo), the coupled Newton-Schulz iteration initializes and , iterating:
where is a scaling factor chosen to bound the spectrum inside the convergence radius (). As , and .
Because Newton-Schulz uses only GEMM kernels, it executes at hardware peak throughput on modern accelerator platforms.
5. Distributed Systems Architecture
Materializing and inverting preconditioners every optimization step incurs excessive communication and compute overhead. Scalable implementations, such as PyTorch Distributed Shampoo (Bernacchia et al., 2023), decouple the pipeline into asynchronous execution tiers:
+-------------------------------------------------------------------------+
| Distributed Asynchronous Preconditioning |
+-------------------------------------------------------------------------+
| |
| [GPU Compute Stream (Every Step t)] |
| Forward Pass -> Backward Pass -> Gradient G_t |
| Accumulate Statistics: L_t += G_t G_t^T, R_t += G_t^T G_t |
| Apply Cached Preconditioners: \Delta W_t = P_L G_t P_R |
| Update Weights: W_{t+1} = W_t - \eta \Delta W_t |
| |
| | (Every K steps, e.g. K = 50-100) |
| v |
| [Asynchronous Preconditioner Engine (Host CPU or Background Stream)] |
| Gather Statistics Across Data-Parallel Ranks (All-Reduce / DTensor)|
| Compute Inverse Roots: P_L = L_t^{-1/4}, P_R = R_t^{-1/4} |
| Send Updated Preconditioner Tensors back to Compute Engine |
| |
+-------------------------------------------------------------------------+Key Engineering Optimizations:
- Preconditioner Staleness (-Step Delay): Recomputing matrix inverse roots every steps incurs negligible convergence loss while amortizing the inversion cost over iterations.
- Block Diagonalization of Large Tensors: For large embedding or vocabulary projection layers where , factoring the matrix into smaller diagonal blocks (e.g., sub-matrices) bounds peak memory and compute requirements.
- DTensor Sharding: Sharding the preconditioner state tensors across data-parallel and pipeline-parallel ranks avoids GPU out-of-memory errors during multi-node distributed training.
6. Comparison of Pre-Training Optimization Paradigms
+-------------------------------------------------------------------------------------------------------+
| Method | Curvature Metric Captured | Per-Step FLOP Overhead | Memory Footprint | Coordinate Invariant|
+--------------+------------------------------+------------------------+------------------+---------------------+
| SGD+Momentum | None (Euclidean) | Low (0%) | Low (1x params) | No |
| AdamW | Diagonal (Coordinate Variance)| Moderate (~5%) | Medium (2x state)| No |
| K-FAC | Block-Kronecker Fisher (GGN) | Moderate-High (~15-25%)| High (Covariances| Yes (Affine Layer) |
| Shampoo | Block-Kronecker Tensor Covar | Moderate (~10-20%) | Medium-High | Yes (Unitary/Linear)|
| Muon | Orthogonal Momentum Matrix | Low-Moderate (~5-10%) | Medium | Yes (Spectral) |
+-------------------------------------------------------------------------------------------------------+7. Current Landscape and Modern Adaptations
While first-order adaptive optimizers like AdamW remain the industry default due to implementation simplicity and minimal hyperparameter tuning, second-order Kronecker preconditioning is seeing renewed interest in frontier AI development:
- Memory-Bandwidth Saturation: Modern GPUs provide surplus compute (TFLOPs) relative to memory bandwidth (HBM capacity and bus speed). Because K-FAC and Shampoo perform dense matrix multiplications rather than element-wise operations, their computational arithmetic intensity matches GPU hardware architecture more closely than element-wise optimizers.
- Large-Batch Scaling: Second-order methods exhibit greater stability under very large batch sizes (hundreds of thousands to millions of tokens per step), where first-order gradient noise benefits plateau (Osawa et al., 2019).
- Geometric Offshoots (Muon): Recent optimizer developments, such as the Muon optimizer (Jordan, 2024), adapt Shampoo's matrix-valued Newton-Schulz iterations to orthogonalize updates directly, trading off full Fisher tracking for lower computational overhead while retaining non-coordinate preconditioning dynamics.
Sources
- Martens, J., & Grosse, R. (2015). Optimizing Neural Networks with Kronecker-factored Approximate Curvature. International Conference on Machine Learning (ICML). https://arxiv.org/abs/1503.05671
- Grosse, R., & Martens, J. (2016). A Kronecker-factored Approximate Fisher Matrix for Convolutional Layers. International Conference on Machine Learning (ICML). https://arxiv.org/abs/1602.01407
- Gupta, V., Shamir, O., & Srebro, N. (2018). Shampoo: Preconditioned Stochastic Tensor Optimization. International Conference on Machine Learning (ICML). https://arxiv.org/abs/1802.09568
- Anil, R., Gupta, V., Koren, T., Regan, K., & Singer, Y. (2020). Scalable Second Order Optimization for Deep Learning. arXiv preprint. https://arxiv.org/abs/2002.09018
- Amari, S. (1998). Natural Gradient Works Efficiently in Learning. Neural Computation, 10(2), 251–276. https://doi.org/10.1162/089976698300017746
- Osawa, K., Tsuji, Y., Ueno, C., Naruse, A., Foo, C. S., & Yokota, R. (2019). Large-Scale Distributed Second-Order Optimization Using Kronecker-Factored Approximate Curvature for Deep Convolutional Neural Networks. IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). https://arxiv.org/abs/1811.12019
- PyTorch Distributed Shampoo Implementation. Meta Research. https://github.com/facebookresearch/optimizers



