Repository navigation
Resize FSAL, nlsolver and J/W buffers in deleteat!/addat!, once per array - #4796
Merged
ChrisRackauckas merged 2 commits intoOct 8, 2026
Merged
ChrisRackauckas merged 2 commits into
ChrisRackauckas merged 2 commits into
Conversation
…rray deleteat!/addat! on an ODEIntegrator only touched full_cache, so fsallast (and fsalfirst when not aliased), the nonlinear solver buffers and J/W kept the old length, and the next step! threw. Cache fields that alias each other were also shortened twice. Visit each distinct buffer once and resize the solver internals the same way resize! does. Fixes SciML#4789 Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Agent-Harness: Claude Code Agent-Model: claude-opus-5-5[1m] Agent-Session: https://claude.ai/code/session_01AXwyJDRaMKgnYMG9M1Ut49
Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Agent-Harness: Claude Code Agent-Model: claude-opus-5-5[1m] Agent-Session: https://claude.ai/code/session_01AXwyJDRaMKgnYMG9M1Ut49
This was referenced Oct 7, 2026
ChrisRackauckas
marked this pull request as ready for review
October 8, 2026 11:14
ChrisRackauckas
referenced
this pull request
Oct 13, 2026
…inaryDiffEqBDF, OrdinaryDiffEqExplicitRK, OrdinaryDiffEqFIRK, OrdinaryDiffEqFeagin, OrdinaryDiffEqHighOrderRK, OrdinaryDiffEqPDIRK, OrdinaryDiffEqRKN, OrdinaryDiffEqSDIRK, StochasticDiffEqHighOrder, StochasticDiffEqLowOrder, and StochasticDiffEqMilstein for release (#4871) Agent-Harness: Devin CLI 3000.11.3 Agent-Model: Fusion (Claude Opus 5.5 Medium + SWE-2 Medium) Agent-Session: local transcript ~/.local/share/devin/cli/transcripts/flash-hour.json Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ignore until reviewed by @ChrisRackauckas.
deleteat!/addat!on anODEIntegratoronly touchedfull_cache(integrator). They missedfsallast(andfsalfirstwhen it doesn't alias a cache field), the nonlinear-solver buffers, andJ/W. They also ran twice on any array that appears more than once infull_cache; Vern7Cache, for example, aliasesk3/k10tok2. This PR visits each distinct buffer once (deduplicated by===, with the FSAL arrays included) and then resizesf's split cache, the nlsolver andJ/Wthe same wayresize!does. Only thedeleteat!/addat!paths change. Theresize!methods that #4763 edits are untouched.Fixes #4789. The same double-delete-on-aliased-buffers mechanism caused the default-solver failure in #2549. With this change, an adapted version of that reproducer returns
Success. The setup I measured was the default solver ondu .= 0withu0 = [1.0, 2.0, 3.0], onestep!, thendeleteat!(integ, 1)andsolve!, givingu = [2.0, 3.0]. The Cursor review ran a decaying right-hand side with fivestep!s and also gotSuccess, with u ≈ [0.298, 0.447] (the decayed kept components). I have not run the original callback script from #2549, so I am not closing it here.Verification
The new test
test/Integrators_II/deleteat_addat_tests.jlcovers Trapezoid, ImplicitEuler, KenCarp4, Tsit5, Vern7 and Rodas5P. For each method it takes 5 fixed steps (dt = 1/64) on a decoupled 6-component decay problem, appliesdeleteat!oraddat!, and continues tot_end. It then assertsSuccess, the kept components, and agreement withinrtol = 1e-12against a solve of the reduced or extended system started from the same state.Fail before (master 0fd3326, fix stashed, test wrapped in an outer testset):
Pass after:
Issue reproducer after the fix: all 12 method×operation combinations print
Success. Tsit5 and Rodas5P already passed on master.GROUP=Integrators_II julia +1.12 --project=. -e 'using Pkg; Pkg.test()'(repo root):Runic (
julia +1.12 --project=@runic -e 'using Runic; exit(Runic.main(ARGS))' -- --checkon all 3 touched files, at the branch head): exit 0.typoson the touched files: exit 0.Not verified
DelayDiffEqdefines its owndeleteat!/addat!forDDEIntegratorand is not changed here. Itsdeleteat!passes an undefineditodeleteat_non_user_cache!, which is a separate bug.addat!on arrays follows SciMLBase's semantics: it appends uninitialized slots at the end and ignores the positions. The test usesaddat!(integ, 7:8)and sets the new values explicitly.Risk assessment
deleteat!(::ODEIntegrator, idxs)andaddat!(::ODEIntegrator, idxs)in OrdinaryDiffEqCore. On master these already threw for every in-place implicit FSAL method and for Vern7. For methods that worked (Tsit5, Rodas5P), the only behavior change is that an array aliased infull_cacheis no longer edited twice. No public API change.🤖 Generated with Claude Code (model: claude-opus-5-5[1m])
https://claude.ai/code/session_01AXwyJDRaMKgnYMG9M1Ut49
Risk assessment
deleteat!(::ODEIntegrator, idxs)andaddat!(::ODEIntegrator, idxs)inlib/OrdinaryDiffEqCore/src/integrators/integrator_interface.jlchange.full_cacheis now deleted from only once.fsalfirstandfsallastare now edited.nothingentries are skipped.resize_f!,resize_nlsolver!andresize_J_W!now run with the same argumentsresize!already uses.DDEIntegratormethods and never calls these. StochasticDiffEq uses a different integrator type.CompositeCache/DefaultCache,resize_J_W!andresize_nlsolver!do nothing, because theJ/W/nlsolverfields live in the sub-caches. A stiff switch afterdeleteat!(for exampleAutoTsit5(Rosenbrock23())) is probably still broken.resize!has the same limitation.SplitFunctionbranch ofresize_f!is never exercised by the new test.J/W, are resized by truncation orsimilar, not by index deletion. This is safe becausefirstcall = trueand the Rosenbrock check onlast_u_lengthboth force a freshJ/W.1a07ddb, 250 checks pass, 8 fail and 1 is skipped (a template-named matrix job). Integrators_II passes on Julia 1, lts and pre; the new tests live there. Runic, Typos and OrdinaryDiffEqCore QA also pass. None of the 8 failures is a regression:0fd3326,6ef1364,cceca42) with the same signature:tests / GPU (julia 1): three QNDFmass=diag_cufailures attest/gpu/dae_tests.jl:481, 170 pass / 3 fail on both head and master.SciMLSensitivity.jl/Core1/1: "Mooncake with MooncakeAdjoint" errors atconcrete_solve_derivatives.jl:451, 241 pass / 1 error on both.downgrade-sublibraries / test (lib/DiffEqBase): fails on master too.downgrade-sublibraries / test (lib/OrdinaryDiffEqDifferentiation): fails on master too.sublibrary-cijobs don't run on master pushes. The first three fail on unrelated master-based PRs Skip the step between tstops an ulp apart #4805 and Differentiate with a fitting chunk after resize!/deleteat! shrinks the state below the ForwardDiff chunk #4804; GlobalDiffEq Core fails on Skip the step between tstops an ulp apart #4805. None of the errors involves deleteat or addat:diag(::ScalarOperator)MethodErrorLineSearchExceptionin Newton Testsinference_tests.jlresize!helpers (resize_f!,resize_nlsolver!,resize_J_W!) without reaching into any dependency's non-public internals and changes no public API (SemVer patch). It weakens no tests and adds a new test that compares the result against a fresh solve atrtol = 1e-12. There are no review comments on the PR.CompositeCache/DefaultCachegap forJ/W/nlsolver, and a test forSplitFunctionand the default solver.🤖 Risk assessment posted by an AI agent (fleet master) — harness: Devin CLI (Mac) / fusion-claude-opus-5-5-high-sidekick-swe-2-medium; dispatched by Devin CLI 3000.11.3 (Mac) fleet-master head, model Fusion (claude-opus-5-5 medium + swe-2 medium)
Conversation: local transcript ~/.local/share/devin/cli/transcripts/helpful-exception.json