Amortized Eigendecomposition for Neural Networks

Tianbo Li, Zekun Shi, Jiaxi Zhao, Min LinNeurIPS 2024

Eigendecomposition is a crucial but computationally agonizing bottleneck in deep learning, often running orders of magnitude slower than standard matrix multiplications. This paper introduces "amortized eigendecomposition," a method that replaces exact, step-by-step eigenvalue solvers with a continuous "eigen loss" optimized jointly with the neural network using fast QR decomposition. This approach yields up to 600x speedups during training without sacrificing downstream accuracy.

The Bottleneck of Exact Eigendecomposition

Eigendecomposition (ED) and Singular Value Decomposition (SVD) are fundamental linear algebra operations used to uncover the intrinsic structure of matrices. In deep learning, they are essential for tasks like nuclear norm regularization (encouraging low-rank weight matrices), latent-space Principal Component Analysis (PCA), and defending Graph Neural Networks (GNNs) against adversarial attacks.

However, there is a massive problem: deep learning hardware is optimized for matrix multiplication, not iterative eigenvalue solvers. Operations like torch.linalg.eigh or svd can be four to five orders of magnitude slower than a standard matrix multiplication of the same size.

Comparison of CPU time ratios for QR, eigh, and SVD operations relative to standard matrix multiplication.

When you place an exact ED solver inside a neural network's training loop, the GPU grinds to a halt at every single step to solve a complex math problem on a matrix that is just going to change again in the next gradient update anyway.

Amortized Eigendecomposition: A Joint Optimization Approach

The authors propose amortized eigendecomposition, which shifts the paradigm from exact computation to joint optimization. Instead of decoupling the ED from the network and solving it perfectly at every forward pass, they relax it into an optimization problem that is solved gradually alongside the network's main loss.

This is achieved through two main components:

  1. The Eigen Loss: They introduce a penalty term to the network's loss function. However, standard trace maximization fails to find exact eigenvectors due to "rotational symmetry"—it finds the right subspace, but the vectors can be arbitrarily rotated. To fix this, they use Brockett’s cost function (which assigns distinct weights to different eigenvalues) or a Convex Trace Loss to break the symmetry and force the network to find the exact eigenvectors.
Contour plots demonstrating how Brockett's cost function and Convex trace loss break the rotational symmetry present in standard trace loss.
  1. QR Reparameterization: Eigenvectors must be orthogonal (i.e., they live on the Stiefel manifold). Enforcing this constraint is usually expensive. The authors cleverly use QR decomposition ($U = QR(W)$) to reparameterize the weight matrix. QR decomposition is significantly faster than SVD, highly numerically stable, and has well-supported automatic differentiation in frameworks like PyTorch and JAX.

By adding the eigen loss and using QR decomposition, the network "learns" the eigenvectors over the course of training, amortizing the computational cost.

Key Insights

  • Good enough is perfect: The core realization of the paper is that an inner loop (eigendecomposition) doesn't need to reach full convergence if the outer loop (network parameters) hasn't converged yet. The eigenvectors just need to trend in the right direction and arrive at the correct values by the end of the training process.
  • Breaking Rotational Symmetry: If you just tell a network to "find the subspace with the most variance," it will find a blended, rotated mix of the principal components. By mathematically forcing the network to value the first component strictly more than the second (via Brockett's cost), the loss landscape physically changes to have a single, correct global optimum.
  • QR as a Manifold Shortcut: Manifold optimization (keeping vectors strictly orthogonal during gradient descent) is notoriously tricky. Using QR decomposition as a differentiable layer is a brilliant, computationally cheap workaround that plays perfectly with modern auto-diff engines.

Experimental Results

The authors evaluated their method on several standard benchmarks, including MNIST, Celeb-A-HQ (256x256), and Citation Networks (Cora, Citeseer, Pubmed). The amortized approach achieves identical performance to exact solvers but at a fraction of the computational cost:

  • Nuclear Norm Regularization: Achieved a 105.4x speedup per iteration on 512x512 matrices compared to standard SVD.
  • Graph Structure Learning: When computing low-rank approximations of graph Laplacians (19,717 x 16 dimensions) to defend against adversarial attacks, the method achieved a staggering 615.2x speedup.
  • Massive Scalability: The authors successfully trained a 64-layer, 1-billion parameter autoencoder with a 4096-dimensional latent space PCA. Traditional exact solvers scaled terribly and choked on this dimensionality, whereas the amortized method's execution time barely increased.

Limitations and Future Work

The authors are highly transparent about one major limitation: this is not a general-purpose numerical eigensolver.

If you have a static matrix and simply need to find its eigenvalues, this amortized optimization method will not offer any speed or precision advantages over classical algorithms (like Lanczos or LOBPCG). Its superpower is strictly limited to scenarios where eigendecomposition is embedded as a dynamic, continuous component within a neural network's training loop. The framework can also be easily extended to Generalized Eigendecomposition and standard Singular Value Decomposition (SVD) problems.

Summary updated

BibTeX
@inproceedings{li2024amortized,
  author = {Tianbo Li and Zekun Shi and Jiaxi Zhao and Min Lin},
  title = {{Amortized Eigendecomposition for Neural Networks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=OYOkkqRLvj},
}
Figure