Repository navigation
Concretize initialization problems once at construction - #5062
ChrisRackauckas merged 3 commits into
Conversation
|
CI found a downstream AD regression that is distinct from the already-bisected Optimization and downgrade-QA base failures.
Plan: preserve the shared residual-function wrapper while keeping initialization parameters concrete, then rerun the smallest failing Core8 file, the branch's type-sharing tests, its TTFX benchmark, and the full relevant groups. The optimization will not be accepted if the only way to restore AD is to disable concretization. |
|
The reverse-AD companion is now available as draft PR SciML/NonlinearSolve.jl#1228. It unwraps
The PR body contains the full failing-before/passing-after record. |
040ce89 to
dd208c0
Compare
|
CI after the rebase is fully resolved. An exhaustive audit of all 89 failed-job logs found The failure reproduces on clean master and is tracked at SciML/SparseColumnPivotedQR.jl#72. The green focused fix is SciML/SparseColumnPivotedQR.jl#71. In particular, the SciMLSensitivity Core8 CI job https://github.com/SciML/ModelingToolkit.jl/actions/runs/33900026045/job/101111661142 did not reach the downstream tests; the equivalent local run with that dependency fix and SciML/NonlinearSolve.jl#1228 passed 21 assertions with 5 pre-existing broken. |
|
Follow-up commit a053e22 addresses the released-root/new-ModelingToolkitBase CI combination and pins the required NonlinearSolveBase behavior. Failing before: the exact Julia 1.10 mixed-version workload raised Passing after: The final signature-preserving implementation has the same 152 ModelingToolkit-rooted invalidated instances and the same 4,991 unique invalidated instances as the pre-follow-up tree. Runic, typos, and The new NonlinearSolveBase 2.49.3 floor is intentional: 2.49.0 fixes the ForwardDiff Links
|
|
The refreshed CI confirms the expected release-order boundary. Documentation, downgrade, and release testing fail while resolving dependencies because General currently contains
Formatting and spelling are green. The remaining registry-based matrices are still settling; they cannot exercise this branch until 2.49.3 is released. The exact local environment developed against the 2.49.3 source completed InterfaceII, focused SCC regressions, docs, QA (apart from Aqua's deliberate fresh-registry resolver), formatting, spelling, and invalidation checks as reported above. |
|
Closing and reopening to re-trigger CI now that NonlinearSolveBase 2.49.3 is in General (JuliaRegistries/General#167222). |
CI triage for a053e22, and what changedEvery one of the 91 failing jobs on a053e22 (the 27 downstream jobs in https://github.com/SciML/ModelingToolkit.jl/actions/runs/33932928483 / https://github.com/SciML/ModelingToolkit.jl/actions/runs/33932928474 / https://github.com/SciML/ModelingToolkit.jl/actions/runs/33932928475, plus Tests, Sublibrary CI, Downgrade, Documentation) died in the resolver, not in tests. Scripted classification of all 91 Action taken: registered NonlinearSolveBase 2.49.3 from NonlinearSolve master Results after the reopen: 95 pass / 11 fail / 1 skipped
Changes pushed to this branch (5f309d6)
SciMLSensitivity Core8, before/after (local, Julia 1.12.7, CI recipe:
|
| MTK | NonlinearSolveBase | Result |
|---|---|---|
master 2b4f11a7 |
2.49.3 (registry) | Testing SciMLSensitivity tests passed (Pass + Broken only) |
this PR a053e22796 |
2.49.3 (registry) | CI: 88 passed, 0 failed, 2 errored, 5 broken — the BoundsError above |
this PR 5f309d68f9 |
2.49.4 (NonlinearSolve#1230 dev'd) | Testing SciMLSensitivity tests passed (Pass + Broken only) |
NonlinearSolve#1230 CI: 93 pass / 0 fail / 1 skipped, including its downstream ModelingToolkit.jl/Initialization, InterfaceI, InterfaceII jobs.
Still open
- CI on 5f309d6 will fail in the resolver again until NonlinearSolve#1230 is merged and 2.49.4 registered (same release-order boundary as before); rerun after that.
- StructuralIdentifiability stays red until RationalFunctionFields relaxes its TimerOutputs compat.
- Optimization / QA / downgrade-QA are master issues, not this PR.
🤖 Generated with Claude Code (model: claude-fable-5-1)
https://claude.ai/code/session_01FeJYXni9MkJhPFA9yxYvfn
The initialization problem stored in `OverrideInitData` carried the model's
generated function in its type, so its solve inside `init` was compiled once
per model. `maybe_build_initialization_problem` now runs
`NonlinearSolveBase.get_concrete_problem` over the `NonlinearProblem` /
`NonlinearLeastSquaresProblem` (or each nonlinear `SCCNonlinearProblem` block)
when the initialization problem is `AutoDespecialize`, so the stored problem's
type is shared across models. `SCCNonlinearProblem{iip, specialize}` threads the
specialization marker through to the blocks (the standalone default stays
`AutoSpecialize`), and `InitializationProblem` passes it.
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Agent-Harness: Claude Code 2.1.259
Agent-Model: claude-fable-5-1
Agent-Session: https://claude.ai/code/session_01FeJYXni9MkJhPFA9yxYvfn
Route specialized SCC initialization through the historical one-parameter constructor so a newer ModelingToolkitBase remains compatible with the released root package. Require the NonlinearSolveBase reverse-AD fixes used by downstream sensitivity tests. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: OpenAI Codex <[email protected]> Agent-Harness: Codex (version unknown) Agent-Model: unknown Agent-Session: local thread 01a06c1d-564b-7ef0-ada6-d83a233b55e2
The concretized initialization problem stores its residual and callbacks behind NonlinearSolveBase's despecialization wrappers. Before NonlinearSolveBase 2.49.4 those wrappers reported arity 1, so `remake` of the stored problem re-derived `isinplace` through method-table introspection, which Enzyme reverse mode cannot differentiate (SciMLSensitivity Core8: `BoundsError: attempt to access Core.SimpleVector at index [2]`). The new test asserts the generated arity survives concretization. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]> Agent-Harness: Claude Code 2.1.259 Agent-Model: claude-fable-5-1 Agent-Session: https://claude.ai/code/session_01FeJYXni9MkJhPFA9yxYvfn
fe19a26 to
833ec7f
Compare
- Add constraints_to_penalties: lower constraints to quadratic penalty costs (#5111) - Fix QA: approve the `limited`/`constraints_to_penalties` API additions (#5116) - Concretize initialization problems once at construction (#5062) - Make tovar public (#5120) - Fix SciCompDSL model macro hygiene (#5058) - Release ModelingToolkitBase 1.71.0 (#5126) - Forward ProblemTypeCtx metadata to OptimizationProblem (#5115) - Release ModelingToolkitBase 1.71.1 (#5127) Agent-Harness: Claude Code Agent-Model: claude-opus-5[1m] Claude-Session: https://claude.ai/code/session_014FEzNTLFutCmTEAZ3zBg5R Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
What changed and why
The initialization problem stored in
OverrideInitDatacarried the model's generated function in its type, so the solve insideinitcompiled once per model.maybe_build_initialization_problemnow calls the publicNonlinearSolveBase.get_concrete_problemonce at construction for default-AutoDespecializenonlinear initialization problems, including each nonlinear block of anSCCNonlinearProblem. This gives equivalent models a shared stored problem type while leaving explicitly specialized and unsupported-state problems unchanged.SCCNonlinearProblem{iip, specialize}(sys, op)now threads the specialization marker into its blocks. The historical one-parameter constructor remains the compatibility boundary and acceptsspecializeas a keyword, because released root ModelingToolkit versions call it when used with a newer in-repository ModelingToolkitBase.NonlinearSolveBaseis now a direct MIT-licensed dependency of ModelingToolkitBase with a2.49.3floor. Version 2.49.0 first preserved despecialized parameters acrossreinit!; 2.49.3 additionally contains the reverse-mode AD fixes exercised by SciMLSensitivity's Core8 group.Required companion: SciML/NonlinearSolve.jl#1228 provides the reverse-mode AD fixes and releases NonlinearSolveBase 2.49.3. Optional performance companion: SciML/NonlinearSolve.jl#1226 avoids re-concretizing already wrapped problems and unwraps a residual when a later
u0promotion requires a new wrapper.TTFX evidence
Julia 1.12.7,
--startup-file=no, warm session, chain-DAE family from https://github.com/ChrisRackauckas/InternalJunk/issues/88#issuecomment-5508665437, Rodas5P. Each reported model is a fresh instance after one model of the same kind was solved.init(prob)init(get_concrete_problem(prob))init(prob)init(get_concrete_problem(prob))Across models with matching structure, non-SCC initialization problem types are identical. SCC block problem types are identical; the outer SCC type additionally depends on its intentional
NTuple{N}block count. Initial algebraic residuals remained1e-11–1e-14, and all measured solves returnedSuccess.AD evidence
ForwardDiff gradients through initialization, compared with central finite differences using registry NonlinearSolveBase 2.49.2:
Failing-before / passing-after evidence
The new type-sharing and specialization-threading tests failed on master:
They pass on this branch:
The initial PR commit also failed against the released-root/new-sublibrary combination used by CI:
The compatibility follow-up routes that call through the historical one-parameter constructor. The exact Julia 1.10 mixed-version workload now prints:
The direct routing regression test also discriminates the follow-up: on the pre-follow-up checkout it fails with
AssertionError: isdefined(ModelingToolkitBase, :_initialization_problem_constructor). On the final tree the helper selects the historicalSCCNonlinearProblem{true}boundary and forwards(; specialize = AutoDespecialize); every constructed block isAutoDespecialize.The downgrade lane with NonlinearSolveBase 2.46.0 also failed the new ForwardDiff assertion with a
9.898834314793689e154gradient after the initialization solve reached NaN. The preservation fix is in SciML/NonlinearSolve.jl@d1cd765 and first released in 2.49.0. Narrow ForwardDiff-floor verification with registry 2.49.0:The final tree was tested against the exact local NonlinearSolveBase 2.49.3 source from the required companion PR.
Invalidation audit
SnoopCompile measurements were repeated on the pre-follow-up commit and final working tree in the same environment. Julia-wide edge counts are sensitive to compiler and precompile state, so the package-rooted and unique-instance counts are the discriminating measures here:
The final implementation introduces no ModelingToolkit-rooted invalidation and no unique invalidated instance. An explicit named
specializekeyword in the method signature did add 104 edges and 52 tree-counted instances, so the final implementation preserves the historicalkwargs...signature and extracts the keyword inside the method.Local verification
Earlier final-commit runs on Julia 1.12.7:
Final compatibility follow-up:
ModelingToolkitBase QA's JET typo-mode failure reproduces unchanged on clean master and is tracked at #5063. The downgrade-action QA failure is separately tracked at #5064.
Not verified
Reviewer notes
AutoDespecializeinitialization problems whose state is a mutable, non-DualAbstractArray; an earlier broader guard failed an existing static-array construction case.SciMLBase.DespecializedParameters; existing_unwrap_mtk_parameterspaths handle them.SCCNonlinearProblem(sys, op)retains its existingAutoSpecializedefault.get_concrete_problem; it also gates the reverse-mode AD corrections required by downstream testing.Links
@matchcodegen #5063🤖 Initial implementation generated with Claude Code 2.1.259 (model: claude-fable-5-1; session: https://claude.ai/code/session_01FeJYXni9MkJhPFA9yxYvfn)
🤖 Compatibility follow-up generated with Codex (version unknown; model: unknown; session: local thread 01a06c1d-564b-7ef0-ada6-d83a233b55e2)