Repository navigation
Record the SCC lowering of a SteadyStateProblem on its system - #5155
Merged
ChrisRackauckas merged 3 commits intoSep 17, 2026
Merged
ChrisRackauckas merged 3 commits into
ChrisRackauckas merged 3 commits into
Conversation
SteadyStateProblem(sys, op) now tags `sys` (under the
`Type{SCCNonlinearProblem}` metadata key) with a deferred builder that
produces the SCCNonlinearProblem the steady-state residual lowers to:
the NonlinearSystem residual of the original uncompiled model is
mtkcompiled and decomposed into SCCs. The lowering is lazy — building it
requires a full mtkcompile that most SteadyStateProblem consumers never
need — and memoized on first access, and it rides on `prob.f.sys` so it
survives `remake`.
Retrieval goes through `SciMLBase.SCCNonlinearProblem(prob)`, which
returns `nothing` for problems that record no lowering, so downstream
solvers can detect SCC-decomposable steady-state problems without
knowing MTK internals. The MTKBase stub/hook split mirrors
`get_initialization_problem_type`: ModelingToolkitBase owns the ctor
tagging and the accessor, ModelingToolkit supplies the lowering.
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Agent-Harness: Devin CLI 3000.10.21
Agent-Model: SWE-2 Max
Agent-Session: daily-primrose (local Devin CLI session ID, no shareable URL; workspace /home/crackauc/sandbox/tmp_20260913_211211_19443)
This was referenced Sep 14, 2026
Merged
Moves the lowering association off the shared system metadata (which captured the construction-time operating point and went stale after remake) onto the problem itself. The stored value is a callable `prob -> problem`: the mtkcompile'd residual system is memoized, while the operating point is rebuilt from the queried problem's u0/p via calculate_op_from_u0_p, so a remake'd SteadyStateProblem yields a lowering matching its current values. `SCCNonlinearProblem(prob::SteadyStateProblem)` reads the field, and `NonlinearProblem(prob)` prefers it over wrapping f directly. Requires the `lowered_problem` field from SciMLBase (SciML/SciMLBase.jl#1603); on older versions the hasfield guards keep construction a no-op and the accessor returns nothing. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <[email protected]> Agent-Harness: Devin CLI 3000.10.21 Agent-Model: SWE-2 Max Agent-Session: /home/crackauc/.local/share/devin/cli/summaries/history_f9264d4995564dac.md (local transcript; no shareable URL)
ChrisRackauckas
approved these changes
Sep 14, 2026
…blem The field shipped in SciMLBase 3.55.0, so drop the hasfield guards and store the SCC lowering builder unconditionally (still skipped on the codegen path). The accessor dispatches on AbstractSciMLProblem rather than Base.Callable to avoid a non-public qualified access. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <[email protected]> Agent-Harness: Devin CLI 3000.10.21 Agent-Model: SWE-2 Max Agent-Session: daily-primrose (local Devin CLI session ID, no shareable URL; workspace /home/crackauc/sandbox/tmp_20260913_211211_19443)
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 17, 2026
Ships #5155: the new public `steady_state_sccprob` stub (with docstrings) that lets a SteadyStateProblem record the SCC lowering of its residual, plus the SciMLBase compat floor of 3.55. Minor rather than patch because it adds public API that ModelingToolkit 11.44.0 extends. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude <[email protected]> Agent-Harness: Claude Code 2.1.273 Agent-Model: claude-opus-5[1m] Agent-Session: 6a01e420-3436-4518-83cc-6cd853283cfb (local transcript; this harness publishes no conversation URL)
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 17, 2026
Ships #5155: the new public `steady_state_sccprob` stub (with docstrings) that lets a SteadyStateProblem record the SCC lowering of its residual, plus the SciMLBase compat floor of 3.55. Minor rather than patch because it adds public API that ModelingToolkit 11.44.0 extends. Agent-Harness: Claude Code 2.1.273 Agent-Model: claude-opus-5[1m] Agent-Session: 6a01e420-3436-4518-83cc-6cd853283cfb (local transcript; this harness publishes no conversation URL) Co-authored-by: Claude <[email protected]>
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 17, 2026
#5155 defines MTKBase.steady_state_sccprob, which is new public API in ModelingToolkitBase 1.74.0. The floor was still 1.70, so a resolve picking an older ModelingToolkitBase would fail to load. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude <[email protected]> Agent-Harness: Claude Code 2.1.273 Agent-Model: claude-opus-5[1m] Agent-Session: 6a01e420-3436-4518-83cc-6cd853283cfb (local transcript; this harness publishes no conversation URL)
Merged
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 17, 2026
#5155 defines MTKBase.steady_state_sccprob, which is new public API in ModelingToolkitBase 1.74.0. The floor was still 1.70, so a resolve picking an older ModelingToolkitBase would fail to load. Agent-Harness: Claude Code 2.1.273 Agent-Model: claude-opus-5[1m] Agent-Session: 6a01e420-3436-4518-83cc-6cd853283cfb (local transcript; this harness publishes no conversation URL) Co-authored-by: Claude <[email protected]>
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/SteadyStateDiffEq.jl
that referenced
this pull request
Sep 17, 2026
MTK 11.44 ships the lowered_problem storage (SciML/ModelingToolkit.jl#5155), so MTK-built SteadyStateProblems always carry the SCC builder and the tests can assert the delegation unconditionally. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <[email protected]> Agent-Harness: Devin CLI 3000.10.21 Agent-Model: SWE-2 Max Agent-Session: daily-primrose (local Devin CLI session ID, no shareable URL; workspace /home/crackauc/sandbox/tmp_20260913_211211_19443)
ChrisRackauckas
added a commit
to SciML/SteadyStateDiffEq.jl
that referenced
this pull request
Sep 17, 2026
* Forward SCCNonlinearProblem through SSRootfind to the SCC solver An SCCNonlinearProblem has no top-level u0/kwargs fields, so the generic AbstractNonlinearProblem solve preprocessing cannot handle it. solve(prob::SCCNonlinearProblem, alg::SSRootfind) now bypasses that path and forwards the problem directly to the wrapped algorithm, where SCCNonlinearSolve.jl's dispatches solve it in SCC order while preserving the linear/nonlinear block decomposition. The returned solution wraps the inner solve as `original`, matching the SteadyStateProblem path. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.10.21 Agent-Model: SWE-2 Max Agent-Session: daily-primrose (local Devin CLI session ID, no shareable URL; workspace /home/crackauc/sandbox/tmp_20260913_211211_19443) * Integrate an SCCNonlinearProblem directly with DynamicSS A second `solve` specialization: `solve(prob::SCCNonlinearProblem, alg::DynamicSS)` bypasses the generic nonlinear solve path and integrates the pseudo-transient system `u' = g(u)`, where `g` is the concatenated residual of the SCC blocks evaluated at the trial state. Upstream trial values reach each block's parameter cache through `explicitfuns!`, exactly as in the SCC solve. Linear blocks contribute `b - A*u` (ModelingToolkit's `calculate_A_b` encodes `A*u - b = -expr`); homotopy blocks are evaluated at `λ = 1`. The problem is deep-copied since `explicitfuns!` mutate the block caches on every residual call, and the result is wrapped on the original problem with the inner steady-state solve as `original`. ModelingToolkit needs no integration change: its generated SCCNonlinearProblems solve through this path, and MTK SteadyStateProblems whose `initialization_data.initializeprob` is an SCCNonlinearProblem already work through the ODE initialization machinery. Both directions are covered by the new tests. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.10.21 Agent-Model: SWE-2 Max Agent-Session: daily-primrose (local Devin CLI session ID, no shareable URL; workspace /home/crackauc/sandbox/tmp_20260913_211211_19443) * Solve SCCNonlinearProblem blocks sequentially under DynamicSS Replace the monolithic-residual integration with the SCC solve protocol: each block's parameter cache is updated from upstream solutions through explicitfuns!, LinearProblem blocks are solved directly, and nonlinear blocks are integrated to steady state by DynamicSS on the block residual. Direct linear solves no longer require b - A*u to be attracting, and convergence only needs each nonlinear block to be attracting under its own pseudo-transient dynamics rather than a globally attracting concatenated field. HomotopyProblem blocks evaluate the residual at the lambda endpoint of lambda_span, which is the actual system. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <[email protected]> Agent-Harness: Devin CLI 3000.10.21 Agent-Model: SWE-2 Max Agent-Session: /home/crackauc/.local/share/devin/cli/summaries/history_f9264d4995564dac.md (local transcript; no shareable URL) * Solve SteadyStateProblems through a stored SCCNonlinearProblem lowering A SteadyStateProblem carrying lowered_problem now does an SCC-style solve: DynamicSS delegates to the sequential block solve and SSRootfind's NonlinearProblem(prob) conversion already returns the lowering. The inner solution is expressed on the lowered problem since its block ordering need not match the steady-state problem's u0. The alias/verbose specifiers injected by the nonlinear solve pipeline are stripped when forwarding to an SCCNonlinearProblem because LinearProblem block solves reject the nonlinear specifier types. Requires SciMLBase 3.55 for the lowered_problem field. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <[email protected]> Agent-Harness: Devin CLI 3000.10.21 Agent-Model: SWE-2 Max Agent-Session: daily-primrose (local Devin CLI session ID, no shareable URL; workspace /home/crackauc/sandbox/tmp_20260913_211211_19443) * Raise the ModelingToolkit floor to 11.44 for the stored SCC lowering MTK 11.44 ships the lowered_problem storage (SciML/ModelingToolkit.jl#5155), so MTK-built SteadyStateProblems always carry the SCC builder and the tests can assert the delegation unconditionally. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <[email protected]> Agent-Harness: Devin CLI 3000.10.21 Agent-Model: SWE-2 Max Agent-Session: daily-primrose (local Devin CLI session ID, no shareable URL; workspace /home/crackauc/sandbox/tmp_20260913_211211_19443) --------- Co-authored-by: ChrisRackauckas-Claude <[email protected]> Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Devin <[email protected]>
This was referenced Sep 17, 2026
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 18, 2026
…owering (#5163) * Fix `solve(::SteadyStateProblem)` for SCC lowerings #5155 stores a deferred `SCCNonlinearProblem` lowering on `SteadyStateProblem`, which `SciMLBase.NonlinearProblem(prob)` materializes on every solve. Several bugs made that path fail: - `NonlinearSystem(sys)` called `bound_parameters` on complete systems whose `parameter_bindings_graph` was invalidated by `complete(; flatten = false)`, and merged child-system data through the recursive accessors while also keeping the converted subsystems, double-counting equations, unknowns and bindings (the duplicate `t => Inf` was the first failure). - Initialization equations were copied untranslated into the time-independent residual, so bare unknowns were rejected; they are now wrapped in `Initial`, and derivatives (including `Initial(D(x))`) collapse to zero. - Bound parameters were merged into the operating point, colliding with the lowered system's own `bindings`. - A residual that `mtkcompile` reduces entirely to `observed` produced an empty SCC schedule; the lowering is now a stateless `NonlinearProblem`. - `solve` re-dispatched `__solve` on the materialized `SCCNonlinearProblem`, whose generic fallbacks read `prob.u0` — a field it does not have. `solve` on `SteadyStateProblem` now routes SCC lowerings through `SCCAlg` and leaves every other problem/algorithm combination on the upstream path. Fixes #5162 Generated with [Devin](https://devin.ai) Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.10.31 Agent-Model: SWE-2 Max Agent-Session: local session, no shareable URL; transcript summary at /home/crackauc/.local/share/devin/cli/summaries/history_53525bdc70b74343.md * Move variable bindings to initial conditions in `NonlinearSystem(sys)` SteadyStateDiffEq 2.17's `__solve_scc_lowering` invokes the deferred lowering on `DynamicSS` solves too, which exposed a latent crash: a completed time-dependent system stores variable defaults like `z(t) => z0` in `bindings`, and the `System` constructor rejects variable bindings when `iv === nothing`, so `NonlinearSystem(sys)` threw before ever building a problem. Mirror `convert_bindings_for_time_independent_system` on the local `get_*` fields — the recursive `bindings(sys)` would re-fold subsystem data that this conversion already handles separately. Generated with [Devin](https://devin.ai) Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.10.31 Agent-Model: SWE-2 Max Agent-Session: local session, no shareable URL; transcript summary at /home/crackauc/.local/share/devin/cli/summaries/history_d2dbf511181844c4.md * Move `solve(::SteadyStateProblem)` SCC routing to SteadyStateDiffEq Per review on #5163, the steady-state solve dispatch belongs in the solver package rather than the problem producer. The interception now lives in SteadyStateDiffEq (SciML/SteadyStateDiffEq.jl#169); MTK keeps the lowering side (`NonlinearSystem` conversion, empty-SCC schedule, bound-parameter guards). `test/scc_nonlinear_problem.jl` imports SteadyStateDiffEq so the routing is loaded when solving these problems. Generated with [Devin](https://devin.ai) Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.10.31 Agent-Model: SWE-2 Max Agent-Session: local session, no shareable URL; transcript summary at /home/crackauc/.local/share/devin/cli/summaries/history_d2dbf511181844c4.md --------- Co-authored-by: ChrisRackauckas-Claude <[email protected]> Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This was referenced Sep 21, 2026
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
SteadyStateProblem(sys, op)stores its SCC lowering in the newSteadyStateProblem.lowered_problemfield (SciMLBase 3.55,SciML/SciMLBase.jl#1603): a
prob -> problemcallable that lazilymtkcompiles the residualNonlinearSystemand returns theSCCNonlinearProblem. The compiled residual system is memoized in aRef,while the operating point is rebuilt from the queried problem's
u0/pviacalculate_op_from_u0_p— soremake(prob; u0 = ..., p = ...)produces alowering reflecting the new values, fixing the stale-construction-op capture
of the earlier metadata design.
Consumers:
SciMLBase.SCCNonlinearProblem(prob::SteadyStateProblem)(defined inMTKBase; generic fallback returns
nothing) materializes the lowering —a verbatim
AbstractSciMLProblemis returned as-is, anything else istreated as a builder and called on
prob.NonlinearProblem(prob)prefers the stored lowering over wrappingf(SciMLBase side), so
SSRootfind-style solves and SteadyStateDiffEq.jl#166'sDynamicSS/SSRootfindSCC routing pick the decomposition upautomatically.
expression = Val{true}codegen path —build_scimlproblem_exprembeds kwargs as literals and cannot embed aclosure capturing
sys.steady_state_sccprob(sys, op; kwargs...)is the MTKBase stub + MTK implbridge, same pattern as
get_initialization_problem_type.Compat:
SciMLBase = "3.55"on bothModelingToolkitandModelingToolkitBase— the guards that kept this inert on older SciMLBaseare removed.
Companion to SciML/SciMLBase.jl#1603 (merged, released in 3.55.0) and the
SSRootfind/DynamicSSSCCNonlinearProblemsupport inSciML/SteadyStateDiffEq.jl#166.
Test plan
test/scc_nonlinear_problem.jl— all testsets pass, including"SteadyStateProblem stores its SCC lowering" (18 assertions): builder
presence/callability,
SCCNonlinearProblem(prob)materialization, 2-blockLinearProblem+NonlinearProblemdecomposition,getu-indexedoperating-point values,
NonlinearProblem(prob)preference, Newton solve →[1, 2, ∛3], remake-correctness regression (remake(prob; u0)producesa lowering reflecting the new operating point, not the construction
op),build_initializeprob=false,nothingforODEProblemsolve(ssprob, DynamicSS())takes the sequential SCC path and
solve(ssprob, SSRootfind(...))runs thedecomposition, with
sol[states]indexing on the lowered problemMethodErrors without the changeSCCNonlinearProblem(::SteadyStateProblem)extension is allowlisted viaINTENTIONAL_EXTERNAL_GENERIC_EXTENSIONS, matching MTKBase's ownership ofSCCNonlinearProblem(::System)construction)steady_state_sccprobadded toNONPUBLIC_QUALIFIED_ACCESSES(sameconvention as
get_initialization_problem_type)typosover the diffNote: MTKBase's JET QA lane is red on master already — 234
##And#…/##Call#…"may be undefined" reports, the documented short-circuit-guard false positives
(JuliaLang/julia#62745, JET.jl#858) that forced
jet = falseon root MTK. Noreport touches the files changed here.
🤖 Generated with Devin CLI (model: SWE-2 Max). Session: local transcript at
/home/crackauc/.local/share/devin/cli/summaries/history_45335a77847a4532.md(no shareable URL for this harness).