Skip to content

Minimal SCCNonlinearProblem support for SSRootfind and DynamicSS - #166

Merged
ChrisRackauckas merged 5 commits into
SciML:masterfrom
ChrisRackauckas-Claude:scc-rootfind-forwarding
Sep 17, 2026
Merged

ChrisRackauckas merged 5 commits into
SciML:masterfrom
ChrisRackauckas-Claude:scc-rootfind-forwarding

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

Summary

Minimal version of #165: SCCNonlinearProblem can be pushed straight at the steady-state algorithms.

SSRootfind — solve(prob::SCCNonlinearProblem, alg::SSRootfind) forwards the problem directly to the wrapped algorithm (alg.alg), where SCCNonlinearSolve.jl's dispatches solve it in SCC order. This works because SSRootfind's only job is to route a problem to a nonlinear solver — and an SCCNonlinearProblem is the nonlinear problem, just pre-decomposed:

  • alg === nothing → SCCAlg() default
  • alg isa AbstractNonlinearAlgorithm (e.g. NewtonRaphson()) → wrapped in SCCAlg(nlalg = alg)
  • alg isa SCCAlg → separate linear/nonlinear block solver configuration

DynamicSS — solve(prob::SCCNonlinearProblem, alg::DynamicSS) solves the blocks sequentially in SCC order, following the SCCNonlinearSolve protocol: each block's parameter cache is updated from the upstream solutions through explicitfuns!, then:

  • LinearProblem blocks are solved directly (remake(block; A, b) recomputes A/b through SymbolicLinearInterface for MTK-generated blocks, then a plain linear solve). This needs no stability assumption — a negative-definite A still solves correctly, whereas integrating b - A*u would repel.
  • Nonlinear blocks are integrated to steady state by DynamicSS on the block residual through the existing __solve path — convergence only requires each block to be attracting under its own pseudo-transient dynamics, not a globally attracting concatenated field. (Note the per-block field can converge to a different root of a multi-rooted block than the monolithic field would — that is inherent to blockwise pseudo-transient solves, same as per-block Newton.)
  • HomotopyProblem blocks take a DynamicSS branch evaluating the residual at λ = λspan[2] (the actual system end). They bypass solve's preprocessing, which has no get_concrete_problem for HomotopyProblem, and go through __solve directly.

The per-block solutions are aggregated by concatenating u/resid (block order = state_values(prob) order) and stored on sol.original, so each block's inner DynamicSS solve — and its ODESolution — remains recoverable. A failing block's retcode propagates.

An SCCNonlinearProblem has no top-level u0/kwargs/f, so it cannot go through the generic AbstractNonlinearProblem solve preprocessing in NonlinearSolveBase — both are SciMLBase.solve overrides for that reason.

A SteadyStateProblem carrying SCC information does an SCC-style solve. With SciMLBase 3.55's SteadyStateProblem.lowered_problem field (SciML/SciMLBase.jl#1603, merged), DynamicSS checks the materialized lowering and delegates to the sequential block solve when it is an SCCNonlinearProblem rather than running one monolithic integration. SSRootfind gets the same routing for free through NonlinearProblem(prob), which now prefers the stored lowering. Two consequences handled here:

  • The solution is expressed on the lowered problem (sol.prob is the SCCNonlinearProblem), because the lowering defines its own state ordering — MTK's torn SCC order differs from prob.u0's, and may even have a different length (eliminated unknowns). Wrapping it as the outer problem would silently break symbolic indexing.
  • The alias/verbose specifiers injected by the nonlinear solve pipeline are stripped when forwarding to an SCCNonlinearProblem: they arrive as NonlinearAliasSpecifier/NonlinearVerbosity, which LinearProblem block solves inside SCCNonlinearSolve reject (LinearSolve wants LinearAliasSpecifier/LinearVerbosity).

