Fix reinit! to propagate Initial(...) params with SciMLBase 3.6#3577
Merged
ChrisRackauckas merged 2 commits intoSciML:masterfrom Apr 28, 2026
Merged
Conversation
SciMLBase 3.6.0 added a `LateBindingUpdateU0PContext` argument to `late_binding_update_u0_p`. The 6-arg wrapper now forwards through a new 8-arg `(prob, root_indp, u0, p, t0, newu0, newp, ctx)` overload, so MTK's existing 7-arg overload `(prob, sys::AbstractSystem, ...)` is never reached. As a result, `reinit!(integrator, new_u0)` no longer propagated the new state into `Initial(x)` / `Initial(y)` parameters, leaving both the `integ.ps[Initial(...)]` values and `integ[x]` / `integ[y]` stale. Sidestep the new context-aware dispatch by computing `root_indp` here and calling the 7-arg form directly, which still hits MTK's overload. Fixes the four `reinit!` updates initial parameters` failures in `lib/OrdinaryDiffEqNonlinearSolve/test/modelingtoolkit/dae_initialize_integration.jl`. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks
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 4 pre-existing master failures in
OrdinaryDiffEqNonlinearSolve_ModelingToolkitCI (e.g. https://github.com/SciML/OrdinaryDiffEq.jl/actions/runs/25053979241/job/73389128637) — the\reinit!` updates initial parameterstestset inlib/OrdinaryDiffEqNonlinearSolve/test/modelingtoolkit/dae_initialize_integration.jl` (lines 98-101).Root cause
SciMLBase 3.6.0 added a
LateBindingUpdateU0PContextparameter tolate_binding_update_u0_p. Its 6-arg wrapper now forwards through a new 8-arg(prob, root_indp, u0, p, t0, newu0, newp, ctx)overload, which dispatches to the SciMLBase identity stub. MTK's existing 7-arg overloadlate_binding_update_u0_p(prob, sys::AbstractSystem, u0, p, t0, newu0, newp)(withoutctx) is no longer reached fromreinit!. As a result,reinit!(integrator, new_u0)stops propagating the new state intoInitial(x)/Initial(y)parameters: bothinteg.ps[Initial(x)]/integ.ps[Initial(y)]andinteg[x]/integ[y]stay at their pre-reinit!values.This is dispatch-driven and does not show up at all under SciMLBase < 3.6.
Fix
In
OrdinaryDiffEqCore'sreinit!, sidestep the new context-aware dispatch by computingroot_indp = SciMLBase.get_root_indp(integrator.sol.prob)ourselves and calling the 7-arg formlate_binding_update_u0_p(prob, root_indp, u0, ..., newp)(noctx). That form still dispatches to MTK's 7-arg overload, which is the path that actually updates theInitial(...)parameters inMTKParameters.initials.This keeps the change scoped to ODE Core (one-line plus comment) and works whether MTK upgrades to overload the new 8-arg form or not.
Test plan
~/.juliaup/bin/julia +1.11 --project=lib/OrdinaryDiffEqNonlinearSolve/test/modelingtoolkit lib/OrdinaryDiffEqNonlinearSolve/test/modelingtoolkit/dae_initialize_integration.jlagainst master — 4 fails onreinit!testsetreinit!updates initial parameters: 8/8lib/OrdinaryDiffEqCore/src/integrators/integrator_interface.jlOrdinaryDiffEqNonlinearSolve_ModelingToolkitto confirm green