A Neural Hierarchical-Matrix Preconditioner for Real-Time GPU Solves

Carl Osborne, Minghao Guo, Crystal Owens, Wojciech Matusik

MIT CSAIL

SIGGRAPH Asia 2026 Posters · Kuala Lumpur, December 1–4

Abstract

Interactive simulation solves Ax=b for a sparse SPD A that changes every frame, inside an 8–16 ms budget. At a few thousand unknowns, algebraic multigrid’s setup alone exceeds that budget, while Jacobi and other local preconditioners have no setup but cannot move error across the domain. We learn a preconditioner for this gap: a graph-and-attention network predicts an SPD approximate inverse in \mathcal{H}^2-matrix format. On a spatially ordered 3D mesh, blocks of the true inverse lose rank as the clusters they couple move apart; the format’s nested bases follow that decay, so inference and apply are dominated by leaf-block work linear in N, where a dense inverse costs N^2. Our main finding concerns training. Probe losses reach M only through a product with A, so their gradient vanishes on the near-null modes that set the conjugate-gradient iteration count. A truncated Kaporin condition number has no such factor; changing only the objective cuts iterations on a held-out frame from 116 to 33. On a ladder of stiff tetrahedral diffusion problems ours alone fits an 8.3 ms (120 fps) frame from N=572 to 3{,}647.

Four panels. Total solve time against problem size for seven methods, with our curve the only one below the 8.3 millisecond line from 572 to 3,647 unknowns; relative residual against wall-clock time, where ours descends fastest; a schematic block partition with dense diagonal blocks, low-rank off-diagonal tiles and a highlighted row and column strip; and a heat map of the learned preconditioner, whose bright square leaf blocks sit on a diagonal against a textured off-diagonal background.

Fig. 1. Left to right: median wall clock per matrix on the barrier-heat ladder, where ours alone fits 120 fps up to {\sim}3.6k; residual against wall clock at N=3{,}647, same legend; the nested \mathcal{H}^2 partition (highways in red); and a learned factor on a 2D multiphase Poisson frame.

0.1 Setting

Interactive simulations of pressure, implicit diffusion and elasticity solve Ax=b with A sparse, SPD and different every frame, and at 60–120 fps the whole solve gets 8–16 ms on the GPU. The systems we target are small by solver standards and sit inside larger pipelines: the coarse levels of a multigrid cycle, the per-subdomain solves of a Schwarz preconditioner (Wu, Wang, and Wang 2022), and the systems that follow a change of contact set.

Two families of preconditioner meet this regime from opposite sides. Algebraic multigrid (Naumov et al. 2015) moves error between scales, so its iteration count barely grows with N; but on an unstructured mesh it rebuilds its hierarchy for every new matrix, and that setup alone costs 12–16 ms at our sizes. Jacobi, and learned sparse factors and approximate inverses (Li et al. 2023; Yang et al. 2025), have negligible setup but act locally, so they stall when error has to cross long, high-contrast seams. We want the global transport of multigrid at the setup cost of a local method: setup is one feed-forward inference (1.8–2.5 ms). Hierarchical matrices give the operator its shape; networks built on that structure have so far learned solution maps with the hierarchy fixed in their weights (Fan et al. 2019), or compressed a learned Green’s function into an \mathcal{H}-matrix per operator (Xu, Li, and Xi 2025). We predict the factor for each new matrix and use it inside conjugate gradients.

0.2 Preconditioner

Structure and apply. Unknowns are ordered along a space-filling curve and cut into K leaves of L=128 nodes. This induces a weak-admissibility \mathcal{H}-matrix partition (Fig. 1, third panel): K dense diagonal blocks and O(K) tiles that grow away from the diagonal.

The partition follows the inverse. For elliptic operators, even with rough, high-contrast coefficients like our barriers, a block of A^{-1} coupling two separated clusters is numerically low-rank (Bebendorf and Hackbusch 2003), and for neighbouring clusters, which weak admissibility also compresses, the rank grows with the area of their shared interface rather than their volume. We subdivide each tile by this interface-area rule: a tile spanning S leaves splits into sub-blocks of about S^{1/3} leaves, so its rank grows as S^{2/3}, and every sub-block touching a leaf reuses that leaf’s basis. These nested bases make an \mathcal{H}-matrix an \mathcal{H}^2-matrix (Hackbusch, Khoromskij, and Sauter 2000). Storage and apply are dominated by the NL entries of the leaf blocks, linear in N at fixed L, against a dense inverse’s N^2. Applying M is a batch of dense matrix products; with no host allocation or data-dependent control flow, each PCG iteration is one CUDA graph.

