Skip to content

Restore the controller's step after a step shortened onto a tstop - #4751

Merged
ChrisRackauckas merged 12 commits into
SciML:masterfrom
SebastianM-C:smc/fix-tstop-dt-restore
Nov 27, 2026
Merged

ChrisRackauckas merged 12 commits into
SciML:masterfrom
SebastianM-C:smc/fix-tstop-dt-restore

Conversation

@SebastianM-C

@SebastianM-C SebastianM-C commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Fixes #4749 with an opt-in resume_dt_after_tstop = true solve option.

By default, the controller proposes the next step from the accepted landing step. Set resume_dt_after_tstop = true to request faster recovery on algorithms that support it. The callback interpolation test preserves behavior observed on the merge base. The work-precision results below describe an earlier always-resume revision.

_loopfooter! is meant to resume the step the controller proposed before modify_dt_for_tstops! shortened it to land on a tstop, so that the next step isn't grown from the (much shorter) landing step. Since modify_dt_for_tstops! also runs in apply_step! (#3096), it runs twice per accepted step, and the second call records the already-shortened dt in dtpropose. So the restore (#2869) restored the shortened step: after a stop placed 1% into a step, the next step was 0.1× the controller's proposal.

Changes

Default behaviour: controllers see the accepted step

  • integrator.dt stays at the step actually taken while step_accept_controller! runs. Controllers that record the step therefore store the step that was taken: Nordsieck tau, and PredictiveController's dtacc for RadauIIA and the stabilized RK methods.
  • Callbacks see the same accepted step, and the current-step interpolant spans [tprev, t]; the test for this (Callback interpolation after a tstop-clamped step uses the restored proposal dt #4655) preserves behavior observed on the merge base.
  • The next step is the controller's proposal from the landing step, so the growth bound qmax holds relative to the shortened step.
  • Without the new option, the step sequence is the same as master, except where master recorded the wrong length. On master, a stop inside the first step left the unshortened initial dt in dtacc/tau.

Opt-in: solve(prob, alg; resume_dt_after_tstop = true)

  • Record the step before either modify_dt_for_tstops! call in a new dt_before_tstop field of ODEIntegrator (clamped to dtmax when used).
  • After the landing step, the next step is max(dtnew, dt_before_tstop * min(1, dtnew / accepted_dt)), computed in _resume_dt_after_tstop. The landing step's factor may shrink the resumed step but not grow it, and the result is never smaller than the controller's own proposal. The resumed step is not limited by qmax relative to the landing step.
  • The step is resumed only when all of these hold:
    • modify_dt_for_tstops! actually shortened the step. A stop exactly at the end of the proposed step leaves the proposal alone.
    • The step is not a discontinuity step (is_disco_step).
    • The integrator records dt_before_tstop. Other integrators, e.g. DelayDiffEq's DDEIntegrator, keep the controller's own proposal.
    • The active algorithm supports it.
  • New public trait resumes_dt_after_tstop(alg), true by default. get_current_resumes_dt_after_tstop(alg, cache) makes the active member of a CompositeAlgorithm decide.
  • resumes_dt_after_tstop(::NordsieckBDFAlgs) = false: the Nordsieck BDF methods regrow within their own step-ratio limit, as CVODE does.
  • DiffEqBase exempts the keyword from the kwargshandle check only for algorithms that list it in the new documented hook DiffEqBase.solver_specific_kwargs(alg); OrdinaryDiffEqCore lists it for OrdinaryDiffEqAlgorithm and DAEAlgorithm. Other solvers, e.g. DelayDiffEq's MethodOfSteps, reject it under strict keyword validation. The behaviour is documented in docs/src/api/controllers.md.

Versions: OrdinaryDiffEqCore 4.21.0, which requires DiffEqBase 7.22. OrdinaryDiffEqBDF 2.4.15, which requires OrdinaryDiffEqCore 4.21.

Work-precision with resume_dt_after_tstop = true

These numbers compare step resumption against master. They were measured on af36792, where resumption was always on, so they show what the option gives (the composite-member fix in a3ddbcc doesn't affect these solvers). The default path matches master on the same probes.

Setup: Julia 1.13.4, abstol = reltol = tol for tol = 1e-4 … 1e-10 (Robertson: abstol = 1e-4 tol).

  • Error: the maximum over 401 points of the dense solution, relative to a RadauIIA5 reference at 1e-13 with no tstops. The relative error has a floor of 1 (Robertson: 1e-6).
  • Work at matched error: nf with resumption divided by nf on master interpolated, in log-log, at the same error. The table gives the geometric mean over tolerances; < 1 means resumption is cheaper.
  • Problems:
    • u' = -u on (0, 10), tstops every 0.11 and 0.37;
    • Van der Pol with ε = 1e-3 on (0, 2), tstops every 0.037 and 0.11;
    • Robertson on (0, 1e5), log-spaced tstops 10 .^ (-4:0.25:5);
    • Lotka–Volterra on (0, 20), tstops every 0.11 and 0.37.
u' = -u Van der Pol Robertson Lotka–Volterra
Tsit5 0.89, 0.89 1.02, 0.95
Rodas5P 0.90, 0.89 0.87, 0.96 0.89
RadauIIA5 1.09, 1.23 0.66, 0.72 0.88
KenCarp4 1.02, 0.88 0.91, 1.11 0.95
FBDF 0.85, 1.02 1.07, 1.13 0.97
QNDF 1.05, 1.07 1.02, 0.99 1.02

Two numbers in a cell are for the two tstop spacings, denser first. Over all 29 cases the geometric mean is 0.95: 17 cases are cheaper and 6 are more than 5% more expensive. Accepted steps go down in every case.

Where resumption costs more:

  • FBDF on Van der Pol: +7% / +13% at matched error, with more rejections (514 → 662 and 566 → 711).
  • QNDF: about neutral at matched error, with more rejections. For example, 57 → 120 on u' = -u, and 142 → 243 on Robertson.
  • RadauIIA5 on u' = -u: +9% / +23%. It is 28–34% cheaper on Van der Pol.
  • KenCarp4: both versions are noisy. Each has isolated tolerances on Van der Pol with O(1) or larger errors.

nf doesn't count Jacobians or factorizations, so for the implicit methods this is a proxy for cost, not wall time.

Known issue with the option

AN5 with resume_dt_after_tstop = true returns a wrong result. On the lib/OrdinaryDiffEqNordsieck state-resizing test, the solve reports success but the end value is off by 8.8%, against 3.5e-10 without the option. Making AN5 opt out with resumes_dt_after_tstop(::AN5) = false fixes it. JVODE gives the same results with or without the option on that test.

Tests

  • test/InterfaceI/ode_tstops_tests.jl
    • With the option, the step after a tstop resumes the proposal and never exceeds it (Tsit5, Rodas5P, FBDF).
    • The step after a tstop respects qmax by default and resumes with the option: PIController(Tsit5(); qmax = 2) and a 2^-16 landing step give 2^-15 and 0.125 respectively.
    • Callbacks after a step shortened to a tstop see the accepted step and a correct interpolant (Callback interpolation after a tstop-clamped step uses the restored proposal dt #4655).
    • A tstop exactly at the end of the proposed step does not limit the next proposal (paired with the no-tstop case).
    • PredictiveController records a step shortened onto a tstop at its accepted length in dtacc. This covers RadauIIA5 (core controller) and AdaptiveRadau (FIRK override), with exact dyadic stops inside the first step and after it, with and without the option. The first-step case fails on master.
  • lib/OrdinaryDiffEqBDF/test/nordsieck_tests.jl: NordsieckBDF records the accepted length in tau for a first-step and an interior stop, and its next proposal stays within its growth bound, with and without the option.
  • lib/OrdinaryDiffEqCore/test/algorithm_interface_tests.jl: get_current_resumes_dt_after_tstop follows the active member of a CompositeAlgorithm.
  • lib/DelayDiffEq/test/interface/discontinuities.jl: for MethodOfSteps(Tsit5()), the step after an interior tstop grows past the landing step and the solve reaches the end of tspan.

🤖 Generated with Claude Code

https://claude.ai/code/session_018GADJLyZrg1HGFBsU9ht7f

`_loopfooter!` restores the step the controller proposed before `modify_dt_for_tstops!`
shortened it to land on a tstop, so that the next step is not grown from the (much
shorter) landing step. Since `modify_dt_for_tstops!` also runs in `apply_step!` (SciML#3096),
it runs twice per accepted step and the second call records the already shortened `dt` in
`dtpropose`, so the restore (SciML#2869) restored the shortened step: after a stop placed 1%
into a step, the next step was 0.1× the controller's proposal (the PI controller's `qmax`
growth from the landing step).

Record the step before either call in a new `dt_before_tstop` field and resume with it
after the landing step. The landing step's error may shrink it but not grow it: scaling the
restored step by the landing step's factor (up to `qmax`× on the strength of a tiny step's
tiny error) overshoots, with more rejections and larger errors at matched tolerance.
Callbacks of the landing step now see the accepted step in `integrator.dt`, so the
current-step interpolant spans [tprev, t] (SciML#4655).

Periodic tstops cost fewer steps at equal tolerance (u' = -u, stops every 0.11, 1e-8:
Tsit5 199 → 151, Rodas5P 171 → 136); at matched achieved error the effect on small test
problems is mostly within ±10%, larger where stops are dense relative to the step size.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@ChrisRackauckas-Claude ChrisRackauckas-Claude left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @SebastianM-C, this fixes #4749 and also #4655. On the reproducer, the step after a tstop landing goes back to 1.00× the controller's proposal (master: 0.10× for Tsit5/Rodas5P, 0.51× for FBDF). In the #4655 callback, dt is 1.0 and Rodas5P's i(0.5) is 1.5. The new testsets fail on master and pass here. An automated review found one blocking item.

  1. DelayDiffEq gets worse (blocking). DDEIntegrator has next_step_tstop but no dt_before_tstop, so _get_dt_before_tstop falls back to dtpropose, the already-shortened landing step. The new cap if landed && abs(dtnew) > abs(integrator.dt) then holds every following step to that landing step.
    • On u' = -u(t-1) with MethodOfSteps(Tsit5()), tol 1e-8, tstops = 0.11:0.11:10, master takes 134 accepted steps and this branch takes 207. Limiting the cap to ODEIntegrator brings it back to 134.
    • DDEs without user tstops are affected too, because propagated discontinuities are tstops.
    • Could you add dt_before_tstop (plus the _get_/_set_dt_before_tstop! methods) to DDEIntegrator in lib/DelayDiffEq, or at least apply the cap only where the field exists? A DDE step-count regression test would be good either way.
  2. Default behaviour change. Every adaptive solve with tstops now takes a different step sequence. With periodic tstops it usually takes fewer accepted steps (Rodas5P 335→265, FBDF 479→439), but sometimes with more rejections and a larger error at the stops. For FBDF with Δ = 0.37, rejections go 13→23 and the max error 6.9e-5→3.9e-4, which is above its no-tstop baseline of 2.3e-4. An FBDF work-precision comparison in the PR body would help the maintainers decide between making this the default and putting it behind a keyword. Since results change, it probably wants at least a minor version bump.
  3. Comments. About 18% of the added lines are comments, and the dt_before_tstop rationale appears twice. One short comment at the helper definitions would be enough.
  4. Minor. On accepted steps the step is recorded in apply_step! before fix_dt_at_bounds!, so the restored step can exceed dtmax. calc_dt_propose! clamps it later, so it isn't a bug, but recording it after the bounds are applied would be clearer.

Related: our draft #4805 (for #4750) fixes something different, the one-ulp step between tstops an ulp apart, and doesn't touch the controller. The two are complementary. This PR is the one for #4749, and whichever merges second only needs a trivial rebase.

🤖 Review by an AI agent (Claude Code, model claude-opus-5-5[1m]) on behalf of Chris Rackauckas — https://claude.ai/code/session_01AXwyJDRaMKgnYMG9M1Ut49

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

PR: #4751

Reviewed head: 11daadf
Raw SHA-256: 5887d4b00f372fd55e063f7a59987a0a0a0560b85a546346806d607ae0e80df9
Source SHA-256: 6f85d1115f3297dbef1ac7e4da168f650b1685ede412d08eaa6ab12369de07a3
Source: standard-review-v1 (harness-log)
Reviewer session: 01a21679-203d-7c62-b276-b44c6575e205
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: high (H2)
  • Verdict: CHANGES
  • Reviewed head: 11daadf

Review report

VERDICT: CHANGES
Round: 1
Head: 11daadf
Slot: 1
CI: CI unreadable; review only; merge gates unchanged
Session: 01a21679-203d-7c62-b276-b44c6575e205
Reviewer: codex-cli 0.170.0; model: gpt-6.2-sol

Risk

high (H2: adaptive tstop handling changes step control and numerical results for the default solver)

Blocking findings

  • Blocking priorities: P1, P2

  • [P1] Nordsieck BDF records the proposed length as accepted history. lib/OrdinaryDiffEqCore/src/integrators/integrator_utils.jl:655 assigns the unshortened proposal to integrator.dt before calling step_accept_controller!. The Nordsieck acceptance method feeds that value to nordsieck_complete! at lib/OrdinaryDiffEqBDF/src/controllers.jl:685, and the next coefficient calculation uses the resulting tau history. For u' = 1 with dt = dtmax = 0.125 and a stop at 0.125 + 2^-14, both revisions accepted a second step of 6.103515625e-5. The head recorded tau[1] = 0.125 while the merge base recorded 6.103515625e-5. The history assertion passed 3/3 on the merge base and failed 1 of 3 on the head. A separate first-step probe found the wrong history on both revisions, so the head extends the defect to interior stops.

    Implementation fix — In _loopfooter!, keep the accepted step length in integrator.dt while ODE controllers commit their history. Pass the unshortened proposal separately to the next-step calculation. In OrdinaryDiffEqBDF/src/controllers.jl, use the accepted length for Nordsieck bookkeeping and apply recovery only to the returned next proposal. Preserve the existing controller hook signatures and check PredictiveControllerCache.dtacc in OrdinaryDiffEqCore/src/integrators/controllers.jl, which also records the accepted step length. In lib/OrdinaryDiffEqBDF/test/nordsieck_tests.jl, add first-step and interior dyadic stops and assert that the newest tau entry equals the accepted length in both cases.

  • [P2] The growth cap also fires when there is no unshortened step to recover. lib/OrdinaryDiffEqCore/src/integrators/integrator_utils.jl:667 uses the landing flag, which is also set for a stop exactly coincident with the proposed step. For Tsit5 on u' = 1 with dt = 0.125 and dtmax = 0.5, an exact stop at 0.125 reduced the next proposal from 0.5 on the merge base to 0.125 on the head. Both revisions proposed 0.5 when the stop was omitted. DelayDiffEq also reaches this branch through lib/DelayDiffEq/src/integrators/interface.jl:4 and uses the generic proposal fallback. For MethodOfSteps(Tsit5()) with dt = dtmax = 0.125 and a stop at 0.125 + 2^-16, the proposal fell from 1.52587890625e-4 to 1.52587890625e-5. The full solve took 12 accepted steps on the merge base and 13 on the head, with zero rejections and endpoint 2.0 on both.

    Implementation fix — In _loopfooter!, apply recovery and its cap only when the integrator recorded a proposal and the accepted step is strictly shorter in magnitude. Keep exact time snapping independent of that decision and preserve the existing controller proposal for integrators using the fallback. Add a paired exact-stop and no-stop test to test/InterfaceI/ode_tstops_tests.jl that asserts get_proposed_dt(integ) == 0.5 in both cases. Add the interior MethodOfSteps(Tsit5()) case to lib/DelayDiffEq/test/interface/discontinuities.jl and assert that the next proposal grows beyond the landing step and the endpoint equals 2.0.

Non-blocking findings

  • lib/OrdinaryDiffEqCore/src/integrators/integrator_utils.jl:125 and :277, plus test/InterfaceI/ode_tstops_tests.jl:319 and :336. The diff adds 13 comment lines out of 71 added lines, including repeated explanations of the recorded step and a historical fallback description. Implementation fix — Keep # Record the proposed step before either tstop adjustment. at the capture in loopheader!. Delete the accessor comment and the two cited test comments. The existing tests cover this comment-only edit.

What I ran

  • git diff --name-status -M origin/master...HEAD identified three ODE core source files and one tstop test file, all modifications. H6 is inapplicable. git diff --check origin/master...HEAD exited 0.
  • GROUP=InterfaceI julia --startup-file=no --project=. -e 'using Pkg; Pkg.test()' on Julia 1.12.4 exited 0 with Testing OrdinaryDiffEq tests passed. The summaries reported 664 passes and seven existing broken cases, including 78/78 passes in the tstop testset. A direct run of test/InterfaceI/ode_tstops_tests.jl in the resolved test environment also passed. I stopped the duplicate InterfaceI runs with reduced compilation after the standard run completed.
  • julia --startup-file=no --project=. ../probe_regressions.jl on both revisions verified the added assertions. Proposal recovery passed 10/12 on the merge base and 12/12 on the head. Callback assertions passed 1/4 on the merge base and 4/4 on the head.
  • The same Julia command with probe_history.jl and probe_dde_interior.jl, using the respective ODE and DelayDiffEq environments, produced the failing head and passing merge-base results above. The exact-stop probe used --compile=min -O0 --compiled-modules=existing --pkgimages=existing and passed 4/4 on the merge base and 3/4 on the head.
  • julia --startup-file=no --project=. ../probe_ode.jl compared both revisions with the analytic solution exp(-t). With interior stops and abstol = reltol = 1e-8, default solve(prob) succeeded on both. Accepted steps changed from 39 to 34, and maximum sampled absolute error changed from 6.421e-12 to 5.753e-12.
  • uv run --locked python --version printed Python 3.13.13 and warned that --locked has no effect outside a project. The checkout has no uv.lock.

What I did not verify

The full BDF and DelayDiffEq suites, other Julia versions and platforms, and downstream packages beyond the DelayDiffEq probe.

AUTHOR_GRADE: {"task":"bugfix","score":2,"difficulty":4,"rounds":1,"author_harness":"unknown","author_model":"unknown","note":"The new ODE tests discriminate on the merge base and InterfaceI passes, but the shared acceptance path records incorrect Nordsieck history and suppresses valid step growth."}

Head link: 11daadf


🤖 Posted by an AI agent — harness: codex-cli 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a21679-203d-7c62-b276-b44c6575e205 (no session URL)

ChrisRackauckas and others added 2 commits November 26, 2026 12:02
Resolve the conflict in _loopfooter!: keep this branch's restore of
dt_before_tstop and its growth cap, and master's restore of the accepted
step before callbacks.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude <[email protected]>
Agent-Harness: Claude Code 2.1.332
Agent-Model: claude-opus-5-5
Agent-Job: SciML__OrdinaryDiffEq.jl__4751--20261126T152703Z-claude-claude-opus-5-5
Agent-Session: local session a5a71e23-1cd4-4ab9-83fc-6b9c0f657a5b (no session URL)
The landing step used to overwrite integrator.dt with the unshortened
step before step_accept_controller!, so controllers that record the step
(Nordsieck tau, PredictiveController dtacc) stored a step that was never
taken. Controllers now see the accepted step. The unshortened step is
applied afterwards, in _resume_dt_after_tstop, and only when:

- modify_dt_for_tstops! actually shortened the step (an exact stop at the
  end of the proposed step leaves the proposal alone);
- no discontinuity cap applies to the next step;
- the integrator records dt_before_tstop (DelayDiffEq's integrator keeps
  the controller's own proposal);
- resumes_dt_after_tstop(alg) holds. The new public trait is false for
  NordsieckBDF and DNordsieckBDF, which regrow within their own step-ratio
  limit, as CVODE does.

The controller's step factor from the landing step then may shrink the
unshortened step but not grow it, and the result is never smaller than
the controller's own proposal. dt_before_tstop is clamped to dtmax.

OrdinaryDiffEqCore 4.21.0 (new public trait, changed step sequences with
tstops); OrdinaryDiffEqBDF 2.4.15 requires it.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude <[email protected]>
Agent-Harness: Claude Code 2.1.332
Agent-Model: claude-opus-5-5
Agent-Job: SciML__OrdinaryDiffEq.jl__4751--20261126T152703Z-claude-claude-opus-5-5
Agent-Session: local session a5a71e23-1cd4-4ab9-83fc-6b9c0f657a5b (no session URL)

Copy link
Copy Markdown
Member Author

Thanks for af36792. Keeping the accepted step in integrator.dt while step_accept_controller! runs fixes the Nordsieck tau history and also PredictiveController's dtacc. On the original head, dtacc after a landing step was 100× the step actually taken. For RadauIIA5 on u' = -u with tstops every 0.11 that took 117 accepted steps, against 96 on master; with af36792 it's back to 96.

The new tests don't cover the dtacc case. Should I add one, e.g. RadauIIA5 with an interior tstop, asserting that dtacc equals the step taken? Or is the agent that pushed af36792 taking this branch over? I don't want us both pushing to it.

I've also put the FBDF work-precision comparison asked for in the earlier review into the description, along with the other solvers. Overall the matched-error cost is about 5% lower. FBDF on Van der Pol is the main case that costs more (+7% / +13%, with more rejections).


Generated by Claude Code

…p landing

The landing step's `dtacc` must be the step actually taken, not the step the
controller asked for before it was shortened onto the tstop. On 11daadf it was
100x the accepted step for both RadauIIA5 (core PredictiveController path) and
AdaptiveRadau (the FIRK override); af36792 fixed both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018GADJLyZrg1HGFBsU9ht7f
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

PR: #4751

Reviewed head: 4bb4b27
Raw SHA-256: d6845b21a9938dad34afd3dc11306604c86b6a7665d66a9294f3a8ace95d4ac0
Source SHA-256: 556f5ad1bce8364344eaa8fedb5707ca012bded3d4c6599905ddd4cd07ff88ef
Source: standard-review-v1 (harness-log)
Reviewer session: 01a219aa-70a3-7491-ae4a-4c1f74876179
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: high (H2)
  • Verdict: CHANGES
  • Reviewed head: 4bb4b27

Review report

VERDICT: CHANGES
Round: 3
Head: 4bb4b27
Slot: 1
CI: formatter or lint is not green
Session: 01a219aa-70a3-7491-ae4a-4c1f74876179
Reviewer: codex-cli 0.170.0; model: gpt-6.2-sol

Risk

high (H2: recovery after a shortened tstop changes adaptive step control on default OrdinaryDiffEq paths)

Blocking findings

  • Blocking priorities: P1, P2

  • [P1] lib/OrdinaryDiffEqCore/src/integrators/integrator_utils.jl:679. Tstop recovery overrides the documented per-step growth bound (lib/OrdinaryDiffEqCore/src/integrators/controllers.jl:34)). With Tsit5, PIController(Tsit5(); qmax = 2), dt = dtmax = 0.125, and a stop at 0.125 + 2^-16, the landing length was 2^-16on both revisions. The base proposed and accepted2^-15next. This head proposed and accepted0.125, 8,192 times the landing length. With a compact forcing term just after the stop and abstol = reltol = 1e-10, the head returned 0.0withSuccessand zero rejections. The base returned1.0000000013114927. The exact integral is 1 because the forcing is (30/w) * x^2 * (1-x)^2on0 < x < 1, with x = (t - tstop - w/2) / wandw = 2^-16`.

    Implementation fix — In _loopfooter! and _resume_dt_after_tstop, cap the increase due to recovery at the accepted length times the controller's effective growth bound. Use get_current_qmax(integrator, get_qmax(integrator)) for controllers that use this bound, preserve the existing first-step rule and direction, and preserve the controller's proposal as the floor. A separately documented opt-in for faster recovery is a design option. I recommend retaining the existing controller contract because callers already use qmax to limit growth. Document the cap in lib/OrdinaryDiffEqCore/src/alg_utils.jl and docs/src/api/controllers.md. Add the dyadic qmax = 2 case to test/InterfaceI/ode_tstops_tests.jl and assert the next proposal and accepted length are both 2^-15 and the transient integral is within 1e-8 of 1. Exercise full recovery with a landing length that permits it under the effective growth bound.

  • [P2] lib/OrdinaryDiffEqCore/src/integrators/integrator_utils.jl:287. The composite wrapper receives the generic true trait even when the active algorithm opts out. In the isolated probe, a test-only false trait on Tsit5 yielded a proposal of 0.000152587890625 for standalone Tsit5. A CompositeAlgorithm((Tsit5(), Vern7()), _ -> 1) running Tsit5 proposed 0.125. Selecting Vern7 also proposed 0.125.

    Implementation fix — In lib/OrdinaryDiffEqCore/src/alg_utils.jl, add current-member dispatch following get_current_has_stiff_interpolation. Use _eval_index(resumes_dt_after_tstop, alg.algs, cache.current) for the composite and call the helper from _dt_shortened_for_tstop. Document the active-member semantics in the trait docstring. In lib/OrdinaryDiffEqCore/test/algorithm_interface_tests.jl, add two local test algorithms with opposite trait values and assert that both active cache indices yield their selected member's trait. In the tstop suite, assert that an opted-out active member produces the same controller-only proposal as its standalone equivalent.

Non-blocking findings

  • test/InterfaceI/ode_tstops_tests.jl:369. The new interior-stop case passed 6/6 on both the base and the head. It caught both incorrect history writes on the pre-history-fix implementation. A first-step stop exercises a distinct path and failed on the base for both Radau methods. Implementation fix — Keep the interior test and add an exact first-step case with dt = dtmax = 0.125 and tstops = [2.0^-16]. After one step, assert that the clock and controller_cache.dtacc both equal 2.0^-16. The first-step probe passed 4/4 on the head and 2/4 on the base, which recorded 0.125 in both caches.
  • test/InterfaceI/ode_tstops_tests.jl:364. The test commit contains a Claude co-author and a Claude-Session trailer. The required Chris co-author and the three standard agent trailers are absent. Implementation fix — Add Co-Authored-By: Chris Rackauckas <accountsChris.com> and Agent-Session: https://claude.ai/code/session_018GADJLyZrg1HGFBsU9ht7f. Fill Agent-Harness: and Agent-Model: with the exact values reported by that authoring session, using unknown for an unavailable value. This is a commit metadata correction.

What I ran

  • Compared the supplied delta with the prior-head diff byte for byte and inspected all 13 paths in git diff --name-status -M origin/master...HEAD. There were no renames or authority or security path changes. The delta adds a test using FIRK, which is already a test dependency. git diff --check origin/master...HEAD, Runic 1.10.0 in check mode on the changed Julia files, and typos on the changed paths exited 0. The checkout was clean.

  • Ran the package groups below from a scratch archive of the head using Julia 1.12.4, the layered depot, and the repository's package sources. Command form was GROUP=<group> julia --startup-file=no --compiled-modules=existing --pkgimages=existing -O1 --project=<project> -e 'using Pkg; Pkg.test(; julia_args=["--compiled-modules=existing", "--pkgimages=existing", "-O1"])'. Each exited 0 and printed the package's tests passed message.

    Group Project Affected assertions
    InterfaceI . Tstops 88/88 and tstop callback interpolation 728/728
    Core lib/OrdinaryDiffEqBDF Nordsieck BDF 144/144
    Interface lib/DelayDiffEq Discontinuity 72/72
  • Ran julia --startup-file=no --compiled-modules=existing --pkgimages=existing -O1 --project=<revision>/probe-env probe.jl <case> against resolved scratch environments. External dependency versions matched on the base and head. qmax passed 5/5 on the base and 2/5 on the head. composite passed 1/2 on the head. The unmodified Radau test body (radau-control) passed 6/6 on base and head and 4/6 on the parent of the controller-history fix. The independent interior dyadic probe (radau-exact) passed 8/8 on base and head. With the same flags, probe_first_radau.jl produced the first-step result above.

  • uv run --locked python --version printed Python 3.13.13. This checkout contains no uv.lock, and uv reported that --locked had no effect outside a project.

What I did not verify

Hosted CI, the docs build, QA, GPU, downstream suites, and Julia versions other than 1.12.4. The harness reported the Codex session recorded above. A Devin session name was unavailable for this run.

AUTHOR_GRADE: {"task":"bugfix","score":2,"difficulty":4,"rounds":3,"author_harness":"unknown","author_model":"unknown","note":"The new Radau test catches both pre-fix history writes. The current head still bypasses an explicit growth limit and ignores the active composite member's opt-out."}

Head link: 4bb4b27


🤖 Posted by an AI agent — harness: codex-cli 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a219aa-70a3-7491-ae4a-4c1f74876179 (no session URL)

ChrisRackauckas and others added 3 commits November 26, 2026 17:29
The next step after a step shortened onto a tstop resumes the pre-shortening
proposal only with the new `resume_dt_after_tstop = true` solve/init keyword
(default false). By default the controller's proposal from the accepted
landing step stands, so `qmax` bounds the growth: with
`PIController(Tsit5(); qmax = 2)` and a 2^-16 landing step the next step is
2^-15, and a transient right after the stop is resolved again.

`_dt_shortened_for_tstop` queries `get_current_resumes_dt_after_tstop`, which
for a `CompositeAlgorithm` evaluates `resumes_dt_after_tstop` on the member
selected by `cache.current` instead of the wrapper.

DiffEqBase accepts the keyword alongside `stage_limiter`/`step_limiter` in its
keyword check, and OrdinaryDiffEqCore requires DiffEqBase 7.22.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude <[email protected]>
Agent-Harness: Claude Code 2.1.332
Agent-Model: claude-opus-5-5
Agent-Job: SciML__OrdinaryDiffEq.jl__4751--20261126T203233Z-claude-claude-opus-5-5
Agent-Session: local session 28d82478-4548-4435-9492-bfb0bfbba8bd (no session URL)
…stop

Use exact dyadic steps (u' = 1, dt = dtmax = 0.125) with a stop 2^-16 into
the first step and 2^-16 past the first step, and compare `dtacc` with the
accepted step exactly, with and without `resume_dt_after_tstop`. The
first-step case fails on master, which records 0.125 for RadauIIA5 and
AdaptiveRadau; both cases failed before the controllers saw the accepted
step.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018GADJLyZrg1HGFBsU9ht7f
The DiffEqBase keyword check exempted resume_dt_after_tstop for every
solver, so MethodOfSteps silently accepted a keyword it ignores. The check
now receives the selected algorithm and exempts the names returned by the
new documented hook DiffEqBase.solver_specific_kwargs(alg), which
OrdinaryDiffEqCore specializes for OrdinaryDiffEqAlgorithm and
DAEAlgorithm. stage_limiter and step_limiter stay exempt for all solvers.

Tests: DelayDiffEq init and solve reject the keyword under KeywordArgError;
solve and init with default algorithm selection accept it. The controller
docs describe the default growth from the accepted step and the
short-transient caveat of the opt-in.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude <[email protected]>
Agent-Harness: Claude Code 2.1.332
Agent-Model: claude-opus-5-5
Agent-Job: SciML__OrdinaryDiffEq.jl__4751--20261126T231403Z-claude-claude-opus-5-5
Agent-Session: local session 55017f2f-bc8c-4359-b190-2a0fbcdef634 (no session URL)
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

PR: #4751

Reviewed head: caa23b9
Raw SHA-256: fedd0b82d8bf14ff987baa5a633185729483af77ac733976a4945a91373a6527
Source SHA-256: 96b208949948601c62a32330a0b9af7e15a8c6daf3cbdf265fd7ef1cd13d4c0f
Source: standard-review-v1 (harness-log)
Reviewer session: 01a21a30-7dab-7e30-9b38-a2bb3d5ba80c
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: high (H2)
  • Verdict: CHANGES
  • Reviewed head: caa23b9

Review report

VERDICT: CHANGES
Round: 5
Head: caa23b9
Slot: 1
CI: formatter or lint is not green
Session: 01a21a30-7dab-7e30-9b38-a2bb3d5ba80c
Reviewer: codex-cli 0.170.0; model: gpt-6.2-sol

Risk

high (H2: the shared accept path changes default adaptive step control after a shortened first tstop, reproduced with Tsit5)

Blocking findings

  • Blocking priorities: P2

  • [P2] lib/DiffEqBase/src/solve.jl:114 — The global exemption for resume_dt_after_tstop still bypasses strict keyword validation for DelayDiffEq. With MethodOfSteps(Tsit5()) and kwargshandle = KeywordArgError, the merge base threw CommonKwargError in all four cases (init and solve, with the option passed at the call or stored in the problem). The reviewed head reported No exception thrown in all four cases. On the head, with a first stop at 2^-16 and dt = dtmax = 0.125, the DDE's next proposal was 0.0010305419054041766 both with and without the explicit opt-in.

    Implementation fix — In lib/DiffEqBase/src/solve.jl, keep the unconditional exemption for the two limiter keywords and make init_call and solve_call exempt the resumption keyword only for algorithms that consume it. Use solver dispatch so unsupported ODE algorithms also retain strict validation. Define and document the capability in DiffEqBase if it needs a new cross-package hook, and specialize it for the consuming methods in lib/OrdinaryDiffEqCore/src/solve.jl. Handle omitted algorithms at the selection point in lib/OrdinaryDiffEqDefault/src/default_alg.jl and preserve the caller's kwargshandle. In lib/DelayDiffEq/test/interface/discontinuities.jl, assert CommonKwargError for both entry points and both keyword sources. In test/InterfaceI/ode_tstops_tests.jl, retain explicit Tsit5 coverage and assert that default algorithm selection honors the opt-in. Scope the documented option to adaptive OrdinaryDiffEq solves in docs/src/api/controllers.md.

Non-blocking findings

  • docs/src/api/controllers.md:121 — The unconditional qmax claim fails on the first accepted step. With PIController(Tsit5(); qmax = 2) and a first stop at 2^-16, the head proposed a step about 67.54 times the landing length. The first step uses qmax_first_step. Implementation fix — Replace the growth-bound clause with “The next step uses the controller's proposal from the accepted landing step, subject to the usual step-size limits. Controllers with growth limits apply their configured first-step and subsequent-step limits.” Extend the first-stop cases in test/InterfaceI/ode_tstops_tests.jl with distinct qmax_first_step and qmax values, and assert that the first proposal follows the first-step bound and the interior proposal follows qmax.

What I ran

  • Matched the supplied delta byte for byte with the previous-head comparison and read the supplied previous-head review. The delta only changes the Radau testset. Inspected all 16 paths in the whole diff with rename detection. There were no renames or authority, security, workflow, hook or deployment executor changes. git diff --check origin/master...HEAD, Runic 1.10.0 and 1.13.0 in check mode on all 12 changed Julia files, and typos 1.47.0 on all changed paths exited 0. The original checkout was clean.

  • Ran the exact changed PredictiveController testset from test/InterfaceI/ode_tstops_tests.jl on Julia 1.12.4. It passed 16/16. The separate analytic probe checked the state against u(t) = t, the landing against the prescribed stop, and the recorded length against signed 2^-16. It passed 64/64 on the head across both Radau algorithms, both stop positions, both integration directions and both option settings. The merge base, with the option omitted, passed 28 assertions and failed four. Both Radau algorithms recorded signed 0.125 for the first landing where the accepted step was signed 2^-16.

  • Ran the strict DDE probe on the merge base and head. It passed 4/4 on the base and failed 4/4 on the head as described above. Ran the default-controller Tsit5 probe on both revisions. After the first landing at 2^-16 with initial dt = 0.125, the merge base proposed and took 0.125 and the head proposed and took 0.0010305419054041766. Starting with dt = 2^-16 reproduced the head's proposal on both revisions.

  • Ran all five groups on Julia 1.12.4 from scratch copies of the repository with the supplied layered depot. The command was GROUP=<group> julia --startup-file=no --compiled-modules=existing --pkgimages=existing -O1 --project=<project> -e 'using Pkg; Pkg.test(; julia_args=["--compiled-modules=existing", "--pkgimages=existing", "-O1"])'. OrdinaryDiffEqCore used GROUP=Core julia --startup-file=no --project=lib/OrdinaryDiffEqCore -e 'using Pkg; Pkg.test()' with normal precompilation. Each run exited 0 and reported tests passed.

    Project Group Relevant assertions
    OrdinaryDiffEq InterfaceI Tstops 107/107, tstop callback interpolation 728/728
    DelayDiffEq Interface Discontinuity 72/72
    OrdinaryDiffEqBDF Core Nordsieck BDF 152/152
    OrdinaryDiffEqCore Core Algorithm trait contract 16/16, tolerance default equality 110/110
    DiffEqBase Core Problem kwargs merging 27/27
  • Evaluated docs/make.jl with the docs project and the deployment call omitted. Documenter completed cross-reference and document checks and produced docs/build/api/controllers/index.html. uv run --locked python --version printed Python 3.13.13 and warned that --locked had no effect outside a project. The checkout has no uv.lock.

  • The active harness reported the Codex session UUID used in the header. This run has no Devin session name.

What I did not verify

Hosted CI, deferral issue status, QA, GPU and downstream suites, and Julia versions other than 1.12.4.

AUTHOR_GRADE: {"task":"bugfix","score":3,"difficulty":4,"rounds":5,"author_harness":"unknown","author_model":"unknown","note":"The exact Radau testset passes and the independent probe detects the first-step bug on the base. The shared keyword exemption still makes strict DelayDiffEq calls silently accept an option they ignore."}

Head link: caa23b9


🤖 Posted by an AI agent — harness: codex-cli 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a21a30-7dab-7e30-9b38-a2bb3d5ba80c (no session URL)

ChrisRackauckas and others added 5 commits November 26, 2026 20:09
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude <[email protected]>
Agent-Harness: Claude Code 2.1.332
Agent-Model: claude-opus-5-5
Agent-Job: SciML__OrdinaryDiffEq.jl__4751--20261126T231403Z-claude-claude-opus-5-5
Agent-Session: local session 55017f2f-bc8c-4359-b190-2a0fbcdef634 (no session URL)
With resume_dt_after_tstop = true, AN5 restarted across a resizing tstop
returned an 8% endpoint error with a Success retcode. AN5 now keeps its
established restart step, like the Nordsieck BDF methods. The resize
cases run with both option values.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude <[email protected]>
Agent-Harness: Claude Code 2.1.332
Agent-Model: claude-opus-5-5
Agent-Job: SciML__OrdinaryDiffEq.jl__4751--20261127T040210Z-claude-claude-opus-5-5
Agent-Session: local session 9d3a9ca6-424c-4f05-b24a-c1cc817d53b2 (no session URL)
Both QA environments source the checkout's OrdinaryDiffEqCore, which now
requires DiffEqBase 7.22 for solver_specific_kwargs, but resolved their
direct DiffEqBase dependency from the registry, where the newest release
is 7.21.6. Resolution failed before any QA assertion ran. Sourcing
DiffEqBase from the checkout matches the ExplicitRK, ExponentialRK,
HighOrderRK and SSPRK QA environments.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude <[email protected]>
Agent-Harness: Claude Code 2.1.332
Agent-Model: claude-opus-5-5
Agent-Job: SciML__OrdinaryDiffEq.jl__4751--20261127T053510Z-claude-claude-opus-5-5
Agent-Session: local session e30f946c-684d-4eed-93ca-bc001612e0e0 (no session URL)
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: opencode <[email protected]>
Agent-Harness: opencode 2.0.27
Agent-Model: opencode-go/hungerg-free
Agent-Job: SciML__OrdinaryDiffEq.jl__4751--20261127T102122Z-opencode-opencode-go-hungerg-free
Agent-Session: local session ses_de3781fdcffeQk4pHoPXMPpLvy (no session URL)
A custom `step_accept_controller!` may compute its proposal by mutating
`integrator.dt`. Without the restore, callbacks and `current_interpolant`
saw the proposed interval instead of the completed step, so dense output
inside the callback was evaluated with the wrong normalization.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude <[email protected]>
Agent-Harness: Claude Code 2.1.332
Agent-Model: claude-opus-5-5
Agent-Job: SciML__OrdinaryDiffEq.jl__4751--20261127T161917Z-claude-claude-opus-5-5
Agent-Session: local session 0b0c5333-f2ce-4681-bd0a-be20af559a69 (no session URL)
@ChrisRackauckas

Copy link
Copy Markdown
Member

🤖 Automated status from an AI agent running as Chris Rackauckas's account — not written or reviewed by Chris.

Review status. Counted round-10 review on this head (97d6d803) returned MERGE with zero blocking findings. Round 9's single P1 (the accept path left the proposed step size visible to callbacks and to interpolation when a custom accept hook computes via integrator.dt) is repaired with the reviewer's prescription verbatim — a one-line restoration in _loopfooter! — plus a custom-controller regression test (33/33, and it fails 1/2-pass on the prior head exactly as the reviewer measured). All feature behavior graded green in rounds 4–9 was re-run on this head and is byte-identical: interior-tstop landing snapshot, dt_before_tstop, opt-in resume_dt_after_tstop both ways, midpoint and hold-precision probes, Tstops 111/111, callback-interpolation 728/728; InterfaceI, Core, QA, docs, Runic and typos are clean.

CI status. The reds on this head all reproduce on master and were individually attributed in earlier rounds: GPU autoswitch and the AD-on-LTS tape failure; DiffEqBase QA/Downstream registry drift (stale explicit imports + an Enzyme union in pre-existing SciMLBase metadata, reproduced on a clean master checkout); and the OrdinaryDiffEqNonlinearSolve Core failure is the Newton line-search exception tracked in #5032. Every other leg (format, Runic, spell, docs, benchmarks, Downgrade, IntegrationTest) is green on this head.

Non-blocking — for the author. Two PR-description corrections came from the review (agents cannot edit contributor descriptions, so these are relayed): the verification paragraph should state that by default the controller computes the next step from the accepted landing interval — the next proposal can therefore change, including for PIController on the first step when master passed the unclipped interval to the accept hook — and the attribution footer should link the original Claude Code session with its model recorded.

Next step. Handed to the merge queue for a maintainer merge.

🤖 Posted by an AI agent — harness: Claude Code · model: qwen3.8-flash-next

Conversation: directed-6 head session, local job directed-6-20261126 (no session URL)

@ChrisRackauckas
ChrisRackauckas merged commit cb87b90 into SciML:master Nov 27, 2026
285 of 293 checks passed
ChrisRackauckas referenced this pull request Nov 28, 2026
Bump version to 2.3.2
Bump version to 2.3.2
Bump version to 2.3.2
Bump version to 2.3.2
Bump version to 2.3.2
Bump version to 2.3.2

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: AI agent <[email protected]>
Agent-Harness: hourly_releases
Agent-Model: none (deterministic)
Agent-Session: local job hourly-release-74dba2e6-d998-45b2-acda-764f0cc7c3c4 (no session URL)
Agent-Session: local job hourly-release-3fa5fb01-9edb-4207-a008-f3e965ad262a (no session URL)
Agent-Session: local job hourly-release-12159859-e451-418a-b40a-03a35d145353 (no session URL)
Agent-Session: local job hourly-release-1f090ad0-9f29-4772-9a87-f993ebb136a2 (no session URL)
Agent-Session: local job hourly-release-399633b3-4944-4d57-9c31-97c7a8620b97 (no session URL)
Agent-Session: local job hourly-release-bac847af-5e64-4a93-b113-bf0e92dc91bd (no session URL)
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.

Step after a tstop grows from the shortened landing step: modify_dt_for_tstops! runs twice and overwrites dtpropose

4 participants