Skip to content

docs: document symbolic factorization reuse for sparse matrices (#1060)#1067

Merged
ChrisRackauckas merged 2 commits into
SciML:mainfrom
ChrisRackauckas-Claude:docs-sparse-symbolic-reuse
Jun 28, 2026
Merged

docs: document symbolic factorization reuse for sparse matrices (#1060)#1067
ChrisRackauckas merged 2 commits into
SciML:mainfrom
ChrisRackauckas-Claude:docs-sparse-symbolic-reuse

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Contributor

Please ignore until reviewed by @ChrisRackauckas.

What

Addresses #1060 (and the follow-up comment). Adds a "Reusing the Symbolic Factorization with Sparse Matrices" section to docs/src/tutorials/caching_interface.md. The existing tutorial only covered changing b and replacing a dense A; reuse_symbolic was not mentioned anywhere in it.

The new section covers:

  • What reuse_symbolic / check_pattern do for UMFPACKFactorization / KLUFactorization, and why reusing the symbolic part matters (symbolic analysis is the expensive part; numeric refactor is cheap) — the common FE/Newton/implicit-timestepping case of fixed pattern, changing values.
  • The gotcha from the issue: in-place edits to A.nzval are not seen by the cache, so the next solve! silently reuses the stale factorization and returns a wrong result.
  • The supported fix: signal the change with linsolve.A = A (reassigning the same mutated object is fine and still reuses the symbolic factorization when the pattern is unchanged). A note documents the internal isfresh flag as an equivalent-but-not-preferred escape hatch.

Verification

Ran the new @example block locally against this branch:

doc example OK; residual = 1.6e-15, changed = 0.24

i.e. the post-update solve is correct (tiny residual) and the solution actually changed after the in-place value edit + linsolve.A = A (confirming the numeric refactorization fired while the symbolic factorization was reused).

Docs-only change; no source modified.

🤖 Generated with Claude Code

Add a "Reusing the Symbolic Factorization with Sparse Matrices" section to
the caching interface tutorial. Explains reuse_symbolic/check_pattern, and
the key gotcha that in-place edits to A's values are not seen by the cache:
the change must be signaled with `linsolve.A = A` (or, internally, isfresh).

Addresses SciML#1060.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
@ChrisRackauckas ChrisRackauckas marked this pull request as ready for review June 28, 2026 15:45
@ChrisRackauckas ChrisRackauckas merged commit 94044a0 into SciML:main Jun 28, 2026
6 of 9 checks passed
@lijas

lijas commented Jun 28, 2026

Copy link
Copy Markdown

@ChrisRackauckas
Is it really true that: "For sparse factorizations such as UMFPACKFactorization and KLUFactorization,
the most expensive part of a solve is often the symbolic factorization"? I dont really see much speed up for my case.

@ChrisRackauckas

Copy link
Copy Markdown
Member

No depends. I usually see it's like 20-25%

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.

3 participants