Repository navigation
Accept a stage predictor on the Newton nonlinear solvers - #4471
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
|
Why just SDIRK? This should generally be for any implicit method? And it should be done in the newton setup not in the algorithm, given all newton's can do this? |
singhharsh1708
force-pushed
the
custom-predictor
branch
from
September 12, 2026 20:16
0a4ac12 to
e80de51
Compare
Member
Author
|
Moved it into |
3 of 4 tasks
singhharsh1708
force-pushed
the
custom-predictor
branch
from
September 13, 2026 05:44
e80de51 to
dd652cd
Compare
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 13, 2026
* Accept a callable stage predictor on the nlsolve algorithms A `predictor` keyword on `NLNewton`, `NLFunctional`, `NLAnderson`, and `NonlinearSolveAlg` takes a callable that guesses the stage *value*: `predictor(uprev, p, t + c*dt, dt)` out of place and `predictor(upred, uprev, p, t + c*dt, dt)` in place. `nlsolve!` applies it once per solve attempt via `apply_predictor!`, so every implicit method driven through the shared nonlinear solver (DIRK/IMEX RK, coefficient-form multistep, DAE BDF, PDIRK) gets it for free — the generalization requested in review of #4471, which had wired the same callable through SDIRK's stage kernels by hand. The guess is mapped onto the solver's iterate `z` by inverting the residual's `ustep` map — `z = (u_pred - tmp)/γ` for DIRK-style methods, `z = u_pred` for `COEFFICIENT_MULTISTEP`, `z = u_pred - u₀` for `DAEFunction` — the same inverse the tableau/interpolant predictors already apply inside the kernels. When both are set, the callable overrides the algorithm's `Predictor` enum seed. Passing a `Predictor` enum value to the nlsolve `predictor` is rejected with a pointer at the algorithm-level option, and `HomotopyNonlinearSolveAlg` rejects `predictor` outright: continuation starts each stage from the λ = 0 anchor, not an initial guess. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.10.21 Agent-Model: SWE-2 Max Agent-Session: local transcript /home/crackauc/.local/share/devin/cli/summaries/history_68a468ef87ff4372.md (Devin CLI exposes no shareable URL) * Skip enum predictor seeding in SDIRK when a callable is set With `nlsolve = NLNewton(predictor = f)` the kernel's `Predictor` enum seed is dead work: `apply_predictor!` inside `nlsolve!` overwrites `nlsolver.z` before Newton iterates. Collapse the local predictor to `Trivial` in `_perform_step_iip!`/`_perform_step_oop!` when `stage_predictor(nlsolver.alg)` is set, so the interpolant predictors (`addsteps!`, `current_extrapolant`, Hermite evaluation) are skipped instead of computed and thrown away. Enum behavior is unchanged when no callable is configured. BDF seeds are broadcasts over already-computed history and PDIRK seeds are `zero(u)`, so nothing is gated there. StochasticDiffEqImplicit's `:interpolant` extrapolant has the same dead-work pattern but seeds the stage value `u` (not `z`) amid noise computations — left for a separate look. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.10.21 Agent-Model: SWE-2 Max Agent-Session: local transcript /home/crackauc/.local/share/devin/cli/summaries/history_7369bf642d694288.md (Devin CLI exposes no shareable URL) --------- Co-authored-by: ChrisRackauckas-Claude <[email protected]> Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.
NLNewtonandNonlinearSolveAlgnow takepredictor, a callable giving the initial guess for the state at each implicit stage:predictor(uprev, p, t, dt)out of place andpredictor(upred, uprev, p, t, dt)in place, withtthe stage time anddtthe time fromuprevto it. It is applied once per stage innlsolve!and mapped back to the stage unknown the waycompute_ustepmaps it forward, so every method that solves through these (SDIRK and ESDIRK, BDF, PDIRK, IMEX multistep, the implicit StochasticDiffEq solvers) gets it, and the SDIRK-only version is gone. ADAEProblemstage solve rejects it with anArgumentError.The new test runs ImplicitEuler, TRBDF2 and FBDF with both solvers, in and out of place: all 36 pass, and 12 fail with the call removed from
nlsolve!.On
u' = -50uat 1e-8, passing the exact solution as the guess takes Kvaerno5 from 662 to 516 Newton iterations and in-place FBDF from 323 to 244, with the same accepted and rejected steps. A first-order Euler guess on Lotka-Volterra is slower than the methods' own predictors (TRBDF2 48057 to 55299, FBDF 8726 to 26165), so this is for guesses that know something about the problem rather than a better default.Closes #4331.
AI Disclosure: Claude assisted with this change.