Fix @inferred type instability from JacReuseState Union type#3399
Merged
ChrisRackauckas merged 1 commit intoSciML:masterfrom Apr 12, 2026
Merged
Conversation
_make_jac_reuse_state previously returned Union{Nothing, JacReuseState{T}}
because it conditionally allocated based on max_jac_age > 1. This caused
type instability in the Rosenbrock cache's JRType parameter, which
propagated to ODESolution return types and broke @inferred tests in:
- OrdinaryDiffEqRosenbrock: DAE Rosenbrock AD Tests
- OrdinaryDiffEqNonlinearSolve: Mass Matrix Tests with Singular Mass Matrices
Fix: always allocate JacReuseState regardless of max_jac_age. When
max_jac_age <= 1, the age check in _rosenbrock_jac_reuse_decision
triggers every step anyway, so behavior is unchanged.
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
ChrisRackauckas
added a commit
that referenced
this pull request
Apr 12, 2026
Bumps every subpackage that has accumulated source, compat, or formatting changes on master since its last registered version (i.e. since #3387). Each entry is registered after this PR merges via @JuliaRegistrator. - DelayDiffEq 5.73.0 -> 5.74.0 (shift_past_discontinuity! alg_choice, composite DDE fix, #3394) - DiffEqBase 6.215.0 -> 6.216.0 (solve hook for shift-past d_discontinuities, #3394) - DiffEqDevTools 2.52.0 -> 2.53.0 (LICENSE.md add) - OrdinaryDiffEqCore 3.30.0 -> 3.31.0 (shift_past_discontinuity! integrator path, alg_utils formatting) - OrdinaryDiffEqDifferentiation 2.8.0 -> 2.9.0 (StaticArrays -> StaticArraysCore, #3405) - OrdinaryDiffEqNonlinearSolve 1.27.0 -> 1.28.0 (StaticArrays -> StaticArraysCore + formatting) - OrdinaryDiffEqRosenbrock 1.30.0 -> 1.31.0 (JacReuseState type-inference fix, #3399) - OrdinaryDiffEqStabilizedRK 1.10.0 -> 1.11.0 (StaticArrays -> StaticArraysCore, #3405) - OrdinaryDiffEqTaylorSeries 1.13.0 -> 1.14.0 (FunctionWrappers compat bound) Not bumped (still awaiting their initial General registration at 1.0.0; new READMEs, compat fixes, and formatting from #3388/#3390/#3400 will be picked up by the first registration): - OrdinaryDiffEqAMF - OrdinaryDiffEqMultirate Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2 tasks
ChrisRackauckas
added a commit
that referenced
this pull request
Apr 12, 2026
…#3408) Bumps every subpackage that has accumulated source, compat, or formatting changes on master since its last registered version (i.e. since #3387). Each entry is registered after this PR merges via @JuliaRegistrator. - DelayDiffEq 5.73.0 -> 5.74.0 (shift_past_discontinuity! alg_choice, composite DDE fix, #3394) - DiffEqBase 6.215.0 -> 6.216.0 (solve hook for shift-past d_discontinuities, #3394) - DiffEqDevTools 2.52.0 -> 2.53.0 (LICENSE.md add) - OrdinaryDiffEqCore 3.30.0 -> 3.31.0 (shift_past_discontinuity! integrator path, alg_utils formatting) - OrdinaryDiffEqDifferentiation 2.8.0 -> 2.9.0 (StaticArrays -> StaticArraysCore, #3405) - OrdinaryDiffEqNonlinearSolve 1.27.0 -> 1.28.0 (StaticArrays -> StaticArraysCore + formatting) - OrdinaryDiffEqRosenbrock 1.30.0 -> 1.31.0 (JacReuseState type-inference fix, #3399) - OrdinaryDiffEqStabilizedRK 1.10.0 -> 1.11.0 (StaticArrays -> StaticArraysCore, #3405) - OrdinaryDiffEqTaylorSeries 1.13.0 -> 1.14.0 (FunctionWrappers compat bound) Not bumped (still awaiting their initial General registration at 1.0.0; new READMEs, compat fixes, and formatting from #3388/#3390/#3400 will be picked up by the first registration): - OrdinaryDiffEqAMF - OrdinaryDiffEqMultirate Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
singhharsh1708
pushed a commit
to singhharsh1708/OrdinaryDiffEq.jl
that referenced
this pull request
Apr 16, 2026
) _make_jac_reuse_state previously returned Union{Nothing, JacReuseState{T}} because it conditionally allocated based on max_jac_age > 1. This caused type instability in the Rosenbrock cache's JRType parameter, which propagated to ODESolution return types and broke @inferred tests in: - OrdinaryDiffEqRosenbrock: DAE Rosenbrock AD Tests - OrdinaryDiffEqNonlinearSolve: Mass Matrix Tests with Singular Mass Matrices Fix: always allocate JacReuseState regardless of max_jac_age. When max_jac_age <= 1, the age check in _rosenbrock_jac_reuse_decision triggers every step anyway, so behavior is unchanged. Co-authored-by: ChrisRackauckas-Claude <accounts@chrisrackauckas.com>
singhharsh1708
pushed a commit
to singhharsh1708/OrdinaryDiffEq.jl
that referenced
this pull request
Apr 16, 2026
…SciML#3408) Bumps every subpackage that has accumulated source, compat, or formatting changes on master since its last registered version (i.e. since SciML#3387). Each entry is registered after this PR merges via @JuliaRegistrator. - DelayDiffEq 5.73.0 -> 5.74.0 (shift_past_discontinuity! alg_choice, composite DDE fix, SciML#3394) - DiffEqBase 6.215.0 -> 6.216.0 (solve hook for shift-past d_discontinuities, SciML#3394) - DiffEqDevTools 2.52.0 -> 2.53.0 (LICENSE.md add) - OrdinaryDiffEqCore 3.30.0 -> 3.31.0 (shift_past_discontinuity! integrator path, alg_utils formatting) - OrdinaryDiffEqDifferentiation 2.8.0 -> 2.9.0 (StaticArrays -> StaticArraysCore, SciML#3405) - OrdinaryDiffEqNonlinearSolve 1.27.0 -> 1.28.0 (StaticArrays -> StaticArraysCore + formatting) - OrdinaryDiffEqRosenbrock 1.30.0 -> 1.31.0 (JacReuseState type-inference fix, SciML#3399) - OrdinaryDiffEqStabilizedRK 1.10.0 -> 1.11.0 (StaticArrays -> StaticArraysCore, SciML#3405) - OrdinaryDiffEqTaylorSeries 1.13.0 -> 1.14.0 (FunctionWrappers compat bound) Not bumped (still awaiting their initial General registration at 1.0.0; new READMEs, compat fixes, and formatting from SciML#3388/SciML#3390/SciML#3400 will be picked up by the first registration): - OrdinaryDiffEqAMF - OrdinaryDiffEqMultirate Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
_make_jac_reuse_statereturnedUnion{Nothing, JacReuseState{T}}based on runtimemax_jac_age, causing type instability in Rosenbrock cache'sJRTypeparameter@inferredtests in OrdinaryDiffEqRosenbrock (dae_rosenbrock_ad_tests.jl) and OrdinaryDiffEqNonlinearSolve (mass_matrix_tests.jl)JacReuseState— whenmax_jac_age ≤ 1the age check in_rosenbrock_jac_reuse_decisiontriggers every step anyway, so behavior is unchangedIntroduced by #3075.
Test plan
Pkg.testpasses locally (was erroring onDAE Rosenbrock AD Tests)Pkg.testpasses locally (was erroring onMass Matrix Tests with Singular Mass Matrices)🤖 Generated with Claude Code