Skip to content

Fix conditioning for OOP no-init nonlinear solves - #4438

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix/oop-noinit-cache-semantics
Aug 31, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix/oop-noinit-cache-semantics

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Aug 30, 2026 •

Copy link
Copy Markdown
Member

Important

Please ignore this PR until it has been reviewed by @ChrisRackauckas.

What changed

This is a focused follow-up to the now-merged #3798. It keeps out-of-place W reuse for unconditioned SimpleNonlinearSolve no-init solvers while preserving conditioning semantics:

  • the complete no-init solve now receives supported postcondition data;
  • a preconditioned residual no longer reuses the raw residual's StaticWOperator;
  • regression tests cover both paths alongside the existing no-init allocation and nested-AD coverage.

precondition itself remains embedded in the NonlinearProblem through PreconditionWrapper; the bug was specifically that W reuse supplied a Jacobian for the untransformed residual. Generic traced algorithms continue to use the no-init fallback, so this does not make ReverseDiffAdjoint depend on a mutating inner cache.

Regression evidence

I checked both focused probes against the unfixed stacked parent commit ChrisRackauckas-Claude@9b6517a90.

The postcondition probe defines a no-init algorithm with supports_postcondition(::NoInitPostconditionProbe) = true, records whether postcondition reaches SciMLBase.__solve, and asserts the record after an ImplicitEuler solve. With Julia 1.12.7, --compiled-modules=no, and an isolated local test environment, the unfixed code produced:

Test Failed at none:19
  Expression: seen[]
ERROR: There was an error during testing
EXIT_CODE=1

The static out-of-place probe used this assertion sequence:

static_prob = ODEProblem((u, p, t) -> -u, SVector(1.0), (0.0, 1.0))
inner = SimpleNewtonRaphson(autodiff = AutoFiniteDiff())
static_plain = init(
    static_prob, ImplicitEuler(nlsolve = NSA(inner), concrete_jac = true); dt = 0.1
)
@test static_plain.cache.nlsolver.cache.W isa Ref
static_cond = init(
    static_prob,
    ImplicitEuler(
        nlsolve = NSA(inner; precondition = (fu, u, p) -> 2fu), concrete_jac = true
    );
    dt = 0.1
)
@test static_cond.cache.nlsolver.cache.W === nothing

The unfixed code produced:

Test Failed at none:10
  Expression: static_cond.cache.nlsolver.cache.W === nothing
   Evaluated: Base.RefValue{SMatrix{1, 1, Float64, 1}}([-1.0;;]) === nothing
ERROR: There was an error during testing
EXIT_CODE=1

With the final fix commit ChrisRackauckas-Claude@35685f9 applied, the combined probes completed with exit code 0:

focused OOP no-init conditioning probes passed

Verification

Formatting, additions-only spelling, and diff checks:

~/.julia/packages/Runic/rL5ii/bin/runic --check \
  lib/OrdinaryDiffEqNonlinearSolve/src/newton.jl \
  lib/OrdinaryDiffEqNonlinearSolve/src/utils.jl \
  lib/OrdinaryDiffEqNonlinearSolve/test/nsa_conditioning_tests.jl
git diff origin/master...HEAD --no-ext-diff --unified=0 | \
  sed -n '/^+/ { /^+++/d; s/^+//; p; }' | typos -
git diff origin/master...HEAD --check

All completed successfully with no findings.

QA group:

QA_DEPOT="$PWD/.qa-depot-codex-rebase2-01a04fd1"
JULIA_DEPOT_PATH="$QA_DEPOT:$HOME/.julia" TMPDIR="$HOME/tmp" GROUP=QA \
  ~/.juliaup/bin/julia +1.12 --project=lib/OrdinaryDiffEqNonlinearSolve \
  -e 'using Pkg; Pkg.test()'
JET: 13 passed, 33 expected broken, 46 total
Aqua: 41 passed, 41 total
Testing OrdinaryDiffEqNonlinearSolve tests passed

Core group:

CORE_DEPOT="$PWD/.core-depot-codex-rebase2-01a04fd1"
JULIA_DEPOT_PATH="$CORE_DEPOT:$HOME/.julia" TMPDIR="$HOME/tmp" GROUP=Core \
  ~/.juliaup/bin/julia +1.12 --project=lib/OrdinaryDiffEqNonlinearSolve \
  -e 'using Pkg; Pkg.test()'
Linear Nonlinear Solver Tests: 56 passed, 56 total
Nested AD over NonlinearSolveAlg: 5 passed, 5 total
NonlinearSolveAlg No-Init Inner Solver Tests: 102 passed, 102 total
NonlinearSolveAlg Preconditioning Tests: 74 passed, 74 total
Testing OrdinaryDiffEqNonlinearSolve tests passed

The full Core group passed, including every remaining declared Core testset. Master advanced afterward by one commit that only formats two OrdinaryDiffEqDifferentiation test files; I inspected that delta, rebased onto it, then reran Runic, typos, the diff check, and both focused probes on the exact final tree.

Not verified

  • GROUP=Everything was not run.
  • GPU-specific groups were not run locally.
  • The docs build was not run because this changes no public API, docstrings, or documentation.

