Repository navigation
Build W through the allocating path for a sparse GPU Jacobian with a scalar mass matrix - #4452
Merged
ChrisRackauckas merged 2 commits intoSep 7, 2026
Conversation
…scalar mass matrix
This was referenced Sep 1, 2026
Member
|
Does this hold when the prototype has a structural zero on the diagonal? |
singhharsh1708
approved these changes
Sep 3, 2026
singhharsh1708
left a comment
Member
There was a problem hiding this comment.
Looks good to me, copyto! carries the structure so the filled-in diagonal is fine.
Member
Author
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 7, 2026
- DiffEqBase: wrap mass-matrix problems on the finite-difference promote_f path (#4459) - Preserve the DAE step start during callback interpolation (#4466) - Release DiffEqBase 7.20.1 (#4474) - Release OrdinaryDiffEqCore 4.16.1 (#4475) - Release OrdinaryDiffEqNonlinearSolve 2.9.5 (#4476) - Run IDSolve's nonlinear solve at the integrator's tolerances (#4468) - Build W through the allocating path for a sparse GPU Jacobian with a scalar mass matrix (#4452) - Fix threaded stochastic work-precision isolation (#4462) - Differentiate wrapped DAEFunctions with chunk size 1, like ODEFunctions (#4464) - Rebuild MethodOfSteps W after history updates (#4396) 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]>
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.
jacobian2W!formsW = J - M/dtgamma. When the mass matrix is scalar (I, the default), it writesW's diagonal in place, either by scalar indexing or by broadcasting into@view(W[idxs]). Neither works for aCuSparseMatrix: the view falls back togetindex(W, i, j), so every implicit solver given a sparse GPUjac_prototypethrewScalar indexing is disallowedon the first step.The allocating path for this already exists and is what
dae_jacobian2W!uses, but injacobian2W!it sits in anelseifthat a scalar mass matrix never reaches. This adds the guard ahead of the diagonal write, using the samecopyto!(W, ...)form. The CPU branches are untouched, and the denseMatrixmethod is not affected.This unblocks the Brusselator from #1566. On a T4 that example now solves with a
CuSparseMatrixCSRjac_prototype under Rosenbrock23, Rosenbrock23 withKrylovJL_GMRES, and FBDF, matching the CPU reference to about 1e-10. With this branch disabled all three fail with scalar indexing, so the change is required rather than incidental. That example also needs its RHS to broadcast over a device-resident index set, which is a property of the script rather than of the solver, and is noted on the issue.Tests: a CPU unit test that the allocating formula agrees with the diagonal write, and that CPU sparse and dense still take the old branch; plus
test/gpu/sparse_jac_prototype.jl, whichgpu_group()picks up automatically. That GPU test passes with the fix and errors on all four solver configurations without it.jacobian2W!is a hot path. The new condition is a branch ahead of the CPU code and should fold away for non-GPU arrays, but it is worth a second opinion.AI Disclosure: Used Opus 5