Repository navigation
SCCNonlinearSolve: continue HomotopyProblem blocks with the block algorithm as inner corrector - #1104
Merged
ChrisRackauckas merged 1 commit intoJul 23, 2026
Conversation
…orithm as inner corrector Route a `HomotopyProblem` block of an `SCCNonlinearProblem` through continuation (`HomotopyPolyAlgorithm`) instead of solving it at the target λ, threading the SCC's nonlinear algorithm in as the inner corrector so its autodiff / linear-solver choices are honored per block. - NonlinearSolveBase: add `HomotopyPolyAlgorithm(; inner = nothing)` threading a shared inner algorithm into both default stages (2.36 -> 2.37). - SCCNonlinearSolve: route homotopy blocks in `solve_single_scc`; add the NonlinearSolveBase dep; cover it in core_tests__item5.jl (1.13.3 -> 1.14.0). Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GSXiS4u4BaR2RvGFWGEQeH
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/OrdinaryDiffEq.jl
that referenced
this pull request
Jul 22, 2026
…w-up The SCC homotopy `default_nlsolve` methods return `nothing` (each block picks its own default) so homotopy blocks continue on the correct branch, at the cost of the continuation using its default inner corrector instead of the requested AD backend. SciML#1104 adds the SCCNonlinearSolve per-block routing that makes returning `FastShortcutNonlinearPolyalg(; autodiff)` here honor autodiff per block; the NOTE now points at it as the concrete follow-up. Comment-only; no behavior change. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GSXiS4u4BaR2RvGFWGEQeH
ChrisRackauckas
marked this pull request as ready for review
July 23, 2026 07:17
ChrisRackauckas
added a commit
that referenced
this pull request
Jul 23, 2026
…ntinuation default (#1105) `FastShortcutHomotopyPolyalg` is the homotopy analogue of `FastShortcutNonlinearPolyalg`: a `HomotopyPolyAlgorithm` (fast `HomotopySweep`, then robust `ArcLengthContinuation`) whose inner corrector is a `FastShortcutNonlinearPolyalg` built from the requested `autodiff`. It gives the previously hand-rolled default continuation polyalgorithm a discoverable name. Also wire it as the homotopy initialization default: `initialization_alg(::HomotopyProblem, autodiff)` now returns it, closing a gap where the `AbstractNonlinearProblem` fallback would hand a homotopy init system a plain nonlinear polyalgorithm that solves only the target-λ system (and can land on the wrong branch). - Defined in top-level src/poly_algs.jl, exported, docstring'd, added to docs. - Uses `HomotopyPolyAlgorithm(; inner)` from NonlinearSolveBase 2.37 (#1104); top-level compat bumped 2.36 -> 2.37. NonlinearSolve 4.22 -> 4.23. - Test: test/Core/homotopy_polyalg_tests__item4.jl (wiring, branch selection, init routing). Claude-Session: https://claude.ai/code/session_01GSXiS4u4BaR2RvGFWGEQeH Co-authored-by: ChrisRackauckas-Claude <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
ChrisRackauckas
added a commit
to SciML/OrdinaryDiffEq.jl
that referenced
this pull request
Jul 23, 2026
…lve → nothing) (#3989) * Initialize HomotopyProblem init systems by continuation, honoring autodiff The DAE-initialization OverrideInit path picks the nonlinear algorithm for the init problem via `default_nlsolve`. A `SciMLBase.HomotopyProblem` (built by ModelingToolkit when the init system carries Modelica `homotopy(actual, simplified)` operators) must be solved by continuation, not by a Newton polyalgorithm. `default_nlsolve` now returns a `HomotopyPolyAlgorithm` (sweep, then pseudo-arclength) for a `HomotopyProblem`, with the `autodiff` argument threaded into the continuation's *inner corrector* (`FastShortcutNonlinearPolyalg`) — the differentiation the sweep and the secant-predictor arclength stage actually use, and where a finite-diff initialization must avoid dual-numbering a residual that is not ForwardDiff-safe. (A high-level `autodiff` knob on `HomotopyPolyAlgorithm` itself cannot do this: it lives in NonlinearSolveBase, which cannot construct the concrete inner solver, so the AD rides on the inner algorithm here.) Handing a `HomotopyProblem` a plain Newton polyalgorithm instead — as the previous `AbstractNonlinearProblem` default did — solves only the target-λ system directly (see the companion `solve(::HomotopyProblem, ::AbstractNonlinearSolveAlgorithm)` in NonlinearSolve), which on branch selection returns a `Success` retcode on the wrong root (measured `-1.0` vs the physical `+1.0`). An `SCCNonlinearProblem` with `HomotopyProblem` blocks is solved with `nothing` so each block picks its own default (homotopy blocks continue, plain blocks Newton-solve). The `autodiff` signal cannot be threaded per block from here — `SCCNonlinearSolve` applies one algorithm to every block — so that is left to a follow-up (routing by block type in `SCCNonlinearSolve`); the code comment records this. Adds test/homotopy_default_nlsolve_tests.jl (including a ForwardDiff-hostile residual that only the finite-diff inner can solve, proving the AD is genuinely threaded). Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GSXiS4u4BaR2RvGFWGEQeH * Cite SciML/NonlinearSolve.jl#1104 as the per-block SCC autodiff follow-up The SCC homotopy `default_nlsolve` methods return `nothing` (each block picks its own default) so homotopy blocks continue on the correct branch, at the cost of the continuation using its default inner corrector instead of the requested AD backend. #1104 adds the SCCNonlinearSolve per-block routing that makes returning `FastShortcutNonlinearPolyalg(; autodiff)` here honor autodiff per block; the NOTE now points at it as the concrete follow-up. Comment-only; no behavior change. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GSXiS4u4BaR2RvGFWGEQeH * Note FastShortcutHomotopyPolyalg (#1105) as the _homotopy_init_alg collapse target _homotopy_init_alg hand-rolls exactly NonlinearSolve.FastShortcutHomotopyPolyalg(; autodiff) (SciML/NonlinearSolve.jl#1105). Once that releases, this body collapses to a call to it. Comment-only; no behavior change. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GSXiS4u4BaR2RvGFWGEQeH * Correct the homotopy-init follow-up notes: blocked on OrdinaryDiffEq LinearSolve-5 migration The SCC per-block-autodiff flip and the FastShortcutHomotopyPolyalg collapse both need NonlinearSolve 4.23 / SCCNonlinearSolve 1.14 / NonlinearSolveBase 2.37, which require LinearSolve 5. OrdinaryDiffEq is capped at LinearSolve "3.75.0, 4" (pinned to NonlinearSolve <= 4.21), so the follow-ups are blocked on the LinearSolve-5 migration, not merely on those packages being released (they are). The SCC flip additionally needs a direct SCCNonlinearSolve dependency (it is a reverse dep of NonlinearSolve). Notes updated to say so. Comment-only; no behavior change. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GSXiS4u4BaR2RvGFWGEQeH --------- Co-authored-by: ChrisRackauckas-Claude <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
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.
What
Route a
HomotopyProblemblock of anSCCNonlinearProblemthrough continuation instead of solving it directly at the targetλ, and thread the SCC's own nonlinear algorithm in as the continuation's inner corrector so its autodiff / linear-solver choices are honored per block.Two coordinated pieces in this monorepo:
NonlinearSolveBase — add a
HomotopyPolyAlgorithm(; inner = nothing, ...)convenience constructor that threads a shared inner algorithm into both default stages (HomotopySweepandArcLengthContinuation).inner === nothingkeeps each stage's own default. (2.36.0 → 2.37.0, additive API, docstring updated.)SCCNonlinearSolve — in
solve_single_scc, when a blockprob isa HomotopyProblem, solve it withHomotopyPolyAlgorithm(; inner = alg.nlalg)rather thanalg.nlalgdirectly. (1.13.3 → 1.14.0, gains aNonlinearSolveBasedep.)Why
solve(::HomotopyProblem, ::AbstractNonlinearSolveAlgorithm)(#1085) makes a standard nonlinear algorithm solve the block's target-λ system by fixingλ = λspan[2]. That is the right default for a bareHomotopyProblem, but it is not what a Modelicahomotopy(actual, simplified)operator asks for: the whole point of the operator is to be continued from thesimplifiedanchor to theactualsystem so initialization lands on the physical branch. When such a block sits inside anSCCNonlinearProblem(ModelingToolkit now emits homotopy blocks per-SCC, SciML/ModelingToolkit.jl#4766), the SCC solver was handing it straight to the block algorithm — silently solving the target system and, on any multi-branch residual, potentially converging to the wrong root.Routing the block through
HomotopyPolyAlgorithmrestores continuation. Passingalg.nlalgas the inner corrector keeps the per-block algorithm choice (crucially its autodiff backend) intact — an OverrideInit / SCC init that selected finite differencing for a ForwardDiff-hostile residual still finite-differences inside the continuation.Test
test/core_tests__item5.jl(registered incore_tests.jl):(1-λ)·2(m-1) + λ·(m²-1): the target (λ=1) systemm²-1has roots±1; from guessm=-3a direct Newton solve lands on the unphysical-1(asserted as a control), while continuation from the simplified2(m-1)(anchored at+1) reaches the physical+1. The SCC solve returns+1, so the block must have been continued. A neighboring plain block is unaffected.badf(::Float64)computes,badf(::Any)throws) is solved when the SCC algorithm carriesAutoFiniteDiff()and throws underAutoForwardDiff()— confirming the block algorithm's AD reaches the continuation's inner corrector.Verified locally against the fresh monorepo (
LinearSolve 5): item5 green (control + 4 assertions), and the pre-existing SCC suite (items 1–4) still passes.Coordination
default_nlsolveinit methods can return a standardFastShortcutNonlinearPolyalg(; autodiff)and rely on this per-block routing to continue homotopy blocks with that autodiff, instead of falling back tonothing.Please ignore until reviewed by @ChrisRackauckas. Opened as a draft.
🤖 Generated with Claude Code