Skip to content

[bot] ImplicitDiscreteSolve: run the nonlinear solve at the integrator's tolerances - #4468

Merged
ChrisRackauckas merged 1 commit into
masterfrom
idsolve-forward-tolerances
Sep 7, 2026
Merged

ChrisRackauckas merged 1 commit into
masterfrom
idsolve-forward-tolerances

Conversation

@ChrisRackauckas

Copy link
Copy Markdown
Member

🚧 Filed by an AI agent running as @ChrisRackauckas — Chris has not reviewed this PR. Please ignore it until reviewed by @ChrisRackauckas.
Harness: Claude Code 2.1.260 · Model: claude-opus-5[1m]
Conversation: https://claude.ai/code/session_01UBTNFZ4A8Ciw27TmVHkpRD

What and why

IDSolve never passes a tolerance into its nonlinear solve: alg_cache builds the cache with
init(prob, alg.nlsolve), so NewtonRaphson always terminates against NonlinearSolve's default
Float64 abstol = 3e-13, whatever the caller asked init/solve for. (alg_cache is handed
reltol and ignores it; abstol never reaches it at all, and the cache is built before the
integrator exists.)

That default is unreachable for any residual whose terms are large: the floor is
eps * magnitude, so terms of magnitude 1e7 floor the residual at ~1e-9 and the Newton stalls
(ReturnCode.Stalled) on a problem that is solvable to any tolerance a caller would actually ask
for. Downstream this surfaces as ModelingToolkit throwing UnsolvableCallbackError for a
perfectly solvable symbolic affect — SciML/ModelingToolkit.jl#5079.

This forwards the tolerances the integrator was initialized with into the nonlinear solve, at
both call sites (perform_step! and the DefaultInit path of _initialize_dae!). An
ImplicitDiscreteProblem with no tolerance supplied keeps false in integrator.opts, which
maps to nothing and leaves NonlinearSolve's default in place, so nothing changes unless a
tolerance is actually given.

Verification

ImplicitDiscreteSolve test suite (GROUP=Core), aarch64 Linux, Julia 1.10.12.

Before (git stash push lib/ImplicitDiscreteSolve/src/solve.jl, new test only, rest of the
suite unchanged):

Nonlinear solve runs at the integrator's tolerances: Test Failed at .../test/runtests.jl:359
  Expression: check_error(integ) != ReturnCode.InitialFailure
   Evaluated: SciMLBase.ReturnCode.InitialFailure != SciMLBase.ReturnCode.InitialFailure

Nonlinear solve runs at the integrator's tolerances: Test Failed at .../test/runtests.jl:360
  Expression: integ.u[1] ≈ root
   Evaluated: 1.224744871391589 ≈ 1.2247448950087523     # unmoved from the initial guess

Nonlinear solve runs at the integrator's tolerances: Test Failed at .../test/runtests.jl:366
  Expression: SciMLBase.successful_retcode(sol)

Nonlinear solve runs at the integrator's tolerances | 2  4  6  9.0s
ERROR: Package ImplicitDiscreteSolve errored during testing

After (whole suite, unmodified except for the added testset):

Test Summary:  | Pass  Total   Time
Implicit Euler |    2      2  35.9s
Solver initializes |   16     16  2.7s
Reinitialize integrator |   15     15  15.3s
Constant extrapolant resets nonlinear iterate |    2      2  2.4s
Hard problem  |    1      1  2.4s
Kantorovich strict acceptance |    4      4  0.1s
Handle nothing in u0 |    2      2  5.3s
Create NonlinearLeastSquaresProblem |    3      3  9.4s
Null u0 bypasses NonlinearSolve |    3      3  0.9s
nlsolve accepts polyalgorithms and SimpleNonlinearSolve |   13     13  52.6s
InitialFailure thrown |    3      3  4.6s
Nonlinear solve runs at the integrator's tolerances |    6      6  6.4s
     Testing ImplicitDiscreteSolve tests passed

