Repository navigation
Fix type inference for AutoVern7+Rodas5P with autodiff and linsolve - #3202
Merged
ChrisRackauckas merged 1 commit intoMar 20, 2026
Conversation
Three changes to fix the inference regression on Julia 1.11: 1. Add @inline to SciMLBase.remake for implicit algorithms (OrdinaryDiffEqCore/src/algorithms.jl). The kwargs splatting in remake exceeded Julia 1.11's inference budget for algorithms with many type parameters. Inlining allows the compiler to track through the struct_as_namedtuple + kwargs merging. 2. Use Val{ST}() dispatch in prepare_alg instead of standardtag(alg)::Bool (OrdinaryDiffEqDifferentiation/src/alg_utils.jl). Split prepare_ADType for AutoForwardDiff into Val{true}/Val{false} methods to eliminate the Union{AutoForwardDiff{CS,Nothing}, AutoForwardDiff{CS,Tag}} return type. 3. Update prepare_alg for CompositeAlgorithm to also prepare algorithms stored in AutoSwitch (OrdinaryDiffEqCore/src/alg_utils.jl). Previously, the algorithms in AutoSwitchCache had unprepped autodiff types while the algorithm tuple had prepped types, causing a type mismatch. Fixes SciML#3200 Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Member
|
The failure is just sources not used on v1.10, which should now be handled by the test infra fixes. |
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/OrdinaryDiffEq.jl
that referenced
this pull request
Mar 22, 2026
Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 4.6 <[email protected]>
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/OrdinaryDiffEq.jl
that referenced
this pull request
Mar 22, 2026
Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 4.6 <[email protected]>
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/OrdinaryDiffEq.jl
that referenced
this pull request
Mar 22, 2026
The @inferred test from PR SciML#3202 requires Julia 1.11+ compiler improvements to pass. On Julia 1.10 (LTS), the return type is not fully inferred for CompositeAlgorithm with AutoSwitch. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 4.6 <[email protected]>
6 of 7 tasks
ChrisRackauckas
added a commit
to ChrisRackauckas-Claude/OrdinaryDiffEq.jl
that referenced
this pull request
May 27, 2026
Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 4.6 <[email protected]>
ChrisRackauckas
added a commit
to ChrisRackauckas-Claude/OrdinaryDiffEq.jl
that referenced
this pull request
May 27, 2026
The @inferred test from PR SciML#3202 requires Julia 1.11+ compiler improvements to pass. On Julia 1.10 (LTS), the return type is not fully inferred for CompositeAlgorithm with AutoSwitch. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 4.6 <[email protected]>
ChrisRackauckas
added a commit
to ChrisRackauckas-Claude/OrdinaryDiffEq.jl
that referenced
this pull request
May 27, 2026
Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 4.6 <[email protected]>
ChrisRackauckas
added a commit
to ChrisRackauckas-Claude/OrdinaryDiffEq.jl
that referenced
this pull request
May 27, 2026
The @inferred test from PR SciML#3202 requires Julia 1.11+ compiler improvements to pass. On Julia 1.10 (LTS), the return type is not fully inferred for CompositeAlgorithm with AutoSwitch. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 4.6 <[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 #3200 —
@inferred solve(prob, AutoVern7(Rodas5P(autodiff=AutoForwardDiff(chunksize=1), linsolve=GenericLUFactorization())))now passes on Julia 1.11.The root cause was a combination of three inference barriers:
SciMLBase.remakefor implicit algorithms used kwargs splatting (struct_as_namedtuple(thing)...+kwargs...) that exceeded Julia 1.11's inference budget when the algorithm had many type parameters (custom autodiff + custom linsolve). Adding@inlinelets the compiler track through the merging.prepare_ADTypeforAutoForwardDiffbranched onstandardtag::Bool, producing aUnion{AutoForwardDiff{CS,Nothing}, AutoForwardDiff{CS,Tag}}return type. Splitting intoVal{true}/Val{false}dispatch eliminates the union.prepare_algforCompositeAlgorithmupdated the algorithm tuple but left theAutoSwitchchoice function with unprepped (stale) algorithm types, causing a type mismatch inAutoSwitchCache.Changes
lib/OrdinaryDiffEqCore/src/algorithms.jl: Add@inlinetoSciMLBase.remakefor implicit/DAE algorithmslib/OrdinaryDiffEqDifferentiation/src/alg_utils.jl: ExtractSTtype parameter inprepare_alg, useVal{ST}()dispatch; splitprepare_ADTypeforAutoForwardDiffintoVal{true}/Val{false}methodslib/OrdinaryDiffEqCore/src/alg_utils.jl: Updateprepare_algforCompositeAlgorithmto also prepare algorithms stored inAutoSwitchtest/regression/inference.jl: Add regression testTest plan
@inferred solve(prob, AutoVern7(Rodas5P(autodiff=AutoForwardDiff(chunksize=1), linsolve=GenericLUFactorization())))passes on Julia 1.11.9🤖 Generated with Claude Code