Network. A width-128 encoder (an MLP and two A-weighted graph convolutions) feeds two transformer stacks over the block layout. A diagonal stack emits each dense leaf block as F_k=U_kU_k^\top; an off-diagonal stack emits low-rank factor pairs in the shared bases from strip embeddings pooled to 32 tokens per tile of any size. Scatter-added row, column and global buffers (“highways”) route information between blocks at O(Nd): a communication scaffold, not a coarse solve. A learned per-node Jacobi gate adds \mathrm{diag}(\boldsymbol\lambda)D^{-1/2} to H, helping early in training. Inference is \Theta(N) in the leaf products plus two attention launches over K=N/L tokens.

SPD by construction. Mirroring the off-diagonal blocks makes H symmetric, so M=H^2 is SPD whenever H is nonsingular; we monitor \lambda_{\min}(H) and would fall back to Jacobi, and no held-out frame has needed it. Learning M\approx A^{-1} directly gave indefinite M on unseen frames, which is what motivated the squared form.

Two panels. Left: gradient share per mode against eigenvalue on a linear vertical axis, where the distance and cosine curves sit at zero across the small eigenvalues while the log-determinant curve stays high, together with a dotted curve on a second axis showing CG's cost per mode rising towards the small eigenvalues. Right: each of the sixty smallest modes' term in log K after training with each objective on a logarithmic axis, largest at the smallest modes and lowest throughout for the Kaporin-trained model, with each objective's PCG iteration count printed inside the panel.
Fig. 2. (a) What each objective can see on the spectrum of S=HAH, held-out N=3{,}306 frame. A probe loss reaches M only through MAz, so its gradient share on a mode (left axis) carries the eigenvalue and vanishes at the near-null end, where CG spends its iterations (right axis). (b) What each objective leaves in \log K: each mode’s term after training, with its PCG count.

0.3 Training objective

What a probe loss can see. Let S=HAH, similar to MA. Conjugate gradients spends its iterations on the smallest eigenvalues of S (Fig. 2a, right axis), the modes M must amplify most: on an eigenmode Aw=\lambda w the ideal M acts as Mw=w/\lambda. Approximate inverses are trained self-supervised on probes: draw z, form Az, and compare MAz with z, whether by the distance \|MAz-z\|_2^2 with A scaled by \|A\|_\infty (the sparse-approximate-inverse loss of Yang et al. (2025) up to norm and operand order), or by an angular loss on a block Z of n_z=256 probes, \mathcal{L}_{\cos}=1-\langle MAZ,Z\rangle_F/(\|MAZ\|_F\|Z\|_F). The distance asks the spectrum of MA to cluster at the particular value \|A\|_\infty; the angular loss is blind to the scale of M, so it rewards clustering wherever the spectrum can gather most tightly.

Every one of them touches M only through its product with A. With y=MAz, \partial\mathcal{L}/\partial M=(\partial\mathcal{L}/\partial y)(Az)^\top, which on a mode Aw=\lambda w is O(\lambda); the AMz ordering picks up the same factor through A^\top. A annihilates the mode before M can learn from it, and the signal that would teach M its required action is suppressed by the very factor that makes the mode expensive (Fig. 2a). The symptom is known: Chen (2025) reweights probes toward the bottom of the spectrum, and Xu, Li, and Xi (2025) report a flat loss surface near singular modes. Reweighting moves probe energy, not the factor. Pre-smoothing, Z\leftarrow(I-\omega D^{-1/2}A)Z twice with \omega=0.6 and D=\mathrm{diag}(A), the relaxation bootstrap AMG uses to expose algebraically smooth error (Brandt et al. 2011), shifts probe energy toward the low end and cuts iterations from 91 to 68: a tilt, not a fix.

A term that never passes a probe through A. One quantity escapes this. The gradient of -\log\det MA with respect to M is -M^{-\top}: no probe, no product with A, and the same weight on every mode in \log\lambda, the near-null modes included.

Kaporin’s condition number makes that term a training target: K(S)=\frac{\big(\tfrac{1}{N}\mathrm{tr}\,S\big)^N}{\det S}, the ratio of the arithmetic to the geometric mean of the eigenvalues of S, raised to the Nth power. It is 1 exactly when every eigenvalue is equal, it does not change under M\to sM, and it bounds PCG directly: \lceil\log_2 K+\log_2(1/\varepsilon)\rceil iterations reduce the M-norm residual by \varepsilon (Kaporin 1994). Calì et al. (2023) train on K with triangular factors, whose determinant is cheap. Ours has no such shortcut, and a stochastic Lanczos estimate of \log\det is too noisy to descend on.