The regression test is the residual-floor case: terms of magnitude 1e7 make 1.2e-9 the smallest
|residual| any Float64 reaches (brute-forced over the 4001 floats around the root), so the
solve stalls at 3e-13 and succeeds at 1e-8 — same iterate, only the tolerance differs.

Formatting: Runic clean on both changed files. typos is not installed on this machine, so the
spell check was not run locally (no British spellings or unusual words were added).

What I did not verify


🤖 Posted by an AI agent — harness: Claude Code 2.1.260 · model: claude-opus-5[1m]
Conversation: https://claude.ai/code/session_01UBTNFZ4A8Ciw27TmVHkpRD

🤖 Generated with Claude Code

https://claude.ai/code/session_01UBTNFZ4A8Ciw27TmVHkpRD

`IDSolve` built its nonlinear cache with `init(prob, alg.nlsolve)` and never
passed a tolerance on, so `NewtonRaphson` always terminated against
NonlinearSolve's default Float64 `abstol = 3e-13`, whatever `init`/`solve` was
asked for. That default is unreachable for any residual whose terms are large --
the floor is `eps * magnitude` -- so a step that is solvable at the caller's
tolerance stalls instead.

Forward the integrator's tolerances at both `reinit!` sites (`perform_step!` and
the `DefaultInit` path of `_initialize_dae!`). An `ImplicitDiscreteProblem` with
no tolerance supplied keeps `false` in `integrator.opts`, which maps to `nothing`
and leaves the nonlinear solver's own default in place, so nothing changes unless
a tolerance is actually given.

Co-Authored-By: Chris Rackauckas <[email protected]>
Agent-Harness: Claude Code 2.1.260
Agent-Model: claude-opus-5[1m]
Agent-Session: https://claude.ai/code/session_01UBTNFZ4A8Ciw27TmVHkpRD
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01UBTNFZ4A8Ciw27TmVHkpRD
@ChrisRackauckas

Copy link
Copy Markdown
Member Author

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

Related:


🤖 Posted by an AI agent — harness: Claude Code 2.1.260 · model: claude-opus-5[1m]
Conversation: https://claude.ai/code/session_01UBTNFZ4A8Ciw27TmVHkpRD

@ChrisRackauckas

Copy link
Copy Markdown
Member Author

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

CI on this branch: lib/ImplicitDiscreteSolve sublibrary tests pass on lts, 1 and pre, and the QA
(JET/Aqua) job passes too:

sublibrary-ci / lib/ImplicitDiscreteSolve / Julia 1   / Tests - Core   pass  10m3s
sublibrary-ci / lib/ImplicitDiscreteSolve / Julia pre / Tests - Core   pass   8m27s
sublibrary-ci / lib/ImplicitDiscreteSolve / Julia lts / Tests - Core   pass   9m33s
sublibrary-ci / lib/ImplicitDiscreteSolve [QA] / Julia 1 / Tests - QA  pass  12m28s

Runic, runic-suggestions and the spell check pass. The rest of the matrix (downstream, downgrade,
benchmarks) was still running when this was written and has not been read.


🤖 Posted by an AI agent — harness: Claude Code 2.1.260 · model: claude-opus-5[1m]
Conversation: https://claude.ai/code/session_01UBTNFZ4A8Ciw27TmVHkpRD

@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review September 7, 2026 05:36
@ChrisRackauckas
ChrisRackauckas merged commit d629348 into master Sep 7, 2026
133 checks passed
ChrisRackauckas added a commit that referenced this pull request Sep 7, 2026
- 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)
- Run IDSolve's nonlinear solve at the integrator's tolerances (#4468)
- Build W through the allocating path for a sparse GPU Jacobian with a scalar mass matrix (#4452)
- Fix threaded stochastic work-precision isolation (#4462)
- Differentiate wrapped DAEFunctions with chunk size 1, like ODEFunctions (#4464)
- Rebuild MethodOfSteps W after history updates (#4396)



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.

1 participant