Fix type inference regression with PIController on Julia 1.10 LTS#3033
Closed
ChrisRackauckas-Claude wants to merge 1 commit intoSciML:masterfrom
Closed
Fix type inference regression with PIController on Julia 1.10 LTS#3033ChrisRackauckas-Claude wants to merge 1 commit intoSciML:masterfrom
ChrisRackauckas-Claude wants to merge 1 commit intoSciML:masterfrom
Conversation
…ia 1.10 LTS
The `@inferred init()` tests were failing on Julia 1.10 LTS because the
return type was inferred as Union{..PIController.., ..PIControllerCache..}
instead of a concrete type.
Root cause: Two code paths for creating controllers existed:
1. `default_controller_v7` returning new-style controllers
2. `legacy_default_controller` returning legacy controllers
Julia 1.10's type inference couldn't determine at compile time which
path would be taken, resulting in a Union type.
Changes:
- Always use `default_controller_v7` for the controller default parameter
- Enable `CompositeController` for composite algorithms instead of returning
`nothing` (which triggered the legacy fallback)
- Add `new_controller_from_legacy_params` to create new-style controllers
when legacy parameters are provided, ensuring type stability
- Replace `legacy_default_controller` call with new controller constructors
This fixes the Regression_II (LTS) test failure without breaking backwards
compatibility for users who specify legacy controller parameters.
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
ChrisRackauckas
approved these changes
Feb 3, 2026
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
@inferred init()tests on Julia 1.10 LTSUnion{..PIController.., ..PIControllerCache..}instead of a concrete typeRoot Cause
Two code paths existed for creating controllers:
default_controller_v7returning new-style controllers (NewPIController→PIControllerCache)legacy_default_controllerreturning legacy controllers (PIController)Julia 1.10's type inference couldn't determine at compile time which path would be taken, resulting in a Union type.
Changes
lib/OrdinaryDiffEqCore/src/solve.jl:
default_controller_v7for the controller default parameterlegacy_default_controllercall withnew_controller_from_legacy_paramslib/OrdinaryDiffEqCore/src/alg_utils.jl:
CompositeControllerfor composite algorithms (instead of returningnothing)_default_controller_v7_tuplegenerated function for type-stable tuple creationnew_controller_from_legacy_paramsto create new-style controllers from legacy parametersTest plan
@inferred init(prob, BS3())passes on Julia 1.10.10@inferred init(prob, Tsit5())passes on Julia 1.10.10@inferred init(prob, RK4())passes on Julia 1.10.10@inferred init(prob, Vern6())passes on Julia 1.10.10solve()still works correctly for all above solvers🤖 Generated with Claude Code