Repository navigation
Install the explicit attempt check only near maxiters - #327
Merged
Merged
Conversation
singhharsh1708
referenced
this pull request
Oct 24, 2026
* Read the option names PETSc 3.25 renamed * Bump to 0.12.3
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.
Adaptive explicit solves install a maxiters check through
TSSetFunctionDomainError, which PETSc calls at every stage of every step attempt: 7 calls perTSRK("5dp")step, 13 per"8vr"step. The check can only act when the attempts so far are within one ofmaxiters, and with PETSc's default of at most 10 rejections a single TSStep makes at most 11 attempts. This installs the check only once the remaining attempts drop to 13, armed from the monitor before each TSSolve step and before each integrator TSStep. A-ts_max_rejectoption keeps the old behaviour of installing it from the start, andreinit!removes it again.Per step on Lotka-Volterra with
save_everystep = false, the time goes from 516 to 497 ns for"3bs", from 833 to 768 ns for"5dp"and from 1546 to 1402 ns for"8vr"; on a 200-state Lorenz-96 problem"5dp"goes from 4252 to 4023 ns. On the Lotka-Volterra work-precision setup every PETSc point is 5 to 12% faster at the same error and step count, while BS3 and DP5, which this does not touch, moved by -3% to +6% between the same runs.A comparison of 152 solves against main is identical bit for bit in t, u, stats, retcode and dense interpolation. It covers every TSRK subtype with dense output, saveat, Float32, callbacks, tstops and dtmin, and maxiters reached with up to 146 rejected steps, through
solve, the integrator,reinit!, a maxiters lowered mid-run, and with-ts_max_rejectset. The TSRK, maxiters, statistics, callback and integrator testsets pass (3258 tests), as does PETScAdjoint (4125).AI Disclosure: Claude assisted with the code. Testing and review by @singhharsh1708.