Repository navigation
Make the stabilized-RK step cap and eigenvalue tolerance direction-agnostic - #4536
Merged
ChrisRackauckas merged 1 commit intoSep 12, 2026
Conversation
…nostic `dtnew_modification` caps the controller's proposed step at the method's stability limit, which is a magnitude: `min(dtnew, bound)` silently does nothing for a backward solve, where dtnew < 0 < bound. Cap on |dtnew| and restore the sign. Affects ROCK2, ROCK4, SERK2, ESERK4, ESERK5, RKMC2, RKL1, RKL2, RKG1, RKG2. The power-iteration convergence test in `maxeig!` compares against `max(eigen_est, inv(integrator.opts.dtmax))`. `dtmax` is negative for tdir < 0, so the floor term went negative and the tolerance differed between directions; take `abs` of dtmax. Same one-liner in OrdinaryDiffEqStabilizedIRK's `maxeig!`. Note: these caps are currently unreachable from `calc_dt_propose!` because OrdinaryDiffEqStabilizedRK defines `dtnew_modification` without importing it from OrdinaryDiffEqCore, so the generic identity method is what runs. Filed separately; this commit only makes the shadowed implementation correct. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Agent-Harness: Claude Code 2.1.269 Agent-Model: claude-opus-5[1m] Agent-Session: https://claude.ai/code/session_01JQATpLKMyYX3VbPPX8qdeE Claude-Session: https://claude.ai/code/session_01JQATpLKMyYX3VbPPX8qdeE
ChrisRackauckas
marked this pull request as ready for review
September 12, 2026 20:48
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 13, 2026
- OrdinaryDiffEqDefault: require OrdinaryDiffEqCore 4.17.1 (#4520) - Add adaptive step size control to SDC (#4346) - Allow JET 0.12 in every QA test environment (#4513) - Resolve OrdinaryDiffEqDefault against the local sublibraries (#4514) - NonlinearSolveAlg: stale-Jacobian retry + rejected-step W reassembly (carries #4282 to current master) (#4505) - Do not seed a retry from the previous-step interpolant (#4473) - Say why the linear path ignores new_W_dt_cutoff (#4527) - Carry the QNDF2 difference array across steps (#4526) - Pass Θ = 0, not the absolute time, to the AN5 startup interpolant (#4534) - Make the stabilized-RK step cap and eigenvalue tolerance direction-agnostic (#4536) 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]>
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.
Ignore until reviewed by @ChrisRackauckas. Draft.
What changed and why
Two sign bugs of the same kind, in
OrdinaryDiffEqStabilizedRKand its siblingOrdinaryDiffEqStabilizedIRK.1. The stability-limit step cap.
dtnew_modificationcaps the controller's proposed step at the method's stability limit. The limit is a magnitude, somin(dtnew, bound)does nothing at all for a backward solve, wheredtnew < 0 < bound:Ten methods: ROCK2, ROCK4, SERK2, ESERK4, ESERK5, RKMC2, RKL1, RKL2, RKG1, RKG2. With
eigen_est = 1e6and a proposed|dt|of 1.0, ROCK2 forward caps to 0.0324385 and backward leaves it at 1.0 — a 30× difference.2. The power-iteration convergence tolerance.
maxeig!compares againstmax(eigen_est, inv(integrator.opts.dtmax)).dtmaxis negative fortdir < 0, so the floor term goes negative and the tolerance differs between the two directions, giving a different number of power iterations and hence a different spectral-radius estimate. Same one-liner inOrdinaryDiffEqStabilizedIRK'smaxeig!(1.0 / integrator.opts.dtmax).Important caveat: the cap is currently dead code
OrdinaryDiffEqStabilizedRKdefinesdtnew_modificationwithout importing it fromOrdinaryDiffEqCore, so it shadows rather than extends, andcalc_dt_propose!calls Core's generic identity method. See #4535. That means:I am not fixing the import here on purpose: enabling a dormant stability cap for ten methods changes step sizes for every user of them and deserves its own PR.
Verification
New
lib/OrdinaryDiffEqStabilizedRK/test/dtnew_cap_direction_tests.jl, registered inruntests.jl. It calls the package's owndtnew_modificationdirectly (the only way to reach it, per the caveat above), witheigen_estset high enough that the bound binds for every method, and asserts (a) the cap actually binds forward and (b) the capped magnitude is identical backward.Failing on master (
git stash push -- lib/OrdinaryDiffEqStabilizedRK/src/alg_utils.jl) — one assertion per method:Passing with the fix:
Full package suites on this branch (Julia 1.10.11):
What I did not verify — please read
The two
inv(dtmax)changes have no discriminating test. I could not surface an end-to-end difference from them. The floor only matters wheneigen_est < 1/|tspan|; I triedu' = 1e-3 uover a unit-length tspan withabstol = reltol = 1e-10across ROCK2/ROCK4/RKC/SERK2/RKL2/RKG2, in-place and out-of-place, and every case was already bitwise reversible. I am shipping them as sign corrections that are obviously right by inspection, not as fixes to an observed failure — if you would rather they went in with a demonstration, say so and I will drop them from this PR.Also not verified: GPU and Downstream groups, Julia
pre; and whether the intended stability bounds are still the right ones (that question belongs with #4535).Worth pushing back on
_capis a new unexported one-line helper inalg_utils.jl. If you would prefer thecopysign(min(abs(...), ...), ...)written out at each of the ten sites, or the helper placed elsewhere, easy to change.maxeig!implementations, so splitting felt like more noise than signal. Happy to split.Related: #4535 (the cap never runs).
🤖 Generated with Claude Code (model: claude-opus-5[1m], harness: Claude Code 2.1.269)
https://claude.ai/code/session_01JQATpLKMyYX3VbPPX8qdeE