Repository navigation
Floor the Newton direction's linear tolerance at sqrt(eps) - #4301
Closed
singhharsh1708 wants to merge 1 commit into
Closed
singhharsh1708 wants to merge 1 commit into
singhharsh1708 wants to merge 1 commit into
Conversation
Member
|
I reproduced the NonlinearSolve downstream Hairer regression locally and verified this patch discriminates it. Using the same focused Hairer regression file with NonlinearSolve 4.27, NonlinearSolveBase 2.46, and SciMLBase 3.49: The branch also cherry-picks cleanly onto current OrdinaryDiffEq master and For tracking, the failure surfaced from 4bb8495. Current master has separate inherited QA/Core failures being investigated independently; they are not caused by this focused tolerance-floor change. |
Member
|
No just update the test to use appropriate defaults. |
Member
|
I mean not defaults but tolerances. |
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.
Fixes #4293.
compute_step!forNLNewtonhandsintegrator.opts.reltolstraight to the linear solve.A Newton correction has to be more accurate than the tolerance it is being used to reach, so
at the default
reltol = 1e-3the Krylov solve returns a direction good only to 1e-3, thestage never converges to 1e-3,
dtcollapses and the step controller gives up.test/Regression_I/newton_krylov_roundoff.jlis the thing that broke because it callssolvewith no tolerances, so the linear solve inherits the 1e-3 default. On
upstream/masterat202f5fd:
Hairer4masterHairer42masterHairer4hereHairer42hereThe gate is
drift < 1e-5and that file's own comment puts a round-off reproducible run inthe 1e-15 to 1e-7 band.
The floor is
sqrt(eps)because that is LinearSolve's own default, which is where this satbefore #4192 made the linear tolerance integrator-driven. It is not a constant fitted to this
reproducer. A run looser than that behaves as it did before #4192, a tighter one still gets
the tighter linear solve.
Why here and not in
set_linear_reltol!Clamping inside
set_linear_reltol!also fixes the reproducer, and I measured it, but itfloors every caller including the Rosenbrock path. A Rosenbrock stage is a single linear solve
whose accuracy caps the stage directly rather than feeding an iteration, so
reltolis theright target there and flooring it is just over-solving: at
reltol = 1e-3on Robertson itmoves
Rodas5Pfrom 1.1e-3 error to 2.1e-6 while doing more work for accuracy nobody askedfor. It also fails four assertions across two files rather than one.
I also tried extending the same floor to
set_inner_linear_reltol!, on the theory thatNonlinearSolveAlg's inner Krylov descent is a Newton direction too. That fails two moreassertions in
nsa_krylov_tolerance_tests.jl, and that file's third testset already measuresthe loose tolerance there as costing no accuracy and no
nnonlinconvfail, so there is nothingto fix on that path. Left alone.
Test change, please look at this one
lib/OrdinaryDiffEqDifferentiation/test/krylov_linear_tolerance_tests.jlassertednewton_cache(integrator).reltol == tolfortol = 1e-6, which is the behaviour that breaks#4293, so it had to move to
min(tol, sqrt(eps(Float64))). Thetol = 1e-10case in the sameloop is unchanged and still checks that a tighter tolerance passes through. The other three
assertions in that file, and all three testsets of
nsa_krylov_tolerance_tests.jl, areuntouched and pass.
Testing
Ran against this branch:
krylov_linear_tolerance_tests.jl,nf_accounting_tests.jl,warm_start_default_tests.jl,stale_w_linear_operator_tests.jl,newton_krylov_roundoff.jl,linear_nonlinear_tests.jl,nsa_krylov_tolerance_tests.jl,nsa_residual_convergence_tests.jl,nsa_conditioning_tests.jl,mass_matrix_tests.jl. All pass.newton_tests.jlI could not runlocally,
DiffEqDevToolsfails to precompile on my Julia 1.10 for unrelated reasons.Also swept
Hairer4,Hairer42,TRBDF2,KenCarp4,FBDF,QNDF,Rodas5P,Rosenbrock23and theNonlinearSolveAlgvariants ofTRBDF2andKenCarp4withKrylovJL_GMRESat default tolerances over an index-1 DAE, Allen-Cahn and Robertson. Everycase that succeeded on master still succeeds, and
KenCarp4andFBDFon Robertson improvefrom 2.7e-4 and 5.7e-4 error to 1.4e-6 and 3.1e-5.
One thing that sweep turned up and that this PR does not address:
Rosenbrock23withKrylovJL_GMRESon a mass-matrix problem with ajac_prototypeerrors withMethodError: no method matching jacobian!(::SciMLOperators.NullOperator, ...). That happenson unmodified master too, so it is a separate bug. I can file it if it is not already known.
AI Disclosure
Claude assisted with this work.