Reviewer note

conditioning_kwargs(cache) intentionally forwards only conditioning supported by the selected inner algorithm. Its unconditioned result remains the specialized empty named tuple, preserving the allocation behavior added by the parent PR.

🤖 Generated with Codex 0.151.0 (model: gpt-5; session: local session ID 01a04fd1-292a-7cf3-b2e1-c6924b2a96c9).

@ChrisRackauckas-Claude
ChrisRackauckas-Claude force-pushed the fix/oop-noinit-cache-semantics branch from 107eb1c to fb1da72 Compare August 31, 2026 02:58
Forward supported postconditions into complete no-init inner solves and avoid reusing a raw-residual W operator for preconditioned residuals.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: OpenAI Codex <[email protected]>
Agent-Harness: Codex 0.151.0
Agent-Model: gpt-5
Agent-Session: local session ID 01a04fd1-292a-7cf3-b2e1-c6924b2a96c9
@ChrisRackauckas-Claude
ChrisRackauckas-Claude force-pushed the fix/oop-noinit-cache-semantics branch from fb1da72 to 35685f9 Compare August 31, 2026 06:05
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review August 31, 2026 18:31
@ChrisRackauckas
ChrisRackauckas merged commit 1d26fdf into SciML:master Aug 31, 2026
174 of 175 checks passed
ChrisRackauckas added a commit that referenced this pull request Sep 7, 2026
- Fix SciMLBase reexport QA on Julia LTS (#4450)
- Preserve conditioning in OOP no-init solves (#4438)
- Read the test group from GROUP like the CI passes it (#4447)
- Raise root GPU test timeout (#4449)
- Fix default SDE dt vector lengths (#4454)
- Bump DiffEqDevTools to 3.6.2 (#4461)
- DiffEqBase: wrap mass-matrix problems on the finite-difference promote_f path (#4459)
- Preserve the DAE step start during callback interpolation (#4466)
- Release DiffEqBase 7.20.1 (#4474)
- Release OrdinaryDiffEqCore 4.16.1 (#4475)



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 referenced this pull request Sep 7, 2026
* Resolve symbolic idxs in the integrator interpolant

`integrator(t; idxs = sym)` passed `idxs` straight to the dense-output
interpolant, which only accepts integer component indices, so any symbolic index
threw `ArgumentError: invalid index` and an observed equation could never be
retrieved. `sol(t; idxs = sym)` has resolved both for a long time.

Symbolic `idxs` now route to `SciMLBase.symbolic_interpolation`, which evaluates
the current step's interpolant and applies the symbolic getter to it. Integer,
`nothing`, and in-place calls are unchanged.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019wKpyZHy9u4QhR4ePiVmam

* Route symbolic idxs for DelayDiffEq integrators too

`DDEIntegrator` has the same gap `ODEIntegrator` did: `integrator(t; idxs = sym)`
went straight to the dense-output interpolant, which only accepts integer
component indices, so symbolic indexes threw and observed equations were
unreachable.

The predicate moves to the public `SciMLBase.has_symbolic_idxs` rather than
staying an OrdinaryDiffEqCore internal, since DelayDiffEq, Sundials and
ODEInterfaceDiffEq all need the same decision.

`HistoryODEIntegrator` is deliberately left alone: it implements none of the
`SymbolicIndexingInterface` methods a `DEIntegrator` needs, so symbolic indexing
against it is unsupported before and after this change.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019wKpyZHy9u4QhR4ePiVmam

* Require SciMLBase 3.53 for has_symbolic_idxs

`has_symbolic_idxs` did not make it into the 3.52.0 release, so the floor moves
to the version that carries it.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019wKpyZHy9u4QhR4ePiVmam

---------

Co-authored-by: ChrisRackauckas-Claude <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
ChrisRackauckas added a commit that referenced this pull request Sep 11, 2026
- Preserve conditioning in OOP no-init solves (#4438)
- Read the test group from GROUP like the CI passes it (#4447)
- Raise root GPU test timeout (#4449)
- Fix default SDE dt vector lengths (#4454)
- Bump DiffEqDevTools to 3.6.2 (#4461)
- DiffEqBase: wrap mass-matrix problems on the finite-difference promote_f path (#4459)
- Preserve the DAE step start during callback interpolation (#4466)
- Release DiffEqBase 7.20.1 (#4474)
- Release OrdinaryDiffEqCore 4.16.1 (#4475)
- Release OrdinaryDiffEqNonlinearSolve 2.9.5 (#4476)



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 that referenced this pull request Sep 11, 2026
- Add serial SDC solver family (OrdinaryDiffEqSDC) (#4208)
- Give each threaded complex stage its own JVP operator (#4430)
- Fix the adaptive error estimates of MRIGARKERK22a and MIS (#4232)
- Skip sparsity prep for matrix-free jac_prototype operators (#4445)
- Format differentiation tests (#4446)
- Fix SciMLBase reexport QA on Julia LTS (#4450)
- Preserve conditioning in OOP no-init solves (#4438)
- Read the test group from GROUP like the CI passes it (#4447)
- Raise root GPU test timeout (#4449)
- Fix default SDE dt vector lengths (#4454)



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