Skip to content

Build sparse Jacobians from one CSR and share their colouring - #323

Merged
singhharsh1708 merged 4 commits into
mainfrom
sparse-fixed-cost
Oct 24, 2026
Merged

singhharsh1708 merged 4 commits into
mainfrom
sparse-fixed-cost

Conversation

@singhharsh1708

Copy link
Copy Markdown
Member

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.

@singhharsh1708
singhharsh1708 merged commit 4f6b1a8 into main Oct 24, 2026
30 of 32 checks passed
singhharsh1708 referenced this pull request Oct 24, 2026
* Read the option names PETSc 3.25 renamed

* Bump to 0.12.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant