Repository navigation
Add a lowered_problem slot to SteadyStateProblem - #1603
Merged
ChrisRackauckas merged 2 commits intoSep 14, 2026
Merged
ChrisRackauckas merged 2 commits into
ChrisRackauckas merged 2 commits into
Conversation
Symbolic frontends can construct a SteadyStateProblem whose intended non-transient form is a lowered problem (e.g. an SCC-decomposed SCCNonlinearProblem) rather than the ODE residual wrapped as a NonlinearProblem. SteadyStateProblem had nowhere to record that lowering, so ModelingToolkit stored it in system metadata — which survives remake structurally but captures the construction-time operating point, so remake(prob; u0, p) returned a lowering built from stale values. Add a `lowered_problem` field (default `nothing`) following the `problem_type` slot added to OptimizationProblem in SciML#1600: it holds either an AbstractNonlinearProblem (used verbatim) or a callable `prob -> problem` that is evaluated on the current problem, letting frontends defer the lowering while still seeing remade u0/p. `remake` carries and can override the field, and `NonlinearProblem(::SteadyStateProblem)` prefers the stored lowering over wrapping `f`, so non-dynamic steady-state solves (NonlinearSolveBase's solve_call, SteadyStateDiffEq's SSRootfind) pick it up automatically. 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; workspace /home/crackauc/sandbox/tmp_20260913_211211_19443)
The callable-vs-stored check now keys on Base.Callable rather than AbstractNonlinearProblem: a system whose steady-state residual lowers to a single linear SCC stores a LinearProblem, which is an AbstractLinearProblem and would otherwise have been invoked as a callable. 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-Claude
pushed a commit
to ChrisRackauckas-Claude/ModelingToolkit.jl
that referenced
this pull request
Sep 14, 2026
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)
This was referenced Sep 14, 2026
Merged
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 14, 2026
- Add a lowered_problem slot to SteadyStateProblem (#1603) 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]>
ChrisRackauckas
added a commit
to SciML/ModelingToolkit.jl
that referenced
this pull request
Sep 17, 2026
* Record the SCC lowering of a SteadyStateProblem on its system
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)
* Store the SCC lowering in SteadyStateProblem.lowered_problem
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)
* Bump SciMLBase lower bound to 3.55 for SteadyStateProblem.lowered_problem
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)
---------
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]>
ChrisRackauckas
added a commit
to SciML/DiffEqDocs.jl
that referenced
this pull request
Sep 22, 2026
) SciML/SciMLBase.jl#1603 (c13c04c7ce, "Add a lowered_problem slot to SteadyStateProblem") added a `lowered_problem` field whose docstring text contains `[`NonlinearProblem`](@ref)`. The `SteadyStateProblem` docstring is rendered on docs/src/types/steady_state_types.md, but `SciMLBase.NonlinearProblem` was not included anywhere in this manual, so Documenter's cross-reference check failed: Error: Cannot resolve @ref for md"[`NonlinearProblem`](@ref)" in docs/src/types/steady_state_types.md. - No docstring found in doc for binding `SciMLBase.NonlinearProblem`. ERROR: LoadError: `makedocs` encountered an error [:cross_references] -- terminating build before rendering. Document the binding on the same page so the existing cross-reference resolves. The green-to-red bracket is SciMLBase v3.53.3 (green run 34702898469) to v3.55.0 (red run 35146255120); the only DiffEqDocs change in between was the unrelated CSV compat bump. Agent-Harness: OpenCode Agent-Model: muse-spark-1.3-contributor-free Agent-Session: local session at /home/crackauc/sandbox/tmp_20260917_040834_91074 (no public conversation URL) Co-authored-by: ChrisRackauckas-Claude <[email protected]>
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/SciMLBase.jl
that referenced
this pull request
Oct 7, 2026
…sion. After SciML#1603, MTK-lowered SteadyStateProblems surface SCCNonlinearProblem through NonlinearProblem(::SteadyStateProblem); callers that touch .u0 then FieldError. Forward .u0 to state_values and raise ArgumentError on NonlinearProblem(::SCC). Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Cursor Agent <[email protected]> Agent-Harness: Cursor Agent CLI Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/jobs/master-SciMLBase-scc-u0/log.txt on amdci2
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/SciMLBase.jl
that referenced
this pull request
Oct 20, 2026
…sion. After SciML#1603, MTK-lowered SteadyStateProblems surface SCCNonlinearProblem through NonlinearProblem(::SteadyStateProblem); callers that touch .u0 then FieldError. Forward .u0 to state_values and raise ArgumentError on NonlinearProblem(::SCC). Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Cursor Agent <[email protected]> Agent-Harness: Cursor Agent CLI 2026.09.26-dd393fe Agent-Model: cursor-grok-4.5-high Agent-Session: local session b2e00361-e7ad-4cb5-a134-76b6ed75a02f (no session URL)
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
Symbolic frontends (ModelingToolkit) can construct a
SteadyStateProblemwhose intended non-transient form is a lowered problem — e.g. an SCC-decomposedSCCNonlinearProblem— rather than the ODE residual wrapped as aNonlinearProblem.SteadyStateProblemhad nowhere to record that lowering, so MTK stored it inSystemmetadata (SciML/ModelingToolkit.jl#5155), which captures the construction-time operating point: afterremake(prob; u0, p),SCCNonlinearProblem(prob)still returned the lowering built from the originalop.This adds a
lowered_problemfield toSteadyStateProblem(defaultnothing), following theproblem_typeslot precedent from #1600:AbstractSciMLProblem(used verbatim — anSCCNonlinearProblem,NonlinearProblem,HomotopyProblem, or even aLinearProblemwhen the residual is a single linear SCC) or a callableprob -> problemevaluated on the current problem — so frontends can defer an expensive lowering until first use while still reflectingremakedu0/pvalues. A callable is what MTK stores; carrying it throughremakeis inherently correct since it is not bound to particular values.Base.Callable, not a problem abstract type, so anyAbstractSciMLProblemis returned verbatim.remakecarries the field and acceptslowered_problemas an override.NonlinearProblem(::SteadyStateProblem)prefers the stored lowering over wrappingf. This is the conversionNonlinearSolveBase.solve_call(::SteadyStateProblem, ::AbstractNonlinearAlgorithm)and SteadyStateDiffEq'sSSRootfindboth go through, so non-dynamic steady-state solves pick up an SCC lowering (and its sequential/direct-block solve path) automatically.Downstream companions: SciML/ModelingToolkit.jl#5155 moves its deferred
SCCNonlinearProblembuilder fromsysmetadata into this field (fixing the stale-op bug), and SciML/SteadyStateDiffEq.jl#166 adds the matchingDynamicSS/SCCNonlinearProblemdispatch that sequentially solves SCC blocks.Test plan
SteadyStateProblem lowered_problemtestset (17 tests): defaultnothing+f-wrap fallback, verbatim storedNonlinearProblemandLinearProblem, callable materialized against current problem,remakecarry/override/clear —test/problem_building_test.jlremake_tests.jl: all 88-per-container SteadyStateProblem cases pass (field rides throughconstructorof/setproperties/@reset)lowered_problemleaks intoprob.kwargsandprob.lowered_problemthrowsFieldError;NonlinearProblem(prob)ignores itGROUP=CoreandGROUP=QAleft to CI (no new imports/exports/extensions; QA env is heavy locally)Generated with Devin (harness: Devin CLI 3000.10.21, model: SWE-2 Max, session transcript:
/home/crackauc/.local/share/devin/cli/summaries/history_f9264d4995564dac.md— local file, no shareable URL for this harness).