Accept ctx arg in late_binding_update_u0_p for SciMLBase v3.1.0+#4474
Open
ChrisRackauckas-Claude wants to merge 2 commits intoSciML:masterfrom
Open
Accept ctx arg in late_binding_update_u0_p for SciMLBase v3.1.0+#4474ChrisRackauckas-Claude wants to merge 2 commits intoSciML:masterfrom
ChrisRackauckas-Claude wants to merge 2 commits intoSciML:masterfrom
Conversation
SciMLBase v3.1.0 (commit 09770ffa, 2026-04-10, "refactor: pass context struct to late_binding_update_u0_p") added a trailing `ctx::LateBindingUpdateU0PContext` argument (with default) that the v3 public path now forwards as an 8th positional. MTK's 7-arg overload no longer dispatches; SciMLBase's 8-arg no-op fallback wins, so `newp.initials` was never updated and `initialize_dae!` then re-solved `u` against the stale `Initial` values. This surfaced as four failing assertions in the OrdinaryDiffEq.jl `reinit! updates initial parameters` testset (lib/OrdinaryDiffEqNonlinearSolve/test/modelingtoolkit/dae_initialize_integration.jl:98-101). Wraps the original body in a small `_late_binding_update_u0_p_impl` helper and dispatches via `@static if isdefined(SciMLBase, :LateBindingUpdateU0PContext)` so the patch keeps working on the SciMLBase v2 line that the package's `[compat]` still supports (`SciMLBase = "2.149.0, 3"`). On v3.1.0+ the 8-arg method matches; on v2 the 7-arg method is defined as before. Verified locally: with this patch and SciMLBase v3.6.0 resolved, the OrdinaryDiffEq `reinit! updates initial parameters` testset goes from 4 fail / 4 pass to 8 / 8 pass. Fixes SciML#4473. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
fa0b071 to
e53a79f
Compare
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
SciMLBase v3.1.0 (commit
09770ffa, 2026-04-10, refactor: pass context struct tolate_binding_update_u0_p) added a trailingctx::SciMLBase.LateBindingUpdateU0PContextargument tolate_binding_update_u0_p. The 6-arg public entry point now forwardsctxas an 8th positional argument internally.MTK's existing 7-arg overload no longer dispatches against the new 8-arg call site, so SciMLBase's default 8-arg fallback (
return newu0, newp) wins and silently drops theInitial(x)parameter propagation inreinit!(and any other call path that goes throughlate_binding_update_u0_p).which(...)evidence on the regression:This PR adds the optional
ctxargument to MTK's overload, restoring dispatch under SciMLBase v3.1.0+. The function body is unchanged; this is a 3-line signature update inlib/ModelingToolkitBase/src/systems/nonlinear/initializesystem.jl(lines 686-689).Fixes #4473.
Unblocks SciML/OrdinaryDiffEq.jl#3553 (which marks the now-fixed
reinit!assertions@test_brokenuntil this lands).Test plan
Run Runic on the touched file (
fredrikekre/runic-action@v1, version1, matches.github/workflows/FormatCheck.yml). No formatting changes beyond the patch itself.Verified locally with the OrdinaryDiffEq.jl
NLS_MTKtestset:lib/OrdinaryDiffEqNonlinearSolve/test/modelingtoolkit/dae_initialize_integration.jl, testset`reinit!` updates initial parameters(the same one referenced by issue reinit!(integ, new_u0) doesn't update Initial parameters or integ[x] for mtkcompile'd ODE #4473). With the patched MTK developed into the test env (using SciMLBase v3.6.0 from the resolved Manifest):All 8 assertions pass — both the pre-
reinit!checks and the 4 post-reinit!checks (integ.ps[Initial(x)],integ.ps[Initial(y)],integ[x],integ[y]) that the issue identifies as failing.CI on this PR (Tests / Downstream / FormatCheck).
🤖 Generated with Claude Code