Fast Approximate Determinants Using Rational Functions

Thomas Colthurst, Srinivas Vasudevan, James Lottes, Brian PattonarXiv 2024 · DOI

Introduction

Calculating the log-determinant of a large $n \times n$ matrix is a fundamental operation in machine learning, particularly for training Gaussian Processes (GPs). However, exact algorithms scale at $O(n^3)$, creating a significant computational barrier for modern datasets where $n$ can exceed $10^6$. Researchers at Google have proposed a new approach, the $r^*$ algorithm, which leverages rational function approximations and stochastic trace estimation to achieve $O(n^2)$ scaling with high accuracy.

Methodology

The $r^*$ algorithm integrates several key components to approximate $\log \det M$:

  1. Rational Function Approximation: Instead of a direct logarithmic approximation, the method uses rational functions $r_k(z)$—ratios of polynomials—optimized to minimize error near $z=1$. As shown in Figure 1, higher-order approximations significantly reduce the error, particularly when the matrix spectrum is concentrated around unity.
Error of rational function approximations $r_k(x)$ for various orders $k$.
  1. Stochastic Trace Estimation: Utilizing Hutchinson’s Trick, the log-determinant is estimated via the trace of the matrix logarithm: $\log \det M = \text{tr} \log M$. This is computed by probing the matrix with random vectors.
  2. Preconditioning: To ensure the matrix is close to the identity (where the rational approximation is most accurate), a randomized, truncated SVD is used as a preconditioner $P$. The final calculation becomes $\log \det P + \text{tr} \log (MP^{-1})$.
  3. Multi-shift Solver: Efficiency is gained by decomposing the rational function into partial fractions and using a multi-shift Lanczos solver to handle multiple linear systems simultaneously.

Results and Discussion

The algorithm was evaluated against the state-of-the-art Stochastic Lanczos Quadrature (SLQ) using synthetic covariance matrices from Matérn-5/2 and Radial Basis Function (RBF) kernels.

Accuracy and Efficiency

The researchers found that the third-order approximation ($r_3$) provides an optimal balance between accuracy and computational cost. While $r_5$ is theoretically more precise, the gains are marginal compared to the increased complexity.

Log-determinant error (left) and computation time (right) for an RBF kernel with $d=5$.

As illustrated in Figure 4, the $r^*$ methods consistently outperform SLQ in terms of accuracy. In the challenging $d=5$ dimension case, where errors typically peak, the $r$ algorithms maintain significantly lower error rates. Crucially, this accuracy does not come at the expense of speed; the computation time for $r^*$ algorithms remains comparable to SLQ and scales much better than the exact Cholesky decomposition.

Dimensionality and Hardware

A notable insight is the "hump" of difficulty at moderate dimensions ($d \approx 5$). Accuracy is highest at very low or very high dimensions, but mid-range dimensionality presents unique challenges for preconditioning. Despite this, the algorithm's parallelizable nature allows it to run efficiently on modern hardware like NVIDIA A100 GPUs and Intel CPUs.

Conclusion

The $r^*$ algorithm represents a significant step forward in large-scale matrix operations. By achieving $O(n^2)$ complexity with superior accuracy over existing stochastic methods, it enables more reliable inference in fields like geo-statistics and machine learning. Future work will focus on understanding the error peaks in moderate dimensions and expanding the method's application to diverse matrix types beyond GP covariance matrices.

Summary updated

BibTeX
@misc{colthurst2024fast,
  author = {Thomas Colthurst and Srinivas Vasudevan and James Lottes and Brian Patton},
  title = {{Fast Approximate Determinants Using Rational Functions}},
  year = {2024},
  eprint = {2405.03474},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.03474},
}
Figure