Skip to content

Fix Feagin in-place stage updates to avoid scalar indexing - #4757

Merged
ChrisRackauckas merged 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:feagin-iip-no-scalar-index
Oct 7, 2026
Merged

ChrisRackauckas merged 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:feagin-iip-no-scalar-index

Conversation

@ChrisRackauckas-Claude

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

Copy link
Copy Markdown
Member

Summary

In-place Feagin10/12/14 perform_step! used @tight_loop_macros/@inbounds scalar element loops for stage updates and the adaptive residual, which errors on JLArray under JLArrays.allowscalar(false) (out-of-place already worked). Those loops are rewritten as @inbounds @.. broadcast = false fused broadcasts with the same arithmetic grouping (restoring the matching-cache-axes inbounds scope), and a JLArray IIP regression test plus JLArrays/LinearAlgebra [extras]/[targets] entries are added.

Failing-before / passing-after: with the src change stashed, the JLArray IIP repro errors with Scalar indexing is disallowed at feagin_rk_perform_step.jl:176 (exit 1, before.txt); with the fix, Feagin10/12/14 all succeed under allowscalar(false) (after.txt). sol.u SHA-256 hashes for Vector Lorenz, Pleiades, and linear100 (adaptive and fixed) are bitwise identical vs master for all three methods.

Vector solve time (round 2, pinned): JULIA_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 taskset -c 64, @benchmark minima, 5 interleaved master/head rounds. Median of trial minima (ms); negative is faster than master. All 12 cases are within ~2% of master or faster.

Problem Method Adaptive Master ms Head ms Change
lorenz Feagin10 true 7.9423 7.7253 -2.73%
lorenz Feagin10 false 9.4087 9.0192 -4.14%
lorenz Feagin12 true 8.0853 8.0508 -0.43%
lorenz Feagin12 false 13.1007 13.0874 -0.10%
lorenz Feagin14 true 12.4653 12.1789 -2.30%
lorenz Feagin14 false 20.3515 19.9835 -1.81%
linear100 Feagin10 true 1.4778 1.4188 -3.99%
linear100 Feagin10 false 30.1263 28.7107 -4.70%
linear100 Feagin12 true 1.6834 1.5375 -8.67%
linear100 Feagin12 false 46.3160 41.9748 -9.37%
linear100 Feagin14 true 5.7208 5.1873 -9.33%
linear100 Feagin14 false 89.7567 80.3410 -10.49%

Test-group tails (round 2)

Core (GROUP=Core):

Test Summary: | Pass  Total     Time
Feagin Tests  |   30     30  8m19.0s
Testing OrdinaryDiffEqFeagin tests passed

QA (GROUP=QA):

Allocation Tests | 3 pass
JET Tests        | 1 pass
Aqua             | 21 pass
Testing OrdinaryDiffEqFeagin tests passed

Also verified the JLArray IIP repro on Julia 1.10.12 (round 1) and again under allowscalar(false) after @inbounds (round 2).

What was NOT verified

  • Real GPU backends (CUDA/AMDGPU), only JLArray under allowscalar(false).
  • Full monorepo CI / Downstream.
  • Dense interpolation / FSAL edge cases beyond the existing Core + AllocCheck paths.
  • Whether every commented historical #= Feagin kernel block should be deleted (left untouched).

What a reviewer should push back on

  • Whether @inbounds @.. is the right way to restore FastBroadcast's skipped shape checks vs leaving DimensionMismatch paths.
  • Whether Feagin12’s parenthesized stage groupings should be flattened vs kept (kept to match prior scalar-loop order).
  • Whether LinearAlgebra belongs in test extras solely for mul! in the JLArray probe.

Please ignore until reviewed by @ChrisRackauckas.

Risk assessment

Independent review: Codex CLI (gpt-6-astra) round 1 CHANGES: @inbounds scope; round 2 restores it, Vector speed re-measured

