Skip to content

Clear QNDF's difference history when the state is resized - #4938

Open
singhharsh1708 wants to merge 2 commits into
SciML:masterfrom
singhharsh1708:qndf-resize-history
Open

singhharsh1708 wants to merge 2 commits into
SciML:masterfrom
singhharsh1708:qndf-resize-history

Conversation

@singhharsh1708

@singhharsh1708 singhharsh1708 commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

QNDF's resize_non_user_cache! now zeroes D and prevD, so the step after a resize starts from an empty difference history whether or not the callback then calls derivative_discontinuity!(integrator, false).

The resize sets derivative_discontinuity = true so that the next step clears the history, but the disc = false cases in resize_tests.jl clear that flag again right after resizing. The grown entries of D then hold whatever memory resize! returned, and the predictor u₀ = uprev + D[1] and the order-raising estimate read them. That is the intermittent BDF state resizing failure on CI (seen on #4931 and on #4920's downgrade lane: dt below eps at t = 0.5).

With a stale 1e200 planted in the slot resize! reuses, master stops with Unstable (error 0.30) for disc = false, and this branch matches the disc = true run exactly (141 steps, error 1.9e-10). Repeating the resize test with a scribbled heap, master failed once in 400 rounds (QNDF, disc = false) and this branch did not fail in 1000. The new testset checks that the history is zero right after the resize, which fails on master on every run. BDF Core passes.

FBDF already restarts from uprev after a resize (iters_from_event = 0), so it is unchanged. #4809 moves this function as it is. BDF goes to 2.4.15.

AI Disclosure: Claude assisted with this change.

@singhharsh1708

Copy link
Copy Markdown
Member Author

🤖 Automated comment from an AI agent running as @singhharsh1708, not written or reviewed by the account holder.

Independent review (Codex CLI 0.163.0, model gpt-6.1-sol, reasoning effort high): MERGE, risk medium-low (ML2). Reviewed head: 7cf17429f215f9d0ecf9fe26296dffb2bdf2f50d.

Full review

VERDICT: MERGE
PR: #4938
Round: 1
Head: 7cf1742
Base: 45ff46a
Slot: 1
Reviewer: Codex CLI 0.163.0 / gpt-6.1-sol
Session: 01a1977f-74b9-7aa0-a497-7345a0f9b3e2
Reviewed: 2026-11-01T14:33:21Z
Summary: Clears QNDF’s difference histories immediately when resizing and adds a deterministic regression with independent accuracy coverage. The regression fails on base and passes on head; no blocking defect was found.

Risk

medium-low (ML2: localized restart-history correction for the non-default QNDF solver, verified failing-before/passing-after with matrix-exponential accuracy coverage.)

Risk assessment

  • Risk: medium-low (ML2: specialized QNDF resize behavior changes, with independent numerical evidence and a reproduced regression.)
  • Blast radius: Mutable QNDF difference-history caches after state resizing, particularly callbacks that subsequently clear derivative_discontinuity. The source change does not alter FBDF or default solver selection.
  • Evidence: Head passes all 14 assertions. The identical changed test file copied into the merge-base worktree fails its new cache-clearing assertion. BDF Core, GPU, QA and downgrade CI pass; five other failed jobs have matching master signatures, while one ModelingToolkit failure remains unattributed.
  • Verdict: MERGE
  • Round: 1
  • Blocking priorities: none
  • Merge: merge

Blocking findings

None.

Non-blocking findings

None.

What I ran

Runner paths are abbreviated as jrun; arguments below are exact. Julia execution used the supplied serialized runner, Julia 1.13.1, four Julia threads and one OpenBLAS thread.

Git inspection commands, all exit 0:

git rev-parse HEAD
git diff origin/master...HEAD
git merge-base origin/master HEAD
git diff --check origin/master...HEAD
git log -1 --no-merges --format=%B
git status --short

HEAD and merge-base matched the specified SHAs. The diff check produced no output. The newest non-merge commit contains no agent trailers.

From the head worktree:

jrun --project=lib/OrdinaryDiffEqBDF -e 'using TestEnv; TestEnv.activate(); using Test, SafeTestsets; println("Julia ", VERSION); include("lib/OrdinaryDiffEqBDF/test/resize_tests.jl")'

Exit 0; output tail:

BDF state resizing                       | 12  12
QNDF resize clears its difference history |  2   2

I copied the PR’s changed lib/OrdinaryDiffEqBDF/test/resize_tests.jl into the supplied merge-base worktree and ran the same command there against unchanged base source.

Exit 1; output tail:

BDF state resizing | 12  12
QNDF resize clears its difference history:
  Test Failed at lib/OrdinaryDiffEqBDF/test/resize_tests.jl:67
  Expression: cleared == [true]
  Evaluated: Bool[0] == Bool[1]
QNDF resize clears its difference history | 1 passed, 1 failed

This confirms the regression by running. The matrix-exponential accuracy assertion passed on both revisions in these runs; the deterministic fail-before evidence is the cache invariant. Resolved dependency versions matched between worktrees apart from OrdinaryDiffEqBDF’s version bump. Final status showed a clean head and only the copied test changed on base.

Inspected the supplied check results and failed-log excerpts:

What I did not verify

  • Full package or downstream suites were not run locally.
  • GPU resizing, AD through resizing, Reactant and MPI execution were not exercised locally; no corresponding kernels or differentiation rules change in this PR.
  • The author’s heap-scribbling stress runs and seeded 1e200 experiment were not repeated.
  • The ModelingToolkit CI failure was not reproduced or attributed.

AUTHOR_GRADE: {"task":"bugfix","score":5,"difficulty":2,"rounds":1,"author_harness":"unknown","author_model":"unknown","note":"Narrow history-reset fix with a deterministic regression that fails on base and passes on head, plus independent matrix-exponential accuracy checks. The implementation is small and reuses the solver's existing history-clearing operation."}


🤖 Posted by an AI agent · harness: Claude Code · model: claude-opus-5-5 (coordinating gpt-6.1-sol reviewers)
Review: unreviewed
Session: 01a1977f-74b9-7aa0-a497-7345a0f9b3e2

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.

1 participant