Skip to content

Route SCC-lowered SteadyStateProblems through the default init/solve - #1319

Open
SebastianM-C wants to merge 2 commits into
SciML:masterfrom
SebastianM-C:smc/steadystate-scc-default
Open

SebastianM-C wants to merge 2 commits into
SciML:masterfrom
SebastianM-C:smc/steadystate-scc-default

Conversation

@SebastianM-C

@SebastianM-C SebastianM-C commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Fixes SciML/ModelingToolkit.jl#5194. This also fixes the SciMLBase.jl/SymbolicIndexingInterface IntegrationTest failure on ModelingToolkit master.

Problem

Since ModelingToolkit 11.44/11.45 (SciML/ModelingToolkit.jl#5155, #5163), a SteadyStateProblem built from a System stores an SCCNonlinearProblem lowering, and NonlinearProblem(prob) returns it (SciML/SciMLBase.jl#1603). The default-algorithm methods in src/default.jl then do

nlprob = SciMLBase.NonlinearProblem(prob)
return SciMLBase.__solve(nlprob, nothing, args...; kwargs...)   # same for __init

They dispatch on AbstractSteadyStateProblem, but that is only an alias of AbstractNonlinearProblem, so the SCCNonlinearProblem goes back into the same method. There, NonlinearProblem(::AbstractNonlinearProblem) reads prob.u0, which SCCNonlinearProblem doesn't have:

FieldError: type SCCNonlinearProblem has no field `u0`, available fields: `probs`, `explicitfuns!`, `f`, `p`, `parameters_alias`

This breaks solve(prob) whenever SteadyStateDiffEq isn't loaded (its solve(::SteadyStateProblem, ...) override handles SCC lowerings before reaching this code). It breaks init(prob) in every case, because nothing defines init for an SCCNonlinearProblem. SCCNonlinearSolve's solve(::SCCNonlinearProblem, ::Nothing) does exist, but these methods call __solve, so they never reach it.

Changes

  • src/default.jl:
    • Both defaults now dispatch on SteadyStateProblem, so an SCC lowering no longer re-enters them.
    • __solve hands an SCCNonlinearProblem lowering to its own solve dispatch (SCCNonlinearSolve).
    • __init iterates on the unlowered residual (NonlinearProblem{iip}(prob.f, prob.u0, prob.p), what it built before the lowering existed). An SCC problem is solved block by block, so there is no single-residual cache to init.
  • lib/SCCNonlinearSolve: routing solve there exposed an existing bug. solve fills in alias::NonlinearAliasSpecifier and verbose::NonlinearVerbosity, and SCCNonlinearSolve forwarded both unchanged to LinearProblem blocks, which LinearSolve rejects (FieldError: ... no field alias_A and MethodError: no method matching _process_verbose_param(::NonlinearVerbosity)). This also affected a direct solve(sccprob; verbose = NonlinearVerbosity()). Linear blocks now get verbose.linear_verbosity, the same mapping as descent/newton.jl, and the nonlinear alias specifier is dropped.

With a new NonlinearSolve but an old SCCNonlinearSolve, the default solve would fail with the alias_A error until both are released.

Tests

  • test/Core/default_alg_tests__item1.jl: init/init(prob, nothing) + solve! on a SteadyStateProblem with a stored SCC lowering.
  • lib/SCCNonlinearSolve/test/core_tests__item7.jl: default solve of such a problem, plus nonlinear verbose/alias reaching a linear block, for both nothing and NewtonRaphson().

Both only run when SciMLBase has lowered_problem (≥ 3.55); the compat floor is 3.46. Without the source changes, each new testset fails with the error above.

Local runs (Julia 1.12.5): SCCNonlinearSolve Core and QA pass, NonlinearSolve QA passes, and the NonlinearSolve steady-state default test file passes (26/26); I didn't run NonlinearSolve's full Core group locally. The MWE from SciML/ModelingToolkit.jl#5194 and SciMLBase's test/downstream/comprehensive_indexing.jl setup both work with ModelingToolkit 11.45.1 and SciMLBase 3.56.0.

Written by Claude Code on Sebastian's behalf.

🤖 Generated with Claude Code
Model: Claude Opus 5.5

@ChrisRackauckas

Copy link
Copy Markdown
Member

🤖 Automated review from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris. It is posted so that you can act on it. Chris or a maintainer may disagree.

Verdict: changes needed before merge (reviewed at bded09b).

The PR fixes default solve/init of a SteadyStateProblem that stores an SCCNonlinearProblem lowering (ModelingToolkit #5194). It also fixes SCCNonlinearSolve forwarding NonlinearVerbosity/NonlinearAliasSpecifier to LinearSolve. Both fixes work, and the new tests fail without them and pass with them. It needs changes because narrowing the default methods from AbstractSteadyStateProblem to SteadyStateProblem breaks the default algorithm for ImmutableNonlinearProblem: solve(ip), solve(ip, nothing) and init(ip) work on master and error on this head.

Risk assessment

  • Risk: medium
  • Blast radius: Anyone calling solve/init on an SciMLBase.ImmutableNonlinearProblem without an algorithm. That includes GPU/kernel-style and StaticArrays users, and MTK's ImmutableNonlinearProblem constructor. The SCC and SteadyStateProblem changes themselves are narrow.
  • Evidence:
    • CI on the head: every check passes except tests / Adjoint (all 4: julia 1/lts × ubuntu/macos) and downgrade-sublibraries / test (lib/NonlinearSolveFirstOrder).
    • The same checks fail on master 29af7e6: CI run 36094728765 and Downgrade Sublibraries run 36094728481.
      • Adjoint shows the same error on both: ArgumentError: @NamedTuple{values..., coeffs::ChainRulesCore.Tangent...} keys must be a subset of ..., 4 passed / 1 errored.
      • Downgrade FirstOrder shows the same rootfind_tests__item8.jl:30 SVector errors on both.
      • So none of the CI failures are new. The Core, SCCNonlinearSolve Core/QA, Runic, typos, Docs and downstream MTK/OrdinaryDiffEq/BVP checks all pass on the head.
    • What I ran locally (Julia 1.12, SciMLBase 3.56.0, LinearSolve 5.18.1; logs are in the scratch logs/ dir):
      • test/Core/default_alg_tests__item1.jl: 26/26 pass on the head. With only src/default.jl reverted to master: 22 pass, 1 error (FieldError: type SCCNonlinearProblem has no field u0 at init(prob)).
      • SCCNonlinearSolve GROUP=Core: 70/70 pass on the head.
        • With both src files reverted, both core_tests__item7.jl testsets error: one with alias_A FieldError, one with u0 FieldError.
        • With only SCCNonlinearSolve.jl reverted, both still error with alias_A. So each source change is needed.
      • Probe script, master vs head, using ImmutableNonlinearProblem{false}(NonlinearFunction{false}((u,p)->u.*u.-p), [1.0,1.0], 2.0):
        • solve(ip): master Success [1.414…]; head NoDefaultAlgorithmError: Default algorithm choices require DifferentialEquations.jl.
        • solve(ip, nothing): master Success; head NonSolverError: The arguments to solve are incorrect.
        • init(ip) and init(ip, nothing), each followed by solve!: master Success; head NoDefaultAlgorithmError.
        • A plain SteadyStateProblem gives the same result on both.
      • Runic --check on the 4 changed files: clean.
      • SCCNonlinearSolve QA (qa.jl run in a hand-built env): ExplicitImports 6/6 pass. There was one Aqua persistent-tasks error, caused by the env (missing Scratch for GPUCompiler) and unrelated to the diff.
    • Rule checks:
      • No skipped or loosened tests, and no new dependencies.
      • NonlinearVerbosity and its documented linear_verbosity field are exported from NonlinearSolveBase (in the same monorepo, and present well below the 2.44 compat floor). SciMLBase.NonlinearAliasSpecifier is public.
      • No new public names.
      • No version bumps. That fits the repo's separate "Release X" PR convention.
    • Reviews: no reviews or comments yet. The PR is a draft, but the author does not describe it as unfinished.
  • Merge: needs changes (restore default-algorithm dispatch for ImmutableNonlinearProblem and add a regression test)

Findings

  1. src/default.jl:63 and :73. Problem: changing __init/__solve(prob::AbstractSteadyStateProblem, ::Nothing) to prob::SteadyStateProblem drops every other AbstractNonlinearProblem subtype that had no default of its own. ImmutableNonlinearProblem is one of them (ImmutableNonlinearProblem <: AbstractSteadyStateProblem is true). Its no-algorithm solve/init now error, as the probe output above shows. No existing test caught this. Fix: keep the AbstractSteadyStateProblem signature and branch on nlprob isa SciMLBase.SCCNonlinearProblem after the conversion. Short-circuit when prob itself is an SCCNonlinearProblem: hand it to SciMLBase.solve, or throw a clear "load SCCNonlinearSolve" error. Alternatively, add explicit ImmutableNonlinearProblem default methods. Either way, add a test that solve(ip), solve(ip, nothing) and init(ip) succeed on an ImmutableNonlinearProblem.
  2. src/default.jl:84 (SCC branch of __solve). Problem: SciMLBase.solve(nlprob, nothing, ...) needs SCCNonlinearSolve to be loaded, and NonlinearSolve does not depend on it. Without it, the user gets a generic NoDefaultAlgorithmError/MethodError instead of the old FieldError. This is not a regression (it errored before), but the message tells the user nothing useful. Fix (optional): give a clear error naming SCCNonlinearSolve when its method is missing. The PR body also says a new NonlinearSolve paired with an old SCCNonlinearSolve still hits the alias_A error. The SCCNonlinearSolve release should ship together with this change.
  3. Whole diff, style only. Problem: about 17 of ~91 added lines are comments (~19%), including narration such as "(as the Newton descent does)" and the three-line ## block explaining the dispatch choice. This is above the ~10% bar Chris applies to agent-written diffs. Fix: trim the comments to the non-obvious "why".

Push a fix and the PR is reviewed again automatically at the new head.


🤖 Posted by an AI agent — harness: Claude Code · model: claude-opus-5-5[1m] (fleet master); review by Devin CLI (Mac) / fusion-claude-opus-5-5-high-sidekick-swe-2-medium
Conversation: local Claude Code session 3cd6500a-1f81-46b5-ac0b-c466e15b6a53 on Chris's Mac (session ID, no URL)

@SebastianM-C

SebastianM-C commented Sep 26, 2026 •

Copy link
Copy Markdown
Member Author

Thanks for the review. Addressed in f3e6f86 (branch rebased onto master):

  1. ImmutableNonlinearProblem default algorithm: the no-algorithm __init/__solve now dispatch on Union{SteadyStateProblem, ImmutableNonlinearProblem}. ImmutableNonlinearProblem has no default of its own and used to fall into the AbstractSteadyStateProblem catch-all, so listing it explicitly keeps master's behavior (convert to NonlinearProblem, then the default polyalgorithm). I didn't bring back the catch-all with an SCC guard: it needs two guards (the converted problem, and prob itself being an SCCNonlinearProblem when SCCNonlinearSolve isn't loaded), and it would keep silently catching other subtypes. For example, on master init(::HomotopyProblem) converts it to a plain NonlinearProblem whose f lacks the λ argument (from reading the code; I didn't run it). There's a new regression test in test/Core/default_alg_tests__item1.jl covering solve(ip), solve(ip, nothing), init(ip) and init(ip, nothing). It errors at 78801c1 and passes now (34/34).
  2. Error when SCCNonlinearSolve isn't loaded: not changed in this PR. As you noted, it isn't a regression. The SCCNonlinearSolve release should go out together with this change.
  3. Comment density: trimmed to the non-obvious "why". It's now 7 comment lines out of 88 added.

Also checked: lib/SCCNonlinearSolve/test/core_tests__item8.jl passes 8/8 (renamed from core_tests__item7.jl, since #1328 added an item7 on master), upstream's core_tests__item7.jl still passes after the rebase, and Runic --check is clean on the changed files (Julia 1.12.7, SciMLBase 3.56.1).


Posted by Claude Code (claude-opus-5-5[1m]) on behalf of Sebastian.

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

Independent review (Codex CLI 0.166.0 / gpt-6.1-sol), session 01a19822-e8f3-7600-8f67-2bd3986bcdef, reviewed head f3e6f86

  • Verdict: MERGE-WITH-ISSUES
  • Risk: medium-high (MH1: core default solve/init dispatch changes; numerical algorithms and tolerances are unchanged).
  • Round / slot: 1 / 1
  • Blocking priorities: none

Review written by the reviewer named above in a session other than the PR author's, and copied here by the posting agent without change to its findings. The posting agent did not re-run the reviewer's commands.

Summary: Routes SCC-lowered steady-state problems through SCC solving, preserves default immutable-problem dispatch, and normalizes linear-block keywords. The targeted regressions and independent probes pass, with non-blocking CI failures requiring separate triage.

Blast radius: Default solve/init of SteadyStateProblem and ImmutableNonlinearProblem, plus nonlinear verbosity and alias keywords forwarded to SCC linear blocks; ordinary NonlinearProblem default selection is unchanged.

Evidence: Blind assessment sealed in INITIAL.md and INITIAL.sha256 before author context. Julia 1.13.2 with SciMLBase 3.57.0: both targeted files pass at head (42 assertions); the same head tests against base reproduce three SCC-related errors, while the immutable regression passes on both. Independent analytic, remake, container, alias, repeated-call, and static-array probes pass 39 assertions. SCC Core and downstream CI jobs pass; Adjoint and FirstOrder downgrade jobs fail on unchanged explicit-algorithm tests.

Blocking findings

None.

Non-blocking findings

  1. non-blocking [P3] Triage the outstanding CI failures before treating CI as green. At test/Adjoint/adjoint_tests__item1.jl:58, all four Adjoint jobs error with structured-parameter tangent keys not matching the wrapped parameter keys; at lib/NonlinearSolveFirstOrder/test/rootfind_tests__item8.jl:30, the downgrade job reports 28 Enzyme errors expecting an SVector but receiving a Vector. Confirmed by inspecting CI logs, not reproduced locally. These unchanged tests use explicit NewtonRaphson/TrustRegion algorithms and do not traverse the changed steady-state default dispatch or SCC keyword helper. Recent completed master runs do not reproduce these exact errors: their Adjoint jobs and downgrade workflow pass, while other jobs have different failures. Refresh or diagnose these jobs separately; I do not claim an established master baseline for either failure.

What I ran

Commands below use REVIEW_DIR for the review workspace and SHARED_DEPOT for the supplied depot, so no machine-specific paths are included. No upstream writes were made; the source checkout was not edited.

  • gh pr view 1319 --repo SciML/NonlinearSolve.jl --json number,url,state,isDraft,headRefOid,baseRefName,baseRefOid (exit 0): OPEN, draft, live head equal to the reviewed head.
  • In the checkout: git status --short; git rev-parse HEAD; git fetch origin '+refs/pull/1319/head:refs/remotes/pr/1319' master; git checkout --detach pr/1319; git diff --stat origin/master...HEAD; git diff origin/master...HEAD; git merge-base origin/master HEAD (exit 0). Worktree initially clean; merge-base equals Base above. Read AGENTS.md and surrounding dispatch, SCC, conversion, and alias code.
  • sha256sum INITIAL.md > INITIAL.sha256 (exit 0), before gh pr view 1319 --repo SciML/NonlinearSolve.jl --json title,body,commits,statusCheckRollup and gh issue view 5194 --repo SciML/ModelingToolkit.jl --json title,body (exit 0).
  • git log -1 --format=%B f3e6f8695da575d013bde2fcab22d19b54d11b87 (exit 0): neither Agent-Harness nor Agent-Model trailer is present. codex --version reports codex-cli 0.166.0.

Exactly three Julia runs, sequentially, each with JULIA_PKG_PRECOMPILE_AUTO=0 JULIA_NUM_THREADS=4 OPENBLAS_NUM_THREADS=1 TMPDIR="$REVIEW_DIR/tmp" JULIA_DEPOT_PATH="$SHARED_DEPOT:" timeout 3600 julia +1.13.2 --startup-file=no:

  • Head: REVIEW_SETUP=1 plus --project=env tmp/regressions.jl (exit 0). The driver activates an external temporary environment, develops the checkout and its local solver subpackages, and instantiates with automatic precompilation disabled. It includes test/Core/default_alg_tests__item1.jl and lib/SCCNonlinearSolve/test/core_tests__item8.jl in separate modules. Output: LOWERED_PROBLEM_SUPPORTED=true; default tests 34/34; SCC tests 8/8; PASS_REGRESSION default; PASS_REGRESSION scc.
  • Base: exported with git -C src archive 29af7e6072032a8cef58af9f0f6f2faaae5ed6b6 | tar -x -C base; copied the resolved environment with package paths redirected to that export. Ran --project=env-base tmp/base-regressions.jl (exit 1), including the same head test files within outer testsets so later testsets still execute. Output: default 30 passed, 1 errored; SCC 0 passed, 2 errored. New init regression errors with FieldError: type SCCNonlinearProblem has no field u0; mixed-block regression errors with FieldError: type SciMLBase.NonlinearAliasSpecifier has no field alias_A; new default lowered solve regression errors with missing u0. ImmutableNonlinearProblem's eight assertions pass on both base and head, testing preservation rather than a base regression.
  • Independent probe: --project=env tmp/probe.jl (exit 0). Analytic equations x^2=p and 4y=x give reference [sqrt(p), sqrt(p)/4], independent of solver output. Callable lowerings and parameter remakes at p=2 and p=9, solve/init equivalence, and input preservation: 12/12. Tuple/vector mixed SCC blocks, both alias_u0 settings, repeated solves, and matrix preservation: 24/24. Out-of-place static-array init fallback: 3/3. No further Julia runs.

CI inspected using gh pr checks 1319 --repo SciML/NonlinearSolve.jl, gh run view ... --log-failed, and recent completed master push runs. Log retrieval initially failed because the CLI cache was read-only; setting XDG_CACHE_HOME to the review scratch cache allowed inspection.

What I did not verify

No full package suite, Pkg.test(), heavy downstream suite, or original ModelingToolkit symbolic MWE was run locally. SciMLBase's minimum supported 3.46 version, other Julia versions/platforms, GPU/MPI/Reactant, and reverse-mode differentiation through SCC lowerings were not independently run. The changed code adds no AD rules or GPU/cluster kernels; local nonlinear solves exercise ordinary automatic Jacobian construction, and CI exercises SCC Core. The combined keyword regression stops at alias_A on base, so verbose-only failure and the later explicit NewtonRaphson iteration were not isolated on base; both keyword test iterations pass on head. I did not directly invoke the legacy variadic SCC builder overload, which the current _scc_solve entry point does not call. CI failures were diagnosed from logs, with no proof that their exact errors also occur on master. No prior review was read.

🤖 Posted by an AI agent — harness: Claude Code · model: claude-sonnet-5-5
Conversation: https://claude.ai/code/session_01379heiiB35TtywhR7uSU74

@ChrisRackauckas-Claude
ChrisRackauckas-Claude marked this pull request as ready for review November 2, 2026 02:06
@SebastianM-C
SebastianM-C force-pushed the smc/steadystate-scc-default branch from f3e6f86 to d92d732 Compare November 2, 2026 14:30
SebastianM-C and others added 2 commits November 10, 2026 17:54
Since ModelingToolkit 11.44 records an `SCCNonlinearProblem` lowering on
`SteadyStateProblem`s, `NonlinearProblem(prob)` returns that lowering. The
steady-state default methods dispatched on `AbstractSteadyStateProblem`, an
alias of `AbstractNonlinearProblem`, so the `SCCNonlinearProblem` re-entered
them and `NonlinearProblem(::AbstractNonlinearProblem)` read its nonexistent
`u0`, breaking `solve(prob)` and `init(prob)` (SciML/ModelingToolkit.jl#5194).

- Dispatch the defaults on `SteadyStateProblem`.
- `__solve` hands an SCC lowering to its own `solve` (SCCNonlinearSolve).
- `__init` iterates on the unlowered residual, since an SCC problem has no
  single-residual cache.
- SCCNonlinearSolve maps the `NonlinearVerbosity` that `solve` fills in to its
  `linear_verbosity` and drops the `NonlinearAliasSpecifier` before solving
  `LinearProblem` blocks, which LinearSolve rejected.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Narrowing the no-algorithm `__init`/`__solve` from `AbstractSteadyStateProblem`
to `SteadyStateProblem` dropped `ImmutableNonlinearProblem`, which has no
default of its own and relied on that catch-all. Dispatch on
`Union{SteadyStateProblem, ImmutableNonlinearProblem}` instead and add a
regression test for `solve`/`init` with and without `nothing`.

Also trim the comments added in the previous commit.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@SebastianM-C
SebastianM-C force-pushed the smc/steadystate-scc-default branch from d92d732 to 2f89e68 Compare November 10, 2026 15:55
@SebastianM-C

Copy link
Copy Markdown
Member Author

Thanks for the review. On the CI triage (P3): I rebased onto current master (6b33892). The head is now 2f89e68, and the code changes are the same as the f3e6f86 you reviewed. On the new head, 70 checks pass and 5 fail. Each of the 5 also fails on master:

  • Adjoint (all 4 jobs) and downgrade lib/NonlinearSolveFirstOrder now pass.
  • SCCNonlinearSolve Core (Julia 1, lts) fails one check, core_tests__item4.jl:100 (isconcretetype(eltype(scc_sol_debug.original)) in "Vector-form SCCNonlinearProblem with FunctionWrappers"). This PR doesn't change that test file. The same check fails without this PR on master Sublibrary CI runs 41620405945 (d254af9) and 41318239202 (fb66652), and passes on other master runs, so it's intermittent on master.
  • CUDA fails the @test_nowarn check in the GeneralizedFirstOrderAlgorithm testset. The latest master run 42570345416 (6b33892) fails the same check.
  • Documentation and downgrade lib/NonlinearSolveHomotopyContinuation both fail because TaylorDiff v0.3.5 doesn't precompile (TypeError: non-boolean (Symbolics.Num) used in boolean context). The master runs on 6b33892 fail the same way (Documentation, Downgrade Sublibraries).

Posted by Claude Code (claude-opus-5-5) on behalf of Sebastian.

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

PR: #1319

Reviewed head: 2f89e68
Raw SHA-256: d5700a52c57bcc93f9343f46ddd53f56cd386a1fb606e6399f147845670a9eb8
Source SHA-256: e2df80687c0f4910d461280ddd8c168d8710d818990c86d677f16c188d38d554
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1ffb7-a0d3-7690-baa7-4b8a0de0a060
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: high (H1)
  • Verdict: CHANGES
  • Reviewed head: 2f89e68

Review report

VERDICT: CHANGES
Round: 1
Head: 2f89e68
Slot: 1
CI: CI is not green (regress:Documentation / Build and Deploy Documentation; downgrade-sublibraries / test (lib/NonlinearSolveHomotopyContinuation))
Session: 01a1ffb7-a0d3-7690-baa7-4b8a0de0a060
Reviewer: codex-cli 0.170.0; model: gpt-6.2-sol

Risk

high (H1: default solve and init reject previously supported implementations of the public AbstractSteadyStateProblem interface)

Blocking findings

  • Blocking priorities: P1, P1
  • [P1] src/default.jl:69 — Cache initialization can return a root outside the SCC lowering's bounds. I used the same equation, u[1]^2 - 1 = 0, in the steady-state residual and in an SCC block with bounds [0.25, 2] and initial guess -0.5. On the reviewed head, solve(prob) returned approximately +1 with Success, while solve!(init(prob)) returned approximately -1 with Success. The new test at test/Core/default_alg_tests__item1.jl:114 supplies a one-element SCC to a two-element steady-state problem and checks only the unlowered answer. Preserve the lowering in the cache interface or report that SCC cache initialization is unsupported. Add a regression test in which both entry points must honor the same constraints.
  • [P1] src/default.jl:61 — Narrowing conversion dispatch breaks user-defined steady-state problems. I defined an AbstractSteadyStateProblem subtype with a residual u .- p and a method on the documented NonlinearSolveBase.get_concrete_problem hook. On origin/master, solve(prob), solve(prob, nothing), solve!(init(prob)), and solve!(init(prob, nothing)) all returned [3.0] with Success. On the reviewed head, the four calls threw NoDefaultAlgorithmError or NonSolverError, even though solve(NonlinearProblem(prob)) still returned [3.0]. Preserve default conversion for compatible subtypes and handle the SCC conversion result explicitly.

Non-blocking findings

  • lib/SCCNonlinearSolve/test/core_tests__item4.jl:100 — The concrete solution element-type assertion failed on the head and on origin/master (12 passed, 1 failed in that testset). The vector branch at lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl:150 supplies ten type parameters. A Julia probe showed that they form a concrete type on SciMLBase 3.55.0 and a nonconcrete type on 3.57.0 and 3.58.0, which have an additional return-code parameter. Derive the element type from the stripped solution in a separate fix.
  • lib/NonlinearSolveBase/src/solve.jl:219 — On both revisions, solve(prob, NewtonRaphson()) on an SCC-lowered steady-state problem failed with a missing SCC u0 field. The matching explicit cache call failed with a residual arity error. Route explicit nonlinear algorithms through the SCC block solver if this interface is extended to support them.

What I ran

  • GROUP=Core JULIA_PKG_PRECOMPILE_AUTO=0 julia --project -e 'using Pkg; Pkg.instantiate(); Pkg.test()' using Julia 1.12.4, SciMLBase 3.58.0, and LinearSolve 5.18.3. Root Core passed the default-algorithm testset (34/34) and printed 69 testset summaries with zero failures and 91 assertions marked Broken in unchanged test files. I stopped the process after one hour and confirmed it exited with TERM before a group result. SCC Core exited 1 on both revisions at the concrete element-type assertion.
  • Using the resolved test environment, I ran the changed test files directly with Julia include. The default-algorithm file passed 34/34 and the new SCC file passed 8/8. The three SCC test files between the failing testset and the new test passed 39/39 when run separately.
  • Ran julia --startup-file=no --project=. ../probe.jl and julia --startup-file=no --project=. ../custom_problem.jl in both source snapshots, loading the matching local SCC library for the mixed-block probe. The base threw FieldError for nonlinear alias settings on both tuple and vector SCCs and for missing SCC u0 on the default steady-state solve. The head returned [1.0, 0.25] with zero residuals in these cases. Genuine linear alias and verbosity settings returned [0.25] on both revisions. The same probes reproduced both blockers above.
  • git diff --check origin/master...HEAD, Runic --check, and typos on the changed files exited 0.
  • uv run --locked python --version printed Python 3.13.13. There is no uv.lock, and uv reported that --locked had no effect outside a Python project.

What I did not verify

  • The remainder of root Core after the time limit, the documentation build, and the minimum-compatibility HomotopyContinuation CI job.

AUTHOR_GRADE: {"task": "bugfix", "score": 2, "difficulty": 3, "rounds": 1, "author_harness": "unknown", "author_model": "unknown", "note": "The intended one-shot solve and mixed-block keyword fixes reproduce, but cached initialization can violate the supplied lowering and default dispatch regresses custom steady-state problems."}

Head link: 2f89e68


🤖 Posted by an AI agent — harness: codex-cli 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a1ffb7-a0d3-7690-baa7-4b8a0de0a060 (no session URL)

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

PR: #1319

Reviewed head: 2f89e68
Raw SHA-256: 59ce73ffaa0e6b0f74b4cf371f845142030c3b1ac0ea3ac76f854cb4b10ca3af
Source SHA-256: 2350624e8c0831e58d62e3d1c2311750c8c1afa94ccfba6f4789a79fe307e98b
Source: standard-review-v1 (harness-log)
Reviewer session: 01a215d3-54d5-7bd1-a3cf-f31924104030
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: high (H1)
  • Verdict: CHANGES
  • Reviewed head: 2f89e68

Review report

VERDICT: CHANGES
Round: 2
Head: 2f89e68
Slot: 1
CI: CI unreadable; review only; merge gates unchanged
Session: 01a215d3-54d5-7bd1-a3cf-f31924104030
Reviewer: codex-cli 0.170.0; model: gpt-6.2-sol

Risk

high (H1: the narrower default dispatch rejects previously working nonlinear problem wrappers using the public concretization interface)

Blocking findings

  • Blocking priorities: P1, P1

  • [P1] src/default.jl:69 discards the SCC lowering for cached solves and can return the wrong state with Success. I used the steady-state residual (2.0^60 + u[1]) - (2.0^60 + p) with u0 = [0.0], p = 4.0, and the algebraically equivalent SCC block u[1] - p. Direct solve returned Success at [4.0]. Both solve!(init(prob)) and solve!(init(prob, nothing)) returned Success at [0.0] with a zero reported residual. A second probe used two blocks for x = 4 and y = sqrt(x), starting at [-1.0, 0.0]. Direct solve returned [4.0, 2.0] with zero residual, and init(prob) raised DomainError. The fixture at test/Core/default_alg_tests__item1.jl:114 supplies a one-state lowering for a two-state model and asserts the result of the unlowered system.

    Implementation fix

    Route the SCC branch of SciMLBase.__init through an SCC cache entry point in lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl. A minimal cache can retain the lowered problem and solver options and delegate solve! to the existing ordered block solve. An explicit unsupported-cache error is also a valid design if SCC caching is deferred. Prefer the cache to support the two default init forms exercised by this PR. Replace the mismatched root fixture with equivalent lowerings in lib/SCCNonlinearSolve/test/core_tests__item8.jl. Assert success, the analytic state, and the independently evaluated lowered residual for direct solve and both cache forms on the cancellation and domain cases. Document the supported cache operations in docs/src/basics/nonlinear_problem.md.

  • [P1] src/default.jl:61 limits default conversion to two concrete types and breaks other AbstractNonlinearProblem wrappers. I defined a wrapper with f, u0, p, and kwargs, and implemented the public NonlinearSolveBase.get_concrete_problem hook to return the concretized wrapper. For the equation u^2 = 4 starting at [1.0], the merge base returned Success and u ≈ [2.0] for solve(prob), solve(prob, nothing), and both init forms followed by solve!. The reviewed head raises NonSolverError for solve(prob, nothing) and NoDefaultAlgorithmError for the other three.

    Implementation fix

    Restore abstract conversion fallback in both SciMLBase.__solve and SciMLBase.__init in src/default.jl. Handle SCC input or an SCC conversion result before forwarding to the generic conversion path, so the SCC dispatch cannot re-enter the fallback. Add the wrapper to test/Core/default_alg_tests__item1.jl and assert success and the analytic root for all four default calls. Exercise the SCC route in the SCC Core regressions and retain the immutable problem test.

Non-blocking findings

  • test/Core/default_alg_tests__item1.jl:111 and lib/SCCNonlinearSolve/test/core_tests__item8.jl:23 put the task's issue reference in compatibility comments. Replace both comment lines with # SCC lowering requires SciMLBase 3.55 or newer.

What I ran

  • Reviewed git diff origin/master...HEAD and git diff HEAD^..HEAD. The supplied delta.diff was empty. The rename-aware path audit covered five solver source and test paths, with zero renames and zero H6 paths. git diff --check and Julia Runic's --check passed.
  • Ran GROUP=Core julia --startup-file=no --project=<archived project> -e 'using Pkg; Pkg.test(; allow_reresolve=true)' for the root and SCC projects on Julia 1.12.4 with SciMLBase 3.58.0 and LinearSolve 5.19.0. SCC Core stopped at lib/SCCNonlinearSolve/test/core_tests__item4.jl:100, with 12 passes and one failure in that item. The same assertion failed on origin/master. On unchanged master, the item passed 13/13 with SciMLBase 3.56.1 and failed 1/13 with 3.57.0. The added NonlinearSolution type parameter leaves SCC's hardcoded vector element type nonconcrete.
  • Stopped standard root Core after an hour. A process stack showed LLVM optimization, and termination identified test/Core/homotopy_effort_tests__item2.jl:67. Retried the same group with julia_args set to -O0 --compiled-modules=existing --pkgimages=existing. It stopped at the Broyden Watson case with 93 passes, one unexpected-pass error, and 21 broken assertions in that item. The same result reproduced on origin/master at -O0. An independent Watson residual evaluation on master gave 1.45e-14 at -O0 and 3.83 at -O2.
  • Ran the two changed test files individually with SafeTestsets at -O0. The root default-algorithm file passed 34/34 and the SCC file passed 8/8. Targeted probes on the same dependency versions confirmed direct SCC solve, linear-block keyword adaptation, and callable lowering with parameter overrides for tuple and vector storage. The merge base threw field errors for the mixed steady-state solve and nonlinear alias probe. ImmutableNonlinearProblem passed all four default calls at the merge base and reviewed head, and failed all four at the immediately preceding PR commit. The cancellation and domain probes produced two failed assertions and one error respectively at the reviewed head.
  • uv run --locked python --version printed Python 3.13.13. uv reported that --locked had no effect outside a Python project.

What I did not verify

A complete pass of the root and SCC Core groups, other Julia versions, or a ModelingToolkit-generated lowering.

AUTHOR_GRADE: {"task":"bugfix","score":2,"difficulty":3,"rounds":2,"author_harness":"unknown","author_model":"unknown","note":"Direct SCC routing and keyword adaptation work, and the last commit restores the immutable case. Cached solves can report success at the wrong state, and formerly working wrappers lose default solve and init."}

REVIEWER_GRADE: {"task": "bugfix", "score": 5, "rounds": 2, "reviewer_harness": "codex", "reviewer_model": "gpt-6.2-sol", "verdict": "agree", "note": "Both P1 findings match. The earlier bounded-root probe exposed the discarded SCC lowering, and its custom steady-state problem reproduced the default dispatch regression on all four calls."}

Head link: 2f89e68


🤖 Posted by an AI agent — harness: codex-cli 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a215d3-54d5-7bd1-a3cf-f31924104030 (no session URL)

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

PR: #1319

Reviewed head: 2f89e68
Raw SHA-256: f6515983b3abb01dd0914c2f101afe311e875b092473dfc6b9ade8e0f9226210
Source SHA-256: 4cd25f7f733ce0b0b2e2e0826375348898ee3f8b84f6c39ca00997b69283a468
Source: standard-review-v1 (harness-log)
Reviewer session: 01a21e75-e1b1-7af0-bf4d-cc38bfc57e47
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: high (H2)
  • Verdict: CHANGES
  • Reviewed head: 2f89e68

Review report

VERDICT: CHANGES
Round: 3
Head: 2f89e68
Slot: 1
CI: CI unreadable; review only; merge gates unchanged
Session: 01a21e75-e1b1-7af0-bf4d-cc38bfc57e47
Reviewer: codex-cli 0.170.0; model: gpt-6.2-sol

Risk

high (H2: default SCC-lowered steady-state paths can report success for stale inputs or on the wrong continuation branch)

Blocking findings

  • Blocking priorities: P1, P1
  1. [P1] src/default.jl:78 — Default solve uses stale parameters and initial guesses from the SCC lowering. For a steady-state residual u[1] - p built and lowered at p=1.0, both default call forms with p=3.0 returned u=[1.0], Success and reported residual [0.0]. Evaluating the requested equation independently gave [-2.0]. For u[1]^2 - 1 built and lowered from [-3.0], both call forms with u0=[3.0] returned [-1.0]. The equivalent single-residual control returned [1.0].

    Implementation fix — Preserve both overrides through solve_up and get_concrete_problem(::SteadyStateProblem) in lib/NonlinearSolveBase/src/solve.jl. In the SCC arm of SciMLBase.__solve in src/default.jl, dispatch only to blocks prepared with those inputs. Use the model's symbolic update hook where it can update the block mapping. For generic lowerings without a mapping, raise an actionable ArgumentError asking the caller to rebuild the lowering with the requested inputs. Passing keywords to the SCC entry point alone leaves its block inputs intact. In lib/SCCNonlinearSolve/test/core_tests__item8.jl, exercise omitted and explicit nothing with each override. Check the residual at the requested parameter and the positive root for the supplied positive guess, or the explicit error on an unsupported mapping. Cover an unmodified solve of the same fixture and document the override behavior in docs/src/basics/solve.md.

  2. [P1] src/default.jl:69 — Cached initialization bypasses SCC continuation and reports success on the opposite branch. I started both representations at [-3.0, 1.5] with a homotopy block whose first coordinate has the regular root x=1 throughout the sweep. Direct SCC solve and both default steady-state solve forms returned [1.0, 2.0]. Both solve!(init(prob)) forms returned [-1.0, 2.0] with Success and zero residual. The added Core cache test requires a full-residual solve and cannot catch the loss of branch selection.

    Implementation fix — In SciMLBase.__init in src/default.jl, use an SCC cache that preserves each block's solver and initialization, or raise a targeted unsupported-cache error directing callers to solve(prob). I recommend the explicit error until SCC cache semantics are available for solve!, step! and reinit!. Update test/Core/default_alg_tests__item1.jl to cover both default init spellings. Add the branch-selecting fixture to lib/SCCNonlinearSolve/test/core_tests__item8.jl and require the analytically known positive branch on supported paths. Document the cached interface in docs/src/basics/solve.md.

Non-blocking findings

  • src/default.jl:80 — With only NonlinearSolve and SciMLBase loaded, a valid SCC-lowered steady-state problem reached the generic solver and raised FieldError: type SCCNonlinearProblem has no field kwargs.

    Implementation fix — Add a fallback for SCC problems in lib/NonlinearSolveBase/src/solve.jl that is less specific than the methods in lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl and raises an error with the message “Load SCCNonlinearSolve to solve a SteadyStateProblem with SCC lowering.” Check the diagnostic in a fresh process without SCCNonlinearSolve and retain the existing successful solve test with it loaded.

What I ran

  • git diff --name-status -M origin/master...HEAD and git diff --check origin/master...HEAD. The supplied delta.diff was 0 bytes. The full diff changes five solver/test paths with no renames or H6 paths.
  • uv run --locked python --version printed Python 3.13.13 and warned that --locked has no effect outside a project. The checkout has no uv.lock. Julia tests used Julia 1.12.4, the repository's Pkg test environments and the inherited depot. The main resolve used SciMLBase 3.58.0 and LinearSolve 5.19.0.
  • GROUP=Core julia --startup-file=no --project=. -e 'using Pkg; Pkg.test()' exited 0 with Testing NonlinearSolve tests passed. The changed default-algorithm test set passed 34/34. Running that file against merge-base code yielded 30 passes and one error, FieldError for missing SCC u0.
  • GROUP=SCCNonlinearSolve julia --startup-file=no --project=. -e 'using Pkg; Pkg.test()' stopped on the same assertion on the head and merge base, isconcretetype(eltype(scc_sol_debug.original)) at lib/SCCNonlinearSolve/test/core_tests__item4.jl:100. I reproduced it on origin/master as well. Including all SCC Core items under one enclosing test set yielded 82 passes and that one failure. The new SCC test file on its own passed 8/8 on the head and reported two errors on merge-base code, missing alias_A and missing u0.
  • The baseline investigation ran the unchanged master assertion with LineSearch 0.1.19 held constant. It passed 13/13 with SciMLBase 3.55.0 and had 12 passes and one failure with 3.57.0. A Julia type probe showed the hard-coded ten-parameter specialization becoming abstract when SciMLBase added the return-code type parameter.
  • Ran probe.jl on the head and merge base with SCCNonlinearSolve loaded, and on the head without it. Ran override_probe.jl on the head. The outputs reproduced the branch-selection, override and missing-solver diagnostics above. The mixed linear/nonlinear fixture with nonlinear verbosity and alias options changed from an alias_A error on the merge base to [1.0, 0.25] with Success on the head.

What I did not verify

  • ModelingToolkit-generated lowerings and their symbolic update hooks, downstream sensitivity tests, and other supported Julia versions.
  • The exact upstream commit that introduced the baseline SCC type-layout incompatibility.

AUTHOR_GRADE: {"task":"bugfix","score":2,"difficulty":3,"rounds":3,"author_harness":"unknown","author_model":"unknown","note":"The authored SCC regressions fail before and pass after, but the new default paths silently discard solver overrides or select the opposite continuation branch."}

REVIEWER_GRADE: {"task": "bugfix", "score": 4, "rounds": 3, "reviewer_harness": "codex", "reviewer_model": "gpt-6.2-sol", "verdict": "missed", "note": "The cancellation probe correctly showed that cached initialization discards SCC lowering, and the wrapper probe documented a separate dispatch regression. The callable-lowering probe missed the P1 on prebuilt blocks: solving with p=3 returned the root for p=1 with residual -2 at the requested parameter, and overriding u0 selected the wrong root."}

Head link: 2f89e68


🤖 Posted by an AI agent — harness: codex-cli 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a21e75-e1b1-7af0-bf4d-cc38bfc57e47 (no session URL)

This branch has not been deployed

No deployments
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.

Fails to solve SteadyStateProblem

3 participants