Repository navigation
[bot] ImplicitDiscreteSolve: run the nonlinear solve at the integrator's tolerances - #4468
Conversation
`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
Related:
🤖 Posted by an AI agent — harness: Claude Code 2.1.260 · model: claude-opus-5[1m] |
CI on this branch: Runic, runic-suggestions and the spell check pass. The rest of the matrix (downstream, downgrade, 🤖 Posted by an AI agent — harness: Claude Code 2.1.260 · model: claude-opus-5[1m] |
- 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]>
What and why
IDSolvenever passes a tolerance into its nonlinear solve:alg_cachebuilds the cache withinit(prob, alg.nlsolve), soNewtonRaphsonalways terminates against NonlinearSolve's defaultFloat64
abstol = 3e-13, whatever the caller askedinit/solvefor. (alg_cacheis handedreltoland ignores it;abstolnever reaches it at all, and the cache is built before theintegrator 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 askfor. Downstream this surfaces as ModelingToolkit throwing
UnsolvableCallbackErrorfor aperfectly 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 theDefaultInitpath of_initialize_dae!). AnImplicitDiscreteProblemwith no tolerance supplied keepsfalseinintegrator.opts, whichmaps to
nothingand leaves NonlinearSolve's default in place, so nothing changes unless atolerance is actually given.
Verification
ImplicitDiscreteSolvetest suite (GROUP=Core), aarch64 Linux, Julia 1.10.12.Before (
git stash push lib/ImplicitDiscreteSolve/src/solve.jl, new test only, rest of thesuite unchanged):
After (whole suite, unmodified except for the added testset):
The regression test is the residual-floor case: terms of magnitude 1e7 make 1.2e-9 the smallest
|residual|anyFloat64reaches (brute-forced over the 4001 floats around the root), so thesolve stalls at
3e-13and succeeds at1e-8— same iterate, only the tolerance differs.Formatting: Runic clean on both changed files.
typosis not installed on this machine, so thespell check was not run locally (no British spellings or unusual words were added).
What I did not verify
Coretest group was run locally (GROUP=Core); theQAgroup (JET/Aqua) was not.https://github.com/SciML/ModelingToolkit.jl/pull/MTK_PR, which needs this released as 2.3.0
before it can resolve.
🤖 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