Skip to content

Branch on isinplace so convenience constructors dispatch statically - #1636

Open
ChrisRackauckas-Claude wants to merge 9 commits into
SciML:masterfrom
ChrisRackauckas-Claude:isinplace-static-dispatch
Open

ChrisRackauckas-Claude wants to merge 9 commits into
SciML:masterfrom
ChrisRackauckas-Claude:isinplace-static-dispatch

Conversation

@ChrisRackauckas-Claude

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

Copy link
Copy Markdown
Member

Summary

Convenience constructors such as ODEFunction(f), ODEProblem(f, u0, tspan, p), and NonlinearFunction(f) were written as T{isinplace(f, N), ...}(f; kwargs...). The runtime Bool type parameter forced a dynamic kwargs dispatch on every call. Branching on the Bool with literal {true} / {false} arms keeps each path statically dispatched. The same pattern is applied to the other {isinplace(f, [0-9] constructor sites under src/ (Discrete/SDE/RODE/DAE/DDE/SDDE/… functions, IntegralProblem, function wrappers). This does not touch the broader isinplace rewrite in #1019.

The large win is on Julia 1.10 (~140× / ~1088→16 allocs for ODEFunction(f!)). On Julia 1.12 the same call is only ~7× (26→3.6 µs / 60→16 allocs); 1.12 already paid much less for the dynamic-Bool path.

Ensemble follow-up (CI regression)

Concrete ODEProblem inference made responsible_map / tmap allocate a narrow Vector{T} from the first trajectory's inferred return type. On master that inference was Any, so mixed-u0 ensembles worked by accident. Downstream Ensembles of Zero Length Solutions (and any ensemble whose prob_func changes u0 type) then hit MethodError converting ODESolution{…Matrix…} into Vector{ODESolution{…Float64…}}.

Fix: widen the container when a later element does not fit (Base map/collect style) in responsible_map; tmap collects into Any then tighten_container_eltype (threaded widening is racy). Constructor changes and their numbers are unchanged.

Regression in test/inference_tests.jl (responsible_map over [0.5, diagm(...)]): fails on unfixed PR head, passes with the widen. Downstream zero-length ensemble: fails unfixed / passes fixed; passes on master.

Before / after (OPENBLAS_NUM_THREADS=1, JULIA_NUM_THREADS=1, taskset -c N, @benchmark minima, warmed)

Call 1.12 before 1.12 after 1.10 before 1.10 after
ODEFunction(f!) 26.5 µs / 60 3.58 µs / 16 430 µs / 1088 3.1 µs / 16
ODEProblem(f!,…) IIP 27.9 µs / 62 6.31 µs / 19 415 µs / 1090 6.2 µs / 19
ODEProblem(fo,…) OOP 28.1 µs / 62 5.53 µs / 19 26.9 µs / 62 5.43 µs / 19
NonlinearProblem(nf,…) 17.9 µs / 59 6.82 µs / 19 16.2 µs / 59 6.43 µs / 19

Constructor allocation regression (@allocations … < 40 after warmup in test/inference_tests.jl): fails on master, passes with the fix.

Test plan

  • Core group: Testing SciMLBase tests passed (incl. new ensemble widen regression)
  • Full GROUP=QA with CONDA_OVERRIDE_GLIBC=2.35: QA | 123 123, Testing SciMLBase tests passed
  • Downstream Ensembles of Zero Length Solutions on Julia 1.10: fail unfixed / pass fixed; pass on master
  • OrdinaryDiffEqTsit5 smoke: IIP + OOP ODEProblem via changed constructors
  • Runic + typos on touched files
  • Julia 1.10 / 1.12 constructor allocation regression

What was NOT verified

  • Full Downstream / DownstreamAD / Python / Reactant CI groups (only the zero-length ensemble testset + Tsit5 smoke)
  • ModelingToolkit Extended / SymbolicIndexingInterface CI failures (pre-existing / also on other PRs)
  • Interaction with fix isinplace inference and add inference tests #1019 (left untouched)
  • @inferred on these constructors still returns a Union{…true…, …false…} because isinplace itself is not constant-folded; the win is runtime static dispatch / allocs

Follow-up (separate PR; not changed here)

Same runtime-iip dynamic dispatch remains under other spellings the {isinplace(f, [0-9] grep misses:

  • iip = isinplace(f, N) then T{iip}: SDEProblem, BVProblem, SecondOrderBVProblem, DiscreteProblem, bare-function ImplicitDiscreteProblem, ImmutableODEProblem, SecondOrderODEProblem, SecondOrderDDEProblem, HomotopyProblem, AnalyticalProblem
  • {isinplace(f1|f2, N)}: SplitFunction, DynamicalODEFunction, SplitSDEFunction, DynamicalSDEFunction, DynamicalDDEFunction
  • {isinplace(A, 4)}: LinearProblem

Reviewer pushback

  • Whether the < 40 allocation bound is tight enough across Julia versions / GC noise
  • Whether tmap always going through Vector{Any} + tighten is acceptable vs a typed fast path with mismatch fallback
  • Whether ODEProblem(f,…) should keep the old inline prepare_initial_state path instead of delegating to ODEProblem{true/false}

Please ignore until reviewed by @ChrisRackauckas.

Risk assessment

Independent review: MERGE (low risk) for constructor change; ensemble widen is a correctness fix for the inference side-effect of that change.

🤖 Generated with Cursor Agent CLI (model: auto), transcript; orchestrated by Claude Code (claude-opus-5-5[1m])

Made with Cursor

Risk assessment (independent review, Grok Build grok-4.7, reviewed head d581bf5)

  • Risk: medium
  • Blast radius: Untyped convenience constructors (ODEFunction, ODEProblem, NonlinearFunction, integral / SDE / DAE / DDE / BVP function wrappers, and the Jacobian wrappers) and the ensemble responsible_map / tmap containers. Return values I checked match master. Homogeneous ensemble maps stay in a concrete Vector{T}; a later element that is not isa that T widens the container with promote_typejoin. No public name is removed or renamed. No Project.toml change and no new dependency. Every downstream solver that builds problems through these constructors is in the inference blast radius.
  • Evidence: Head d581bf59255efb780a96f23f6b274287e77660e1. test/inference_tests.jl passed on julia +release 1.13.0 and julia +lts 1.10.12 (all testsets, including 10/10 convenience-constructor checks and 9/9 ensemble-widen checks). @allocations after warmup on 1.13.0: ODEFunction(f!) 60 on master 365283c6, 17 on this head; ODEProblem in-place 63 → 20; NonlinearProblem 59 → 19. The new < 40 bounds therefore fail on master and pass here. ODEProblem(f!, 1, (0, 1), 2) and ODEProblem(fo, [1, 2], (0, 1)) matched master for u0 type, tspan, isinplace, and p. Head CI is 55 pending, 0 failing. The previous SHA 9875b30 failed SymbolicIndexingInterface (same two jobs as master https://github.com/SciML/SciMLBase.jl/actions/runs/38430497911), SciMLSensitivity Core1, and ModelingToolkit Extended. Those two downstream jobs also failed on master IntegrationTest on 2026-10-11 (https://github.com/SciML/SciMLBase.jl/actions/runs/38134190296). Current master IntegrationTest is green (https://github.com/SciML/SciMLBase.jl/actions/runs/38430497479). No skips, @test_broken, or loosened tolerances.
  • Independent review: Grok Build grok-4.7 rated it medium, high: the Bool branch is equivalent for the values checked, the allocation bound discriminates against master, and the ensemble widen is covered by a regression test.
  • Merge: needs human review — constructor inference and ensemble eltype change across the problem API, and the rebased head's CI has not finished. The PR body's "low risk" is the author's label.

🤖 Posted by an AI agent — harness: Grok Build · model: grok-4.7 (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.

Fix by Codex CLI 0.164.0 gpt-6.1-sol (head d621b9a)

Merged upstream master normally, preserving both histories, to include the corrected lowered-solution indexing tests from #1657. No additional source changes were made. The two indexing errors also occur in historical default-branch push CI; the latest default run passes all three requested checks. Reactant's earlier Unknown package: GPUCompiler dependency-setup error did not recur locally; an identical historical default failure was not established.

Failing before / passing after

Saved the original indexing test from head d581bf592 and ran it against the same merged source and downstream dependencies used by the corrected group. The original test command was timeout 7200 julia --project=test/downstream -e 'using Test; @testset "Original indexing regression" begin include("../scratch/comprehensive_indexing_before.jl"); end' (Julia 1.12.4).

ERROR: Some tests did not pass: 3747 passed, 0 failed, 2 errored, 0 broken.
State indexing: Error During Test at original comprehensive_indexing.jl:127
  BoundsError: attempt to access 1-element Vector{Float64} at index [[1, 2]]
Observed: Error During Test at original comprehensive_indexing.jl:164
  BoundsError: attempt to access 1-element Vector{Float64} at index [[1, 2]]

The corrected file passed 3781/3781 in the complete SymbolicIndexingInterface group on both Julia 1.12.4 and LTS 1.10.12.

Local validation

All Julia commands used four threads, one OpenBLAS thread, a dedicated temporary directory, and timeouts of at least 3600 seconds. The LTS group ran in an isolated worktree whose merged files were verified byte-identical.

  • timeout 3600 julia --project=@runic -m Runic --inplace $(git diff --cached --name-only -- '*.jl') on the staged merge: exit 0, no output or file changes.
  • git diff --cached --unified=0 | sed -n '/^+[^+]/s/^+//p' | typos -: exit 0, no output. A raw-diff scan only flagged hash fragments.
  • git diff --check --cached and git diff --check: exit 0.
  • timeout 7200 env GROUP=Core julia --project -e 'using Pkg; Pkg.test()' (Julia 1.12.4):
Compile-time trait inference |   40     40  2.5s
Remake        | 4631   4631  3m11.3s
     Testing SciMLBase tests passed
  • timeout 7200 env GROUP=QA julia --project -e 'using Pkg; Pkg.test()' (Julia 1.12.4): the first run stopped during PythonCall initialization because provisioned Python 3.14 lacked filesystem codecs. The complete rerun used system Python through JULIA_PYTHONCALL_EXE, with JULIA_CONDAPKG_BACKEND=Null; all assertions remained enabled.
Test Summary: | Pass  Total     Time
QA            |  123    123  6m07.2s
     Testing SciMLBase tests passed
  • timeout 7200 env GROUP=SymbolicIndexingInterface julia --project -e 'using Pkg; Pkg.test()' (Julia 1.12.4):
Symbol and integer based indexing of interpolated solutions | 3781   3781  33m52.9s
Symbol and integer based indexing of integrators |   99     99  49.9s
Problem Indexing |  122    122  30.7s
ModelingToolkit Remake |  248       3    251  2m05.4s
     Testing SciMLBase tests passed
  • timeout 7200 env GROUP=SymbolicIndexingInterface julia +lts --project -e 'using Pkg; Pkg.test()' (Julia 1.10.12):
Symbol and integer based indexing of interpolated solutions | 3781   3781  25m09.5s
Symbol and integer based indexing of integrators |   99     99  26.7s
Problem Indexing |  122    122  18.3s
Adjoints      |    6       5     11  3m32.4s
ModelingToolkit Remake |  248       3    251  1m44.1s
     Testing SciMLBase tests passed

Both indexing runs retain eight existing broken tests (five Adjoints, three ModelingToolkit Remake); this merge adds none.

  • timeout 7200 env GROUP=Reactant julia +1 --project -e 'using Pkg; Pkg.test()' (Julia 1.13.3):
Reactant specialization |    4      4  4m47.1s
Reactant return codes |   28     28  9.2s
     Testing SciMLBase tests passed
  • timeout 7200 julia --project=docs docs/make.jl: exit 0.
[ Info: Automatic `version="3.59.1"` for inventory from ../Project.toml
Warning: Documenter could not auto-detect the building environment. Skipping deployment.

The upstream SciMLLogging dependency and SciMLBase both use the MIT license. Full downstream/AD/GPU/distributed suites and performance benchmarks were not rerun. The historical dependency change introducing the indexing mismatch was not bisected; the existing upstream repair was identified and verified instead. No code changes were made for unrelated default-branch failures or optional earlier review suggestions.

Next counted review must come from a smart model in a fresh session, not this fix session (risk.md § Independent reviews).

Links


🤖 Posted by an AI agent — harness: Codex CLI 0.164.0 · model: gpt-6.1-sol
Conversation: local fixer job SciML__SciMLBase.jl__1636 (no session URL)

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

Fix by Codex CLI 0.170.0 gpt-6.2-sol (head cc29a24)

The Mooncake responsible_map and tmap rules use the ordinary ensemble map widening logic for forward values. Mooncake initializes tangent storage from the resulting vector, so pullbacks receive cotangents with the precision of each mapped element. The regression checks output type, exact values, and input cotangents for both rules.

Failing before and passing after

On Julia 1.13.3 with Mooncake 0.5.72, the same test file ran on the reviewed head and with the fix. MOONCAKE_ENV and LTS_ENV are scratch Julia projects developed against the checkout.

timeout 7200 julia +1 --startup-file=no --project="$MOONCAKE_ENV" -e 'using Pkg; Pkg.develop(path=pwd()); Pkg.add("Mooncake"); include("test/downstream/ensemble_mooncake.jl")'
timeout 7200 julia +1 --startup-file=no --project="$MOONCAKE_ENV" -e 'include("test/downstream/ensemble_mooncake.jl")'
timeout 7200 julia +lts --startup-file=no --project="$LTS_ENV" -e 'using Pkg; Pkg.develop(path=pwd()); Pkg.add("Mooncake"); include("test/downstream/ensemble_mooncake.jl")'
Before, exit 1
  Evaluated: Vector{Float32} === Vector{AbstractFloat}
  TypeError: in typeassert, expected Float64, got a value of type Float32
  Mooncake map with mixed float precisions | 4 failed, 2 errored, 6 total
After, Julia 1.13.3, exit 0
  Mooncake map with mixed float precisions | 6 passed, 6 total, 2.9s
After, Julia 1.10.12, exit 0
  Mooncake map with mixed float precisions | 6 passed, 6 total, 2.5s

timeout 7200 julia +1 --startup-file=no --project="$MOONCAKE_ENV" "$PROBE" used prepare_pullback_cache and value_and_pullback!! on a scalar loss over each mapper. The probe exited 0 with Mooncake differentiation through ensemble maps | 4 4 10.4s.

Full local checks

Julia ran with four threads and one OpenBLAS thread. julia was 1.12.4 and julia +1 was 1.13.3. QA used the system Python via JULIA_PYTHONCALL_EXE and JULIA_CONDAPKG_BACKEND=Null.

timeout 7200 julia --project=@runic -m Runic --inplace ext/SciMLBaseMooncakeExt.jl src/ensemble/basic_ensemble_solve.jl test/runtests.jl test/downstream/ensemble_mooncake.jl test/qa/qa.jl
git diff --cached --unified=0 | sed -n '/^+[^+]/s/^+//p' | typos -
git diff --cached --check
git diff --check

Each command exited 0 with no output.

timeout 7200 env GROUP=QA julia --project -e 'using Pkg; Pkg.test()'
timeout 7200 env GROUP=Core julia --project -e 'using Pkg; Pkg.test()'
timeout 7200 env GROUP=DownstreamAD julia +1 --project -e 'using Pkg; Pkg.test()'
timeout 7200 julia --project=docs docs/make.jl
QA            | 123  123  17m38.9s
     Testing SciMLBase tests passed
Compile-time trait inference | 40  40  2.4s
Ensemble functionality | 22  22  6.7s
Remake        | 4631  4631  3m01.1s
     Testing SciMLBase tests passed
Mooncake ensemble map rules | 6  6  42.5s
Autodiff Observable Functions | 15  15  6m44.5s
Enzyme through ensembles of SDEs | 2  2  8m59.4s
PDE solution adjoints | 87  87  4m44.3s
Symbolic solution getindex adjoints | 96  96  5m47.3s
     Testing SciMLBase tests passed
[ Info: RenderDocument: rendering document.
[ Info: HTMLWriter: rendering HTML pages.
Warning: Documenter could not auto-detect the building environment. Skipping deployment.

All four commands exited 0. The full DownstreamAD run retains the suite's existing Julia 1.12+ ensemble adjoint skip. The LTS DownstreamAD Enzyme failure already occurs on the default branch and is tracked in SciMLBase. The latest pre-fix PR run passes the three originally flagged Reactant and SymbolicIndexingInterface jobs. Historical default-branch CI reproduced all three failures, and the existing branch already includes the upstream indexing repair. The LTS DownstreamAD group, Reactant and SymbolicIndexingInterface were checked through existing CI evidence for this fix.

Next counted review must come from a smart model in a fresh session, not this fix session.

Links


🤖 Posted by an AI agent — harness: Codex CLI 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a201c5-7173-77f2-bd7e-579d8d8df25f (no session URL)

ChrisRackauckas and others added 6 commits October 7, 2026 23:22
Splicing a runtime Bool into the type parameter forced dynamic kwargs
dispatch on every ODEFunction/ODEProblem/NonlinearFunction construction;
literal true/false arms keep each path concrete.

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/scimlbase/pr-iip-branch/log.txt on amdci2
isinplace is already static for AbstractSciMLFunction, so the Bool
branch was a no-op; keep the diff minimal.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI
Agent-Model: auto
Concrete ODEProblem inference made responsible_map allocate a narrow
Vector{T} from the first inputs, so ensembles whose prob_func changes
u0 type (and Downstream zero-length mixed-u0 map) MethodError'd on
convert. Widen like Base map/collect; tmap collects via Any then
tightens.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI
Agent-Model: auto
Keep return_type Vector{T} and widen via a misfit side slot only when a
result does not fit, restoring master's EnsembleThreads allocation count
and mixed-type eltypes.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI
Agent-Model: auto
When eltype inference proves every result fits in T, return the typed
vector directly so EnsembleThreads solve stays concrete and matches
master's allocations; keep the side-slot widen path only when it cannot.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI
Agent-Model: auto
Bare constructor warmups do not compile 1.10's inline @Allocations
frame, so LTS CI counted residual compilation (~266) as steady-state
allocs; barrier helpers discard that first measurement.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI
Agent-Model: auto
@ChrisRackauckas

ChrisRackauckas commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

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

Independent review (Devin CLI 3000.11.3, model fusion-claude-opus-5-5-high-sidekick-swe-2-medium): MERGE, risk medium.

Full review

VERDICT: MERGE
RISK: medium

The constructor changes don't change behaviour. The ensemble widening is a real fix, and I checked it fails before the change and passes after. The risk is medium rather than low because the change sits on hot public paths (every ODEFunction(f), ODEProblem(f, …), NonlinearFunction(f) and EnsembleSerial/EnsembleThreads solve). Also, responsible_map/tmap now return a wider eltype for mixed inputs. Before, they threw a MethodError or silently converted the value.

Blocking findings

None.

Non-blocking findings

  1. The widen test misses the silent-wrong case. The PR does fix it. (test/inference_tests.jl:400-423). Confirmed by running. On master, SciMLBase.responsible_map(identity, Any[1, 2.0]) returns Vector{Int64} [1, 2]: the 2.0 is silently converted to an Int. tmap gives the same result. On the PR it returns Vector{Real} Real[1, 2.0]. With Any[1, 2.0, "a", 3], master throws MethodError: Cannot convert String to Int64 at basic_ensemble_solve.jl:525, and the PR returns Vector{Any} correctly. The PR's testset only uses [0.5, diagm(...)], which master already handles because ODEProblem inference was Any there. Suggest adding @test responsible_map(identity, Any[1, 2.0])[2] === 2.0 and the same for tmap. Those would pin the silent-narrowing bug, which a reader of the current test can't see.
  2. Base.promote_typejoin is non-public Base API (src/ensemble/basic_ensemble_solve.jl:30 and :86 in the diff). Confirmed by running: Base.ispublic(Base, :promote_typejoin) == false on 1.12.7. CLAUDE.md says "public API only". Base's own collect uses it, the module already calls Core.Compiler.return_type, and QA passed in CI. So this is a rule-hygiene point, not a defect. The public typejoin would widen Union{Nothing,Int} to Any. If the maintainer wants strictly public API, the alternative is a small local helper.
  3. The tmap misfit branch can't be reached from solve_batch. Suspected from reading. solve_batch(::EnsembleThreads) always passes a UnitRange{Int}, so eltype(args[1]) == typeof(args[1][1]) and the fast path is always taken. The misfit / Vector{Any} path only runs for direct tmap callers with heterogeneous containers, including the Zygote ∇tmap closures. The code works (see "What I ran"), but the comment saying it serves EnsembleThreads solve overstates its role. The branch is about 30 lines of added complexity.
  4. PR body attribution and claims.
    • The body lacks the required first-line banner, and "transcript on a CI box" is not a conversation URL or session ID.
    • "Independent review: MERGE (low risk)" has no link or evidence.
    • The claim "on master that inference was Any" is right for ODEProblem(f, …). But master's EnsembleSerial/EnsembleThreads solve already inferred a concrete EnsembleSolution; I ran this. So the new isconcretetype(rt) downstream assertion guards against a regression this PR itself introduced and then fixed. It does not show an improvement over master.
  5. Branch is one commit behind master (c8ea9cae, which touches the comprehensive_indexing test only). No overlap with this diff.
  6. Sibling PR Branch remaining isinplace constructors for static dispatch #1638 is stacked on this one. It touches the same files (basic_ensemble_solve.jl, scimlfunctions.jl, ode_problems.jl, inference_tests.jl), so merging this first is the intended order. fix isinplace inference and add inference tests #1019 (the isinplace inference rewrite) is still open. It would make these branches redundant but not wrong; neither PR conflicts in semantics.

What I ran

Clones at PR head 9875b30f, master c8ea9cae, and a hybrid (PR head with master's src/ensemble/basic_ensemble_solve.jl), all under scratch/. Envs are scratch/env_{110,112}_{pr,master}, env_ode_{pr,master} and env_112_hybrid.

  • The PR's test/inference_tests.jl, run against PR source and master source on Julia 1.10.12 and 1.12.7 (confirmed by running):

    • PR: 40/40 pass on both versions.
    • Master: the 5 < 40 allocation assertions fail on both versions (evaluated 60, 60, 63, 63, 59), so the allocation regression test fails before the change.
    • Hybrid (PR constructors, master ensemble code): "ensemble map widens…" errors with MethodError: Cannot convert…. So the widen test fails without the ensemble fix and passes with it, as the PR claims.
  • Downstream test/downstream/ensemble_zero_length.jl, with using OrdinaryDiffEq swapped for OrdinaryDiffEqTsit5, on Julia 1.12 with -t 2:

    • PR: 5/5 pass.
    • Master: 5/5 pass.
    • Hybrid: 4 pass, 1 error (MethodError: Cannot convert).
    • This matches the PR body's fail-unfixed / pass-fixed / pass-on-master claim (I ran it on 1.12, not 1.10).
  • Steady-state allocations, after warm-up and behind a function barrier (8 repeated calls):

    Call PR 1.10 PR 1.12 master 1.10 master 1.12
    NonlinearProblem(nf, [1.0], 1.0) 16 19 59 59
    NonlinearFunction(nf) 16 17 57 57

    For ODEFunction / ODEProblem, the iip/oop counts were:

    • PR 1.10: 17/17 and 20/20
    • master 1.10: 574/60 and 577/63
    • PR 1.12: 17/17 and 20/20
    • master 1.12: 60/60 and 63/63

    A one-off reading of 153 for NonlinearProblem on 1.10 was a first-call compile artifact; the repeated calls settle at 16. The < 40 bound sits well between the PR's ~16–20 and master's ~57–63. It isn't tuned to the PR's own output, and it fails on master.

  • Constructor semantics on PR, Julia 1.10 and 1.12. 25 isinplace checks covering ODEFunction, DiscreteFunction, SDEFunction, DAEFunction, DDEFunction, RODEFunction, NonlinearFunction (including lambda_extended=true), IntervalNonlinearFunction, IntegralProblem, BVPFunction, ODEProblem (iip/oop and the Int tspan pass-through) and UJacobianWrapper. All true on PR and master. A wrong-arity ODEFunction still throws TooFewArgumentsError on both. I also checked by reading that ODEProblem{iip}(f, u0, tspan, p; kwargs...) (ode_problems.jl:160-165) has exactly the body that the old ODEProblem(f, …) had inline, so delegating to it is equivalent.

  • Ensemble probe scratch/probe_ens.jl, Julia 1.12, -t 1 and -t 4, PR and master:

    • EnsembleSerial and EnsembleThreads solve infer a concrete EnsembleSolution on both PR and master.
    • responsible_map(h, 1:3) and tmap(h, 1:3) infer Vector{Float64}.
    • Mixed u0 (Float64 → Vector) through prob_func solves under Serial and Threads, with eltype Union{ODESolution{…,2…}, ODESolution{…,1…}}.
    • 3-way mixed inputs, Union{Nothing,Int}, 2-argument calls and a 10,000-element mixed threaded tmap all give the right values and types on PR (correct=true for elementwise value and type).
    • Master crashes on the 3-way mixed input, as described in finding 1.
    • The script's @assert … ≈ … rtol=… lines were mis-written by me and fail identically on PR and master. They are not evidence either way.
  • CI on the PR. The failures were Catalyst/All/1 (SystemError … Permission denied on Project.toml), MTK Extended (CTarget), SciMLSensitivity Core1 (Mooncake… no constructors have been defined for Any) and SymbolicIndexingInterface (SCCNonlinearProblem has no field u0). I checked the master runs https://github.com/SciML/SciMLBase.jl/actions/runs/38085330436 and https://github.com/SciML/SciMLBase.jl/actions/runs/38085330958. The same MTK Extended, SciMLSensitivity Core1 (identical Mooncake error) and SII jobs fail there, so these are pre-existing. Catalyst is an infrastructure permission error.

What I did not verify

  • GROUP=QA, the full Core group, Runic and typos locally. I relied on the PR's green CI checks for QA, Core (lts/1/pre/x86), Runic and Spell Check.
  • The PR's µs timing table. I measured allocation counts only, not time.
  • The zero-length downstream test on Julia 1.10 (I ran it on 1.12 only), and the full Downstream, DownstreamAD, Python, Reactant and GPU groups beyond what CI shows.
  • Zygote and Mooncake ensemble adjoints over the changed tmap/responsible_map. I didn't run them; SciMLSensitivity Core1 fails on master too, so CI says nothing here.
  • EnsembleDistributed / EnsembleSplitThreads (unchanged code, but they call into solve_batch(EnsembleThreads)).

Links


🤖 Posted by an AI agent — harness: Devin CLI 3000.11.3 (review), 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-Claude

Copy link
Copy Markdown
Member Author

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

Independent review (Codex CLI 0.166.0 / gpt-6.1-sol), session 01a19723-978f-7033-8cfe-42971751a2da, reviewed head d581bf5

  • Verdict: MERGE
  • Risk: medium-high (MH1: static constructor dispatch changes inference on core problem-construction paths, and ensemble mapping now widens heterogeneous result containers.)
  • Round / slot: 1 / 1
  • Blocking priorities: none

Review written by the reviewer named above 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: Static Boolean branches reduce convenience-constructor allocations, while ensemble result containers widen safely for heterogeneous trajectories. Focused head/base tests and an independent threaded probe support merging; inspected CI failures reveal no demonstrated PR-specific defect.

Blast radius: ODEProblem and IntegralProblem convenience constructors; ODE, discrete, stochastic, delay, nonlinear, boundary-value and related function constructors; six derivative/Jacobian wrappers; EnsembleSerial and EnsembleThreads result collection. No public signatures, dependencies, solver algorithms or tolerances change.

Evidence: Blind diff assessment was written and hashed before author context. On Julia 1.13.2, the complete head test/inference_tests.jl passed 40 assertions, exit 0. The same head test file against the merge-base failed five allocation assertions, exit 1: 60, 60, 63, 63 and 59 allocations against bounds of <40; the corresponding head testset passed 10/10. The nine added mixed-u0 assertions passed on both revisions, so they protect against an inference side effect introduced within this PR rather than demonstrate a pre-existing base failure. An independent probe passed 23 assertions, including heterogeneous threaded output versus Base.map. Head CI reports 68 successes and five failures; exact master matches were verified for SymbolicIndexingInterface, threaded Enzyme and Catalyst failures. Reactant failed during dependency setup.

Blocking findings

None.

Non-blocking findings

None.

What I ran

All three Julia processes ran sequentially with Julia 1.13.2, four Julia threads, one OpenBLAS thread, a dedicated temporary directory and a 3600-second timeout. No package-wide suite or Pkg.test() was run. In the commands below, $DEPOT substitutes the shared-depot absolute value supplied in TARGET.md; machine-specific path values are omitted as required.

git -C src fetch origin '+refs/pull/1636/head:refs/remotes/pr/1636' master
git -C src checkout --detach pr/1636
git -C src fetch origin '+refs/heads/master:refs/remotes/origin/master'
git -C src rev-parse HEAD origin/master
git -C src merge-base origin/master HEAD
git -C src diff --stat origin/master...HEAD
git -C src diff origin/master...HEAD
sha256sum INITIAL.md > INITIAL.sha256
git -C src log --first-parent --no-merges -1 --format='%H%n%B'
git -C src worktree add --detach ../base 365283c66ec24db40c3fae1f2694693070dd7a46

These git commands exited 0. The reviewed head matches TARGET.md. Base above is the live PR baseRefOid and merge-base; origin/master at inspection was 030ec28. The newest non-merge commit on the PR's first-parent history is 9875b30, whose trailers identify Cursor Agent CLI and auto.

JULIA_NUM_THREADS=4 OPENBLAS_NUM_THREADS=1 JULIA_PKG_PRECOMPILE_AUTO=0 TMPDIR="$PWD/tmp" JULIA_DEPOT_PATH="$DEPOT:" timeout 3600 julia +1.13.2 --startup-file=no run-head.jl > run-head.log 2>&1
JULIA_NUM_THREADS=4 OPENBLAS_NUM_THREADS=1 JULIA_PKG_PRECOMPILE_AUTO=0 TMPDIR="$PWD/tmp" JULIA_DEPOT_PATH="$DEPOT:" timeout 3600 julia +1.13.2 --startup-file=no run-base.jl > run-base.log 2>&1
JULIA_NUM_THREADS=4 OPENBLAS_NUM_THREADS=1 JULIA_PKG_PRECOMPILE_AUTO=0 TMPDIR="$PWD/tmp" JULIA_DEPOT_PATH="$DEPOT:" timeout 3600 julia +1.13.2 --startup-file=no run-probe.jl > run-probe.log 2>&1

The head runner activated env, developed the source checkout, added StaticArrays, and included test/inference_tests.jl. The base runner developed the merge-base checkout in the same environment and included the unchanged head test file. The probe restored the head dependency and checked 10,003 mixed results against Base.map, yielded inside threaded callbacks, verified reference identity, exercised the no-misfit fallback and multiple inputs, and checked constructor fields and wrapper outputs against elementary arithmetic. It also compared homogeneous serial-map inference with the extracted base implementation.

head: exit 0; parameterless_type 4/4; compile-time traits 4/4;
      ensemble map element types 3/3; mixed-u0 widening 9/9;
      homogeneous tmap inference 1/1; static-array totallength 3/3;
      constructor static dispatch 10/10; integrator iteration 1/1;
      optimization cache inference 5/5.
base: exit 1; constructor static dispatch 5 passed, 5 failed;
      allocation counts 60, 60, 63, 63, 59, each expected <40.
      Mixed-u0 widening 9/9 and preceding testsets passed.
probe: exit 0; independent Base.map reference 6/6;
       constructor and wrapper analytic invariants 17/17;
       SERIAL_HEAD_RETURN=Vector{Float64}; SERIAL_BASE_RETURN=Vector{Float64}.

Read-only GitHub inspection used these commands:

gh pr view 1636 --repo SciML/SciMLBase.jl --json number,url,state,isDraft,headRefOid,baseRefName,baseRefOid
gh pr view 1636 --repo SciML/SciMLBase.jl --json title,body,commits,statusCheckRollup
gh pr checks 1636 --repo SciML/SciMLBase.jl
gh run list --repo SciML/SciMLBase.jl --branch master --event push --limit 5 --json databaseId,workflowName,conclusion,headSha,url,createdAt
gh run list --repo SciML/SciMLBase.jl --branch master --event push --workflow Downstream.yml --limit 5 --json databaseId,conclusion,headSha,url,createdAt

The PR is open and draft. gh pr checks exited 1 because of failed checks; the other metadata/list calls exited 0. Failed logs were retrieved with gh run view RUN_ID --repo SciML/SciMLBase.jl --log-failed for 38868691852, 38868691693, 38868691112, 41250980771, 41250980378 and 41250980630, exit 0 with XDG_CACHE_HOME redirected to writable review storage. Initial log-fetch attempts failed because the default gh cache was read-only.

  • Head Run Tests: Core, Downstream and DownstreamAD passed across their reported versions. SymbolicIndexingInterface errors at test/downstream/comprehensive_indexing.jl:127 and test/downstream/comprehensive_indexing.jl:164 are BoundsError exceptions indexing a one-element vector with [1,2]; both exact errors also occur in master Run Tests. Reactant exits during setup with Unknown package: GPUCompiler; I did not establish an identical master failure for this job.
  • Head IntegrationTest: SciMLSensitivity Core4 reaches the threaded ensemble AD test and throws AssertionError: mi2 !== nothing in Enzyme's thread rule. Master IntegrationTest has the same test, assertion, rule location and 15-passed/1-errored/2-broken summary. Numerous other integration groups pass on head; the workflow as a whole is not green.
  • Head ReleaseTest: Catalyst cannot open test/extensions/Project.toml because permission is denied. Master ReleaseTest reports the same permission error on that package test environment.

G1: no numerical algorithm/default/tolerance changes were found; map values were independently checked against Base.map and wrapper values against arithmetic. G2: no GPU kernel, AD rule, Reactant tracing implementation or MPI implementation is modified; downstream AD ran in CI, with the specific threaded Enzyme error disclosed above. G3: added mixed-type threaded tests exercise the new buffering behavior, supplemented by the yielding multi-type probe. No tests were deleted, skipped or weakened.

What I did not verify

I did not run the full package or downstream suites, the downstream zero-length ensemble file locally, Julia versions other than 1.13.2, GPU execution, MPI/distributed workers, Reactant tracing, or AD locally. Reactant CI did not reach its tests; the threaded Enzyme integration test executed but failed on both PR and master, so successful differentiation through that case remains unverified. I did not independently reproduce the author's wall-clock benchmark ratios, run an intermediate unfixed PR commit, or prove behavior equality for every changed convenience constructor and specialization. The base run stopped at the failed constructor testset, so its final two testsets were not executed. The tested mixed-u0 regression passes on the merge-base; only the allocation regression supplies failing-before/passing-after evidence in my runs. No upstream writes were made.

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

@ChrisRackauckas-Claude
ChrisRackauckas-Claude marked this pull request as ready for review November 2, 2026 02:04
Bring in the upstream lowered-solution indexing tests and current base changes.
The corrected indexing tests pass on Julia 1.10 and 1.12; the original tests
reproduce both BoundsError exceptions under the same dependencies.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.164.0
Agent-Model: gpt-6.1-sol
Agent-Session: local fixer job SciML__SciMLBase.jl__1636 (no session URL)
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

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

PR: #1636

Reviewed head: d621b9a
Raw SHA-256: 2581bce84d491981ee282282e0dc02e32a162c7e466606338d1afc2f6148330d
Source SHA-256: fb01f080862ee0aa9cfe0f6ca3e8a4c805e9244a8318e96c051ec72e2cbbb18f
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1ffc4-9c2c-7683-a171-741e75a9b1ee
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: medium-high (MH1)
  • Verdict: CHANGES
  • Reviewed head: d621b9a

Review report

VERDICT: CHANGES
Round: 1
Head: d621b9a
Slot: 1
CI: CI unreadable; review only; merge gates unchanged
Session: 01a1ffc4-9c2c-7683-a171-741e75a9b1ee
Reviewer: codex-cli 0.170.0; model: gpt-6.2-sol

Risk

medium-high (MH1: core constructor inference changes, and heterogeneous ensemble mapping under Mooncake can produce different forward values from ordinary execution)

Blocking findings

  • Blocking priorities: P2
  • [P2] ext/SciMLBaseMooncakeExt.jl:133 and ext/SciMLBaseMooncakeExt.jl:221 allocate the forward result from the first value's type. With identity and Union{Float32, Float64}[1.0f0, 1.0 + 2.0^-35], both head mappers preserve the second value as 1.0000000000291038. Both Mooncake rrule!! methods silently store it as 1.0f0. On the merge base the ordinary and differentiated forward values agree for this input. Apply the mappers' widening policy to the Mooncake forward results, construct matching tangent storage, and test value and type agreement for both rules.

Non-blocking findings

  • src/ensemble/basic_ensemble_solve.jl:374 initializes the default reduction accumulator from the first batch's element type. In a four-trajectory probe through solve, serial and threaded runs preserved 9007199254740995 with batch_size=4 and rounded it to 9007199254740996 with batch_size=2. A matrix following a batch of scalars also raised a conversion MethodError at batch size two. Both behaviors reproduce on the merge base. Widening the default accumulator when later batches introduce a new type would make the output independent of the batch size.

What I ran

  • On Julia 1.12.4 with 11 threads, ran julia --startup-file=no --project=. -e 'using Pkg; Pkg.test()' in scratch copies with GROUP=Core and GROUP=Downstream. Both reported Testing SciMLBase tests passed. Compile-time trait inference passed 40/40 and Ensembles of Zero Length Solutions passed 5/5.
  • Included test/inference_tests.jl with Julia 1.10.12 and the test's StaticArrays dependency in a scratch project. All 40 assertions passed. A separate run loading Tsit5 directly passed all five downstream ensemble assertions and printed Threaded solve return type is concrete: true.
  • Ran four-thread base and head probes for mixed types, ordering, one callback invocation per element, batched solves, and the Mooncake rules. With the head constructors and the original maps, the new mixed-shape test raised a conversion MethodError. With the head maps it passed 9/9. The warmed constructor measurements, in test order, were (574, 574, 577, 577, 59) allocations on the base and (17, 17, 20, 20, 19) on head.
  • julia --startup-file=no -m Runic --check and typos on the changed files, and git diff --check origin/master...HEAD, exited 0. uv run --locked python --version printed Python 3.13.13 and warned that --locked had no effect outside a Python project.

What I did not verify

  • The full DownstreamAD and QA groups, standalone dependent-package suites, and the full Julia version matrix.

AUTHOR_GRADE: {"task":"perf","score":4,"difficulty":4,"rounds":1,"author_harness":"Codex CLI 0.164.0","author_model":"gpt-6.1-sol","note":"Constructor allocations fell and both affected groups passed. The heterogeneous map change leaves Mooncake's forward results silently rounded."}

Head link: d621b9a


🤖 Posted by an AI agent — harness: codex-cli 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a1ffc4-9c2c-7683-a171-741e75a9b1ee (no session URL)

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.170.0
Agent-Model: gpt-6.2-sol
Agent-Job: SciML__SciMLBase.jl__1636--20261122T054040Z-codex-gpt-6.2-sol
Agent-Session: local session 01a201c5-7173-77f2-bd7e-579d8d8df25f (no session URL)
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

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

PR: #1636

Reviewed head: cc29a24
Raw SHA-256: bb864b821abea79c849c04d4fc3fe70e34eca207eaa10e01db4e11a92c0d8026
Source SHA-256: 7f2241ab1aa3245d7b890a7647cb613573473ce92dd5f3e76a472077b8406b9b
Source: standard-review-v1 (harness-log)
Reviewer session: 01a216eb-2aa2-70e3-aa1d-2e2f4cee818e
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: medium-high (MH1)
  • Verdict: CHANGES
  • Reviewed head: cc29a24

Review report

VERDICT: CHANGES
Round: 2
Head: cc29a24
Slot: 1
CI: CI unreadable; review only; merge gates unchanged
Session: 01a216eb-2aa2-70e3-aa1d-2e2f4cee818e
Reviewer: codex-cli 0.170.0; model: gpt-6.2-sol

Risk

medium-high (MH1: the PR changes dispatch in widely used problem constructors and changes ensemble solve result typing, with the key-dependent validation matrix unverified)

Blocking findings

  • Blocking priorities: P1, P2

  • [P1] ext/SciMLBaseMooncakeExt.jl:112 and ext/SciMLBaseMooncakeExt.jl:121 double-count a shared output cotangent. With x = [5.0] and mapper(identity, [x, x]), the loss sum(sum, y) is 10.0 and its derivative with respect to x is [2.0]. In a direct rrule!! probe, adding 1.0 through each output occurrence correctly accumulated a shared seed of [2.0]. The rule fed that entire seed to each element pullback. Both mappers produced [4.0] in the shared input tangent. On the previous head both rules threw MethodError: no method matching zero(::Type{Vector{Float64}}) before producing a pullback for this input.

    Implementation fix: In the shared rrule!!, keep _responsible_map for primal widening and record each callback's forward CoDual and pullback by composing Mooncake rules with the original element tangents. Assemble the output fdata from those forward tangents so aliased values share storage across inputs and outputs. In reverse, feed each saved pullback its element rdata and scatter input rdata through the corresponding indexing pullbacks. This preserves aliasing while supporting mixed result types. In test/downstream/ensemble_mooncake.jl, add the repeated-reference case for both mappers and assert the primal 10.0 and shared derivative [2.0].

  • [P2] ext/SciMLBaseMooncakeExt.jl:128 returns NoTangent() in the mapper's reverse-data slot, which requires NoRData(). For loss(mapper, x) = sum(Float64, mapper(identity, x)) with the new test's mixed-precision input, Mooncake.value_and_gradient!! raised MethodError: no method matching increment!!(::Mooncake.NoRData, ::Mooncake.NoTangent) for both mappers. A debug-mode probe also reported InvalidRDataException identifying the mapper slot. The return convention predates the delta. The new test at test/downstream/ensemble_mooncake.jl:19 discards the pullback tuple, so it misses the error on the repaired mixed-precision case.

    Implementation fix: In ensemble_map_pullback!!, return NoRData() for the mapper and the callback's rdata in the callback slot. If retaining the cache-based path, accumulate callback tangents with increment!!, increment the original callback fdata, and return rdata(Δf). With composed element rules, share callback fdata and accumulate the callback rdata from the saved pullbacks. Add a prepare_gradient_cache and value_and_gradient!! regression for both mappers in test/downstream/ensemble_mooncake.jl. Assert the exact primal 2.0 + 2.0^-35 and per-element gradients 1.0f0 and 1.0. If callback accumulation changes, also assert the captured scalar derivative 5.0 for sum(mapper(x -> a*x, [2.0, 3.0])).

Non-blocking findings

None.

What I ran

  • With Julia 1.12.4 and four threads, ran julia --compiled-modules=existing --startup-file=no --project=. -e 'using Pkg; Pkg.test(; julia_args=["--compiled-modules=existing"])' from a scratch copy with each GROUP selected separately. Core exited 0 with 7,089 passes. Downstream exited 0 with 722 passes, including 5/5 for the zero-length ensemble tests. DownstreamAD exited 0 with 206 passes, including 6/6 for the Mooncake map rules, and one existing skipped ensemble adjoint check.
  • QA exited 1 with 122 passes and one Aqua persistent-task failure. ExplicitImports passed 6/6. The standalone Aqua.test_persistent_tasks(SciMLBase; tmax=60) check with Aqua 0.8.19 hit the same 60-second window on both heads.
  • Ran test/downstream/ensemble_mooncake.jl on both heads with Mooncake 0.5.72 and the same dependencies. The current head passed 6/6. The previous head produced four assertion failures and two errors, including Vector{Float32} === Vector{AbstractFloat} failing for both mappers. The independent regression_probes.jl run exited 1 with two passes, two wrong-gradient failures, and two API errors.
  • With Julia 1.10.12, directly ran the inference tests and the mixed-precision Mooncake test. They passed 40/40 and 6/6. The mixed-precision public gradient probe reproduced the API error on that Julia version.
  • Compared the supplied delta with git diff between the two heads. Runic, typos, and git diff --check origin/master...HEAD exited 0. uv run --locked python --version printed Python 3.13.13. uv warned that --locked has no effect outside a Python project.

What I did not verify

  • Live CI, the standalone key-dependent suites, other Julia and Mooncake version combinations, and the cause of the Aqua shutdown timeout.

AUTHOR_GRADE: {"task":"bugfix","score":2,"difficulty":4,"rounds":2,"author_harness":"Codex CLI 0.170.0","author_model":"gpt-6.2-sol","note":"The direct mixed-precision regression passes. Aliased output cotangents double and the public gradient API errors for both mappers."}

Head link: cc29a24


🤖 Posted by an AI agent — harness: codex-cli 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a216eb-2aa2-70e3-aa1d-2e2f4cee818e (no session URL)

This branch has not been deployed

No deployments
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.

3 participants