Skip to content

Apply stage limiters in every StabilizedRK method - #4550

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:stabilizedrk-stage-limiters
Sep 13, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:stabilizedrk-stage-limiters

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

This PR should be ignored until reviewed by @ChrisRackauckas.

What changed and why

#3835 reported extending limiter support to "all StabilizedRK methods", but it never touched rkc_perform_step.jl: the methods had no stage hooks and did not opt into has_stage_limiter, so solve(prob, ROCK2(); stage_limiter = ...) errored with stage_limiter_unused (raised in #3902 (comment)). Step limiters were already applied centrally and are unchanged.

Every in-place perform_step! in OrdinaryDiffEqStabilizedRK (ROCK2, ROCK4, RKC, RKMC2, ESERK4, ESERK5, SERK2, TSRKC2, TSRKC3, RKL1, RKL2, RKG1, RKG2) now calls integrator.opts.stage_limiter!(buf, integrator, p, t_stage) on each stage buffer right after it is formed and before f reads it — the Chebyshev/Legendre/Gegenbauer recurrence stages, the two- and four-stage finishing procedures of ROCK2/ROCK4, the ESERK extrapolation sub-step results — and on the accepted u. Stage times are the ones the methods already track (tᵢ₋₁, t + dt*th, t + dt*cⱼ, the ESERK r). Following the convention of the other RK families, the out-of-place ConstantCache paths do not apply stage limiters. All 13 algorithms opt into OrdinaryDiffEqCore.has_stage_limiter.

Tests

New lib/OrdinaryDiffEqStabilizedRK/test/stage_limiter_tests.jl (Core group): for each algorithm and adaptive ∈ (false, true), a clamp u .= max.(u, 0.9) is applied by the stage limiter on u' = -10u, and f counts every call whose input violates the clamp. This checks that every state handed to f inside a step has passed through the limiter (a missed hook shows up as a violation), that the limiter receives a DEIntegrator and never uprev, that every accepted u satisfies the clamp, and that the unlimited solve does not (so the test discriminates). test/Integrators_I/step_limiter_test.jl moves the 13 methods into the supported/LIMITER_ALGS lists and removes ROCK2, RKC, ESERK4, RKL1 from unsupported.

Failing before the fix (src stashed, test kept):

has_stage_limiter opt-in: Test Failed at .../test/stage_limiter_tests.jl:12
  Expression: OrdinaryDiffEqCore.has_stage_limiter(A())
ERROR: LoadError: Some tests did not pass: 0 passed, 13 failed, 0 errored, 0 broken.

and solve(prob, ROCK2(); stage_limiter = ...) on master: ErrorException: Verbosity toggle: stage_limiter_unused.

Passing after:

has_stage_limiter opt-in                      |   13     13  0.0s
every stage value is limited before f sees it |  182    182  1m15.6s

Verification

  • Runic --inplace on all changed files: no changes. typos: clean.
  • GROUP=Core julia --project=lib/OrdinaryDiffEqStabilizedRK -e 'using Pkg; Pkg.test()':
    RKC Tests                 | 1258   1258  10m28.2s
    Stage Limiter Tests       |  195    195  50.0s
    dtnew Cap Direction Tests |   20     20  12.9s
         Testing OrdinaryDiffEqStabilizedRK tests passed
    
  • GROUP=QA julia --project=lib/OrdinaryDiffEqStabilizedRK -e 'using Pkg; Pkg.test()':
    Allocation Tests       |  13 broken (pre-existing @test_broken sites)
    Type Agnosticism Tests | 104    104
    JET Tests              |  27     27
    Aqua                   |  21     21
         Testing OrdinaryDiffEqStabilizedRK tests passed
    
  • test/Integrators_I/step_limiter_test.jl run standalone against this checkout: 404 tests, 0 failures, including
    has_stage_limiter trait matches implementation |   98     98
    stage limiter receives the integrator          |   80     80
    stage limiter is never handed uprev            |   40     40
    
  • GROUP=Integrators_I julia --project=. -e 'using Pkg; Pkg.test()' (full group, 64 min): Testing OrdinaryDiffEq tests passed, zero failures; the modified file ran as
    Step Limiter Tests            |  404    404  27m56.7s
    Discontinuity Detection Tests |   28     28   4m56.6s
    
    (the only Broken entries are the two pre-existing ones in Callback Allocation / Error Check).
  • Not verified: GPU group, downstream packages, allowed-to-fail julia pre jobs.

