Skip to content

Fix SRA1 OOP non-diagonal noise (matrix-vector mul vs .*) - #4826

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:sde-sra1-oop-nondiag
Oct 9, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:sde-sra1-oop-nondiag

Conversation

@ChrisRackauckas-Claude

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

Copy link
Copy Markdown
Member

Summary

Out-of-place SRA1ConstantCache applied elementwise chi2 .* gpdt (and W.dW * gpdt under @..) even when g is a matrix. That is only valid for diagonal noise and throws DimensionMismatch for non-diagonal additive problems. The in-place path already branches on is_diagonal_noise and uses mul!(…, gpdt, chi2). This PR mirrors that branch in OOP (gpdt * chi2 / gpdt * W.dW), leaving the diagonal branch byte-identical to master.

Failing before / passing after

Regression (lib/StochasticDiffEqHighOrder/test/sra1_oop_nondiag_tests.jl), src fix stashed vs present (Julia 1.12.7, --check-bounds=auto):

Before (src stashed):

DimensionMismatch: arrays could not be broadcast to a common size: a has axes Base.OneTo(2) and b has axes Base.OneTo(4)
  @ StochasticDiffEqHighOrder …/sra.jl:7
Test Summary:                        | Error  Total  Time
SRA1 OOP non-diagonal additive noise |     1      1  14.8s

After (with fix):

Test Summary:                        | Pass  Total  Time
SRA1 OOP non-diagonal additive noise |    6      6  15.5s
Test Summary:                                 | Pass  Total  Time
SRA1 OOP diagonal additive noise still solves |    2      2   3.2s

Fixed-dt OOP vs IIP non-diagonal trajectories match (≈); adaptive u[end] matches to rtol=1e-10. Diagonal OOP trajectory bitwise identical to master (serialize before/after == true).

Test-group tails

Core (Julia 1.12, --check-bounds=auto, OPENBLAS_NUM_THREADS=1):

Test Summary:                 | Pass  Total     Time
Module loads and constructors |   11     11  1m37.0s
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.4s
Test Summary:                        | Pass  Total  Time
SRA1 OOP non-diagonal additive noise |    8      8  21.1s
     Testing StochasticDiffEqHighOrder tests passed

QA (Julia 1.12, --check-bounds=auto):

Test Summary:     | Pass  Total     Time
QA (Aqua and JET) |   21     21  1m33.7s
     Testing StochasticDiffEqHighOrder tests passed

Julia 1.10.12 regression (standalone env):

Test Summary:                        | Pass  Total  Time
SRA1 OOP non-diagonal additive noise |    6      6  10.7s
Test Summary:                                 | Pass  Total  Time
SRA1 OOP diagonal additive noise still solves |    2      2   2.3s

Runic --inplace and typos on changed files: clean.

Not verified

  • Full umbrella StochasticDiffEq Interface/Adaptive/additive CI groups.
  • Non-square noise (n×m with m≠n beyond the 4×2 additive case), complex, or SVector OOP non-diagonal.
  • Whether SRA2 OOP has the same diagonal-only gap (out of scope; ThreeStage/SOSRA OOP already branches).

Reviewer pushback

  • Whether adaptive OOP/IIP should be forced to match full trajectories (not just u[end]) under shared noise.
  • Whether SRA2ConstantCache should get the same non-diagonal branch in a follow-up.

Please ignore until reviewed by @ChrisRackauckas.

Risk assessment

Independent review: pending

🤖 Generated with Cursor Agent 2026.10.01-14929f9 (model: unknown (Cursor auto)), transcript /home/crackauc/sandbox/goals/performance/jobs/pr-sde-sra1-nondiag/log.txt on amdci2; orchestrated by Claude Code (claude-opus-5-5[1m]) https://claude.ai/code/session_01LPHREnnonfLg1VcE1EJovv

Made with Cursor

Risk assessment

  • Risk: low
  • Blast radius: OOP SRA1ConstantCache perform_step! in StochasticDiffEqHighOrder. It gains an is_diagonal_noise branch: the diagonal branch is the existing code unchanged, and the non-diagonal branch uses matrix-vector products, matching the IIP SRA1Cache. Adds a new Core test file. No public API change. Non-diagonal OOP SRA1 threw DimensionMismatch on master, so no working behavior changes.
  • Evidence: Head 7187ad0 (base 6072e89). CI: 135 pass, 4 fail. All 4 failures are pre-existing and match master: downgrade-sublibraries for DiffEqBase and OrdinaryDiffEqDifferentiation also fail on master Downgrade Sublibraries run https://github.com/SciML/OrdinaryDiffEq.jl/actions/runs/37889760391 (91d6ffa). SciMLSensitivity.jl/Core1 fails at the same concrete_solve_derivatives.jl:451 as master IntegrationTest run https://github.com/SciML/OrdinaryDiffEq.jl/actions/runs/37889760310. GPU (julia 1) shows the same 3 QNDF dae_tests.jl:481 failures as master. Locally (Julia 1.12.7, seed 9), I ran master base and PR with fixed dt=1/64 and adaptive. Diagonal Vector, scalar u, scalar-noise and SVector-diagonal OOP solutions are bitwise identical between master and PR, as is non-diagonal IIP. Non-diagonal (4x2) OOP and SVector/SMatrix OOP throw DimensionMismatch on master and solve on the PR. Non-diagonal OOP matches IIP on the same time grid, with a max difference of 3.3e-16 at fixed dt and 4.4e-16 adaptive (identical t, 98 steps). The PR's test errors on master src (DimensionMismatch at sra.jl:7) and passes on PR src (6/6 and 2/2).
  • Independent review: Claude Code (claude-opus-5-5) rated it low, high confidence: the diagonal path is untouched and bitwise identical, and the new non-diagonal path reproduces the IIP algorithm to round-off, including adaptive step selection.
  • Merge: auto-merge candidate, after a rebase: lib/StochasticDiffEqHighOrder/test/runtests.jl conflicts with master since SRA1 iip: scale k₁ in-place to drop per-step allocation #4822 merged, and it will also conflict with Fix Float32 promotion in SRA/SRI OOP stages and SRI() Vector broadcast #4825. Non-blocking: the test file's header comment narrates the old behavior, and the 4x2 test does not cover non-square cases with m > n.

🤖 Risk assessment posted by an AI agent (fleet master) — harness: Claude Code 2.1.285 · model: claude-opus-5-5
Conversation: local session 3c311569-dda6-4687-bc9f-65febb212c33 (local transcript)

SRA1ConstantCache used elementwise chi2 .* gpdt, which DimensionMismatch-es
for matrix noise; mirror the IIP is_diagonal_noise branch (gpdt * chi2).

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI
Agent-Model: auto
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review October 9, 2026 19:14
@ChrisRackauckas
ChrisRackauckas merged commit 65f5e50 into SciML:master Oct 9, 2026
150 of 154 checks passed
ChrisRackauckas referenced this pull request Oct 14, 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.

2 participants