Repository navigation
Speed up simplicial selected inversion - #14
Merged
Merged
Conversation
The simplicial kernel looked up each entry of the already-computed part of the selected inverse with a binary search through sparse indexing, and allocated a temporary vector per column. Since both row lists involved are sorted, the lookups can be done as a single merge instead, with a galloping search when the merge needs to skip far ahead in a long column. Also: - Read simplicial CHOLMOD factors directly from their column arrays instead of converting through `sparse(F.L)`. - Convert LL to LDL column by column inside the sweep. - Extract the diagonal in `selinv_diag` directly and depermute it with a single scatter. Adds tests for the simplicial path on low-fill problems, LL and LDL factors, unpacked factors after a rank update, and supernodal factors passed to `selinv_simplicial`.
Latent Gaussian models whose Cholesky factors have few nonzeros per column (tree-structured fields, nested random effects, random walks), so CHOLMOD factorizes them with the simplicial method. A 2D grid serves as a supernodal control.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Many sparse problems in statistics have Cholesky factors with only a handful of nonzeros per column: tree-structured models, nested random effects, random walks and other latent Gaussian models. CHOLMOD factorizes these with its simplicial method, so
selinvtakes the simplicial path. That path was noticeably less optimized than the supernodal one, and the SuiteSparse benchmarks never exercised it.Changes
SparseMatrixCSCindexing, which is a binary search, and it allocated a temporary vector per column. Both row lists involved are sorted, so the lookups are now a single merge. When the merge has to skip far ahead in a long column, a galloping search keeps the cost logarithmic.sparse(F.L), which took about as long as the inversion itself on low-fill problems. Unpacked factors, such as those left bylowrankupdate, are handled.selinv_diag. The diagonal is read directly from the result instead of through genericdiagon aSymmetricsparse matrix, and is depermuted with a single scatter. Before,selinv_diagwas slower than the fullselinvit calls.The supernodal code is untouched.
Results
M1 Max, single-threaded. Low-fill problems are generated by the new
benchmark/lowfill_problems.jl:selinvbefore → afterselinv_diagbefore → afterOn these problems, a selected inversion now costs 5–25% of the Cholesky factorization.
Higher-fill matrices pushed through the simplicial path, either by forcing CHOLMOD's simplicial mode or through the LDLFactorizations extension, also benefit. For example, crystm03 drops from 19.5 s to 1.6 s with forced simplicial CHOLMOD. The SuiteSparse benchmark set, which is entirely supernodal, is unchanged within noise.
Testing
New tests in
test/test_simplicial.jlcheck the results against a dense inverse for low-fill problems with LL and LDL factors, unpacked factors after a rank update, a short column pointing into a long one, and a supernodal factor passed toselinv_simplicial. The full suite passes on Julia 1.10, 1.11 and 1.12.