🤖 Generated with Cursor Agent 2026.10.01-14929f9 (model: unknown (Cursor auto)), transcript /home/crackauc/sandbox/goals/performance/jobs/pr-feagin-jlarray/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: Only users of in-place Feagin10/Feagin12/Feagin14 in lib/OrdinaryDiffEqFeagin. Each scalar @tight_loop_macros/@inbounds element loop becomes a matching @inbounds @.. broadcast = false fused broadcast with the same terms and grouping, and nothing else in perform_step! changes. Out-of-place paths, caches, tableaus and the public API are unchanged, so no SemVer impact. The PR stops using the non-public DiffEqBase macro @tight_loop_macros and removes it from the QA ExplicitImports ignore list, which tightens QA rather than loosening it. Pairing @inbounds with @.. (which skips shape checks) is already done in 8 files in this repo, including the interpolants.jl files for Tsit5, Verner and HighOrderRK, and it is safe here because every cache array is built with u's axes in alg_cache. The only new dependencies are test-only (JLArrays 0.3 and the LinearAlgebra stdlib, both MIT).
  • Evidence: 4 checks fail on head e245e3f, and all 4 also fail on the two most recent completed master runs (4a5c0e71, e7068884), so none is a regression:
    • tests / GPU (julia 1, self-hosted …): same 3 QNDF mass=diag_cu failures at test/gpu/dae_tests.jl:481 on head and master, same totals (170 pass / 3 fail / 12 broken). Pre-existing.
    • SciMLSensitivity.jl/Core1/1 / Downstream Tests - Core1: same "Mooncake with MooncakeAdjoint" Error During Test at concrete_solve_derivatives.jl:451 on head and master. Pre-existing.
    • downgrade-sublibraries / test (lib/DiffEqBase) and test (lib/OrdinaryDiffEqDifferentiation): both fail on master too, and the PR touches neither lib. Pre-existing.
    • Every Feagin-specific check passes: sublibrary Core on Julia 1, lts and pre; Feagin QA; downgrade Feagin; Runic; docs. All other CI and Downstream jobs pass.
    • No tests are weakened: the PR adds one testset (JLArray IIP under allowscalar(false), adaptive and fixed-step, compared against exp(A)*u0) and modifies no existing assertion.
  • Independent review: Devin CLI (Mac) / fusion-claude-opus-5-5-high-sidekick-swe-2-medium rated it low, high confidence: it is a mechanical loop-to-broadcast rewrite that keeps the arithmetic grouping (the PR reports bitwise-identical sol.u vs master) and adds no new CI failures.
  • Merge: auto-merge candidate. Minor nits, none blocking:
    • The new test calls JLArrays.allowscalar(false) and never restores it. This only matters if a later test in the same process uses JLArrays.
    • The description does not mention the qa.jl ignore-list removal or the two added # SAFETY: comments.
    • The PR body lacks the required first-line "UNREVIEWED" banner, gives the model as "unknown (Cursor auto)", and asks to be ignored until @ChrisRackauckas reviews it.

🤖 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 caretaker, model Fusion (claude-opus-5-5 medium + swe-2 medium)
Conversation: local transcript ~/.local/share/devin/cli/transcripts/speckle-whale.json (Chris's Mac)

ChrisRackauckas and others added 2 commits October 3, 2026 03:54
Replace @tight_loop_macros/@inbounds element loops in Feagin10/12/14
in-place perform_step! with @.. broadcast=false so JLArray solves work
under allowscalar(false) without changing Float64 arithmetic order.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent 2026.10.01-14929f9
Agent-Model: unknown (Cursor auto)
Agent-Session: local session, transcript /home/crackauc/sandbox/goals/performance/jobs/pr-feagin-jlarray/log.txt on amdci2
Wrap the 80 IIP @.. stage updates so FastBroadcast skips shape checks,
matching the old scalar-loop inbounds assumption, and tighten the
JLArray regression to adaptive/fixed plus the matrix exponential.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent 2026.10.01-14929f9
Agent-Model: unknown (Cursor auto)
Agent-Session: local session, transcript /home/crackauc/sandbox/goals/performance/jobs/pr-feagin-jlarray/log.txt on amdci2
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review October 7, 2026 04:54
@ChrisRackauckas
ChrisRackauckas merged commit 2450a7e into SciML:master Oct 7, 2026
130 of 134 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