Skip to content

Fix reinit! to propagate Initial(...) params with SciMLBase 3.6#3577

Merged
ChrisRackauckas merged 2 commits intoSciML:masterfrom
ChrisRackauckas-Claude:fix-reinit-initial-params-sciml36
Apr 28, 2026
Merged

Fix reinit! to propagate Initial(...) params with SciMLBase 3.6#3577
ChrisRackauckas merged 2 commits intoSciML:masterfrom
ChrisRackauckas-Claude:fix-reinit-initial-params-sciml36

Conversation

@ChrisRackauckas-Claude
Copy link
Copy Markdown
Contributor

Summary

Fixes 4 pre-existing master failures in OrdinaryDiffEqNonlinearSolve_ModelingToolkit CI (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 LateBindingUpdateU0PContext parameter to late_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 overload late_binding_update_u0_p(prob, sys::AbstractSystem, u0, p, t0, newu0, newp) (without ctx) is no longer reached from reinit!. As a result, reinit!(integrator, new_u0) stops propagating the new state into Initial(x) / Initial(y) parameters: both integ.ps[Initial(x)] / integ.ps[Initial(y)] and integ[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's reinit!, sidestep the new context-aware dispatch by computing root_indp = SciMLBase.get_root_indp(integrator.sol.prob) ourselves and calling the 7-arg form late_binding_update_u0_p(prob, root_indp, u0, ..., newp) (no ctx). That form still dispatches to MTK's 7-arg overload, which is the path that actually updates the Initial(...) parameters in MTKParameters.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

  • Reproduce the failure locally with ~/.juliaup/bin/julia +1.11 --project=lib/OrdinaryDiffEqNonlinearSolve/test/modelingtoolkit lib/OrdinaryDiffEqNonlinearSolve/test/modelingtoolkit/dae_initialize_integration.jl against master — 4 fails on reinit! testset
  • Apply fix — DAE Initialize Integration: 21/21 passes locally; reinit! updates initial parameters: 8/8
  • Re-ran NLStep Tests (19 pass / 6 broken — unchanged), Preconditioner Tests (18/18) locally to confirm no regression in adjacent groups
  • Runic check passes on lib/OrdinaryDiffEqCore/src/integrators/integrator_interface.jl
  • Wait for SublibraryCI OrdinaryDiffEqNonlinearSolve_ModelingToolkit to confirm green

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>
Comment thread lib/OrdinaryDiffEqCore/src/integrators/integrator_interface.jl Outdated
@ChrisRackauckas ChrisRackauckas merged commit 3fb56d2 into SciML:master Apr 28, 2026
205 of 210 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants