Skip to content

DelayDiffEq: coalesce tracked dependent-lag discontinuities (fixes Waltman dt = 0) - #4802

Merged
ChrisRackauckas merged 3 commits into
SciML:masterfrom
ChrisRackauckas-Claude:dde-tracked-disc-propagated
Oct 14, 2026
Merged

ChrisRackauckas merged 3 commits into
SciML:masterfrom
ChrisRackauckas-Claude:dde-tracked-disc-propagated

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Ignore until reviewed by @ChrisRackauckas.

What changed and why

lib/DelayDiffEq [Regression] on master fails in test/regression/waltman.jl (Rodas5P + MethodOfSteps on prob_dde_RADAR5_waltman_5, reltol = 1e-7) with ArgumentError: matrix contains Infs or NaNs. The Jacobian is finite at the failure. W is non-finite because the step being attempted has dt == 0.0. Instrumented trace on master cceca4245:

  • Discontinuity tracking for the dependent lags t - u[5] and t - u[6], run on rejected steps, registered two discontinuities exactly one ulp apart: 197.00000007880783 and 197.00000007880786.
  • track_propagated_discontinuities! pushed both into the user heaps, opts.d_discontinuities and opts.tstops.
  • The integrator lands on ...783. handle_discontinuities! pops both discontinuities, because they are within 10eps. It only drops propagated tstops near t, and never drops user tstops (Rkmk2[WIP] #1124), so the tstop at ...786 survives.
  • shift_past_discontinuity! then moves t to nextfloat(...783) == ...786, which is exactly on that tstop. modify_dt_for_tstops! sets dt = distance_to_tstop = 0, so W = I/(dtγ) - J is non-finite.

The fix: tracked discontinuities are solver-generated, just like constant-lag ones. They now go into d_discontinuities_propagated and tstops_propagated, stored as tdir * t to follow those heaps' convention. handle_discontinuities! already coalesces those heaps within 10eps of a handled discontinuity. User tstops are unchanged.

#4592 (498c765cc, clock alignment in calc_dt_propose!) is the bisected first bad commit only because it changes the dt sequence enough to reach this ulp coincidence. The alignment itself is not wrong for DDEs, so this replaces the exemption in #4771 instead of adding to it.

Verification

Julia 1.13.1, lib/DelayDiffEq with the repository's sublibraries dev'ed.

New mechanism test test/regression/tracked_discontinuity_coalescing.jl (Regression group, run for neutral = false and neutral = true). It uses a dependent lag that is constant and has tracking register its propagated discontinuity. The test reads that time td ≈ 1 through the public SciMLBase.first_tstop, then adds a discontinuity and tstop at prevfloat(td). It asserts that the solve returns Success, that prevfloat(td) ∈ sol.t and that sol.t[end] == 2.

Before (track.jl from origin/master, --check-bounds=yes):

tracked discontinuity one ulp after a handled discontinuity (neutral = false): Test Failed
   Evaluated: 0.9999999999999997 == 2
Test Summary: (neutral = false) | Pass  Fail  Total
                                |    3     1      4

(on master the solve stops at td with a dt_min_unstable warning; driving it with step! instead hangs, because DDEIntegrator's step! retry loop has no check_error!)

After:

tracked discontinuity one ulp after a handled discontinuity (neutral = false) |    4      4
tracked discontinuity one ulp after a handled discontinuity (neutral = true)  |    4      4

GROUP=Regression julia +1 --project -e 'using Pkg; Pkg.test()' from lib/DelayDiffEq (the CI path, so --check-bounds=yes):

Allocation Tests |   12     12
Inference Tests  |   18 (broken) 18
Waltman Problem Tests |   26     26  43.9s
...
     Testing DelayDiffEq tests passed

GROUP=Interface and GROUP=Integrators, same command: both exit 0 (e.g. Discontinuity Tests | 55 55, Dependent Delay Tests | 17 17, Backwards Tests pass, Rosenbrock Tests | 42 42, Event Tests | 29 29).

Runic --check and typos are clean on the changed files.

Not verified / for the reviewer

  • The SDDE and QA groups and the Julia lts/pre versions were not run locally.
  • Backward-in-time DDEs with dependent lags: tracked discontinuities are now stored as tdir * t, matching every other heap entry. Before this they were stored unscaled. The tracking code itself still compares raw t against tdir-scaled T, which was already the case. This PR does not attempt to fix that.
  • Two related problems this PR does not fix: (1) DDEIntegrator's step! retry loop (while !integrator.accept_step) does not call check_error!, so a dt == 0 step hangs step! instead of erroring. (2) A user tstop at exactly nextfloat(t_d) of a handled discontinuity t_d would still produce dt = 0.
  • DelayDiffEq: add clock alignment and history regression coverage #4771 exempts DDE integrators from the clock alignment. With this PR it is no longer needed. Reject the step instead of throwing when W is non-finite (Rosenbrock + Newton) #4795 (non-finite W → step rejection) is independent defense in depth.

Risk assessment

  • Risk: low
  • Blast radius: DelayDiffEq.track_propagated_discontinuities! only, i.e. DDEs with dependent_lags. Tracked discontinuities within 10eps of a handled one are now coalesced, as constant-lag discontinuities already are. No public API change.
  • Evidence: new test fails before and passes after; Waltman 8/1 errored → 26/26; Regression, Interface and Integrators groups pass locally.
  • Independent review: Codex gpt-6-astra rated it low risk, verdict CHANGES (round 1). Its one blocking finding, that the test used the non-public first_discontinuity, is fixed. It also flagged a separate, pre-existing inaccuracy in where tracking places discontinuities on master, which is left as a follow-up.
  • Merge: needs human review (independent review pending)

🤖 Generated with Claude Code (model: claude-opus-5-5[1m]) https://claude.ai/code/session_011aK5Xvp9NpdkzKuEwtiMGd

…ated heaps

track_propagated_discontinuities! pushed discontinuities found for
dependent lags into the user heaps opts.d_discontinuities/opts.tstops.
handle_discontinuities! coalesces solver-generated discontinuities within
10eps of the handled one, but deliberately never drops user tstops, so a
tracked tstop one ulp after a handled discontinuity survived the
shift_past_discontinuity! nudge. The integrator then sat exactly on that
tstop and modify_dt_for_tstops! set dt = 0, giving a non-finite Rosenbrock
W (prob_dde_RADAR5_waltman_5 at t = 197.00000007880783 / ...786).

Push tracked discontinuities into d_discontinuities_propagated and
tstops_propagated, like constant-lag ones, stored as tdir * t.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Agent-Harness: Claude Code (subagent of ci-green head)
Agent-Model: claude-opus-5-5[1m]
Agent-Session: https://claude.ai/code/session_011aK5Xvp9NpdkzKuEwtiMGd
Read the tracked stop with SciMLBase.first_tstop instead of the non-public
OrdinaryDiffEqCore.first_discontinuity, assert the handled discontinuity is
saved, and cover neutral problems.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Agent-Harness: Claude Code (subagent of ci-green head)
Agent-Model: claude-opus-5-5[1m]
Agent-Session: https://claude.ai/code/session_011aK5Xvp9NpdkzKuEwtiMGd
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-4802/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 377c324) 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)

@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review October 14, 2026 01:56
@ChrisRackauckas
ChrisRackauckas merged commit 53e7d1d into SciML:master Oct 14, 2026
139 of 140 checks passed
xtalax added a commit to xtalax/OrdinaryDiffEq.jl that referenced this pull request Oct 17, 2026
xtalax added a commit to xtalax/OrdinaryDiffEq.jl that referenced this pull request Oct 17, 2026
xtalax added a commit to xtalax/OrdinaryDiffEq.jl that referenced this pull request Oct 17, 2026
xtalax added a commit to xtalax/OrdinaryDiffEq.jl that referenced this pull request Oct 17, 2026
xtalax added a commit to xtalax/OrdinaryDiffEq.jl that referenced this pull request Oct 17, 2026
ChrisRackauckas referenced this pull request Oct 18, 2026
Bump versions: DelayDiffEq 6.4.4
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Agent-Harness: Claude Code 2.1.301
Agent-Model: claude-opus-5-5
Claude-Session: https://claude.ai/code/session_01VZjwf7Ux9YtTzwHGHMqnsq
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