Repository navigation
Bind NonlinearSolveAlg's inner Krylov tolerance to the integrator tolerance - #4268
Merged
Merged
Conversation
…erance `build_nlsolver` zeroes the inner nonlinear tolerances so the integrator owns convergence, and restores a linear tolerance through `linsolve_kwargs` as a fixed `eps^(4//5)`. That value is independent of `reltol`, so a Krylov descent solve runs to ~3e-13 however loose the integrator is: at `reltol = 1e-3` it is ten orders tighter than the step can use, paid in Jacobian-vector products. Set it per step from the integrator instead, the way SciML#4192 made `dolinsolve` do for `NLNewton`, reusing that PR's `set_linear_reltol!` so a solver that needs a concrete `A` is left alone. Co-Authored-By: Chris Rackauckas <[email protected]>
ChrisRackauckas-Claude
force-pushed
the
nsa-krytol
branch
from
August 15, 2026 11:45
4f0b8e0 to
debe46f
Compare
ChrisRackauckas
marked this pull request as ready for review
August 15, 2026 23:06
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.
Please ignore until reviewed by @ChrisRackauckas.
Follow-up to #4207. Measurements and rationale are in my comment there.
NonlinearSolveAlgzeroes its inner nonlinear tolerances so the integrator owns convergence. That also starves the descent's linear solve, so it restores one throughlinsolve_kwargswithfixed, regardless of
reltol. A Krylov descent therefore runs to ~1e-13 no matter how loose the integrator is — atreltol = 1e-3that is ten orders tighter than the step can use, and it is paid in Jacobian-vector products.This applies #4192's
set_linear_reltol!to NSA's inner linear cache, the waydolinsolvealready does forNLNewton. Direct solvers are unaffected:set_linear_reltol!skips anything withneeds_concrete_A.It also removes an inconsistency that exists today
For NSA the smoothed error estimate's linear cache is the same
LinearCacheobject as the inner Newton descent (they are aliased throughget_linear_cache). So #4192'sset_linear_reltol!already reaches NSA's inner solve — but only on the integrators that use a smoothed estimate:So half of this behaviour is already shipped, by accident, on some integrators and not others. This makes it deliberate and uniform.
Effect
2D Brusselator 16×16×2,
AutoFiniteDiff, counting Jacobian-vector products. Measured with SciML/NonlinearSolve.jl#1169 applied, because without it NSA's Krylov path is not run-to-run reproducible and these numbers would be noise:The split is exactly the leak above: FBDF gains, the ESDIRK integrators were already getting it. All
LUFactorizationrows are byte-identical — sameJv,nf,nacceptandu[end]— confirmed by diff.A broader 80-configuration sweep (Brusselator 8/16/32 + Allen-Cahn 64/256 × FBDF/TRBDF2/KenCarp4/Kvaerno5 × rtol 1e-3…1e-12) gives geometric-mean Jv 0.851, best 0.253, worst 1.036.
Why not Eisenstat-Walker
NewtonRaphsonalready acceptsforcing = EisenstatWalkerForcing2(). At library defaults it is much worse here (geometric-mean Jv 1.277, worst 6.86, +10902nnonlinconvfail) because of an upstream ordering bug:post_step_forcing!runs beforeevaluate_f!, so the forcing term is computed from a two-iteration-stale residual ratio and never adapts. Filed as SciML/NonlinearSolve.jl#1170. Until that is fixed EW cannot be evaluated fairly; once it is, it is worth revisiting.Disclosed
roberDAE/TRBDF2/GMRESat 1e-6 goesnnonlinconvfail0 → 4,pdeDAE/TRBDF2/GMRESat 1e-9 goes 2 → 5. Both still solve; the "no change" claim holds only for non-DAE ODEs.precs. Note the default NSA Krylov path already carries anInvPreconditioner{Diagonal}fromwrapprecs, so the rows above are not unpreconditioned.Tests
New
nsa_krylov_tolerance_tests.jl(13 assertions) checks the inner cache'sreltoltracks the integrator's for iterative algorithms, stays at_inner_lintolfor direct ones, and falls back toepswhenadaptive = false. All tennsa_*.jlfiles pass: 13 + 24 + 21 + 13 + 10 + 10 + 14 + 8 + 102 + 70 = 285, 0 failures. Runic clean.OrdinaryDiffEqNonlinearSolve2.8.0 → 2.9.0,OrdinaryDiffEqDifferentiationfloor 3.6 → 3.9 (forset_linear_reltol!).Note on stacking: #4265 also bumps this package to 2.9.0. Whichever merges second needs 2.10.0 — the changes themselves are disjoint.
🤖 Generated with Claude Code