Compat: SciMLBase = "3.55", test dep ModelingToolkit = "11.44" (the release carrying the lowered_problem storage, SciML/ModelingToolkit.jl#5155). SymbolicIndexingInterface is added as a direct dep (parameter_values, already transitive via SciMLBase; MIT-licensed like the rest of the dep set). SCCNonlinearSolve stays a test-only dependency.

This drops the rest of #165's scope (the SCC algorithm type, the scale/unscale nonlinear scaling machinery, and the ModelingToolkit extension), which the PR author also noted should live elsewhere.

Companion work: SciML/SciMLBase.jl#1603 (merged, released in 3.55.0) adds the SteadyStateProblem.lowered_problem slot with remake-correct prob -> problem builders, and SciML/ModelingToolkit.jl#5155 (merged, released in MTK 11.44.0) stores the SCC lowering there — verified end-to-end against the released MTK: an MTK-built SteadyStateProblem routes through the sequential SCC solve under DynamicSS and the decomposition under SSRootfind, with sol[states] symbolic indexing intact.

Test plan

  • test/scc.jl — 336 tests: all SSRootfind variants on a manual coupled SCCNonlinearProblem (iip × oop, tuple × vector), failure propagation, sequential DynamicSS(Tsit5()) on manual + MTK-built decompositions exercising LinearProblem/NonlinearProblem/HomotopyProblem blocks (iip × oop), a direct-solve discrimination case (A = -1, repelling under residual dynamics), a non-converging-residual failure case, and SteadyStateProblems with stored SCC lowerings (verbatim + callable builder) solved through the lowering by both DynamicSS and SSRootfind
  • End-to-end against dev'd MTK #5155: SteadyStateProblem(sys, op) + DynamicSS → sequential SCC solve (sol.prob isa SCCNonlinearProblem, per-block original), + SSRootfind → decomposition solve; remake(prob; u0) lowering reflects new values
  • Discrimination check: on the previous full-residual approach the sequential testset fails (the A = -1 linear block diverges to e^10 ≈ 22026, and sol.original has the old shape); it passes with this change
  • GROUP=Core julia --project -e 'using Pkg; Pkg.test()' — all pass locally
  • QA (test/qa) — 21 pass + reexport surface 16 (Aqua / ExplicitImports / JET)
  • Runic format + typos over the diff

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the contributor guidelines, in particular the SciML Style Guide and COLPRAC
  • Any new documentation only uses public API

🤖 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).

ChrisRackauckas and others added 2 commits September 13, 2026 20:47
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)
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)
@ChrisRackauckas-Claude ChrisRackauckas-Claude changed the title Forward SCCNonlinearProblem through SSRootfind to the SCC solver Minimal SCCNonlinearProblem support for SSRootfind and DynamicSS Sep 14, 2026
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

Companion MTK PR: SciML/ModelingToolkit.jl#5155 — SteadyStateProblem(sys, op) records its SCC lowering on prob.f.sys metadata, retrievable via SciMLBase.SCCNonlinearProblem(prob) (deferred + memoized, survives remake). That gives SCC-algorithm consumers the decomposed residual problem for MTK-built steady-state problems without MTK-side code in this package.

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)
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)
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

Done — SteadyStateProblem with SCC information now does an SCC-style solve (0b5c91e):

  • DynamicSS intercepts in __solve: when prob.lowered_problem materializes to an SCCNonlinearProblem, it delegates to the sequential block solve instead of the monolithic u' = f(u) integration.
  • SSRootfind gets it through NonlinearProblem(prob), which prefers the stored lowering (SciMLBase 3.55) — so solve(ssprob, SSRootfind(NewtonRaphson())) runs the SCC decomposition automatically.

Two subtleties handled:

  • The solution is expressed on the lowered problem (sol.prob is the SCCNonlinearProblem), since the lowering's block ordering differs from prob.u0's — wrapping it as the outer problem would break symbolic indexing.
  • The nonlinear pipeline's injected alias/verbose specifiers are stripped before forwarding to an SCC problem — LinearProblem block solves reject NonlinearAliasSpecifier/NonlinearVerbosity.

Verified end-to-end against the MTK branch (SciML/ModelingToolkit.jl#5155): SteadyStateProblem(sys, op) stores the lowering, and both algorithms route through it with correct sol[states] indexing. Compat bumped to SciMLBase = "3.55".

One behavioral note: per-block pseudo-transient solves can converge to a different root of a multi-rooted nonlinear block than the monolithic field would — same basin-dependence as per-block Newton.

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
ChrisRackauckas merged commit ed11ac7 into SciML:master Sep 17, 2026
12 checks passed
ChrisRackauckas added a commit that referenced this pull request Sep 17, 2026
Ships SCCNonlinearProblem support: minimal handling for SSRootfind and DynamicSS (#166) and sequential solving of SCC blocks under SICNM (#167). Minor because it adds problem-type support.

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 ChrisRackauckas mentioned this pull request Sep 17, 2026
ChrisRackauckas added a commit that referenced this pull request Sep 17, 2026
Ships SCCNonlinearProblem support: minimal handling for SSRootfind and DynamicSS (#166) and sequential solving of SCC blocks under SICNM (#167). Minor because it adds problem-type support.



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]>
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