Skip to content

Fix SRA resize! leaving H0 stage buffers at the old length - #4764

Merged
ChrisRackauckas merged 4 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/4720-sra-resize
Oct 7, 2026
Merged

ChrisRackauckas merged 4 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/4720-sra-resize

Conversation

@ChrisRackauckas-Claude

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

Copy link
Copy Markdown
Member

Please ignore until reviewed by @ChrisRackauckas.

SRACache/SRICache store stage states in H0/H1 as Vector{uType}. StochasticDiffEqCore's @cache only put fields typed exactly uType/rateType/… into full_cache, so resize! never touched those inner arrays and the next step! threw DimensionMismatch. The macro now splats Vector{uType} (and the matching rate/k/uNoUnits, rand, and rate-noise vector fields) into the generated cache iterators, which is the same path deleteat!/addat! use.

Interaction with #4718

#4718 (merged) made SRACache's u_cache/du_cache/user_cache extend SciMLBase's hooks; user_cache even lists c.H0.... That alone does not fix #4720: OrdinaryDiffEqCore resize! iterates full_cache(integrator) (from @cache), not user_cache. Fresh check on this branch after merging master: restored lib/StochasticDiffEqCore/src/misc_utils.jl to origin/master (kept merged tests including #4718's hook test), ran HighOrder GROUP=Core — constructors 11/11 and cache hooks 9/9 passed; resize regression failed (Fail 1, Error 1). Restored this PR's @cache change afterward (no commit of the temporary revert). This PR remains needed for SRA/SRI (and any other @cache type whose stage buffers are Vector{uType}/rateType/…), not for SciMLBase hook dispatch.

Fail before / pass after

Negative control after #4718 on master: restored lib/StochasticDiffEqCore/src/misc_utils.jl from origin/master, kept the merged HighOrder tests (cache hooks + resize).

cd lib/StochasticDiffEqHighOrder
GROUP=Core /home/crackauc/.juliaup/bin/julia +1.12 --project=. -e 'using Pkg; Pkg.test()'

Before (master @cache + merged #4718 hooks; adaptive and fixed-step covered by the regression):

Test Summary:                 | Pass  Total  Time
Module loads and constructors |   11     11  3.8s
Test Summary:                  | Pass  Total  Time
SRACache SciMLBase cache hooks |    9      9  5.4s
SRA/SRI resize! stage buffers (issue 4720): Test Failed at .../sra_resize_tests.jl:18
  Expression: all((x->begin
            length(x) == 3
        end), c.H0)
...
  DimensionMismatch: Some axes are not equal, or feature a dynamic broadcast!
Test Summary:                                | Fail  Error  Total   Time
SRA/SRI resize! stage buffers (issue 4720)   |    1      1      2  12.6s
ERROR: Package StochasticDiffEqHighOrder errored during testing

Focused adaptive SRA() (no adaptive=false) against master @cache (pre-merge evidence, still applicable):

adaptive SRA H0 lengths: [2, 2]
adaptive SRA stepping: ERROR DimensionMismatch: Some axes are not equal, or feature a dynamic broadcast!

After the @cache change (GROUP=Core, post-merge with #4718 hooks test):

Test Summary:                 | Pass  Total  Time
Module loads and constructors |   11     11  3.5s
Test Summary:                  | Pass  Total  Time
SRACache SciMLBase cache hooks |    9      9  5.3s
Test Summary:                              | Pass  Total   Time
SRA/SRI resize! stage buffers (issue 4720) |   25     25  13.0s
     Testing StochasticDiffEqHighOrder tests passed

Runic --check (julia +1.12 --project=@runic) and typos on the touched files were clean.

Not verified / known remaining

  • Weak-order caches are not covered. Independent measurement: DRI1, RS1, W2Ito1, IRI1 still fail after resize! (master DimensionMismatch → this PR BoundsError) because g2/g3/H12–H23 are noise-dimension (m) length outer vectors; PL1WM still fails with DimensionMismatch. Not a regression; they need m-length handling as a follow-up.
  • SOSRA deleteat! after resize! throws BoundsError on master and this PR alike (ThreeStageSRACache aliases k1 and tmp, so full_cache holds it twice). Separate bug, unchanged here.
  • @allocated resize!(integ, 3) on SRA goes 0 → 240 bytes (full_cache becomes Tuple{V,V,Vararg{V}}). resize! is not a hot path.
  • Adaptive SRA/SRI verified; out-of-place SRA has no full_cache (unchanged).
  • OrdinaryDiffEqCore @cache (ODE FIRK/RKIP/SDC/etc. Vector{uType} fields). SDC already resizes those in resize_non_user_cache!.
  • Non-diagonal noise; StochasticDiffEq umbrella Interface3 cache callback tests.

Please ignore this draft until reviewed by @ChrisRackauckas.

Fixes #4720

Risk assessment

  • Risk: low
  • Blast radius: every StochasticDiffEq @cache type with Vector{uType}/rateType/kType/uNoUnitsType/randType/rateNoiseType fields; full_cache/rand_cache/ratenoise_cache now iterate inner arrays so resize!/deleteat!/addat! mutate each stage buffer instead of skipping them. Weak caches with m-length outer vectors are still wrong (same as master, different exception).
  • Evidence: with Fix StochasticDiffEqHighOrder SRACache to extend SciMLBase cache hooks #4718 on master, issue regression still fails (H0 lengths stay 2; DimensionMismatch on step!) and passes with this PR's macro change (25/25 in HighOrder GROUP=Core).
  • Independent review: Claude Code (claude-opus-5-5[1m]) rated it low, high confidence: new iterator entries only feed resize!/deleteat!/addat!; SRA/SRI fixed+adaptive fixed, weak caches still need m-length handling (follow-up)
  • Merge: auto-merge candidate (independent review MERGE; remaining weak-cache / SOSRA alias / allocation notes are pre-existing or out of hot path)

Harness: Cursor Agent CLI 2026.10.01-14929f9; model: auto; transcript: /home/crackauc/sandbox/goals/issue-backlog/ibd/OrdinaryDiffEq.jl/jobs/4720-cursor/log.txt on amdci2.julia.csail.mit.edu

ChrisRackauckas and others added 4 commits October 3, 2026 06:43
SRA/SRI store H0/H1 as Vector{uType}, so resize! skipped those arrays and the next step DimensionMismatch'd.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI 2026.10.01-14929f9
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/ibd/OrdinaryDiffEq.jl/jobs/4720-cursor/log.txt on amdci2.julia.csail.mit.edu
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI 2026.10.01-14929f9
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/ibd/OrdinaryDiffEq.jl/jobs/4720-cursor/log.txt on amdci2.julia.csail.mit.edu
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI 2026.10.01-14929f9
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/ibd/OrdinaryDiffEq.jl/jobs/4720-cursor/log.txt on amdci2.julia.csail.mit.edu
Keep both HighOrder Core registrations: master's SRACache SciMLBase cache
hooks test and this PR's SRA/SRI resize! stage-buffer regression.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI 2026.10.01-14929f9
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/ibd/OrdinaryDiffEq.jl/jobs/4720-cursor/log.txt on amdci2.julia.csail.mit.edu
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review October 7, 2026 16:11
@ChrisRackauckas
ChrisRackauckas merged commit 6ef1364 into SciML:master Oct 7, 2026
158 of 162 checks passed
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>
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.

SRA: resize! leaves H0 stage buffers at the old length (DimensionMismatch on next step)

2 participants