So we truncate. Only the p=8 smallest eigenvalues \lambda_1\le\cdots\le\lambda_p of S are treated exactly; everything above them is summarized by its mean \bar m. We minimize \widehat{\log K} = N\log\Big(\tfrac{1}{N}\mathrm{tr}\,S^2\Big) - 2\Big[\sum_{i\le p}\log\lambda_i + (N-p)\log\bar m\Big], an estimate of \log K(S^2) whose traces come from Hutchinson probes. The tail is exact: the p smallest eigenpairs come from Chebyshev-filtered subspace iteration and are detached, so gradient reaches them through their Rayleigh quotients, and there the estimator has the log-determinant’s \lambda-free gradient exactly. The bulk is approximate: the mean stands in for its log-determinant, so by Jensen’s inequality the estimate is a lower bound, and the returning \lambda factor turns the term into pressure to cluster the bulk.

What changes. With the same architecture and data, PCG iterations on the held-out N=3{,}306 frame fall from 116 (distance) to 91 (cosine), 68 (smoothed probes) and 33 (truncated Kaporin), and \kappa(S) from 611 to 42. Even with the suppression gone from training, the low end remains the hardest part of the spectrum for this format to learn (Fig. 2b): after Kaporin training, the eight smallest modes still hold 26\% of the \log K that remains.

0.4 Results

Benchmark. Heat diffusion on TetWild tetrahedralizations (Hu et al. 2018) of a Thingi10K solid (Zhou and Jacobson 2016) from N=572 to 13{,}119, with a random barrier field of contrast 10^4 resampled every frame. One network is trained per size on 60–100 frames, in about ten minutes on one GPU, and evaluated on unseen frames of the same mesh. Baselines. Everything stays on the GPU: at these sizes a host round-trip costs more than the solve. We compare unpreconditioned CG, GPU Jacobi, and tuned AMG, the best of an AmgX (Naumov et al. 2015) sweep over aggregation and classical hierarchies with L1-Jacobi, multicolour Gauss–Seidel and DILU smoothers. At N\lesssim1k the hierarchy collapses to a one-iteration direct coarse solve, and that dense solve is what AMG pays for there. Protocol. Every solve runs to a true relative residual of 10^{-8}.

Table 1. Per new matrix on one L40S: medians over unseen test frames; each of our columns is its own median.
Baselines, ms (iters) Ours
N CG Jacobi AMG inf solve it (min–max) tot
572 64.9 (1938) 6.4 (192) 42.0 (1) 1.9 1.6 24 (18–39) 3.9
1,029 145.6 (4269) 8.7 (252) 62.2 (1) 1.8 2.3 34 (33–42) 4.2
1,479 168.9 (5000) 10.4 (306) 20.3 (28) 1.9 1.5 21 (21–45) 3.3
2,072 181.1 (5000) 12.1 (332) 19.4 (26) 1.8 1.8 24 (24–27) 3.6
2,695 166.0 (4530) 12.3 (336) 19.6 (23) 1.9 3.0 39 (33–45) 4.9
3,306 135.5 (3636) 12.7 (342) 19.9 (23) 2.4 3.3 44 (36–51) 5.8
3,647 142.3 (3738) 13.3 (348) 20.7 (24) 2.5 4.8 39 (33–48) 7.4
4,899 140.9 (3598) 15.4 (394) 20.2 (24) 4.3 15.5 192 (177–195) 19.8
13,119 141.4 (3460) 24.6 (582) 23.5 (32) 9.8 50.9 306 (300–327) 60.7

Through {\sim}3.6k the solve alone (1.5–4.8 ms) is faster than Jacobi or AMG, and with inference the total stays inside 120 fps; beyond that, Jacobi and then AMG overtake us. Residual traces (Fig. 1, second panel) separate early, so looser tolerances widen the band.

0.5 The learning gap and generalization

Leaf diagonals are learned first, and the off-diagonal cores degrade first as N grows. This is a learning gap rather than a missing level of the hierarchy: on smaller meshes, fitting the same format to A^{-1/2} directly by per-tile SVD gives an oracle that converges in 3–17 iterations, so the format is not the binding constraint.

Generalization is narrow in our trained example, whose setup is tiny: one mesh, 60–100 frames and minutes of training per size. Held-out barrier fields at a trained size stay in band, but a network trained at N=2{,}072 needs 314 iterations at 3{,}647, one applied below it hits the cap, and a chamber geometry at N=3{,}306 costs 81 iterations against 44 in distribution (supplementary).

Limitations. Quality lags an exact fit of the format and collapses past {\sim}5k, where that fit degrades mildly. The format and objective can beat local methods; training a network that does so robustly across sizes, geometries and PDEs is open.

