Repository navigation
Fix BDF step rejection for backward-in-time integration - #4503
Merged
ChrisRackauckas merged 1 commit intoSep 11, 2026
Merged
ChrisRackauckas merged 1 commit into
ChrisRackauckas merged 1 commit into
Conversation
bdf_step_reject_controller! selects the next step size with min(h, hₖ₋₁) / hₖ₋₁ > hₖ on the signed step sizes h = dt/2, F·h. For tdir < 0 (backward integration, e.g. adjoint solves) dt is negative, so min picks the candidate with the *larger* magnitude. On repeated failures the retry dt can stay at a fixed point with EEst > 1 forever, looping until maxiters. This showed up as SciMLSensitivity DAE-adjoint tests failing on Julia 1.13 after the FBDF reinit ordering fix (SciML#4484) moved restarts onto this path. Do the step-size selection on magnitudes and restore the sign via integrator.tdir when writing back integrator.dt. Behavior is unchanged for forward-in-time integration (tdir = 1). 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 High Agent-Session: local Devin CLI session (no shareable URL); session db at /home/crackauc/.local/share/devin/cli/sessions.db
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 11, 2026
- Fix GlobalDiffEq precompilation on Julia 1.13 and companion accuracy (#4500) - Make mass-matrix identity/zero/diagonal checks GPU-safe (#4502) - Fix BDF step rejection for backward-in-time integration (#4503) 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 11, 2026
- Unify companion global error estimators into GlobalErrorEstimation (#4492) - Add adjoint-based global error control as a SciMLSensitivity extension (#3953) - ExpRK: cache ishermitian (rebase of #4305, + review fixes) (#4497) - Mark discrete time-grid search helpers as Enzyme inactive (#4496) - GlobalAdjoint: every-step trajectory scope and step-grid control (#4495) - GlobalAdjoint: defer to adjoint_sensitivities default instead of pinning an adjoint (#4498) - Release GlobalDiffEq 1.7.1 (#4501) - Fix GlobalDiffEq precompilation on Julia 1.13 and companion accuracy (#4500) - Make mass-matrix identity/zero/diagonal checks GPU-safe (#4502) - Fix BDF step rejection for backward-in-time integration (#4503) 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
- Unify companion global error estimators into GlobalErrorEstimation (#4492) - Add adjoint-based global error control as a SciMLSensitivity extension (#3953) - ExpRK: cache ishermitian (rebase of #4305, + review fixes) (#4497) - Mark discrete time-grid search helpers as Enzyme inactive (#4496) - GlobalAdjoint: every-step trajectory scope and step-grid control (#4495) - GlobalAdjoint: defer to adjoint_sensitivities default instead of pinning an adjoint (#4498) - Release GlobalDiffEq 1.7.1 (#4501) - Fix GlobalDiffEq precompilation on Julia 1.13 and companion accuracy (#4500) - Make mass-matrix identity/zero/diagonal checks GPU-safe (#4502) - Fix BDF step rejection for backward-in-time integration (#4503) 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.
Summary
bdf_step_reject_controller!performs its step-size selection (hₖ₋₁ > hₖ,hₙ = min(h, hₖ₋₁)) on signed step sizes. For backward-in-time integration (tdir < 0, e.g. adjoint solves in SciMLSensitivity)dtis negative, sominpicks the candidate with the larger magnitude. On repeated step failures the retrydtcan converge to a fixed point whereEEst > 1forever — the solver then burnsmaxitersin an infinite reject loop instead of shrinking the step.This is what broke the SciMLSensitivity
downstream/test/Core3/dae_adjoint.jlEnzymeVJP/InterpolatingAdjointtests on Julia 1.13: the backward adjointFBDFsolve stalls att ≈ 0.0088with ~10⁶ consecutive rejections at a frozendt = -6.09e-4, hitsMaxIters, and returns gradients from a truncated adjoint trajectory. The regression surfaced after #4484 movedreinitFBDF!ahead of the cache destructuring (the correct order), which changed the restart trajectory enough to route onto this path — the sign bug itself predates that commit and also reproduces on the releasedOrdinaryDiffEqBDF2.4.7.Fix: do the step-size selection on magnitudes (
h = abs(integrator.dt)) and restore the direction withintegrator.tdirwhen writingintegrator.dt. Forward-in-time behavior is unchanged (tdir = 1).Test plan
New regression test
BDF step rejection shrinks |dt| for backward integrationinlib/OrdinaryDiffEqBDF/test/bdf_regression_tests.jldrives the real reject controller on anFBDFintegrator for bothtdir = ±1, forcingconsfailcnt > 2at order 3 with a smallterkm1.Before the fix (unfixed code):
i.e. |dt| grew by ~1.8x on a rejected backward step. After the fix all 4 tests pass, and the downstream
dae_adjoint.jlsuite passes (44/44), including the two previously failingEnzymeVJPassertions:Also ran
bdf_regression_tests.jl(all pass) andfbdf_time_filter_tests.jl+fbdf_filter_regression_tests.jl(all pass).🤖 Generated with Devin (harness: Devin CLI 3000.10.21, model: SWE-2 High). Session: local Devin CLI session (no shareable URL); session db at /home/crackauc/.local/share/devin/cli/sessions.db