Skip to content

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

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

ChrisRackauckas merged 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:fix-reinit-initial-params-sciml36

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

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 <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@ChrisRackauckas
ChrisRackauckas merged commit 3fb56d2 into SciML:master Apr 28, 2026
205 of 210 checks passed
ChrisRackauckas added a commit that referenced this pull request May 27, 2026
`benchmark.yml` already pins the depot path with the comment "Force
consistent Julia depot path for self-hosted runners" (#3577). The
same workaround is needed in `CI.yml` and `SublibraryCI.yml`, where
self-hosted runners labeled `ubuntu-latest` (demeter3-*, deepsea4-*)
intermittently fail with `expected package X to be registered`
(X = FastBroadcast / ADTypes / SciMLBase / CoverageTools / etc.)
during `Pkg.develop`.

Mechanism (reconstructed from a SublibraryCI log on PR #3407 where
this fired):

1. The "Refresh General registry" step runs `julia --project=. {0}`
   with no env, so DEPOT_PATH defaults to `~/.julia` =
   `/home/chrisrackauckas/.julia`. `Pkg.Registry.add(General.git)`
   writes the fresh registry there. (Log shows the pidfile at
   `/home/chrisrackauckas/.julia/registries/.pid`.)
2. `julia-actions/julia-runtest@v1` invokes Julia through the action
   wrapper, which on a self-hosted runner picks up the runner-injected
   `JULIA_DEPOT_PATH=~/github-runners/<name>/.julia` instead. (Log
   shows "Updating registry at
   ~/github-runners/demeter3-12/.julia/registries/HolyLabRegistry".)
3. That per-runner depot is missing the General registry refreshed in
   step 1, so `Pkg.develop` fails with "expected package FastBroadcast
   [7034ab61] to be registered".

Pinning `JULIA_DEPOT_PATH: ~/.julia` at the job level forces every
step (refresh, buildpkg, runtest) to read and write the same depot,
so the freshly-added General registry is visible to subsequent
resolve calls.

This is the same fix `benchmark.yml` already deploys, just extended
to the other two workflows that run against self-hosted runners.

Co-authored-by: ChrisRackauckas-Claude <[email protected]>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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