Repository navigation
Build sparse Jacobians from one CSR and share their colouring - #323
Merged
Merged
Conversation
singhharsh1708
referenced
this pull request
Oct 24, 2026
* Read the option names PETSc 3.25 renamed * Bump to 0.12.3
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.
This cuts the fixed cost of a solve with a sparse
jac_prototype. The Jacobian's rows are kept as one flat CSR that the AIJ matrix is built from directly, so filling the matrix is a single copy, and the colouring of a pattern is computed once and shared by later solves on the same pattern; only the read-only colouring result is shared, while DifferentiationInterface's buffers are still built per solve.Results are bitwise identical to main on 18 solve paths (sparse AD and user Jacobians, sparse and diagonal mass, DAE, TSIRK, finite differences, TSAlpha2), with PETSc.jl 0.4.14 and 0.5.3, and the new rows equal the old nested rows on 5000 random patterns. On the 1-D Brusselator (n = 1000) setup goes from 204 to 96 µs and a one-step TSRosW solve from 342 to 235 µs with 937 allocations instead of 7041; on the 2-D Brusselator (n = 2048) setup goes from 470 to 179 µs and a one-step TSRosW solve from 867 to 547 µs (Julia 1.12, PETSc 3.22, minima of interleaved runs).
AI Disclosure: Claude assisted with the code. Testing and review by @singhharsh1708.