Batched Conjugate Gradients (mBCG) for Scalable GP Inference
- Batched Conjugate Gradients (mBCG) is a matrix-Krylov method that extends classical CG to solve multiple right-hand sides in parallel, crucial for large-scale Gaussian Process inference.
- The algorithm utilizes on-the-fly Lanczos tridiagonal accumulation to efficiently estimate log-determinants and trace terms, integrating seamlessly with stochastic Lanczos quadrature.
- A specialized low-rank pivoted Cholesky preconditioner is employed to accelerate convergence, reducing the number of iterations and computational complexity on modern GPU hardware.
Batched Conjugate Gradients (mBCG) is a matrix-Krylov method extending the classical Conjugate Gradients (CG) algorithm to support simultaneous solution of multiple right-hand sides and streamlined estimation of matrix functionals. It plays a central role in enabling scalable, highly parallelizable Gaussian Process (GP) inference—especially on modern GPU hardware—by collapsing what would otherwise be multiple serial CG or Lanczos passes into a single, hardware-efficient, batched operation. mBCG directly yields the quantities needed for both predictive posterior and log determinant computations in exact and approximate GP models, and supports stochastic trace and log-determinant estimation in a single sweep. The fundamental advances and practical implications of mBCG are presented below as realized in Blackbox Matrix-Matrix Multiplication (BBMM) inference and related approaches (Gardner et al., 2018).
1. Extension from Standard Conjugate Gradients
Classical CG solves a single linear system for with symmetric positive definite, generating iterates that converge to . mBCG generalizes this to simultaneously solve right-hand sides, i.e., with . In doing so, mBCG further accumulates Lanczos tridiagonal coefficients during the same sweep, enabling on-the-fly estimation of stochastic Lanczos quadrature (SLQ) approximations for log-determinants and trace terms without separate Lanczos passes.
At each iteration , mBCG maintains matrices for the solution, residual, and search directions. The following matrix-matrix recurrences are computed:
- 0 (dense matrix-matrix multiplication, 1)
- Step-size vector: 2
- Solution update: 3
- Residual update: 4
- Conjugacy vector: 5
- Search direction: 6
During iteration, for each right-hand side 7, the scalars
- 8
- 9 populate the diagonals and off-diagonals, respectively, of the partial Lanczos tridiagonal 0. After 1 iterations, mBCG yields 2 and partial tridiagonals for SLQ. This routine enables estimating:
- 3 via 4
- 5 by Hutchinson’s method with random 6
- 7 by stochastic Lanczos quadrature on the tridiagonals
The batched nature allows efficient use of GPU Batched-BLAS through large fused matrix-matrix multiplies (Gardner et al., 2018).
2. Algorithmic Structure and Pseudocode
The essential mBCG algorithm proceeds as follows (unpreconditioned):
1
These outputs are then directly used for the primary quantities of GP inference:
- Posterior mean: 8
- Derivatives: 9
- Log-determinant: 0
Preconditioning is introduced by transforming the residuals and inner products as discussed below (Gardner et al., 2018).
3. Low-Rank Pivoted Cholesky Preconditioning
mBCG achieves rapid convergence in practice by utilizing a specialized preconditioner based on the pivoted low-rank Cholesky decomposition. For an 1 covariance matrix 2, the rank-3 pivoted Cholesky factorization 4 yields the preconditioning matrix 5. The preconditioned system is
6
However, only 7 is required within the mBCG recurrences: initial search directions as 8, and inner products as 9. Log-determinant computation proceeds via
0
where the correction term is estimated via SLQ on the preconditioned tridiagonals.
Key computational properties:
- 1 can be computed in 2
- 3 solves in 4 (Woodbury identity)
- Sampling 5 is 6
- 7 in 8
For scalar RBF kernels, the preconditioned condition number satisfies 9, decaying exponentially in 0. The CG error accordingly falls as 1 (Theorem 4.2 in (Gardner et al., 2018)).
4. Computational Complexity and Parallelism
Each mBCG iteration requires one dense matrix-matrix multiply 2 at 3 cost for dense kernels, plus 4 operations for vector reductions and bookkeeping. For 5 iterations with 6 probe vectors, total work is 7. Cholesky factorization and classical CG require 8 and additional separate linear algebra passes for log-determinants and traces.
On modern GPU hardware, the matrix-matrix multiplies in mBCG enable full utilization of hardware (e.g., via cuBLAS GEMM), while runtime complexity for GP inference is reduced from 9 to 0. Further complexity reductions are achieved for structured kernel approximations (e.g., SKI, SGPR), where 1 decreases to 2 or 3. mBCG therefore unifies these techniques into a single, scalable, matrix-matrix Krylov routine (Gardner et al., 2018).
5. Practical GPU Implementation Strategies
The practical realization of mBCG for BBMM inference involves:
- Storing all block variables (4) as 5 device-resident tensors
- Performing kernel matrix-matrix products 6 using user-supplied GPU routines (either recomputed on the fly or via fast operator representations)
- Allocating all workspace buffers (7) a priori to prevent allocation overhead during iteration
- Compactly storing tridiagonal data as 8, where 9 and 0 require negligible memory
- Achieving 1 TFLOP/s performance per GEMM call by leveraging hardware-batched BLAS kernels
This approach ensures that each CG iteration corresponds to a single fused GEMM plus 2 sequence of small vector operations, maximizing hardware efficiency and enabling large-scale GP inference (Gardner et al., 2018).
6. Empirical Performance and Analytical Results
Empirical results on a Titan Xp GPU demonstrate that:
- For exact GPs (3), BBMM with mBCG is up to 4 faster than CPU-based Cholesky, and 5 faster than GPU-based Cholesky
- For SGPR with 6, BBMM achieves 7 speedup over CPU Cholesky
- For SKI+DKL with 8, BBMM is up to 9 faster than state-of-the-art CPU-based MVM+Lanczos inference
Convergence curves indicate that unpreconditioned mBCG can require 0–100 iterations for 1 relative residuals, while a rank-5 Cholesky preconditioner reduces this to 2–20, and increasing 3 to 4 halves the required iterations further. Test error evaluations match or slightly improve upon Cholesky-based inference, with early-terminated CG occasionally regularizing tiny eigenvalues (Gardner et al., 2018).
7. Connections to Batched and Block Conjugate Gradient Variants
mBCG (as in BBMM) and the closely related cooperative CG (cCG) both generalize classical CG by introducing matrix-valued step sizes, updating multiple descent and conjugate directions in parallel. cCG, analyzed by Bhaya et al. (Bhaya et al., 2012), introduces block updates in 5 via 6 and enforces block (bi)-orthogonality and 7-conjugacy. The per-iteration cost per thread is 8 with 9 worst-case complexity given 0. mBCG, as adopted in GP inference, prioritizes matrix-matrix operations to maximize GPU efficiency and tightly integrates with stochastic Lanczos quadrature for scalable kernel learning.
Both mBCG and cCG maintain the Krylov-optimality and finite step termination characteristics of classic CG, but are tailored for parallel and batched environments, with design tradeoffs for block orthogonalization and rank preservation (Bhaya et al., 2012, Gardner et al., 2018).