Repository navigation
Fix SERK2 in-place inner stage loop evaluating f at the wrong stage vector - #3947
Merged
ChrisRackauckas merged 1 commit intoJul 22, 2026
Merged
Conversation
…ector The in-place SERK2 perform_step! evaluated f at tmp (which holds uᵢ₋₂) instead of uᵢ₋₁ in the inner stage loop, and used a different buffer-shift guard (j < mdeg) than the out-of-place method (j * i < mdeg). The divergent path only executes when mdeg >= 20 (internal_deg >= 2), i.e. for genuinely stiff steps with dt*λ ≳ 300, a regime the existing autonomous test problems never reach. In that regime the in-place solver is unstable: on a forced heat equation with dt*λ ≈ 217 it reaches ~1e83 while the out-of-place solver has error ~2.5e-3. With this fix the two implementations agree to ~1e-13. Adds a stiff fixed-dt in-place/out-of-place agreement regression test across all stabilized RK methods, which fails on the previous code. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015WU5V4PXt8SZ3BpjxdtM7d
This was referenced Jul 18, 2026
Member
Author
|
CI triage (2026-07-18): the failing checks here are pre-existing on
A separate investigation of the master failures is underway and will be filed as its own issue/PR. All checks that exercise this PR's code ( Additionally: |
ChrisRackauckas
marked this pull request as ready for review
July 22, 2026 20:52
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.
Important
This PR should be ignored until reviewed by @ChrisRackauckas.
What
The in-place
SERK2perform_step!evaluatedfattmp(which holds uᵢ₋₂) instead ofuᵢ₋₁in its inner stage loop, and used a different buffer-shift guard (j < mdeg) than the out-of-place implementation (j * i < mdeg).Why it went undetected
The divergent code path only executes when
mdeg >= 20(internal_deg = mdeg ÷ 10 >= 2), i.e. for genuinely stiff steps with dt·λ ≳ 300. The existing convergence tests useprob_ode_linear/prob_ode_2Dlinearwith mild step sizes, which never reach that regime.Impact
In the stiff regime the in-place solver is unstable. On a forced heat equation (N = 32, dt·λ ≈ 217, fixed dt = 0.05):
Tests
Adds a stiff fixed-dt in-place/out-of-place agreement regression testset covering all 13 stabilized RK methods (ROCK2/4, RKC, RKMC2, TSRKC2/3, SERK2, ESERK4/5, RKL1/2, RKG1/2). It fails on the previous code for SERK2 and passes with this fix.
Ran locally:
ODEDIFFEQ_TEST_GROUP=Core Pkg.test()on the sublibrary — 210/210 pass. Runic applied to changed files.Process notes
Found during a correctness/performance audit of the stabilized RK family: code inspection flagged the oop/iip asymmetry, then a fixed-dt stiff comparison confirmed the blow-up, and the one-line fix restores roundoff-level agreement. Related (separate PRs): RKL/RKG non-autonomous stage-time fixes; SERK2 also has a separate non-autonomous order-reduction issue that needs the original paper's coefficients and is intentionally NOT addressed here.
🤖 Generated with Claude Code
https://claude.ai/code/session_015WU5V4PXt8SZ3BpjxdtM7d