Learning Sparse Approximate Inverse Preconditioners for Conjugate Gradient Solvers on GPUs

Zherui Yang, Zhehao Li, Kangbo Lyu, Yixuan Li, Tao Du, Ligang Liu

Abstract

Solving large-scale symmetric positive definite (SPD) linear systems is a cornerstone of scientific computing, yet traditional preconditioning techniques often fail to leverage the massive parallelism of modern GPUs. This paper presents a novel machine learning framework that utilizes Graph Neural Networks (GNNs) to predict Sparse Approximate Inverse (SPAI) preconditioners. Unlike factorization-based methods that rely on sequential triangular solves, the proposed SPAI approach utilizes sparse matrix-vector products (SpMV), aligning perfectly with GPU architectures and GNN message-passing mechanisms. Our method achieves up to a 113% speedup over traditional and existing learning-based solvers across various physical simulation datasets.

1. Introduction

The Conjugate Gradient (CG) method is the standard iterative solver for large, sparse, symmetric positive definite (SPD) systems of the form $Ax = b$. To accelerate convergence, a preconditioner $M$ is typically applied to improve the system's condition number. However, a significant gap exists between algorithmic efficiency and hardware utilization. The most effective traditional preconditioners, such as Incomplete Cholesky (IC), require triangular solves that are inherently sequential. On modern GPUs, which thrive on massive parallelism, these sequential dependencies create a severe bottleneck, leaving hardware underutilized.

Recent attempts to integrate machine learning into this pipeline have largely focused on predicting IC factorizations. While these models can improve convergence rates, they inherit the same structural limitations as traditional IC, failing to address the underlying hardware bottleneck.

2. Methodology

2.1 Sparse Approximate Inverse (SPAI)

To overcome the limitations of factorization-based methods, we propose learning a Sparse Approximate Inverse (SPAI) preconditioner. Instead of approximating $A$ itself, the model directly approximates the inverse: $$M^{-1} \approx GG^T + \epsilon I$$ The primary advantage of this formulation is that applying the preconditioner during each CG iteration requires only sparse matrix-vector products (SpMV). SpMV is highly parallelizable and executes with high efficiency on GPU architectures.

2.2 GNN Architecture and Hardware Alignment

We utilize an encoder-processor-decoder GNN to predict the non-zero entries of the matrix $G$. There is a fundamental structural synergy between GNNs and SPAI: the mathematical locality of SpMV (which depends on local neighborhood connections in the matrix graph) matches the local message-passing mechanism of GNNs. By tasking the GNN with learning local matrix relationships rather than global elimination trees, the model achieves better predictive accuracy and higher runtime performance.

2.3 Scale Invariant Aligned Identity (SAI) Loss

Training neural preconditioners is often computationally prohibitive. We introduce the Scale Invariant Aligned Identity (SAI) loss, which utilizes a stochastic trace estimator to avoid expensive dense matrix operations. Crucially, the loss function normalizes the matrix $A$, making it scale-invariant. This design choice ensures the model focuses on the spectral properties (condition number) of the matrix rather than the absolute magnitude of its entries, mimicking the actual behavior of the CG solver and improving generalization across different physical parameters.

3. Experiments and Results

The method was evaluated on four distinct datasets: Heat Equation (TetWild), Poisson Equation (TetWild), Hyperelasticity (twisting beam simulation), and a Synthetic System of algebraic matrices.

3.1 Performance and Speedup

The proposed method demonstrated significant performance gains over both traditional and neural baselines:

  • GPU Efficiency: Total solution time was reduced by 40% to 53% compared to Diagonal, IC, and AINV preconditioners, translating to a speedup of 68% to 113%.
  • Comparison with ML Baselines: The model outperformed state-of-the-art neural preconditioners (e.g., Neural PCG and Neural IF) in both the time required to construct the preconditioner and the speed of the solver iterations.
  • Iteration vs. Time: While traditional IC may occasionally require fewer iterations to converge, our SPAI-based method wins on total wall-clock time due to the drastically lower cost per iteration on the GPU.

3.2 Generalization

The model showed robust generalization to out-of-distribution (OOD) scenarios. It maintained its performance advantages when tested on meshes up to three times larger than those used in training and on physical systems with unseen material densities.

4. Discussion and Limitations

The success of this approach highlights the importance of "algorithmic-hardware symbiosis"—designing algorithms that are not just mathematically sound but also structurally compatible with the target hardware.

However, several limitations remain:

  • Sparsity Constraints: The current model constrains the matrix $G$ to the same sparsity pattern as $A$. Future iterations could benefit from dynamic sparsity patterns or multi-hop connections.
  • Scope: The framework is currently limited to SPD systems and CG solvers.
  • Scalability: The implementation is currently restricted to single-GPU memory capacities, necessitating future research into distributed GNN techniques.

5. Conclusion

By shifting the focus from factorization to approximate inversion, we have developed a preconditioning framework that fully leverages the parallel processing power of GPUs. The combination of GNN-based prediction and SPAI-based application provides a scalable, efficient, and hardware-aligned solution for large-scale linear systems in scientific computing.

Summary updated

BibTeX
@inproceedings{yang2025learning,
  author = {Zherui Yang and Zhehao Li and Kangbo Lyu and Yixuan Li and Tao Du and Ligang Liu},
  title = {{Learning Sparse Approximate Inverse Preconditioners for Conjugate Gradient Solvers on GPUs}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=jtMDzggo6M},
}
Figure