Skip to content

FBDF/QNDF: O(h²) BDF1 error estimate on the first step - #4615

Draft
ChrisRackauckas-Claude wants to merge 12 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/4606-bdf1-first-step-predictor
Draft

ChrisRackauckas-Claude wants to merge 12 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/4606-bdf1-first-step-predictor

Conversation

@ChrisRackauckas-Claude

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

Copy link
Copy Markdown
Member

🚧 UNREVIEWED — awaiting review by @ChrisRackauckas. Filed by an AI agent running as @ChrisRackauckas; Chris has not seen this.
Harness: Cursor Agent (first pass), then Claude Code · Model: auto (Cursor), then claude-opus-5-5[1m]
Conversation: https://claude.ai/code/session_015tNYhuzygK9z8yhh6MNCAz

Please ignore until reviewed by @ChrisRackauckas.

What changed and why

With no history, FBDF used u₀ = u and QNDF took an NDF1 step with an all-zero difference table. That made the first-step error estimate the whole increment u - uprev, which is O(h). On a stiff transient this forces a tiny first step, and at t0 = 14400 that step is below eps(t0), so the solve aborts (#4606). QNDF's first step was also inconsistent: (1-κ)(u - uprev) = h f(u) is backward Euler with step h/(1-κ). Both methods now take a plain BDF1 first step with an explicit-Euler predictor. FBDF also steps with the increment the integrator actually commits.

  • FBDF, first step (iters_from_event == 0, identity mass matrix): u₀ = uprev + dt*fsalfirst, and lte = -(u - u₀)/2 without the ts-based rescaling, whose second node is still the zero-filled placeholder on a first step. Once history exists, the Lagrange predictor and error are unchanged. Mass-matrix problems keep master's first-step code; see Not fixed here.
  • FBDF, committed increment: perform_step! sets integrator.dt = (t + dt) - t for the step and restores the proposed dt afterwards. The history is stored at the committed times fl(t + dt), and when dt is a few eps(t) the nominal dt differs from that spacing. At t0 = 14400 this mismatch gave EEst = 15.6 at step 6 (proposed 2.97e-12, committed 3.64e-12) and the solve aborted. The core's bounds, tstop and retry decisions are untouched. Every return path of the step goes back through the wrapper, which restores dt. An exception propagates out of the solve.
  • QNDF, first step (k == 1, D all zero, identity mass matrix): κ = 0, with the explicit-Euler predictor as the Newton guess and in the error, and error constant 1/2. D[1] = dt*fsalfirst is seeded only after Newton succeeds, so a Newton-failure retry is again a plain BDF1 start. After update_D!, D[1] = u - uprev.
  • test/Regression_I/ode_dense_tests.jl: the old QNDF check compared a fixed-step solve against the adaptive interpolant at tolerance 0.02. It passed only because master's inconsistent first step cancelled about half of NDF1's first-order error. QNDF now uses compare_fixed_step = false, a new keyword that defaults to true, and gets independent references:
    • the fixed-step solve must match the NDF1 recurrence to rtol = 1e-12;
    • err/h must be within 2% of (1/2+κ)λ²u(1);
    • adaptive dense output must be within a bound derived from the local error, checked against the analytic solution.

Error constant. Let u₀ = uₙ + h f(uₙ), and take one BDF1 step. Then u_BE - u(t+h) = h²/2 u'' and u(t+h) - u₀ = h²/2 u'', so u_BE - u₀ = h² u'' and the BDF1 local error is (u - u₀)/2, which is κγ₁ + 1/2 at κ = 0. The forced dt = 1.8e-12 step from the issue gives EEst = 0.0845 on both methods, against a true weighted h²|u''|/2 = 0.0865.

Evidence

The new testsets in lib/OrdinaryDiffEqBDF/test/bdf_regression_tests.jl were each run standalone on this head and on master's sources (origin/master f9ce35d):

testset master this head
FBDF/QNDF first step: O(h²) BDF1 error estimate (t0=14400 success, forced dt=1.8e-12 with 0 rejects; FBDF/QNDF, IIP/OOP) Fail 16/16 Pass 16/16
QNDF first step after a Newton failure matches a fresh BDF1 start (u'=u², dt=0.8) Fail 2/10 (accepted u = 1.27389 vs backward-Euler root 1.38197) Pass 10/10
FBDF mass-matrix start from an inconsistent algebraic state (t0 = 1e4) Pass 4/4 Pass 4/4
FBDF steps that land on a tstop across t = 0 (explicit cases + seeded 300-tspan sweep, both directions) Pass 18/18 Pass 18/18

The last two testsets guard against regressions found in intermediate revisions of this PR. The mass-matrix testset failed 4/4 on 614629c, and the tstop testset failed 14/18 on db3acde. Both pass on master and on this head.

MWE from the issue, retcode naccept/nreject (IIP, OOP). Master is origin/master f9ce35d:

t0 alg tol master this PR
0 FBDF 1e-8 Success 139/5, 147/5 Success 139/5, 142/7
0 FBDF 1e-10 Success 300/14, 273/10 Success 301/15, 273/11
0 QNDF 1e-8 Success 116/7, 112/2 Success 116/5, 114/6
0 QNDF 1e-10 Success 195/9, 184/6 Success 197/12, 184/7
14400 FBDF 1e-8 Unstable 10/3, 10/3 Success 135/6, 136/6
14400 QNDF 1e-8 Unstable 0/1, 0/1 Success 104/7, 95/3
14400 FBDF, QNDF 1e-10 Unstable Unstable (expected: BDF1 needs h ≈ 5e-13 < eps(14400))

Forced first step dt = 1.8e-12 at t0 = 0: master accepts FBDF dt = 1.2e-15 after 3 rejects and QNDF dt = 5.5e-14 after 2 rejects. This head accepts 1.8e-12 with 0 rejects on both (EEst = 0.0845).

Other runs:

  • cd lib/OrdinaryDiffEqBDF && GROUP=Core julia +1.12 --project=. -e 'using Pkg; Pkg.test()':
DAE Convergence Tests |   50     50  5m54.6s
DAE AD Tests  |   40     40  27m29.5s
DAE Event Tests |    4      4  40.6s
DAE derivative_discontinuity! Tests |   11     11  1m09.3s
DAE Initialization Tests |   38       2     40  3m40.1s
DAE Nonlinear Solve Path Tests |   16     16  2m07.2s
BDF Inference Tests |    1      1  2.8s
BDF Convergence Tests |   98     98  14m40.2s
BDF Regression Tests |   97     97  16m55.7s
BDF Time Reversal Tests |   20     20  5m36.0s
FBDF Time Filter Tests |   41     41  1m39.2s
FBDF Filter Regression Tests |  273    273  1m04.6s
Nordsieck BDF Tests |  140    140  12m21.1s
LHL Factorization Tests |   19     19  2m30.0s
     Testing OrdinaryDiffEqBDF tests passed
(DAE Initialization: 38 pass + 2 pre-existing @test_broken)
  • Root GROUP=Regression_I julia +1.12 --project=. -e 'using Pkg; Pkg.test()':
Dense Tests   | 4082   4082  86m55.5s
Special Interp Tests |   30     30  7m45.6s
Inplace Tests |    2      2  37.7s
Adaptive Tests |   46     46  15m11.5s
Hard DAE Tests |   36     36  36m13.8s
Newton-Krylov Round-off Tests |    6      6  6m38.9s
     Testing OrdinaryDiffEq tests passed
  • SciMLSensitivity test/Core3/dae_adjoint.jl, run with this branch's libraries developed:
Index-1: fully implicit Robertson |   20     20  12m00.2s
Index-1: parameter-dependent algebraic constraint |    4      4  3m42.5s
Index-0: implicit-form ODE vs ODE adjoint |   10     10  5m57.2s
Index-2 Hessenberg with p-dependent constraint |    8      8  48.9s
informative errors |    2      2  18.6s
no algorithm: adjoint in residual form |    4      4  6m42.7s
  • The round-3 review probe tstop-cross.jl: all 20 explicit FBDF/QNDF cases give Success, and the sweep has 0/300 failures for FBDF and QNDF, IIP and OOP.
  • The round-4 rewind probe (callback at a tstop reached by a clamped first step): this head's FBDF gives integrator(0.5) = 1.25, final 2.75. That matches master's Rodas5P (1.25 / 2.75) and is close to ImplicitEuler and TRBDF2 (1.34375 / 2.84375) on the same problem. The bug is in the core and is tracked in Callback interpolation after a tstop-clamped step uses the restored proposal dt #4655. Master's FBDF does not hit it only because it never accepts that large first step.
  • Runic --check and typos on all changed files: clean.

Not fixed here

  • Callback interpolation after a tstop-clamped step uses the restored proposal dt #4655: callback interpolation after a tstop-clamped step uses the restored proposal dt. Pre-existing on master for ImplicitEuler, TRBDF2 and Rodas5P. This PR makes FBDF accept larger first steps, so FBDF now shows it too.
  • modify_dt_for_tstops! snaps within 100 ulps regardless of dt/dtmax; committed step can exceed dtmax #4656: modify_dt_for_tstops! snaps within 100 ulps regardless of dt/dtmax, and the committed step fl(t+dt) - t can exceed dtmax for every solver. It also proposes a public committed_step API. Until that lands, FBDF's committed increment can be 1 ulp beyond dtmax, like every other solver, and in the snap case FBDF keeps master's mismatch.
  • FBDF step-size/order control uses h^k u^(k) (order k-1 error) as the order-k error estimate #4641: FBDF step and order control uses h^k u^(k) as the order-k error estimate.
  • Mass-matrix first step (FBDF) is master's code. Its estimate is ≈ 0 for t ≫ dt. SciMLSensitivity's DAE adjoints start from inconsistent algebraic states and depend on that first step being accepted: an honest estimate broke Core3 dae_adjoint.jl in an intermediate revision. A proper fix needs a consistent start.
  • DFBDF has the same u₀ = u first-step predictor and is not changed.
  • Float32 at a shifted origin: FBDF at t0 = 14400f0, tol 1e-4 returns Success with an error of about 0.035 (found by a reviewer). The accuracy problem predates this PR.
  • Not run locally: ModelingToolkit downstream, QA, GPU.

Push back on

  1. Swapping integrator.dt for the duration of FBDF's step, rather than a core-provided committed step (modify_dt_for_tstops! snaps within 100 ulps regardless of dt/dtmax; committed step can exceed dtmax #4656).
  2. The compare_fixed_step keyword in the shared regression_test helper, and the replacement QNDF checks.
  3. iszero(D[1]) as QNDF's "no history" test. It is also true for an exactly constant solution, where the step is equivalent.

Fixes #4606

Risk assessment

  • Risk: medium
  • Blast radius: FBDF and QNDF step results for every non-mass-matrix problem. Both are default stiff solvers, so step sequences shift slightly for downstream users: completed ROBER accepted-step counts change by −2.9% to +3.0% and short Van der Pol by −2.6% to +1.8% (reviewer's comparison against master). No public API change and no new dependency. FBDF now accepts larger first steps, which exposes the pre-existing callback-interpolation bug Callback interpolation after a tstop-clamped step uses the restored proposal dt #4655 on FBDF, as master's Rodas5P/ImplicitEuler/TRBDF2 already do.
  • Evidence: the new startup tests fail 16/16 on master and pass on this head. The Newton-retry tests fail 2/10 on master and pass 10/10. The QNDF dense checks fail 8 on master and pass 70/70. Also passing: BDF GROUP=Core, root Regression_I, SciMLSensitivity Core3 dae_adjoint.jl 48/48, the zero-crossing tstop sweep with 0/600 failures, and the issue's MWE at t0=14400, tol 1e-8, which fails on master (see Evidence above).
  • Independent review: six rounds by other harnesses. Codex gpt-6-astra reviewed rounds 1, 2, 3, 5 and 6, and Devin SWE-2 Fusion (Opus 5.5) reviewed round 4. Each earlier round's blocking findings were fixed or split out as Callback interpolation after a tstop-clamped step uses the restored proposal dt #4655 and modify_dt_for_tstops! snaps within 100 ulps regardless of dt/dtmax; committed step can exceed dtmax #4656. Round 6 on acf2b3f: VERDICT MERGE, RISK medium, high confidence in the scoped correction. It found no blocking issues and advises human review because changing FBDF stepping affects downstream numerical behavior.
  • Merge: needs human review: this changes the numerics of default stiff solvers.

Authors: Cursor Agent (model auto) first pass; revised by Claude Code (model claude-opus-5-5[1m]).
🤖 Generated with Claude Code
https://claude.ai/code/session_015tNYhuzygK9z8yhh6MNCAz

Risk assessment

  • Risk: medium

  • Blast radius: Step sequences and error estimates change for FBDF and QNDF on all identity-mass-matrix problems. Both are default stiff solvers, and FBDF is also picked by DefaultODEAlgorithm, so downstream numerical results move slightly: different accepted/rejected step counts and larger accepted first steps. The public API is unchanged. Two risky internals:

    • FBDF's perform_step! now overwrites integrator.dt with the committed increment (t+dt)-t while the step runs and puts it back afterwards. If the step throws, dt is not restored.
    • QNDF decides it has no history with iszero(D[1]).

    Because FBDF now accepts larger first steps, it exposes the existing callback-interpolation bug Callback interpolation after a tstop-clamped step uses the restored proposal dt #4655. The description discloses this.

  • Evidence: On head acf2b3f09, 135 checks pass, 4 fail and 1 is skipped. The skipped one is the unexpanded sublibrary-ci matrix placeholder; the per-sublibrary jobs ran separately. All 4 failures also fail on master 4a5c0e71b, the same way, so none is a regression:

    • SciMLSensitivity.jl/Core1: pre-existing. Both fail with the same Mooncake/MooncakeAdjoint Error During Test at concrete_solve_derivatives.jl:451.
    • tests / GPU (julia 1): pre-existing. Both fail QNDF mass=diag_cu at test/gpu/dae_tests.jl:481; master fails 3 variants and the PR 1. This is the mass-matrix path, which the PR deliberately leaves alone (f.mass_matrix === I gate).
    • downgrade-sublibraries (lib/DiffEqBase): pre-existing. Both fail the same high_level_solve.jl:94–101 assertions (1 failed, 3 errored).
    • downgrade-sublibraries (lib/OrdinaryDiffEqDifferentiation): pre-existing. Both fail with the same MethodError: diag(::ScalarOperator).

    These pass on head: OrdinaryDiffEqBDF Core (Julia 1 and lts), BDF QA, BDF GPU, BDF downgrade, root QA, Regression_I and Regression_II (1/lts/pre), ModelingToolkit and the ModelingToolkit downstream groups.

    The head's CI ran on 2026-09-27, about a week before the master runs I compared against. GitHub reports the PR as mergeable, but it has not been re-run on current master.

    Test changes:

    • Removed check: the QNDF fixed-step vs adaptive-interpolant comparison (tolerance 0.02) is gated off by a new compare_fixed_step=false keyword on the shared regression_test helper.
    • Replacements: three stronger checks — an exact NDF1 recurrence at rtol=1e-12, the error constant within 2%, and a dense-output bound against the analytic solution.

    It is disclosed and the reasoning is given, but it is still the removal of an existing assertion. No @test_broken or skips were added and no tolerances were loosened. There are no review comments on the PR.

  • Independent review: Devin CLI / fusion-claude-opus-5-5-high-sidekick-swe-2-medium rated it medium, medium-high confidence: CI shows no regressions and the description is unusually complete, but the PR changes the step-by-step numerics of default stiff solvers, briefly rewrites integrator.dt, and replaces an existing QNDF regression check.

  • Merge: needs human review. Findings:

    1. The numerics of FBDF/QNDF change for all non-mass-matrix users.
    2. The temporary integrator.dt swap is unprotected (no try/finally). The proper core API is deferred to modify_dt_for_tstops! snaps within 100 ulps regardless of dt/dtmax; committed step can exceed dtmax #4656.
    3. The QNDF fixed-step regression check is replaced through a new helper keyword.
    4. The iszero(D[1]) cold-start heuristic.
    5. Not addressed here: DFBDF and the FBDF mass-matrix first step still have the O(h) estimate.
    6. CI results are a week old relative to master.
  • Next review: must come from a non-Codex harness (round fixed by Codex CLI gpt-6.1-sol at head 3036e4e)


🤖 Risk assessment posted by an AI agent (fleet master) — harness: Devin CLI / fusion-claude-opus-5-5-high-sidekick-swe-2-medium; dispatched by Devin CLI 3000.11.3 fleet-master caretaker, model Fusion (claude-opus-5-5 medium + swe-2 medium)
Conversation: local Devin transcript speckle-whale (no session URL)

Independent review (Codex CLI 0.162.1 gpt-6.1-sol, head 3036e4e)

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

VERDICT: CHANGES
Needs verification of the failing downstream check; no additional implementation defect found. The startup correction is supported by local failing-before/passing-after evidence. Risk is high under H2, which explicitly names this PR: FBDF participates in default solver selection, and its error estimate and effective step increment change. The older medium ratings in the PR body do not meet the supplied criteria.

  1. .github/workflows/Downstream.yml:20 — The supplied current-head CI snapshot reports FAILURE for SciMLSensitivity.jl/Core4/1 (job 116819642536). Suspected from reading: a downstream regression remains possible; its cause is not established. The snapshot contains 135 successful checks and three skipped matrix placeholders, but no master comparison or failure log for Core4. The PR body's older comparisons concern different failures and an older head, so they cannot establish that this failure is pre-existing. Obtain the Core4 error output and compare it with master under matching dependencies, rerunning the failed check as required, before calling this mergeable. This is a verification blocker, not a claim that Core4 is broken by the patch.

Local evidence: I extracted all four new BDF regression testsets and the new QNDF fixed-step/dense-output testset verbatim into tmp/newtests.jl, nested under one outer testset so all failures are collected. I ran them on scratch copies of head 3036e4e and base 59ba40e (the master parent of the merge), leaving repo's tracked files unchanged. Commands used JULIA_NUM_THREADS=4 JULIA_NUM_PRECOMPILE_TASKS=4 timeout 3600 choom -n 500 -- julia --startup-file=no --project=tmp/{head,base}/lib/OrdinaryDiffEqBDF -e 'using Pkg; Pkg.instantiate(); include("tmp/newtests.jl")'. Julia was 1.12.7.

Confirmed by running:

  • Head: 60/60 assertions pass (29.4 s after setup).
  • Base: 34 pass, 26 fail (29.5 s after setup): all 16 first-step assertions fail, two of ten Newton-retry assertions fail, and eight of twelve fixed-step/dense-output assertions fail. Mass-matrix startup (4/4) and tstop/time-reversal tests (18/18, including randomized accuracy sweeps) pass on both.
  • Logs: tmp/head-tests.log and tmp/base-tests.log. The latter failures are the added regression expectations on unfixed code, not failures found in the existing master suite.

Gates: G1 is satisfied by analytic backward-Euler roots, exponential reference values, and the independently derived NDF1 recurrence/error constant. G2 has relevant successful AD and GPU jobs in the supplied head snapshot; no AD rule or GPU kernel is edited. G3 is satisfied for startup-history handling by the Newton-failure/fresh-start comparison, which exercises both mutable and constant caches. The general no-test-regressions gate remains unverified because of Core4. High risk requires Chris's decision even after verification is complete.

Not verified: Core4 failure logs, a matching master Core4 run, and a rerun of the failed CI check; the unauthenticated GitHub CLI reports that authentication is required. I did not run full BDF Core, root Regression_I, QA, downstream, GPU, or AD suites locally; passing jobs cited above come from the supplied snapshot. Exception recovery after the temporary integrator.dt assignment and the disclosed callback/tstop limitations were not independently reproduced.

🤖 Posted by an AI agent — harness: Codex CLI 0.162.1 · model: gpt-6.1-sol
Conversation: Codex exec session 01a14b1b-dafb-7012-900d-6ee67266e9a4 (no public URL)

Codex CLI gpt-6.1-sol rated it high (H2) at head 3036e4e

Round 1 fix — Core4 CI verification (2026-10-17)

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

The verification blocker in the Codex review at head 3036e4e is addressed by inspecting the failing PR and master Core4 job logs. No implementation changes were requested or made; the branch remains at 3036e4ebb8d1881be98087a11f015566b9cd4eed.

Run inspected Core4 result First exception line
PR head 3036e4e, tested as merge 284e45a into master 59ba40e — https://github.com/SciML/OrdinaryDiffEq.jl/actions/runs/38853472808/job/116819642536 Failure, 2026-10-16 AssertionError: mi2 !== nothing
Latest completed master IntegrationTest run, a9cc40a — https://github.com/SciML/OrdinaryDiffEq.jl/actions/runs/39049524638/job/117453456193 Failure, 2026-10-17 AssertionError: mi2 !== nothing

Both logs first report 2: EnsembleAlg = SciMLBase.EnsembleThreads(): Error During Test in test/Core4/ensembles.jl:19, followed by the exception above and threadsfor_common in Enzyme's src/rules/parallelrules.jl:233. Both end with Some tests did not pass: 15 passed, 0 failed, 1 errored, 2 broken. This establishes that the reported Core4 failure also occurs on master; it does not establish that Core4 passes.

Dependency comparison: both use Julia 1.13.2, SciMLSensitivity 7.119.13, Enzyme 0.13.216, EnzymeCore 0.8.23, LLVM 9.13.2, GPUCompiler 1.23.0, SciMLBase 3.58.0 and OrdinaryDiffEqBDF 2.4.13 (each run develops its respective repository sources). Comparing all 379 package/version entries found 17 version differences, so these are not identical locked environments. The same exception, test location and Enzyme source location occur in both.

Commands run and observed results:

  • gh run view 38853472808 --repo SciML/OrdinaryDiffEq.jl --job 116819642536 --log: downloaded and inspected the PR failure above.
  • gh run list --repo SciML/OrdinaryDiffEq.jl --branch master --workflow IntegrationTest --limit 5 --json databaseId,headSha,conclusion,createdAt,url: latest run 39061511222 is still in progress; latest completed run 39049524638 failed.
  • gh run view 39049524638 --repo SciML/OrdinaryDiffEq.jl --job 117453456193 --log: downloaded and inspected the matching master failure above.
  • gh run rerun 38853472808 --repo SciML/OrdinaryDiffEq.jl --failed: succeeded; attempt 2 Core4 job is queued at https://github.com/SciML/OrdinaryDiffEq.jl/actions/runs/38853472808/job/117487737409. Its outcome is not yet verified.
  • Fetched the PR's own remote branch and confirmed the supplied head SHA. No commit or push was needed. Runic, typos, local QA, docs and full test groups were not rerun in this verification-only round; no source, tests, docstrings or docs changed. Existing failing-before/passing-after evidence remains above.

The newest master's Core4 job is also queued: https://github.com/SciML/OrdinaryDiffEq.jl/actions/runs/39061511222/job/117483269136. The comparison uses the latest completed run rather than claiming an outcome for a queued job. The existing Codex high-risk H2 assessment and requirement for Chris Rackauckas's merge decision remain in force. This note is verification evidence, not an independent review or merge verdict.


🤖 Posted by an AI agent — harness: Codex CLI 0.162.1 · model: gpt-6.1-sol
Conversation: local session 01a14b67-8e86-7591-bb3d-5a6e854c5121 (no session URL)

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

Risk assessment (independent review, Codex CLI 0.164.0-alpha.11.1 gpt-6-astra, slot 1, head 3036e4e)

  • Risk: high (H2: FBDF participates in default stiff solving, and its first-step predictor, error estimate and effective increment change; QNDF startup and difference-history initialization also change.)
  • Verdict: CHANGES
  • Session: 01a18da8-0055-70e2-850a-45982d205850
  • Blocking priorities: P1

Review round 1, written by the reviewer named above (Codex CLI 0.164.0-alpha.11.1 / gpt-6-astra) in a session other than the PR author's, and copied here by the posting agent without change to its findings. The posting agent did not re-run the reviewer's commands.

Summary: Corrects FBDF/QNDF startup error scaling and adds analytic recurrence, retry and shifted-time tests. A paired full-package probe confirms that the newly accepted large FBDF first step exposes wrong callback interpolation and a wrong final solution after a callback rewind.

Blast radius: FBDF and QNDF identity-mass startup/restart paths, QNDF cold-start history after nonlinear failure, FBDF committed-time rounding, and callbacks reached by the changed accepted-step sequence.

Evidence: Head BDF Regression CI passes 97/97. With the same external dependency resolution, the analytic callback probe is accurate on current master but returns 1.25 instead of 1.5 on head, and a rewind ends at 2.75 instead of 3.0 despite Success. Current-head Enzyme Core4 failure matches recent completed master.

Blocking findings

  1. [P1] lib/OrdinaryDiffEqBDF/src/bdf_perform_step.jl:1557 — confirmed by running: for u' = 1, u(0) = 1, tspan = (0,2), FBDF(), dt = 5, tstops = [1], and tolerances 1e-8, this predictor/error-estimator change accepts the initial interval [0,1]. A discrete callback at 1 querying the midpoint of its accepted interval obtains 1.2499999999999998 instead of the analytic 1.5. Rewinding to that same valid midpoint with change_t_via_interpolation! makes the final state 2.7499999988532386 instead of 3.0, with ReturnCode.Success. The same dynamic-midpoint probe on current master with matching external dependencies gives midpoint and final values within 1e-8 of their analytic answers. The underlying core defect predates this PR: lib/OrdinaryDiffEqCore/src/integrators/integrator_utils.jl:637 restores the proposed step length before handle_callbacks!, so interpolation divides by the wrong interval. This PR exposes it on a previously accurate FBDF call. Integrate or require the accepted-step-length correction in companion PR Fix callback interpolation at tstops and restart BDF after rewinds #4664 before merging this startup change, and retain an analytic callback/interpolation/rewind regression. The correction costs one saved scalar step length and a regression solve; it requires no new numerical approximation.

Non-blocking findings

None.

What I ran

  • git rev-parse HEAD; full SHA matches the recorded PR head. git diff origin/master...HEAD; inspected all changed files and relevant callers/test wiring. Root AGENTS.md and CLAUDE.md are absent. Initial risk was recorded before reading the author's risk assessment.
  • git log -1 --first-parent --no-merges --format=%B; uses the newest PR-line non-merge commit, excluding master commits imported by a merge.
  • gh pr view 4615 --repo SciML/OrdinaryDiffEq.jl --json number,url,state,isDraft,headRefOid,baseRefName,baseRefOid,title,files,statusCheckRollup; gh pr checks 4615 --repo SciML/OrdinaryDiffEq.jl --json name,state,bucket,link,workflow; read the PR body after the initial risk freeze. Retrieval/git commands exited 0; failed check outcomes are described separately below.
  • gh issue view 4606 --repo SciML/OrdinaryDiffEq.jl --json title,body,state,url and gh issue view 4655 --repo SciML/OrdinaryDiffEq.jl --json title,body,state,url: read the original shifted-origin startup failure and the callback interpolation report after the initial independent risk assessment.
  • Julia tool, Julia 1.13.3, four Julia threads/one BLAS thread, isolated depot/temp: evaluated the following full-package probe separately on exact head 3036e4ebb8d1881be98087a11f015566b9cd4eed and base 14b964b315e1310b5e3621a1bcfe6b92e9e506aa, using the same external dependency Manifest. Both evaluations completed normally; this probe prints observations rather than asserting, and has no separate process exit code.
using OrdinaryDiffEqBDF, SciMLBase
for rewind in (false, true)
    done = Ref(false); seen = Ref(NaN); tm = Ref(NaN); prev = Ref(NaN)
    cb = DiscreteCallback((u,t,i) -> !done[] && t == 1.0,
        i -> begin
            prev[] = i.tprev; tm[] = (i.tprev + i.t) / 2
            seen[] = i(tm[])[1]
            rewind && SciMLBase.change_t_via_interpolation!(i, tm[])
            done[] = true
        end; save_positions = (false,false))
    prob = ODEProblem((u,p,t) -> one.(u), [1.0], (0.0,2.0))
    sol = solve(prob, FBDF(); dt=5.0, tstops=[1.0], callback=cb,
                save_everystep=false, abstol=1e-8, reltol=1e-8)
    println((rewind=rewind, tprev=prev[], tmid=tm[], seen=seen[],
             expected=1+tm[], final=sol.u[end][1], retcode=sol.retcode))
end
  • Observed base output: both callbacks use tprev = 0.5396984964784779, tmid = 0.769849248239239, and see 1.7698492478878176 versus expected 1.769849248239239. Final states are 2.9999999998265485 without rewind and 2.9999999994411772 with rewind, both Success. Head uses tprev = 0, tmid = 0.5, and sees 1.2499999999999998 versus 1.5; final states are 3.000000000103964 without rewind and 2.7499999988532386 with rewind, both Success. Every query is strictly inside its current accepted interval. The independent oracle is u(t) = 1+t; comparing against 1e-8 shows base passing and head failing this regression contract.
  • gh run view 38853472960 --repo SciML/OrdinaryDiffEq.jl --job 116842551277 --log, exit 0: BDF Core, Julia 1.13.2, BDF Regression | 97 97. Source inspection verifies analytic backward-Euler roots, exponential solutions and the independently derived NDF1 recurrence/error constant. The fixed/adaptive comparison is replaced with these independent checks and a derived dense-error bound, rather than merely dropping numerical coverage.
  • gh run view 38853472808 --repo SciML/OrdinaryDiffEq.jl --log-failed, exit 0: current Core4 attempt fails at test/Core4/ensembles.jl:19 with AssertionError: mi2 !== nothing in Enzyme's threaded rule; 15 pass / 1 error / 2 broken.
  • gh run list --repo SciML/OrdinaryDiffEq.jl --branch master --event push --limit 5; inspected the IntegrationTest-specific recent list. gh run view 41050161729 --repo SciML/OrdinaryDiffEq.jl --log-failed, exit 0: latest completed master IntegrationTest has the same Core4 test, exception, Enzyme threaded stack and 15 pass / 1 error / 2 broken. This establishes observed failure parity; it does not make either check green or establish identical locked dependencies for those CI runs.

What I did not verify

I did not rerun all new first-step tests on the unfixed base, the full BDF suite, or the root Regression_I suite locally. The earlier review's 60/60 head and 34-pass/26-fail base results are attributed prior evidence, not my executions. GPU/AD suites and the companion #4664 fix were not executed locally for this review. G1 is supported by analytic roots/exponentials and the recurrence checks; G3 includes Newton-failure/retry history tests, but the new callback regression is missing. No speedup is claimed. The first assessment froze risk and candidates before opening the PR description. A fresh independent assessor then froze a complete review of this exact PR head before reading its description, any prior review, other assessment notes, or coordinator-run Julia output. The final comparison and REVIEWER_GRADE below come from that fresh assessment. It subsequently evaluated prior same-head findings and newly available raw execution evidence; prior claims are distinguished from executions in this review session. The independent freeze remains unchanged. The fresh frozen static review initially found no blocker. Post-freeze inspection of the paired analytic callback execution changed its final verdict to CHANGES; this revision is not presented as a finding already in the blind freeze.

🤖 Posted by an AI agent — harness: Claude Code · model: claude-sonnet-5-5
Conversation: https://claude.ai/code/session_01379heiiB35TtywhR7uSU74

ChrisRackauckas and others added 3 commits September 23, 2026 19:21
Use an explicit-Euler predictor on the first order-1 step (and after
restart) so u-u₀≈dt²u'' and the existing factor 1/2 yields an
asymptotically correct BDF1 LTE. QNDF also zeros κ on cold start to
match QNDF1. FBDF stepsize uses EEst at order 1 and grows past eps(t).

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI 2026.09.23-86fc751
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/tmp_20260923_181807_1012334/jobs-root/jobs/4606-cursor/log.txt on amdci2.julia.csail.mit.edu
Covers t0=14400 tol=1e-8 iip/oop success and forced dt=1.8e-12 with
nreject==0 for FBDF and QNDF.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI 2026.09.23-86fc751
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/tmp_20260923_181807_1012334/jobs-root/jobs/4606-cursor/log.txt on amdci2.julia.csail.mit.edu
Remove the eps(t)-relative order freeze and forced step growth in the FBDF
controller, and the order-1 terk -> EEst swap in stepsize_controller!.

FBDF: use the explicit-Euler predictor only when there is no history
(iters_from_event == 0, identity mass matrix) and compute the error from
u - u0 without the ts-based rescaling, whose second node is not a history
point yet. The Lagrange predictor and error are unchanged otherwise.
Set dt to the representable increment (t + dt) - t, since the history
nodes are the rounded times and dt of a few eps(t) otherwise makes the
divided differences inconsistent (spurious EEst ~ 15 at t0 = 14400).

QNDF: with an all-zero difference history, seed D[1] = dt*f(uprev) and
take a plain BDF1 step (kappa = 0) with error constant 1/2, so the
predictor and the D history stay consistent.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Agent-Harness: Claude Code (subagent of orchestrator session)
Agent-Model: claude-opus-5-5[1m]
Agent-Session: https://claude.ai/code/session_015tNYhuzygK9z8yhh6MNCAz
@ChrisRackauckas-Claude ChrisRackauckas-Claude changed the title First pass: FBDF/QNDF O(h²) error estimate on the first order-1 step (#4606) FBDF/QNDF: O(h²) error estimate on the first step, representable dt in FBDF Sep 26, 2026
ChrisRackauckas and others added 6 commits September 26, 2026 11:00
QNDF: keep the difference table empty until Newton succeeds on a
no-history step. The explicit-Euler predictor is used only as the Newton
guess and for the error, and D[1] = dt*f(uprev) is seeded right before
update_D!, so a Newton failure followed by a smaller dt retries a plain
BDF1 start instead of treating the trial predictor as accepted history.

FBDF: round the endpoint t + dt toward t when choosing the representable
step, so the step used in the formulas and taken by the integrator never
exceeds the dt already limited by dtmax and the next tstop.

Regression_I dense tests: a fixed-step QNDF solve is NDF1, so check it
against the NDF1 recurrence and its leading error constant, and check the
adaptive dense output against the analytic solution, instead of comparing
the two with each other.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Agent-Harness: Claude Code (subagent of orchestrator session)
Agent-Model: claude-opus-5-5[1m]
Agent-Session: https://claude.ai/code/session_015tNYhuzygK9z8yhh6MNCAz
With a non-identity mass matrix and no history, the first-step error was
(u - uprev)/2. After an inconsistent algebraic start (e.g. an adjoint
DAE's terminal jump) that is O(1) in the algebraic rows and does not shrink
with dt, so at t0 >> 0 the step fell below eps(t) and the solve aborted.
Master masked this with the zero-filled ts[2] node, which scaled the
estimate by 2dt/(t + dt), i.e. to about zero for t >> dt.

Use M (u - uprev) - dt f(uprev), the explicit-Euler predictor error
premultiplied by M, which needs no M inverse. Differential rows give the
O(dt^2) BDF1 estimate, and algebraic rows give -dt g(uprev), which is zero
for a consistent start and shrinks with dt otherwise.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Agent-Harness: Claude Code (subagent of orchestrator session)
Agent-Model: claude-opus-5-5[1m]
Agent-Session: https://claude.ai/code/session_015tNYhuzygK9z8yhh6MNCAz
SciMLSensitivity's DAE adjoints solve a mass-matrix ODEProblem with FBDF
from an algebraically inconsistent start. On master the cold-start
estimate is rescaled through the zero-filled ts[2] (about 2dt/(t+dt)), so
the first step is accepted at a normal size, and the next step's Lagrange
predictor only extrapolates the algebraic jump by h2/h1. An unscaled
estimate, or M(u - uprev) - dt f(uprev) with or without the algebraic
rows, forces a tiny first step, after which the second step extrapolates
the whole jump and the adjoint aborts below eps(t).

Keep the explicit-Euler cold start for identity mass matrices only, and
restore master's predictor and estimate when mass_matrix !== I. Add a
BDF regression with a stiff constraint started off the manifold at t0 >> 0.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Agent-Harness: Claude Code (subagent of orchestrator session)
Agent-Model: claude-opus-5-5[1m]
Agent-Session: https://claude.ai/code/session_015tNYhuzygK9z8yhh6MNCAz
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Agent-Harness: Claude Code (subagent of orchestrator session)
Agent-Model: claude-opus-5-5[1m]
Agent-Session: https://claude.ai/code/session_015tNYhuzygK9z8yhh6MNCAz
Choose the step to the representable endpoint nearest t + dt if it lies
in [dtmin, dtmax] and does not pass the next tstop (landing on the tstop
itself is allowed below dtmin, as in the core), otherwise its neighbor on
the other side of t + dt. If neither is admissible, reject the step and
terminate with ReturnCode.DtLessThanMin rather than stepping below dtmin
or using a non-representable step.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Agent-Harness: Claude Code (subagent of orchestrator session)
Agent-Model: claude-opus-5-5[1m]
Agent-Session: https://claude.ai/code/session_015tNYhuzygK9z8yhh6MNCAz
When the core flags a step to land on a tstop or the tspan end, it
commits t = tstop regardless of how t + dt rounds. Across t = 0,
fl(tstop - t) can put t + dt one ulp past the tstop, and the bounded
endpoint search rejected both candidates and terminated with
DtLessThanMin. Use tstop - t for flagged steps, which matches the time the
core commits. For other steps, hold the representable endpoint only to the
bounds dt already satisfies, so a dt the core forces below dtmin is not
rejected.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Agent-Harness: Claude Code (subagent of orchestrator session)
Agent-Model: claude-opus-5-5[1m]
Agent-Session: https://claude.ai/code/session_015tNYhuzygK9z8yhh6MNCAz
Remove _fbdf_representable_dt and its dtmin/dtmax/tstop handling, which
moved core step-selection semantics into FBDF and read core-internal
fields. FBDF now runs its step with integrator.dt set to the committed
increment (t + dt) - t and restores the proposed dt afterwards, so the
formulas agree with the times stored in the history while the core keeps
its own bounds, tstop and retry decisions. The dtmin/dtmax cap tests move
to the core follow-up (SciML#4656); the callback interpolation issue exposed by
larger accepted first steps is SciML#4655.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Agent-Harness: Claude Code (subagent of orchestrator session)
Agent-Model: claude-opus-5-5[1m]
Agent-Session: https://claude.ai/code/session_015tNYhuzygK9z8yhh6MNCAz
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Devin <[email protected]>
Agent-Harness: Devin CLI 3000.11.3 (conflict resolution), Claude Code 2.1.285 (orchestration)
Agent-Model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium
Agent-Session: local Claude session 3c311569-dda6-4687-bc9f-65febb212c33 (fleet master); Devin log /Users/chrisrackauckas/sandbox/master/fusion-fixes/SciML_OrdinaryDiffEq.jl-4615/log.txt
@ChrisRackauckas

Copy link
Copy Markdown
Member

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

Merged the default branch into this PR (clean merge, no conflicts; head 603ebca) so CI runs on current master. Its earlier failures in SciMLSensitivity Core1 and the downgrade jobs were fixed on master after this PR's last CI run.


🤖 Posted by an AI agent — harness: Devin CLI 3000.11.3 (merge), Claude Code 2.1.285 (posting) · model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium
Conversation: local Claude session 3c311569-dda6-4687-bc9f-65febb212c33 (fleet master)

This branch has not been deployed

No deployments
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.

FBDF/QNDF: constant predictor on the first step makes the BDF1 error estimate O(h); solve aborts at t0 when t0 ≫ 0 (dt < eps(t0))

2 participants