Bebendorf, Mario, and Wolfgang Hackbusch. 2003. “Existence of \mathcal{H}-Matrix Approximants to the Inverse FE-Matrix of Elliptic Operators with L^\infty-Coefficients.” Numerische Mathematik 95 (1): 1–28. https://doi.org/10.1007/s00211-002-0445-6.
Brandt, Achi, James Brannick, Karsten Kahl, and Ira Livshits. 2011. “Bootstrap AMG.” SIAM Journal on Scientific Computing 33 (2): 612–32. https://doi.org/10.1137/090752973.
Calì, Salvatore, Daniel C. Hackett, Yin Lin, Phiala E. Shanahan, and Brian Xiao. 2023. “Neural-Network Preconditioners for Solving the Dirac Equation in Lattice Gauge Theory.” Physical Review D 107 (3): 034508. https://doi.org/10.1103/PhysRevD.107.034508.
Chen, Jie. 2025. “Graph Neural Preconditioners for Iterative Solutions of Sparse Linear Systems.” In International Conference on Learning Representations.
Fan, Yuwei, Jordi Feliu-Fabà, Lin Lin, Lexing Ying, and Leonardo Zepeda-Núñez. 2019. “A Multiscale Neural Network Based on Hierarchical Nested Bases.” Research in the Mathematical Sciences 6 (2). https://doi.org/10.1007/s40687-019-0183-3.
Hackbusch, Wolfgang, Boris N. Khoromskij, and Stefan A. Sauter. 2000. “On \mathcal{H}^2-Matrices.” In Lectures on Applied Mathematics, edited by Hans-Joachim Bungartz, Ronald H. W. Hoppe, and Christoph Zenger, 9–29. Berlin: Springer. https://doi.org/10.1007/978-3-642-59709-1_2.
Hu, Yixin, Qingnan Zhou, Xifeng Gao, Alec Jacobson, Denis Zorin, and Daniele Panozzo. 2018. “Tetrahedral Meshing in the Wild.” ACM Transactions on Graphics 37 (4): 60:1–14. https://doi.org/10.1145/3197517.3201353.
Kaporin, Igor E. 1994. “New Convergence Results and Preconditioning Strategies for the Conjugate Gradient Method.” Numerical Linear Algebra with Applications 1 (2): 179–210. https://doi.org/10.1002/nla.1680010208.
Li, Yichen, Peter Yichen Chen, Tao Du, and Wojciech Matusik. 2023. “Learning Preconditioners for Conjugate Gradient PDE Solvers.” In Proceedings of the 40th International Conference on Machine Learning, 202:19425–39. Proceedings of Machine Learning Research. PMLR.
Naumov, M., M. Arsaev, P. Castonguay, J. Cohen, J. Demouth, J. Eaton, S. Layton, et al. 2015. “AmgX: A Library for GPU Accelerated Algebraic Multigrid and Preconditioned Iterative Methods.” SIAM Journal on Scientific Computing 37 (5): S602–26. https://doi.org/10.1137/140980260.
Wu, Botao, Zhendong Wang, and Huamin Wang. 2022. “A GPU-Based Multilevel Additive Schwarz Preconditioner for Cloth and Deformable Body Simulation.” ACM Transactions on Graphics 41 (4): 63:1–14. https://doi.org/10.1145/3528223.3530085.
Xu, Tianshi, Rui Peng Li, and Yuanzhe Xi. 2025. “Neural Approximate Inverse Preconditioners.” arXiv Preprint arXiv:2510.13034.
Yang, Zherui, Zhehao Li, Kangbo Lyu, Yixuan Li, Tao Du, and Ligang Liu. 2025. “Learning Sparse Approximate Inverse Preconditioners for Conjugate Gradient Solvers on GPUs.” In Advances in Neural Information Processing Systems.
Zhou, Qingnan, and Alec Jacobson. 2016. “Thingi10K: A Dataset of 10,000 3D-Printing Models.” arXiv Preprint arXiv:1605.04797.

Poster

The SIGGRAPH Asia 2026 poster: the gap between multigrid and local preconditioners, the H² format, the probe-loss finding, and the 120 fps results.

Citation

@inproceedings{osborne2026neural,
  title     = {A Neural Hierarchical-Matrix Preconditioner for Real-Time GPU Solves},
  author    = {Osborne, Carl and Guo, Minghao and Owens, Crystal and Matusik, Wojciech},
  booktitle = {SIGGRAPH Asia 2026 Posters (SA Posters '26)},
  location  = {Kuala Lumpur, Malaysia},
  publisher = {ACM},
  year      = {2026},
  doi       = {10.1145/3829333.3847989}
}

Supplementary Material