Skip to content

Skip sparsity prep for matrix-free jac_prototype operators - #4445

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix/matrix-free-jac-prototype-sparsity
Aug 30, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix/matrix-free-jac-prototype-sparsity

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Please ignore this PR until reviewed by @ChrisRackauckas.

What changed and why

ODEFunction defaults sparsity to jac_prototype. When that prototype is a matrix-free AbstractSciMLOperator (e.g. FunctionOperator), prepare_user_sparsity still entered the KnownJacobianSparsityDetector path and called concrete_mass_matrix, which needs an AbstractMatrix conversion. That threw in prepare_alg before any linear solve ran, so the matrix-free path was unusable regardless of linsolve.

Skip sparsity preparation when sparsity is a non-convertible SciML operator. Convertible operators such as MatrixOperator still unwrap as before. OrdinaryDiffEqDifferentiation is bumped to 3.11.4.

Fixes #4302.

Failing before / passing after

With the regression present and the source fix reverted, the issue reproducer throws:

MethodError: Cannot `convert` an object of type typeof(jv) to an object of type AbstractMatrix
...
concrete_mass_matrix(::FunctionOperator)
prepare_user_sparsity
prepare_alg

With this patch, prepare_user_sparsity returns the dense AD algorithm unchanged, and init/prepare_alg succeed for a FunctionOperator jac_prototype.

Local verification

  • GROUP=Core julia +1.12 --project=lib/OrdinaryDiffEqDifferentiation --startup-file=no -e 'using Pkg; Pkg.test()': package Core tests passed, including prepare_user_sparsity (11/11) and No Jac (21/21).
  • Direct include of prepare_user_sparsity_tests.jl after the final edit: all 6 subsets passed.

Made with Cursor

ODEFunction defaults sparsity to jac_prototype, so a non-convertible
FunctionOperator was fed to KnownJacobianSparsityDetector and crashed
in prepare_alg before any solve (SciML#4302).

Co-authored-by: Cursor <[email protected]>
@ChrisRackauckas
ChrisRackauckas merged commit 27f8eb9 into SciML:master Aug 30, 2026
182 of 184 checks passed
ChrisRackauckas-Claude pushed a commit to ChrisRackauckas-Claude/OrdinaryDiffEq.jl that referenced this pull request Aug 31, 2026
Apply Runic v1.10 formatting to the tests added by SciML#4445.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: OpenAI Codex <[email protected]>
Agent-Harness: Codex (version unknown)
Agent-Model: GPT-5
Agent-Session: unknown
ChrisRackauckas added a commit that referenced this pull request Aug 31, 2026
Apply Runic v1.10 formatting to the tests added by #4445.



Agent-Harness: Codex (version unknown)
Agent-Model: GPT-5
Agent-Session: unknown

Co-authored-by: ChrisRackauckas-Claude <[email protected]>
Co-authored-by: OpenAI Codex <[email protected]>
ChrisRackauckas added a commit that referenced this pull request Sep 7, 2026
- Add serial SDC solver family (OrdinaryDiffEqSDC) (#4208)
- Give each threaded complex stage its own JVP operator (#4430)
- Fix the adaptive error estimates of MRIGARKERK22a and MIS (#4232)
- Skip sparsity prep for matrix-free jac_prototype operators (#4445)
- Format differentiation tests (#4446)
- Fix SciMLBase reexport QA on Julia LTS (#4450)



Agent-Harness: Claude Code
Agent-Model: claude-opus-5[1m]
Claude-Session: https://claude.ai/code/session_014FEzNTLFutCmTEAZ3zBg5R

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
ChrisRackauckas added a commit that referenced this pull request Sep 7, 2026
- Add serial SDC solver family (OrdinaryDiffEqSDC) (#4208)
- Give each threaded complex stage its own JVP operator (#4430)
- Fix the adaptive error estimates of MRIGARKERK22a and MIS (#4232)
- Skip sparsity prep for matrix-free jac_prototype operators (#4445)
- Format differentiation tests (#4446)
- Fix SciMLBase reexport QA on Julia LTS (#4450)



Agent-Harness: Claude Code
Agent-Model: claude-opus-5[1m]
Claude-Session: https://claude.ai/code/session_014FEzNTLFutCmTEAZ3zBg5R

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
ChrisRackauckas added a commit that referenced this pull request Sep 11, 2026
- Add serial SDC solver family (OrdinaryDiffEqSDC) (#4208)
- Give each threaded complex stage its own JVP operator (#4430)
- Fix the adaptive error estimates of MRIGARKERK22a and MIS (#4232)
- Skip sparsity prep for matrix-free jac_prototype operators (#4445)
- Format differentiation tests (#4446)
- Fix SciMLBase reexport QA on Julia LTS (#4450)
- Preserve conditioning in OOP no-init solves (#4438)
- Read the test group from GROUP like the CI passes it (#4447)
- Raise root GPU test timeout (#4449)
- Fix default SDE dt vector lengths (#4454)



Agent-Harness: Claude Code
Agent-Model: claude-opus-5[1m]
Claude-Session: https://claude.ai/code/session_014FEzNTLFutCmTEAZ3zBg5R

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.

Matrix-free jac_prototype crashes in prepare_user_sparsity before any solve

2 participants