Repository navigation
Make mass-matrix identity/zero/diagonal checks GPU-safe (fix Julia 1.13 GPU DAE scalar-indexing regression) - #4502
Merged
ChrisRackauckas merged 1 commit intoSep 11, 2026
Conversation
On Julia 1.13, `==(A::AbstractMatrix, ::UniformScaling)` reads `first(A)`
before falling back to `iszero`/`isone` reductions, so `f.mass_matrix != I`
in `_ode_init` (and in `ode_determine_initdt`) scalar-indexes GPU-backed
mass matrices such as `Diagonal{T, <:CuVector}`, failing with "Scalar
indexing is disallowed". On Julia 1.12 and earlier, `==` dispatched to
`isone(A)`/`iszero(A)`, which reduce via GPU kernels, so the GPU DAE suite
worked; this is why every `mass = diag` case in test/gpu/dae_tests.jl
started failing on Julia 1.13.
Add GPU-safe helpers to OrdinaryDiffEqCore's public solver-author surface
(alongside `find_algebraic_vars_eqs`):
- `_is_identity_massmatrix(mm)`: `mm == I` without scalar indexing
- `_is_zero_massmatrix(mm)`: all-zero check without scalar indexing
- `_diff_alg_vars(mm, n)`: differential/algebraic index split without
`mm[i, i]` loops
and use them at every site that compared the mass matrix to `I` by value
(OrdinaryDiffEqCore solve/initdt guards, OrdinaryDiffEqDefault autoswitch,
StochasticDiffEqCore validation, OrdinaryDiffEqFIRK perform-step) or
scanned its diagonal elementwise (HybridExplicitImplicitRK/Tsit5DA cache
build and step).
Regression test: test/InterfaceV/gpu_dae_mass_matrix_tests.jl solves the
gpu/dae_tests.jl problem with a `Diagonal{T, <:JLArray}` mass matrix under
BrownFullBasicInit and 11 stiff solvers. JLArray enforces GPUArrays'
no-scalar-indexing rules on CPU, so it fails on master with "Scalar
indexing is disallowed" and passes on this branch. `Diagonal` is
dispatched to `all(isone, mm.diag)`-style reductions, so the same code
path serves `Diagonal{T, <:CuVector}` on CUDA.
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Agent-Harness: Devin CLI 3000.10.21
Agent-Model: SWE-2 High
Agent-Session: local Devin CLI session (no shareable URL); session db at /home/crackauc/.local/share/devin/cli/sessions.db
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 11, 2026
- Fix GlobalDiffEq precompilation on Julia 1.13 and companion accuracy (#4500) - Make mass-matrix identity/zero/diagonal checks GPU-safe (#4502) - Fix BDF step rejection for backward-in-time integration (#4503) 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
- Unify companion global error estimators into GlobalErrorEstimation (#4492) - Add adjoint-based global error control as a SciMLSensitivity extension (#3953) - ExpRK: cache ishermitian (rebase of #4305, + review fixes) (#4497) - Mark discrete time-grid search helpers as Enzyme inactive (#4496) - GlobalAdjoint: every-step trajectory scope and step-grid control (#4495) - GlobalAdjoint: defer to adjoint_sensitivities default instead of pinning an adjoint (#4498) - Release GlobalDiffEq 1.7.1 (#4501) - Fix GlobalDiffEq precompilation on Julia 1.13 and companion accuracy (#4500) - Make mass-matrix identity/zero/diagonal checks GPU-safe (#4502) - Fix BDF step rejection for backward-in-time integration (#4503) 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
referenced
this pull request
Sep 12, 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]>
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 12, 2026
- Release OrdinaryDiffEqBDF 2.4.7 (#4490) - Unify companion global error estimators into GlobalErrorEstimation (#4492) - Add adjoint-based global error control as a SciMLSensitivity extension (#3953) - ExpRK: cache ishermitian (rebase of #4305, + review fixes) (#4497) - Mark discrete time-grid search helpers as Enzyme inactive (#4496) - GlobalAdjoint: every-step trajectory scope and step-grid control (#4495) - GlobalAdjoint: defer to adjoint_sensitivities default instead of pinning an adjoint (#4498) - Release GlobalDiffEq 1.7.1 (#4501) - Fix GlobalDiffEq precompilation on Julia 1.13 and companion accuracy (#4500) - Make mass-matrix identity/zero/diagonal checks GPU-safe (#4502) 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-Claude
pushed a commit
to ChrisRackauckas-Claude/DiffEqGPU.jl
that referenced
this pull request
Sep 12, 2026
OrdinaryDiffEqDefault 2.6.1 calls OrdinaryDiffEqCore._is_identity_massmatrix (added in Core 4.17.1, SciML/OrdinaryDiffEq.jl#4502) but bounds Core at "4.11", so a minimum-bounds resolve picks Core 4.16.1 and OrdinaryDiffEq fails to precompile. Reported upstream as SciML/OrdinaryDiffEq.jl#4522. Flooring Core in the test project keeps the downgrade lane green; this is a test-env bound only, not a package compat change. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <[email protected]> Agent-Harness: Devin CLI 3000.10.21 Agent-Model: SWE-2 Max Agent-Session: local transcript /home/crackauc/.local/share/devin/cli/summaries/history_e9ba8699c66b48e4.md
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 12, 2026
…4525) #4502 added `_is_identity_massmatrix`, `_is_zero_massmatrix` and `_diff_alg_vars` to OrdinaryDiffEqCore's internal surface and started using them from four sublibraries. Those sublibraries were released without raising their OrdinaryDiffEqCore floor, so a resolver is free to pair them with an older Core that lacks the symbols: WARNING: Imported binding OrdinaryDiffEqCore._is_identity_massmatrix was undeclared at import time during import to OrdinaryDiffEqDefault. ERROR: LoadError: UndefVarError: `_is_identity_massmatrix` not defined in `OrdinaryDiffEqDefault` The symbols first exist in OrdinaryDiffEqCore 4.17.1. | package | released | old floor | uses | |---|---|---|---| | OrdinaryDiffEqDefault | 2.6.1 | 4.11 | _is_identity_massmatrix | | OrdinaryDiffEqFIRK | 2.8.5 | 4.15.1 | _is_identity_massmatrix | | OrdinaryDiffEqRosenbrock | 2.7.2 | 4.11 | _diff_alg_vars | | StochasticDiffEqCore | 2.2.2 | 4 | _is_identity_massmatrix | All four now require OrdinaryDiffEqCore 4.17.1 and get a patch bump. Raising a compat floor is non-breaking. The already-published versions in the table stay broken for anyone who resolves them; those need a retroactive Compat.toml fix in the General registry, which is a separate pull request there. 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
to ChrisRackauckas-Claude/OrdinaryDiffEq.jl
that referenced
this pull request
Sep 12, 2026
lib/OrdinaryDiffEqDefault/Project.toml has no [sources] block, unlike 44 of the 59 sublibraries. Its CI therefore resolves OrdinaryDiffEqCore and the other lib/ dependencies from the registry rather than from the checkout, so a change to local Core is never exercised against Default before merge. That is how SciML#4502 shipped broken: it added _is_identity_massmatrix to Core and used it from Default in one commit, and the lane that should have caught it was testing Default against an already-released Core. The entries cover every dependency that lives in lib/: the six runtime deps plus the DiffEqDevTools test extra, matching the pattern the sibling sublibraries use. The load failure itself is already fixed: Core 4.17.1 is registered with the new helpers and SciML#4525 raised the four consumers' floors to it. This change is only about closing the CI gap that let it through. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Agent-Harness: Claude Code Agent-Model: claude-opus-5[1m] Claude-Session: https://claude.ai/code/session_014FEzNTLFutCmTEAZ3zBg5R
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 12, 2026
`_is_identity_massmatrix` is imported from OrdinaryDiffEqCore but was only added there in 4.17.1 (#4502). The declared bound of "4.11" lets the resolver pick an older Core, and the package then fails to precompile with `UndefVarError: _is_identity_massmatrix`. In-repo CI never sees this because `[sources]` supplies the local Core. Claude-Session: https://claude.ai/code/session_01FeJYXni9MkJhPFA9yxYvfn Co-authored-by: Chris Rackauckas <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 12, 2026
lib/OrdinaryDiffEqDefault/Project.toml has no [sources] block, unlike 44 of the 59 sublibraries. Its CI therefore resolves OrdinaryDiffEqCore and the other lib/ dependencies from the registry rather than from the checkout, so a change to local Core is never exercised against Default before merge. That is how #4502 shipped broken: it added _is_identity_massmatrix to Core and used it from Default in one commit, and the lane that should have caught it was testing Default against an already-released Core. The entries cover every dependency that lives in lib/: the six runtime deps plus the DiffEqDevTools test extra, matching the pattern the sibling sublibraries use. The load failure itself is already fixed: Core 4.17.1 is registered with the new helpers and #4525 raised the four consumers' floors to it. This change is only about closing the CI gap that let it through. Agent-Harness: Claude Code Agent-Model: claude-opus-5[1m] Claude-Session: https://claude.ai/code/session_014FEzNTLFutCmTEAZ3zBg5R Co-authored-by: ChrisRackauckas <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 13, 2026
- Unify companion global error estimators into GlobalErrorEstimation (#4492) - Add adjoint-based global error control as a SciMLSensitivity extension (#3953) - ExpRK: cache ishermitian (rebase of #4305, + review fixes) (#4497) - Mark discrete time-grid search helpers as Enzyme inactive (#4496) - GlobalAdjoint: every-step trajectory scope and step-grid control (#4495) - GlobalAdjoint: defer to adjoint_sensitivities default instead of pinning an adjoint (#4498) - Release GlobalDiffEq 1.7.1 (#4501) - Fix GlobalDiffEq precompilation on Julia 1.13 and companion accuracy (#4500) - Make mass-matrix identity/zero/diagonal checks GPU-safe (#4502) - Fix BDF step rejection for backward-in-time integration (#4503) 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.
Summary
Fixes the Julia-1.13 regression that broke every
mass = diagcase intest/gpu/dae_tests.jl(136 failures, all solvers × all three Jacobian variants) withScalar indexing is disallowed.Root cause. Julia 1.13 changed
==(A::AbstractMatrix, J::UniformScaling)to readfirst(A)before dispatching toiszero(A)/isone(A)reductions (LinearAlgebra/src/uniformscaling.jl). On Julia ≤ 1.12 the same comparison calledisone(D::Diagonal)/iszero, which reduce overD.diagas GPU kernels. Sof.mass_matrix != IinOrdinaryDiffEqCore._ode_init— and every other by-value mass-matrix/identity comparison — now scalar-indexesDiagonal{T, <:CuVector}and throws. The upstream change is JuliaLang/LinearAlgebra.jl#1369 ("Check for elementwise equality when comparing withUniformScaling", commit3537c3ae), first released in Julia 1.13. This is a Julia-version regression, not an OrdinaryDiffEq commit: none of the recent mass-matrix/W-construction commits (386f6c5,c241543,01e4cc6,4b1c5c4) are implicated.Fix. New GPU-safe helpers on OrdinaryDiffEqCore's public solver-author surface (next to
find_algebraic_vars_eqs):_is_identity_massmatrix(mm)—mm == Iwithout scalar indexing (isone(λ)forUniformScaling,all(isone, mm.diag)forDiagonal, direct==for fast-scalar-indexing matrices, hostMatrixcopy fallback otherwise)_is_zero_massmatrix(mm)— replacesall(isequal(0), mm)(same iteration problem)_diff_alg_vars(mm, n)— differential/algebraic index split replacingfindall(i -> mm[i,i] != 0, 1:n)loops inHybridExplicitImplicitRK/Tsit5DAcache and step codeapplied at every
mass_matrix != I/== Isite:_ode_init(isdaeand the mass-matrix-alg guard),ode_determine_initdt,OrdinaryDiffEqDefaultautoswitch,StochasticDiffEqCorevalidation, andOrdinaryDiffEqFIRKperform-step.Diagonal-based dispatch servesDiagonal{T, <:CuVector}on CUDA identically.Regression test
test/InterfaceV/gpu_dae_mass_matrix_tests.jl(registered in theInterfaceVgroup): solves thegpu/dae_tests.jlDAE withDiagonal{Int64, JLArray{Int64,1}}mass matrix +BrownFullBasicInitunder 11 stiff solvers (Rosenbrock23, ROS2, Rodas5P, SDIRK2, Cash4, Hairer4, ABDF2, QNDF2, QBDF2, FBDF, ImplicitEuler), comparing against the CPU reference.JLArrayenforces GPUArrays' no-scalar-indexing rules on CPU. The test also emulates CUDA.jl'sto_index(::CuArray, ::AbstractArray{Bool}) = findall(I)rule (JLArrays lacks it) so theview(u, bool_mask)calls inBrownFullBasicInitbehave as on CUDA.Test plan / verification
Local env has no CUDA GPU, so verification uses JLArray (GPUArrays' CPU reference backend, same scalar-indexing rules).
Before (master @ 0f08fbd, Julia 1.13.0-rc4) — new test file:
After (this branch, Julia 1.13.0-rc4) — same file:
Same script on Julia 1.10 (lts): all 11 solvers
Successon JLArray, max|u_end - cpu|≤ 1.2e-4 (Rosenbrock23: 5.7e-6).Caveats: GPU (
test/gpu/dae_tests.jl) and docs builds cannot run locally (no GPU; docs env not instantiated). The JLSparseMatrixCSC/CSR prototypes hit a JLArrays-onlyCanonicalIndexErrorinGPUSparseDeviceMatrix*, so the regression test coversjac = none; the CSC/CSR fixes go through the same helpers. Runic--checkpasses on all touched files;typosclean; ExplicitImports clean on OrdinaryDiffEqDefault/FIRK/StochasticDiffEqCore (OrdinaryDiffEqCore flags only its documented ignore-list names; the pre-existing "public API is rendered in docs" QA failure on master is unrelated).🤖 Generated with Devin (harness: Devin CLI 3000.10.21, model: SWE-2 High). Session: local Devin CLI session (no shareable URL); session db at /home/crackauc/.local/share/devin/cli/sessions.db.