For the reviewer

  • Judgment call: the final RKC/RKL/RKG/TSRKC3-startup stage is limited once inside the recurrence loop at t + dt*th (where th == 1 for the last stage) rather than a second time at t + dt, to avoid double-applying the limiter to the same buffer.
  • ExponentialRK is not touched: its step-limiter support from Add solver-level limiter kwargs #3835 is real and already tested in step_limiter_test.jl; no stage-limiter claim was made for it.

🤖 Generated with Devin CLI 3000.10.21 (model: Fusion — Claude Fable 5.1 High + SWE-2 Medium). Local session id five-bladder; the harness publishes no shareable conversation URL.

SciML#3835 claimed to extend limiter support to the StabilizedRK methods but never
touched their perform_step! bodies, so `stage_limiter` still errored as unused
for ROCK2/ROCK4/RKC/RKMC2/ESERK4/ESERK5/SERK2/TSRKC2/TSRKC3/RKL1/RKL2/RKG1/RKG2.
Every in-place perform_step! now applies `integrator.opts.stage_limiter!` to
each recurrence stage (and the finishing stages of ROCK2/ROCK4, the
extrapolation sub-steps of ESERK) before `f` reads it, and to the accepted `u`,
and the methods opt into `has_stage_limiter`. Step limiters were already
applied centrally and are unchanged.

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: Fusion (Claude Fable 5.1 High + SWE-2 Medium)
Agent-Session: local Devin CLI session id five-bladder (no shareable URL)
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review September 13, 2026 09:39
@ChrisRackauckas
ChrisRackauckas merged commit b694035 into SciML:master Sep 13, 2026
132 of 136 checks passed
ChrisRackauckas added a commit that referenced this pull request Sep 13, 2026
- Stop tying the state Jacobian's finite-difference direction to tdir (#4543)
- Extend OrdinaryDiffEqCore.dtnew_modification instead of shadowing it (#4547)
- Pick the DAE initialization dt by magnitude, not signed min (#4549)
- Accept a callable stage predictor on the nlsolve algorithms (#4539)
- Run the QA test group last in every sublibrary that ran it first (#4551)
- Apply stage limiters in every StabilizedRK method (#4550)



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]>
ChrisRackauckas added a commit that referenced this pull request Sep 13, 2026
- Stop tying the state Jacobian's finite-difference direction to tdir (#4543)
- Extend OrdinaryDiffEqCore.dtnew_modification instead of shadowing it (#4547)
- Pick the DAE initialization dt by magnitude, not signed min (#4549)
- Accept a callable stage predictor on the nlsolve algorithms (#4539)
- Run the QA test group last in every sublibrary that ran it first (#4551)
- Apply stage limiters in every StabilizedRK method (#4550)
- Release OrdinaryDiffEqNonlinearSolve 2.9.8 (#4552)
- Declare OrdinaryDiffEqCore.dtnew_modification public (#4553)
- Fix baseline spelling and whitespace checks in tests (#4524)
- Raise OrdinaryDiffEqNonlinearSolve floor for stage_predictor (#4554)



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]>
ChrisRackauckas added a commit that referenced this pull request Sep 17, 2026
Ships stage limiters being applied in every StabilizedRK method (#4550) and the dtnew_modification extension fix (#4547).

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude <[email protected]>
Agent-Harness: Claude Code 2.1.273
Agent-Model: claude-opus-5[1m]
Agent-Session: 6a01e420-3436-4518-83cc-6cd853283cfb (local transcript; this harness publishes no conversation URL)
ChrisRackauckas added a commit that referenced this pull request Sep 17, 2026
Ships stage limiters being applied in every StabilizedRK method (#4550) and the dtnew_modification extension fix (#4547).



Agent-Harness: Claude Code 2.1.273
Agent-Model: claude-opus-5[1m]
Agent-Session: 6a01e420-3436-4518-83cc-6cd853283cfb (local transcript; this harness publishes no conversation URL)

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants