Skip to content

Avoid algorithm boxing in DefaultODEAlgorithm stiff steps - #4665

Merged
ChrisRackauckas merged 7 commits into
SciML:masterfrom
ChrisRackauckas-Claude:unwrap-alg-dispatch
Oct 31, 2026
Merged

ChrisRackauckas merged 7 commits into
SciML:masterfrom
ChrisRackauckas-Claude:unwrap-alg-dispatch

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

What changed and why

Stiff steps in DefaultODEAlgorithm repeatedly boxed the selected algorithm while differentiation and linear-solve helpers used it. Dispatch now selects a concrete constituent before entering those helpers. A regression test covers warmed stiff step! allocations for Van der Pol and ROBER.

Second round (e43ed932b6, a22e897cfe; post-review): the first implementation dispatched through a generated function that specialized every wrapped helper on all six DefaultODEAlgorithm members, which tripled first-solve compile time. The barrier is now _current_alg in OrdinaryDiffEqCore (next to unwrap_alg/_eval_index): caches that carry the concrete member algorithm (the Rosenbrock family) dispatch statically through cache.alg; other callers take the runtime-selected member as an over-split-limit union, so only the executed member is compiled. The stiff differentiation path was also de-nested — _calc_rosenbrock_differentiation!/_calc_W! call the member-alg inner functions directly instead of re-entering the dispatch helper — and dolinsolve takes the member alg as a keyword.

Third round (ca0f2f2d77; packaging): the PR adds a cross-package public name (OrdinaryDiffEqCore._current_alg) and a new keyword (alg= on OrdinaryDiffEqDifferentiation.dolinsolve), so the affected sublibraries are bumped and the compat floors raised — monorepo CI resolves siblings from local [sources] paths and cannot catch a registered-release mismatch. OrdinaryDiffEqCore 4.18.1 → 4.19.0 (minor: new public name), OrdinaryDiffEqDifferentiation 3.12.4 → 3.13.0 (minor: new alg= keyword) with [compat] OrdinaryDiffEqCore floor raised to 4.19 since it imports _current_alg, and OrdinaryDiffEqRosenbrock 2.7.5 → 2.7.6 (patch) with [compat] OrdinaryDiffEqDifferentiation floor raised to 3.13 since it passes alg= to dolinsolve. No other sublibrary uses either API. The packages must be registered in the order Core → Differentiation → Rosenbrock for the floors to resolve. The redundant one-argument _current_alg(integrator) was also dropped — it was a verbatim duplicate of unwrap_alg(integrator, true); its two call sites now call unwrap_alg directly.

Fourth round (7d8de6cd19, 706084d3c2, 9581365ec1; CI fixes): two follow-ups for real CI failures. (1) Empty-state stiff solves threw ArgumentError: range must be non-empty in test/InterfaceI/null_u0_callbacks_test.jl for Rosenbrock23/Rodas5P/TRBDF2 — the de-nested differentiation paths call _jacobian! directly, bypassing the isempty(x) guard that jacobian! provided; _jacobian! now returns early on empty input, restoring master's behavior (null_u0_callbacks_test.jl passes 42/42 on the branch and on clean master). (2) Sublibrary QA environments develop the package under test plus the repository root, whose [sources] path-pin Differentiation 3.13.0 / Rosenbrock 2.7.6; those require Core 4.19 (not yet registered) while each QA environment's direct Core dependency resolved from the registry (≤ 4.18.1) — unsatisfiable in the Extrapolation, Feagin, IMEXMultistep, PDIRK and TaylorSeries QA jobs. Following the established convention (same trap as #4590), each of those five QA environments gets a matching [sources] path entry for OrdinaryDiffEqCore — IMEXMultistep's additionally for OrdinaryDiffEqDifferentiation, which is a direct dep there and must satisfy path-pinned Rosenbrock 2.7.6's 3.13 floor. 9581365ec1 trimmed an earlier broader sweep (18 files) to exactly this set: the extra package-level pins made other jobs (e.g. OrdinaryDiffEqNonlinearSolve downgrade) resolve local sibling code they were meant to test against registered releases. All five QA environments resolve via activate_group_env; the Feagin QA group resolves and passes locally.

Rebase (739379950d base): rebased onto current master, which had released Core 4.18.1, Differentiation 3.12.4 and Rosenbrock 2.7.5 in the meantime; the bumps were recomputed from those values (Rosenbrock now goes to 2.7.6) and the code diff is unchanged. The five QA [sources] entries still apply. The remaining CI reds are all pre-existing on master: the NonlinearSolve Newton LineSearchException (bisected to 498c765ccc, also red on #4667/#4689), ScalarOperator mass matrix in Differentiation Core (#4661, also on #4689), the Rosenbrock QA Rosenbrock32 inference error (also on #4689), the GlobalDiffEq companion-callback error (identical on #4689), the DiffEqBase/Differentiation downgrade jobs (also on #4667), and the SciMLSensitivity downstream job (also on #4667).

Diagnosis (profile)

On Julia 1.12.4, Profile.Allocs with sample_rate = 1.0 over 20 warmed ROBER steps attributed 83,200 bytes to unwrap_alg at OrdinaryDiffEqCore/src/alg_utils.jl:959, reached through dolinsolve, calc_tderivative!, calc_rosenbrock_differentiation!, _rosenbrock_jac_reuse_decision, jacobian!, and calc_W!. After the change, the same profile records 2,240 bytes total: a finite-difference Jacobian config tuple and a boxed scalar. No selected-algorithm allocation remains in the profile.

First-solve (TTFX) check

Fresh process per rep, pinned, JULIA_NUM_THREADS=1, 6 interleaved master/head reps; process CPU:

metric master e43ed932b6 delta
ROBER first solve 0.605 s 0.633 s +4.7%
VdP first solve 21.88 s 22.55 s +3.1%
using OrdinaryDiffEqDefault ~7.3 s ~7.0 s unchanged

Scope note

Warm step! allocations are eliminated on the Rosenbrock differentiation path (VdP FD 8,448 → 0 B, ROBER FD 4,224 → 0 B, ROBER reltol=1e-8 Rodas5P member 6,336 → 0 B) and reduced on the AD variants (VdP AD 7,776 → 96 B, ROBER AD 3,888 → 48 B). The Newton/FBDF path still allocates at master level (~2.1 kB/step while the switch sits on the FBDF member): the remainder lives in isadaptive/nlsolve_f/unwrap_alg inside nlsolve! in OrdinaryDiffEqNonlinearSolve and is left for a follow-up.

Verification

All commands used TMPDIR=<job>/tmp, JULIA_DEPOT_PATH=<job>/depot:$HOME/.julia, JULIA_NUM_THREADS=1, and OPENBLAS_NUM_THREADS=1.

JULIA_REVISE_POLL=1 GROUP=Core taskset -c 18 julia --project=lib/OrdinaryDiffEqDefault -e 'using Pkg; Pkg.test()' (exit 0):

Test Summary:      | Pass  Total  Time
SciMLBase reexport |    2      2  10.9s
Test Summary:        | Pass  Total      Time
Default Solver Tests |   59     59  29m56.1s
     Testing OrdinaryDiffEqDefault tests passed

JULIA_REVISE_POLL=1 GROUP=QA taskset -c 24 julia --project=lib/OrdinaryDiffEqDefault -e 'using Pkg; Pkg.test()' (exit 0):

Test Summary: | Pass  Total     Time
JET Tests     |    1      1  1m49.2s
Test Summary: | Pass  Total     Time
Aqua          |   20     20  2m12.0s
     Testing OrdinaryDiffEqDefault tests passed

JULIA_REVISE_POLL=1 GROUP=QA taskset -c 25 julia --project=lib/OrdinaryDiffEqDifferentiation -e 'using Pkg; Pkg.test()' (exit 0):

Test Summary: | Pass  Total     Time
JET Tests     |    1      1  1m24.6s
Test Summary: | Pass  Total     Time
Aqua          |   19     19  1m23.7s
Test Summary:       | Pass  Broken  Total     Time
JVPCache allocation |   13       2     15  55.7s
     Testing OrdinaryDiffEqDifferentiation tests passed

GROUP=Core taskset -c 19 julia --project=lib/OrdinaryDiffEqDifferentiation -e 'using Pkg; Pkg.test()' (exit 1) passed its first three testsets (4/4, 7/7, 11/11), then stopped in the unrelated SDIRK ScalarOperator mass matrix test:

LoadError: MethodError: no method matching diag(::SciMLOperators.ScalarOperator{Float64, SciMLOperators.FilterKwargs{typeof(SciMLOperators.DEFAULT_UPDATE_FUNC), Val{()}}})
Test Summary:              | Pass  Error  Total     Time
ScalarOperator mass matrix |    5      1      6  9m18.3s
ERROR: Package OrdinaryDiffEqDifferentiation errored during testing

The same minimal ScalarOperator/TRBDF2() solve fails on clean current master and passes on the parent of the introducing commit. This baseline failure is tracked in SciML/OrdinaryDiffEq.jl issue 4661. The first QA attempt also hit the host's file-watcher limit (EMFILE); rerunning with Revise polling completed successfully. The final Default Core run reported a duplicate-method precompile error in DifferentiationInterfaceGPUArraysCoreExt for OrdinaryDiffEqBDF; Pkg.test() continued and passed.

On e43ed932b6+a22e897cfe, the same groups were re-run via the repo-root dispatcher (GROUP=<Sublib>_<group>): OrdinaryDiffEqDefault_Core 59/59, OrdinaryDiffEqDefault_QA JET 1/1 + Aqua 20/20, OrdinaryDiffEqDifferentiation_QA JET 1/1 + Aqua 19/19 + JVPCache 13/15 (2 broken), OrdinaryDiffEqCore_QA AllocCheck 1/1 + JET 30+1broken + Aqua 26/26. OrdinaryDiffEqDifferentiation_Core reaches the same baseline ScalarOperator mass matrix error (issue 4661) after three clean testsets, as on master.

On 7d8de6cd19+9581365ec1, the CI fixes were verified locally: test/InterfaceI/null_u0_callbacks_test.jl passes 42/42 on the branch and 42/42 on clean master (0fac2d0611); all five formerly unsatisfiable QA environments (Extrapolation, Feagin, IMEXMultistep, PDIRK, TaylorSeries) resolve via activate_group_env with Core 4.19.0 from the local path; and GROUP=QA julia --project=lib/OrdinaryDiffEqFeagin -e 'using Pkg; Pkg.test()' passes — Allocation Tests 3/3, JET 1/1, Aqua 21/21.

Re-run on ca0f2f2d77: OrdinaryDiffEqCore_QA (AllocCheck 1/1, JET 30+1broken, Aqua 26/26), OrdinaryDiffEqDifferentiation_QA (JET 1/1, Aqua 19/19, JVPCache 13/15 with 2 broken), and OrdinaryDiffEqDefault_QA (JET 1/1, Aqua 20/20) all pass. OrdinaryDiffEqRosenbrock_QA reports 39/40 with one error in Rosenbrock32 perform_step! inference: the test inits Rosenbrock32() on a singular-mass-matrix DAE, which master commit ffbc2cdc3b (#4653) made throw Rosenbrock32 is unstable on DAEs without updating this test. The guard and the test file are identical to origin/master (this PR touches neither), so the error reproduces on clean master — same class of pre-existing baseline failure as issue 4661.

The OrdinaryDiffEqNonlinearSolve lts Newton Tests LineSearchException is also a pre-existing master regression, bisected to master commit 498c765ccc ("Add implicit Taylor solvers requiring TaylorSeries 2.4"). Its calc_dt_propose! change snaps dtnew to (t + dtnew) - t, which perturbs the step-size sequence enough to flip the finite-difference dϕ0 used by NLNewton's BackTracking line search positive at reltol = abstol = 1e-12; LineSearches then throws LineSearchException on the first Lorenz solve of newton_tests.jl. The file fails identically on clean master (0fac2d0611) on Julia 1.10.12 and 1.12.4, passes on 498c765ccc^, and passes in a pure-registry environment (Core 4.18.0, Differentiation 3.12.3, NonlinearSolve 2.9.8, SDIRK 2.9.6, LineSearches 7.8.2). LineSearches itself is exonerated: BackTracking's descent check and its ls(ϕ, α, ϕ_0, dϕ_0) body are identical between 7.7.2 and 7.8.2, and master + LineSearches 7.7.2 fails too. This PR touches neither OrdinaryDiffEqNonlinearSolve/src nor OrdinaryDiffEqSDIRK/src.

Runic format_string on all changed files, typos on added diff lines, and git diff --check all exited 0; derivative_wrappers.jl carries a pre-existing indentation drift that fails Runic identically on the unmodified base and was left untouched.

Failing-before/passing-after

The test block added to default_solver_tests.jl was run unchanged from a detached origin/master worktree (exit 1):

DefaultODEAlgorithm stiff step! allocations: Test Failed
  Expression: bytes < 1000
   Evaluated: 8448 < 1000
DefaultODEAlgorithm stiff step! allocations: Test Failed
  Expression: bytes < 1000
   Evaluated: 4224 < 1000
Test Summary:                               | Fail  Total     Time
DefaultODEAlgorithm stiff step! allocations |    2      2  40.4s

The same testset passes on this branch with bytes = 0 on both Julia 1.12.4 and Julia 1.10.12.

Before/after numbers (same machine)

Julia 1.12.4, JULIA_NUM_THREADS=1, taskset -c 9, @benchmark minimum of 10 samples with one evaluation each (first commit):

Problem / algorithm Master solve minimum This branch solve minimum
Lorenz / Default 76.420 µs 76.370 µs
VdP μ=10⁶ / Default 75.580 µs 55.420 µs
ROBER / Default 106.190 µs 87.850 µs
ROBER / AutoTsit5(Rosenbrock23()) 73.390 µs 70.060 µs

Behaviour-equivalence check

19 serialized cases (Default on Lorenz, VdP, ROBER, mass-matrix and OOP variants, nothing algorithm, AutoTsit5/AutoVern7/AutoAlgSwitch composites, custom 3-member composites, Rosenbrock23, Rodas5P, FBDF, KenCarp4, TRBDF2): (sol.t, sol.u, all stats fields, sol.alg_choice) bitwise identical to master. Custom composite warmed allocations match master (48 B / 304 B).

JET dispatch check (Julia 1.10)

JET.report_opt on perform_step! for a warmed Default ROBER integrator, target_modules = (OrdinaryDiffEqDifferentiation, OrdinaryDiffEqCore): 47 reports with 28 "failed to optimize due to recursion" on the first commit → 18 reports, zero recursion failures and zero unwrap_alg/_with_current_alg frames, versus 41 reports on master (15 of them the calc_W! > calc_J! > jacobian! union dispatch this change removes).

What was not verified

GPU paths, downstream packages, and Julia versions other than 1.10/1.12 were not run locally. The documentation build was not run because no docstring, public API, or docs/ file changed. The Newton-path allocation residual (FBDF scope) is unchanged and listed above.

Please ignore until reviewed by @ChrisRackauckas.

Risk assessment

  • Risk: medium
  • Blast radius: differentiation and linear-solve paths for composite stiff algorithms; adds public OrdinaryDiffEqCore._current_alg and a keyword on dolinsolve, covered by the version bumps/compat floors above (register Core → Differentiation → Rosenbrock).
  • Evidence: failing-before/passing-after allocation regression on 1.12 and 1.10, TTFX within +5% of master, passing Default Core and both QA groups, confirmed baseline failure in Differentiation Core, bitwise solve comparisons, and pinned timing minima above.
  • Independent review: Claude Code (Opus 5.5) @a22e897cfe: code verified (bitwise incl. DDE/SDE, TTFX within target, JET recursion 0); CHANGES for version bumps/compat floors — fixed in ca0f2f2
  • Merge: needs human review because this changes dispatch in a hot path across composite stiff algorithms.

🤖 Generated with Codex CLI (model: gpt-6-sol), orchestrated by Claude Code (claude-opus-5-5[1m]) session https://claude.ai/code/session_01LPHREnnonfLg1VcE1EJovv
🤖 Review-fix and packaging rounds by Devin (model: swe-2-high); local session log at /log-dv.txt

Review findings addressed

Review: codex-cli 0.162.1 / gpt-6.1-sol on f904dbad5, VERDICT: CHANGES (one finding).

  1. Differentiation's Core floor admitted a released Core without _current_alg. Fixed in 8a7b0d49e. Master released OrdinaryDiffEqCore 4.19.0 on its own (tag OrdinaryDiffEqCore-v4.19.0 at 53e7d1d), and that release has no _current_alg; the branch's Core version had merged to the same 4.19.0. This PR now bumps OrdinaryDiffEqCore 4.19.0 → 4.20.0 (minor, new public name) and raises OrdinaryDiffEqDifferentiation's [compat] OrdinaryDiffEqCore to "4.20". Registration order: Core 4.20.0 → Differentiation 3.13.0 → Rosenbrock 2.7.6. This order replaces the 4.19.0 numbers in the third-round note above. Rosenbrock keeps OrdinaryDiffEqCore = "4.17.1" because it does not import _current_alg. It reaches Core ≥ 4.20 through its Differentiation 3.13 floor.

Consumer check without monorepo [sources]. This copies the branch's OrdinaryDiffEqDifferentiation with [sources] stripped, adds registered OrdinaryDiffEqRosenbrock 2.7.5, and solves ROBER with Rodas5P() on Julia 1.13.0:

  • Before (f904dbad5), resolution selects registered Core 4.19.0:
    [bbf590c4] + OrdinaryDiffEqCore v4.19.0
    ERROR: LoadError: UndefVarError: `_current_alg` not defined in `OrdinaryDiffEqDifferentiation`
    Failed to precompile OrdinaryDiffEqRosenbrock [43230ef6-c299-4910-a778-202eb28ce4ce]
    
  • After, with registry Core only, resolution refuses, so the broken pair cannot be installed:
    Unsatisfiable requirements detected for package OrdinaryDiffEqCore [bbf590c4]:
     ├─possible versions are: 1.0.0 - 4.19.0 or uninstalled
     └─restricted to versions 4.20.0 - 4 by OrdinaryDiffEqDifferentiation [4302a76b] — no versions left
    
  • After, with this branch's Core 4.20.0 (also with [sources] stripped) standing in for the release:
    [bbf590c4] OrdinaryDiffEqCore v4.20.0
    Core has _current_alg: true
    retcode: Success
    

Test-environment resolution under the unregistered 4.20 floor. Each test sub-environment was resolved the way its runtests.jl activates it, using SciMLTesting.activate_group_env(...; instantiate = false). That covers 56 QA envs, the ABM threaded env, root AD/Downstream/ODEInterfaceRegression, Differentiation sparse/modelingtoolkit, the four DiffEqBase sub-envs and docs. A check that drops Feagin QA's OrdinaryDiffEqCore [sources] entry makes it unsatisfiable, which confirms the five existing QA pins are still required.

  • Julia 1.13.0: 66 resolve. The one unsatisfiable env is lib/OrdinaryDiffEqDefault/test/qa, which nothing activates: Default's runtests.jl runs its QA files inside the Pkg.test environment.
  • Julia 1.10.12: 65 resolve. OrdinaryDiffEqNonlinearSolve/test/qa and OrdinaryDiffEqRosenbrock/test/qa fail on the Rosenbrock 2.7.6 → Differentiation 3.13 floor. That failure is identical on unmodified f904dbad5, and QA-on-LTS jobs are not in this PR's CI matrix.

Local validation of 8a7b0d49e (Julia 1.13.0, JULIA_NUM_THREADS=4):

  • GROUP=QA julia --project=lib/OrdinaryDiffEqDifferentiation -e 'using Pkg; Pkg.test()' resolved Core v4.20.0 from the path and passed: JET 1/1, Aqua 19/19, JVPCache allocation 13 pass + 2 broken (pre-existing).
  • GROUP=Core julia --project=lib/OrdinaryDiffEqDefault -e 'using Pkg; Pkg.test()' resolved Core v4.20.0 from the path and passed: SciMLBase reexport 2/2, Default Solver Tests 59/59. The latter includes this PR's stiff step! allocation testset.
  • typos and git diff --check pass on the changed files. Only Project.toml files changed, so Runic has nothing to format.

Not verified: the change is two version fields, so the full CI matrix, GPU, and downstream jobs were not rerun locally. The 4.20.0 release itself is only simulated: the stripped branch Core stood in for it.

Risk assessment (this round)

  • Risk: low for this commit, which changes only two Project.toml version fields.
  • Blast radius: package resolution only. Until Core 4.20.0 is registered, any environment that takes Differentiation from this branch and Core from the registry is unsatisfiable rather than broken. The sweep above found no CI environment in that state.
  • Merge: the PR as a whole still needs human review, per the risk assessment above.

🤖 Posted by an AI agent — harness: Claude Code 2.1.301 · model: claude-opus-5-5
Conversation: local session ID 693654d9-8c20-4cee-ac2a-8cbdf35185fd (headless, no URL)

Risk assessment (independent review, codex-cli gpt-6.1-sol, reviewed head 8a7b0d4)

  • Risk: medium
  • Blast radius: shared Jacobian, W-matrix and linear-solve dispatch in OrdinaryDiffEqDifferentiation, plus Rosenbrock stepping/interpolation and composite stiff solvers. Public additions are _current_alg and the optional dolinsolve(...; alg=...) keyword; existing signatures/defaults remain supported.
  • Evidence: Julia 1.13.0, JULIA_NUM_THREADS=4: OrdinaryDiffEqDefault Core passed 61/61 assertions, including both new allocation regressions. A standalone consumer with sibling [sources] removed fails before the compatibility fix, rejects incompatible registered Core after the fix, and solves ROBER successfully with branch Core 4.20.0 and registered Rosenbrock 2.7.5. CI at both checks: 22 pending, no completed failing jobs. Current runs: https://github.com/SciML/OrdinaryDiffEq.jl/actions/runs/38918138469 and https://github.com/SciML/OrdinaryDiffEq.jl/actions/runs/38918138405 .
  • Independent review: codex-cli 0.163.0 gpt-6.1-sol rated it medium, high confidence: the release-floor defect is resolved and local solver/consumer checks pass; shared numerical dispatch warrants human review.
  • Merge: needs human review — medium risk across shared differentiation paths. No blocking finding; pending CI is permitted for this review verdict. Registration must proceed Core 4.20.0 → Differentiation 3.13.0 → Rosenbrock 2.7.6.

🤖 Posted by an AI agent — harness: codex-cli · model: gpt-6.1-sol (independent reviewer; appended by Claude Code 2.1.301 · claude-opus-5-5)
Conversation: https://claude.ai/code/session_01VZjwf7Ux9YtTzwHGHMqnsq

🤖 Automated review section from an AI agent running as Chris Rackauckas's account — not written or reviewed by Chris.

Risk assessment (independent review, Codex CLI 0.164.0-alpha.11.1 gpt-6-astra, slot 1, head 8a7b0d4)

  • Risk: medium-high (MH1: Algorithm selection and differentiation/linear-solve dispatch are changed across the default stiff main lane; required all-green downstream validation for ML11 is absent.)
  • Verdict: MERGE
  • Session: 01a18da8-0055-70e2-850a-45982d205850
  • Blocking priorities: none

Review round 1, written by the reviewer named above (Codex CLI 0.164.0-alpha.11.1 / gpt-6-astra) in a session other than the PR author's, and copied here by the posting agent without change to its findings. The posting agent did not re-run the reviewer's commands.

Summary: The PR carries concrete cache algorithms through differentiation and Rosenbrock linear solves to avoid algorithm boxing. The public helper, documentation, release floors and allocation tests are present, and I found no blocking defect.

Blast radius: DefaultODEAlgorithm stiff branches, Core algorithm selection, Differentiation Jacobian/W paths, Rosenbrock solves, and dependent package compatibility floors.

Evidence: Exact-head call-chain, API and manifest review; Default, Differentiation and Rosenbrock CI pass; 272 success, 2 failure, 1 skipped checks. Both failures match inspected default-branch signatures; reviewer did not repeat timing/allocation benchmarks.

Blocking findings

None.

Non-blocking findings

  1. lib/OrdinaryDiffEqDefault/test/default_solver_tests.jl:282: Assert the selected stiff branch in the allocation test before measuring. A bytes bound alone does not prove the intended stiff dispatch was reached if solver switching changes.
  2. lib/OrdinaryDiffEqCore/src/alg_utils.jl:170: Retain reproducible cold and warmed measurements for the tradeoff described in this docstring; it currently states compiler-cost consequences without measurements in the diff.

The branch assertion costs one test-only inspection; preserving benchmark evidence costs an additional cold/warm measurement run outside production execution.

What I ran

The exact-head checkout was verified with git rev-parse HEAD (exit 0, SHA in header). git diff origin/master...HEAD and git diff --check origin/master...HEAD completed with exit 0; the latter produced no diagnostics. I inspected changed files, callers, tests, package manifests, and the absence of root AGENTS.md/CLAUDE.md. git log -1 --format=%B, git log --no-merges -1 --format=%B, and git log --no-merges -1 --format=%B origin/master..HEAD were inspected (exit 0); author trailers below come from the newest PR-specific non-merge commit. The header Base is fetched origin/master; GitHub's comparison base at review time was 59ba40e4b5bbae713d8df7b792f6ea62f033ff78.

I followed _current_alg through cache-bearing and fallback callers, including NLNewtonCache (which lacks an alg field), checked the empty-input Jacobian guard, and checked dolinsolve(...; alg=...) in Rosenbrock stage and addsteps calls. _current_alg is declared public with a docstring and docs entry. The Core 4.20.0 / Differentiation 3.13.0 / Rosenbrock 2.7.6 release sequence and Differentiation's Core 4.20 floor exclude the earlier released Core without this helper. The added allocation tests warm the solver and measure repeated default stiff steps; no unmeasured speedup is asserted here.

CI: Default, Differentiation, and Rosenbrock pass. Failed logs Core4 and NonlinearSolve identify the Enzyme assertion and Newton line-search exception. I compared failure text with recent completed default-branch runs, rather than accepting the description's classification. Master IntegrationTest 41050161729 has the same Core4 ensembles.jl:19 Enzyme AssertionError: mi2 !== nothing; master Sublibrary CI 41058796614 has the same Julia-1 Newton LineSearchException: Search direction is not a direction of descent. Step length: 0.0. These are matching baseline failures, not green integration validation.

What I did not verify

No reviewer Julia process or benchmark ran for this PR; no local Julia version/test exit code applies. I did not independently repeat the body's allocation counts, 19-case bitwise matrix, DDE/SDE consumer runs or first-solve timings. CI provides exercised solver paths, but not fully green integration validation. The first assessment froze risk and candidates before opening the PR description. A fresh independent assessor then froze a complete review of this exact PR head before reading its description, any prior review, other assessment notes, or coordinator-run Julia output. The final comparison and REVIEWER_GRADE below come from that fresh assessment. It subsequently evaluated prior same-head findings and newly available raw execution evidence; prior claims are distinguished from executions in this review session. The independent freeze remains unchanged.

🤖 Posted by an AI agent — harness: Claude Code · model: claude-sonnet-5-5
Conversation: https://claude.ai/code/session_01379heiiB35TtywhR7uSU74

@ChrisRackauckas

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

Merged the default branch into this PR (clean merge, no conflicts; head beea975) so CI runs on current master. Its earlier failures in SciMLSensitivity Core1 and the downgrade jobs were fixed on master after this PR's last CI run.


🤖 Posted by an AI agent — harness: Devin CLI 3000.11.3 (merge), Claude Code 2.1.285 (posting) · model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium
Conversation: local Claude session 3c311569-dda6-4687-bc9f-65febb212c33 (fleet master)

ChrisRackauckas and others added 7 commits October 31, 2026 07:30
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI codex-cli 0.157.1
Agent-Model: gpt-6-sol
Agent-Session: local codex session (log /home/crackauc/sandbox/goals/performance/jobs/pr-unwrap-alg/log.txt)
The generated-function dispatch in _with_current_alg compiled every wrapped
function for all DefaultODEAlgorithm members on first solve (~0.65 -> 1.85 s
CPU on ROBER). Replace it with _current_alg in OrdinaryDiffEqCore:

- member caches that carry the concrete algorithm (the Rosenbrock family)
  expose it through cache.alg, so the hot differentiation paths dispatch
  statically with no extra specialization cost;
- other callers fall back to the runtime-selected member, which stays an
  over-split-limit union at the call site, so only the member that actually
  executes gets compiled.

Also de-nest the stiff differentiation path: _calc_rosenbrock_differentiation!
and _calc_W! now call the alg-taking inner functions (_calc_W!,
_calc_tderivative!, _calc_J!, _calc_J_dae!, _rosenbrock_jac_reuse_decision_alg)
directly instead of re-entering the dispatch helper, and dolinsolve takes an
alg keyword with cache.alg passed at Rosenbrock call sites.

Fresh-process CPU, pinned, 6 interleaved reps vs master: first solve ROBER
0.633 s vs 0.605 s (+4.7%), VdP 22.6 s vs 21.9 s (+3.1%); load time
unchanged. Warmed step! bytes: VdP Default FD 8448 -> 0, ROBER Default FD
4224 -> 0, ROBER Default AD 3888 -> 48, ROBER rtol=1e-8 Rodas5P member
6336 -> 0. Custom three-member composites match master (48/304 B). JET
report_opt on 1.10: 47 reports (28 recursion failures) -> 18, versus 41 on
master. All 19 serialized comparison cases remain bitwise identical to
master.

The FBDF/Newton-path residual (Heat100 ~2.1 kB/step, at master level) is
inside nlsolve!/isadaptive/unwrap_alg in OrdinaryDiffEqNonlinearSolve and
is left for a follow-up.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Devin <[email protected]>
Agent-Harness: devin 3000.11.1
Agent-Model: swe-2-high
Agent-Session: local Devin session (log /home/crackauc/sandbox/goals/performance/jobs/pr-unwrap-alg/log-dv.txt)
OrdinaryDiffEqCore QA requires every public name to appear in a @docs
block; _current_alg is selected through cache.alg / unwrap_alg alongside
the other composite-algorithm helpers.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Devin <[email protected]>
Agent-Harness: devin 3000.11.1
Agent-Model: swe-2-high
Agent-Session: local Devin session (log /home/crackauc/sandbox/goals/performance/jobs/pr-unwrap-alg/log-dv.txt)
The PR adds public _current_alg in OrdinaryDiffEqCore and an alg keyword on
dolinsolve in OrdinaryDiffEqDifferentiation; OrdinaryDiffEqRosenbrock is the
only caller that passes it. Registered releases would load mismatched
versions without the bumps — monorepo CI resolves siblings from local
[sources] paths and cannot catch this (same trap as in the SciML#4590 fix).

- OrdinaryDiffEqCore 4.18.1 -> 4.19.0 (minor: new public name)
- OrdinaryDiffEqDifferentiation 3.12.4 -> 3.13.0 (minor: new alg keyword);
  compat OrdinaryDiffEqCore >= 4.19 since it imports _current_alg
- OrdinaryDiffEqRosenbrock 2.7.5 -> 2.7.6 (patch); compat
  OrdinaryDiffEqDifferentiation >= 3.13 since it passes alg=

Also drops the one-argument _current_alg(integrator): it was a verbatim
duplicate of unwrap_alg(integrator, true) for ODE integrators; its two
call sites now call unwrap_alg directly.

Packages must be registered in the order Core -> Differentiation ->
Rosenbrock for the floors to resolve.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Devin <[email protected]>
Agent-Harness: devin 3000.11.1
Agent-Model: swe-2-high
Agent-Session: local Devin session (log /home/crackauc/sandbox/goals/performance/jobs/pr-unwrap-alg/log-dv.txt)
The de-nested stiff-differentiation paths call _jacobian! directly,
bypassing the isempty(x) guard that jacobian! provided. With a null
state (u0 = nothing) the Jacobian inputs are empty, so dense_ad color
vector construction hits `maximum(1:0)` and throws
`ArgumentError: range must be non-empty` for Rosenbrock23, Rodas5P and
TRBDF2 in test/InterfaceI/null_u0_callbacks_test.jl.

Give _jacobian! the same early return so direct callers get the
behavior jacobian! callers had.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Devin <[email protected]>
Agent-Harness: devin 3000.11.1
Agent-Model: swe-2-high
Agent-Session: local Devin session (log /home/crackauc/sandbox/goals/performance/jobs/pr-unwrap-alg/log-dv.txt)
Sublibrary QA environments develop the package under test together
with the repository root, so the root [sources] path-pins
OrdinaryDiffEqDifferentiation 3.13.0 and OrdinaryDiffEqRosenbrock
2.7.5. Differentiation 3.13.0 requires OrdinaryDiffEqCore 4.19, which
is not yet registered, while each QA environment declares
OrdinaryDiffEqCore as a direct dependency and therefore resolves it
from the registry (<= 4.18.0). The result is an unsatisfiable
requirements error in the Extrapolation, Feagin, IMEXMultistep, PDIRK
and TaylorSeries QA jobs (same class of trap as SciML#4590).

Following the established convention (e.g.
StochasticDiffEqImplicit/test/qa, OrdinaryDiffEqBDF), every local
dependency of these projects and test environments now gets a
matching path entry in [sources]:

- Package projects with no [sources] section gain one covering all
  local deps: Extrapolation, Feagin, IMEXMultistep, NonlinearSolve,
  PDIRK.
- Partial [sources] tables are completed: StochasticDiffEq
  (OrdinaryDiffEqDifferentiation), GlobalDiffEq (OrdinaryDiffEqSSPRK),
  TaylorSeriesImplicit (DiffEqDevTools), and the root project
  (OrdinaryDiffEqFeagin).
- Test/QA environments gain path entries for their non-self local
  direct deps, most importantly OrdinaryDiffEqCore where the bumped
  compat floor applies (Extrapolation, Feagin, IMEXMultistep,
  NonlinearSolve, PDIRK, TaylorSeries, Default QA envs, plus
  DiffEqDevTools/ImplicitDiscreteSolve in the modelingtoolkit and
  threaded envs).

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Devin <[email protected]>
Agent-Harness: devin 3000.11.1
Agent-Model: swe-2-high
Agent-Session: local Devin session (log /home/crackauc/sandbox/goals/performance/jobs/pr-unwrap-alg/log-dv.txt)
3b26603 swept 18 files; only the five QA test environments that
hit the unsatisfiable-Core resolver error needed entries. The extra
pins made other envs (e.g. OrdinaryDiffEqNonlinearSolve's downgrade
job) resolve local sibling code they were meant to test against
registered releases. Revert everything except:

- Extrapolation/Feagin/PDIRK/TaylorSeries test/qa: OrdinaryDiffEqCore
  (their QA envs declare Core directly; registry caps it at 4.18.0
  while path-pinned Differentiation 3.13.0 needs 4.19)
- IMEXMultistep test/qa: OrdinaryDiffEqCore + OrdinaryDiffEqDifferentiation
  (Differentiation is also a direct dep there; path-pinned
  Rosenbrock 2.7.5 needs 3.13)

All five QA envs resolve locally via activate_group_env; Feagin QA
passes (AllocCheck 3/3, JET 1/1, Aqua 21/21).

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Devin <[email protected]>
Agent-Harness: devin 3000.11.1
Agent-Model: swe-2-high
Agent-Session: local Devin session (log /home/crackauc/sandbox/goals/performance/jobs/pr-unwrap-alg/log-dv.txt)
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review October 31, 2026 12:01
@ChrisRackauckas
ChrisRackauckas merged commit 2afc3fa into SciML:master Oct 31, 2026
271 of 277 checks passed
ChrisRackauckas referenced this pull request Nov 27, 2026
* Avoid per-step deepcopy in ExplicitTaylorAdaptiveOrder

Order-selection trials cloned the whole controller cache and grew
order_history every step. Snapshot only the restored fields into
preallocated storage and drop the unused history.

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-taylor-deepcopy/log.txt on amdci2

* Preserve native types in AdaptiveOrder controller snapshots

Order-selection restore was converting every controller field through
typeof(t), which MethodError'd Dual tspan and rounded Float32-t PID
history. Snapshot the cache's own isbits/array values as a NamedTuple.

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-taylor-deepcopy/log.txt on amdci2

* Snapshot non-isbits AdaptiveOrder controller scalars

isbits-only NamedTuple snapshots dropped BigFloat PIController q11/errold,
so order trials leaked state. Include every scalar scratch field and make
array history length-generic; tighten Float32 PID and add BigFloat regressions.

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-taylor-deepcopy/log.txt on amdci2

* Restore 0-alloc PIDController AdaptiveOrder snapshots
Runtime-length ntuple boxed the length-3 err history (~1 KB/step).
Specialize on Val(3) after an explicit length check and add a PID
allocation regression.

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-taylor-deepcopy/log.txt on amdci2

* Compare PID AdaptiveOrder step! allocs to ExplicitTaylor2

Julia 1.10/1.11 step! has a fixed 16-byte infrastructure allocation for every solver, so == 0 fails CI while the PID snapshot path is still 0 extra bytes. Keep the bound tight against the round-3 1 KB ntuple regression.

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-taylor-deepcopy/log.txt on amdci2

* Keep deepcopy + sync_controllers! for custom controller caches in AdaptiveOrder

The allocation-free field snapshot assumed every array field was a length-3
history (PIDControllerCache.err), so a user-defined AbstractControllerCache
with, e.g., a length-4 Vector threw an ArgumentError on the first step.
Restrict the field snapshot to OrdinaryDiffEqCore's I/PI/PID/Predictive
caches, whose sync_controllers! copies exactly the walked fields, and send
every other controller cache through the documented protocol: deepcopy
before the order trial, sync_controllers! after.

Adds a Core regression test with a custom controller holding a length-4
history and an accept counter, run IIP and OOP; it errors before this
change and checks that the counter equals stats.naccept after it.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Agent-Harness: Claude Code 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: local session ID bf8d6de7-a858-41b2-b438-bc6101c93513 (headless claude -p, no URL)

* Add public snapshot_controller / restore_controller! to OrdinaryDiffEqCore

ExplicitTaylorAdaptiveOrder pseudo-steps the step-size controller once per
candidate order and rolls it back. The allocation-free rollback depended on
four non-public OrdinaryDiffEqCore cache types and their field layouts, with
matching ExplicitImports exemptions in the Taylor QA test.

OrdinaryDiffEqCore now owns that protocol as documented public API:
snapshot_controller(cache) / restore_controller!(cache, snapshot). The
default is deepcopy + sync_controllers!, so every custom controller that
implements sync_controllers! keeps working. The I/PI/PID/Predictive caches
get allocation-free NamedTuple methods next to their sync_controllers!.
OrdinaryDiffEqTaylorSeries calls only the public pair, its local snapshot
code and the four QA exemptions are gone, and its QA environment resolves
the in-repo OrdinaryDiffEqCore like the other sublibrary QA environments.

OrdinaryDiffEqCore 4.19.0 -> 4.20.0 (new public API). OrdinaryDiffEqTaylorSeries
2.4.0 -> 2.5.0 with OrdinaryDiffEqCore compat raised to 4.20, since it needs
the new functions.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Agent-Harness: Claude Code 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: local session ID bf8d6de7-a858-41b2-b438-bc6101c93513 (headless claude -p, no URL)

---------

Co-authored-by: ChrisRackauckas-Claude <[email protected]>
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: Devin <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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