Skip to content

Fix Float32 promotion in SRA/SRI OOP stages and SRI() Vector broadcast - #4825

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:sde-float32-literals-sri-oop
Oct 9, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:sde-float32-literals-sri-oop

Conversation

@ChrisRackauckas-Claude

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

Copy link
Copy Markdown
Member

Summary

Out-of-place SRA2/SOSRA/SRA and SRI ConstantCache stages multiplied by bare 0.5 / 1/6 Float64 literals, so Float32 problems handed Float64 u into f/g. SRI() OOP also crashed on any Vector u because W.dW .^ 2 - abs(dt) used non-broadcast subtraction (MethodError on modern Julia). This makes those literals eltype-generic (/ 2 or oftype(dt, 1//2) / 1//6) and uses .- for chi1.

Evidence

Regression test lib/StochasticDiffEqHighOrder/test/float32_oop_stages_tests.jl (stashed src = master behavior):

  • Before (unfixed src): SOSRA Float32 OOP failed all(T -> T === Float32, seen) (Float64 stages present); SRI() Vector OOP errored MethodError: -(::Vector{Float64}, ::Float64) at sri.jl:278. Summary: Pass 3 / Fail 1 / Error 1.
  • After (fix): both testsets pass (Pass 7 / 7). Also passes on Julia 1.10.12.
  • Float64 bitwise: SOSRA OOP Vector and SRI() scalar (seed=1) u[end] and step counts identical to master.

Test-group tails

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

Test Summary:                           | Pass  Total  Time
Float32 OOP stages and SRI() Vector OOP |    7      7  16.5s
Testing StochasticDiffEqHighOrder tests passed

GROUP=QA:

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

Runic + typos on touched files: clean.

Not verified

  • Full umbrella StochasticDiffEq test suite / Buildkite CI.
  • Float32 stage eltypes for every SRA/SRI variant beyond SOSRA OOP (SRA2/SRA ConstantCache paths changed the same way; not separately asserted).
  • BigFloat / GPU.

Reviewer pushback

  • Whether / 2 vs oftype(dt, 1//2) should be uniform across SRA and SRI.
  • Whether SRA2 OOP Vector paths with chi2 * g1 (non-broadcast *) deserve a follow-up; out of scope here.
  • Scope: only HighOrder ConstantCache hot paths called out in the audit (C8/C9).

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-f32-sri/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: Float literals in the OOP ConstantCache perform_step! of SRA2, ThreeStageSRA (SRA3/SOSRA/SOSRA2), SRA() and SRI() in StochasticDiffEqHighOrder (0.5*x becomes x/2 or oftype(dt, 1//2)*x; 1/6 becomes oftype(dt, 1//6)), plus .- in SRI()'s chi1. Adds a new Core test file. No public API change.
  • Evidence: Head 01922af (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 5), I compared master base and PR for SRA2, SRA3, SOSRA, SOSRA2, SRA(), SRI(), SRIW1 and SOSRI. Cases: Float64 and Float32, vector and scalar state, fixed dt=1/64 and adaptive, plus non-diagonal 3x2 for the SRA family. Every case that solves on master is bitwise identical on the PR (sol.t and sol.u), so Float64 results do not change. SRI() with a Vector state throws MethodError: -(::Vector, ::Float64) on master and solves on the PR, for Float64 and Float32. The PR's test fails on master src (all(T -> T === Float32, seen), 3 pass / 1 fail) and passes on PR src (4/4 and 3/3).
  • Independent review: Claude Code (claude-opus-5-5) rated it low, high confidence: the literal changes are exact for Float64 (bitwise identical across 8 methods in fixed and adaptive mode), and the .- change fixes a real crash.
  • 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 SRA1 OOP non-diagonal noise (matrix-vector mul vs .*) #4826. Non-blocking: SRA2 OOP with a Vector state still fails (*(::Vector, ::Vector), pre-existing and disclosed), and under Float32 one Float64 operand remains in that path. With a Float32 tspan and Float64 u, oftype(dt, 1//6) rounds the SRI() chi3 coefficient to Float32. The Float32 stage-eltype check covers only SOSRA.

🤖 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)

Replace Float64 `0.5`/`1/6` literals with eltype-generic halves and use
`.-` so chi1 works for Vector noise; SOSRA OOP stages stay Float32 and
SRI() OOP solves Vector problems.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI
Agent-Model: auto
@ChrisRackauckas-Claude
ChrisRackauckas-Claude force-pushed the sde-float32-literals-sri-oop branch from 01922af to 09bcadd Compare October 9, 2026 08:48
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review October 9, 2026 10:45
@ChrisRackauckas
ChrisRackauckas merged commit 0c9db8c into SciML:master Oct 9, 2026
138 of 142 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