Skip to content

Fix NordsieckBDF trial-step interpolation for delay equations - #4575

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix/nordsieck-dde-trial-interp
Sep 17, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix/nordsieck-dde-trial-interp

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Summary

Supersedes #4559 with a different mechanism for the same bug (credit to @svenzenker for identifying and first fixing it).

The bug: DelayDiffEq consumes the step's interpolation data inside perform_step! — advance_or_update_ode_integrator! copies integrator.k into the history integrator right after the step, and the fixed-point iteration refreshes it per iteration — all before the adaptive acceptance controller runs in _loopfooter!. NordsieckBDF only published integrator.k on acceptance (step_accept_controller! → nordsieck_complete!), so a delayed RHS evaluation inside the current step saw the previous step's committed polynomial — stale by a step and at the wrong h scale.

The fix: produce the trial interpolant on demand in _ode_addsteps! instead of publishing eagerly in perform_step!:

  • While cache.predicted holds (post-perform_step!, pre-acceptance), zn is the uncommitted trial state. A rebuild request (always_calc_begin, or force_calc_end — which DelayDiffEq's advance_ode_integrator!/update_ode_integrator! pass) materializes the corrected trial polynomial zn[j] + l[j]*acor — bit-for-bit what nordsieck_complete! commits on acceptance, so trial and post-acceptance k agree exactly.
  • Evaluation-only callers (always_calc_begin = force_calc_end = false: integrator(t), sol(t), get_du) keep the committed columns — mid-step interpolation semantics are unchanged, and saved dense output can't be overwritten by trial data while the HistoryODEIntegrator shares the cache for DefaultCache/CompositeCache configs.
  • Covers NordsieckBDF/DNordsieckBDF, constant and mutable caches, via the existing Union dispatch.

Also fixed (pre-existing, exposed by #4559): nordsieck_predict! is now idempotent via the predicted flag. DelayDiffEq's fixed-point iteration for lag < dt re-invokes perform_step! on the same uncommitted step; without the guard, zn is Pascal-shifted once per iteration and the trial polynomial drifts k·dt forward. This is the lag < dt case #4559 leaves broken — measured error ~0.1 there vs ~8e-9 here.

Differences vs #4559: trial k is generated on demand in _ode_addsteps! rather than eagerly in perform_step! (so perform_step! itself is net unchanged, rejection/retry semantics untouched, and the corrected DAE variants come along through the shared methods), and the lag < dt fixed-point path is fixed rather than regressed.

Test plan

New DelayDiffEq regression test/integrators/nordsieck.jl (registered in the Integrators group): exact-solution DDE u' = -e^{-lag} u(t-lag) with lag = 0.2 (saved-history path) and lag = 0.02 (fixed-point path), in-place/out-of-place RHS, with/without a continuous callback; asserts a rejection occurs, dense output matches exp(-t), and the callback fires once near log(2).

  • Fails without the fix: on unmodified master, the new testset fails 20/40 — both the stale long-delay interpolation (sol err ~1.8e-3, history err ~1.6e-2, event time off ~3.4e-3) and the lag < dt fixed-point drift.
  • Passes with the fix: NordsieckBDF trial-step history 40/40; also 40/40 inside the full GROUP=Integrators DelayDiffEq run.
  • New OrdinaryDiffEqBDF testset mid-step interpolation still sees committed data pins the evaluation-only contract: a step_limiter probe calls integrator(t)/integrator.sol(t) mid-step — 6/6 pass; without the force_calc_end gate it fails 4/6 and permanently corrupts saved dense output (post-solve err ~2e-2).
  • GROUP=Core OrdinaryDiffEqBDF: all pass (incl. Nordsieck BDF 140/140, DAE init/convergence/event/nlsolve).
  • GROUP=Integrators DelayDiffEq: all pass.
  • GROUP=QA OrdinaryDiffEqBDF and DelayDiffEq: pass.
  • Runic-clean; typos-clean; git diff --check clean.
  • GPU / pre / downstream groups not run locally.

🤖 Generated with Devin — Devin CLI 3000.10.27 (model: SWE-2 Max). Local session, transcript: /home/crackauc/.local/share/devin/cli/summaries/history_fa4fe6012694472c.md

DelayDiffEq consumes the step's interpolation data inside perform_step!
(advance_or_update_ode_integrator! and the fixed-point history refresh),
before the adaptive acceptance controller runs. NordsieckBDF only
published integrator.k on acceptance, so delayed RHS evaluations inside
the current step saw the previous step's committed polynomial.

Produce the trial interpolant on demand instead: while the Nordsieck
array is in the predicted state (cache.predicted), a requested rebuild
of the step's columns (always_calc_begin, or force_calc_end as
DelayDiffEq's advance/update pass) yields the corrected trial polynomial
zn[j] + l[j]*acor — exactly what nordsieck_complete! commits on
acceptance. Evaluation-only callers keep the committed columns, so
mid-step integrator(t) and saved-solution interpolation are unchanged.

Also make nordsieck_predict! idempotent: DelayDiffEq's fixed-point
iteration re-invokes perform_step! on the same uncommitted step, and zn
must not be Pascal-shifted again while already predicted.

Builds on the approach in SciML#4559 by moving the trial/committed split into
_ode_addsteps! and covering the lag < dt fixed-point path.

Co-Authored-By: Sven Zenker <[email protected]>
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.27
Agent-Model: SWE-2 Max
Agent-Session: local session transcript /home/crackauc/.local/share/devin/cli/summaries/history_fa4fe6012694472c.md
@ChrisRackauckas
ChrisRackauckas merged commit 7f97c7a into SciML:master Sep 17, 2026
145 of 149 checks passed
ChrisRackauckas added a commit that referenced this pull request Sep 17, 2026
Ships the NordsieckBDF trial-step interpolation fix for delay equations (#4575) and the roundoff-tolerant SBDF dt-change reset (#4574).

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude <[email protected]>
Agent-Harness: Claude Code 2.1.273
Agent-Model: claude-opus-5[1m]
Agent-Session: 6a01e420-3436-4518-83cc-6cd853283cfb (local transcript; this harness publishes no conversation URL)
ChrisRackauckas added a commit that referenced this pull request Sep 17, 2026
Ships the NordsieckBDF trial-step interpolation fix for delay equations (#4575) and the roundoff-tolerant SBDF dt-change reset (#4574).



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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants