Skip to content

Branch remaining isinplace constructors for static dispatch - #1638

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

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

Conversation

@ChrisRackauckas-Claude

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

Copy link
Copy Markdown
Member

Summary

Stacked on #1636. That PR branched convenience constructors written as T{isinplace(f, N)}(…) so each arm uses a literal {true} / {false} type parameter. Its grep missed sites spelled iip = isinplace(f, N); T{iip}(…) or {isinplace(f1|f2|A, N)}, so SDEProblem, BVProblem, and DiscreteProblem stayed slow. This applies the same Bool-branch pattern to every remaining hot-path site (those three, plus SecondOrderBVProblem, bare-function ImplicitDiscreteProblem, ImmutableODEProblem, SecondOrderODEProblem, SecondOrderDDEProblem, HomotopyProblem, AnalyticalProblem, SplitFunction, DynamicalODEFunction, SplitSDEFunction, DynamicalSDEFunction, DynamicalDDEFunction, and LinearProblem), keeping arity, kwargs, specialization, and error behaviour identical.

Before / after

OPENBLAS_NUM_THREADS=1, JULIA_NUM_THREADS=1, taskset -c 3, @benchmark minima (500 samples), measured through a function barrier. Before = #1636 head (9875b30f); after = this PR.

Call 1.12 before 1.12 after 1.10 before 1.10 after
SDEProblem(f!,g!) 22.3 µs / 74 12.9 µs / 39 18.2 µs / 73 9.9 µs / 38
BVProblem(f!,bc!) 28.1 µs / 89 14.3 µs / 40 23.9 µs / 88 11.3 µs / 39
DiscreteProblem(f!) 7.4 µs / 26 6.3 µs / 18 7.2 µs / 26 5.6 µs / 18
SplitFunction(f!,f!) 23.1 µs / 58 7.0 µs / 33 22.3 µs / 58 10.0 µs / 35
DynamicalODEFunction(f1!,f2!) 13.2 µs / 39 3.6 µs / 16 13.0 µs / 39 3.1 µs / 16
LinearProblem(A!) 15.2 µs / 69 4.6 µs / 17 14.0 µs / 69 4.0 µs / 17

Extended barrier-helper allocation regression in test/inference_tests.jl (sdep/bvp/disc/splitf/dynf/linp thresholds < 50/60/22/45/30/22): fails on #1636 head (6 Fail: 74/89/26/58/39/25), passes after (22/22 on 1.12 and 1.10).

Test plan

  • Core (GROUP=Core): Compile-time trait inference | 52 52, Testing SciMLBase tests passed
  • QA (GROUP=QA, CONDA_OVERRIDE_GLIBC=2.35): QA | 123 123, Testing SciMLBase tests passed
  • Runic --inplace on touched files; typos clean
  • Julia 1.10 focused allocation regression: 22/22 Pass
  • Fail-before / pass-after of the new barrier cases (src stashed)

What was NOT verified

  • Full Downstream / DownstreamAD / Python / Reactant / GPU groups
  • ConstructionBase constructorof remake paths still use runtime iip = isinplace(f, N) (not hot convenience constructors)
  • IntegralFunction / BatchIntegralFunction calculated_iip paths (error-checking constructors, not listed in the Branch on isinplace so convenience constructors dispatch statically #1636 follow-up)
  • Absolute µs on a quiet machine (load average was non-trivial)

Reviewer pushback

  • Whether the tighter < 22 DiscreteProblem / LinearProblem bounds are stable across Julia versions / GC noise
  • Whether ConstructionBase remake paths should get the same treatment in a further follow-up
  • Whether ImmutableODEProblem(f,…) should keep the old inline prepare_initial_state body instead of delegating to ImmutableODEProblem{true/false} (mirrors Branch on isinplace so convenience constructors dispatch statically #1636's ODEProblem change)

Please ignore until reviewed by @ChrisRackauckas.

Risk assessment

Independent review: pending

🤖 Generated with Cursor Agent 2026.10.01-14929f9 (model: unknown (Cursor auto)), transcript /pr-iip-rest/log.txt; orchestrated by Claude Code (claude-opus-5-5[1m]) https://claude.ai/code/session_01LPHREnnonfLg1VcE1EJovv

Made with Cursor

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


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

Merged upstream master f75f097ea713f757a257078051032f4936dd5b20 normally, including the lowered steady-state solution indexing correction from #1657. The test indexes the solution through its own symbolic container and checks observed values against the fixture equations. The constructor and ensemble changes remain in this PR.

Failing before / passing after

Before the merge, on the original PR head a680324161cced23fffb86090a9754288788bfa0:

GROUP=SymbolicIndexingInterface timeout 7200 julia +1 --project -e 'using Pkg; Pkg.test()'

Diagnostic excerpt, exit 1 (both State indexing and Observed):

BoundsError: attempt to access 1-element Vector{Float64} at index [[1, 2]]
ERROR: LoadError: Some tests did not pass: 3747 passed, 0 failed, 2 errored, 0 broken.

The same full group after the merge exited 0:

Symbol and integer based indexing of interpolated solutions | 3781   3781  20m38.9s
Test Summary:          | Pass  Broken  Total     Time
ModelingToolkit Remake |  248       3    251  1m26.7s
 86.662428 seconds (92.22 M allocations: 5.090 GiB, 1.08% gc time, 97.67% compilation time: 8% of which was recompilation)
     Testing SciMLBase tests passed 

Local validation

Post-merge runs used Julia 1.13.3, JULIA_NUM_THREADS=4, OPENBLAS_NUM_THREADS=1, JULIA_NUM_PRECOMPILE_TASKS=1, JULIA_PKG_PRECOMPILE_AUTO=0, and CONDA_OVERRIDE_GLIBC=2.35.

GROUP=Core timeout 7200 julia +1 --project -e 'using Pkg; Pkg.test()'

Exit 0:

Compile-time trait inference |   52     52  2.1s
Test Summary: | Pass  Total     Time
Remake        | 4631   4631  2m28.5s
148.512030 seconds (221.54 M allocations: 11.698 GiB, 1.36% gc time, 98.40% compilation time: <1% of which was recompilation)
     Testing SciMLBase tests passed 
GROUP=QA timeout 7200 julia +1 --project -e 'using Pkg; Pkg.test()'

Exit 0:

Test Summary: | Pass  Total     Time
QA            |  123    123  2m30.9s
151.408391 seconds (174.59 M allocations: 9.156 GiB, 3.22% gc time, 46.89% compilation time: 14% of which was recompilation)
     Testing SciMLBase tests passed 
GROUP=Reactant timeout 7200 julia +1 --project -e 'using Pkg; Pkg.test()'

Exit 0:

  [9fa8497b] + Future v1.11.0
Test Summary:           | Pass  Total   Time
Reactant specialization |    4      4  22.9s
Test Summary:         | Pass  Total  Time
Reactant return codes |   28     28  8.5s
     Testing SciMLBase tests passed 

SciMLSensitivity was checked out at e40aa29f3e708d1bc0448a64ccf319ea0f5eb3b6, the revision used by the latest passing default-branch Core8 job. From that checkout, with SCIMLBASE_FIX_CHECKOUT pointing to this PR checkout:

GROUP=Core8 timeout 7200 julia +1 --project -e 'using Pkg; Pkg.develop(PackageSpec(path = ENV["SCIMLBASE_FIX_CHECKOUT"])); Pkg.test()'

Exit 0; all five broken cases are present in that upstream test revision:

Test Summary: | Pass  Broken  Total      Time
Core 8        |  209       5    214  81m15.6s
     Testing SciMLSensitivity tests passed 

This local Core8 run used Enzyme 0.13.219 and GPUCompiler 2.10.0 and completed after extended LLVM compilation.

julia +1 --project=@runic -m Runic --inplace src/ensemble/basic_ensemble_solve.jl \
    src/function_wrappers.jl \
    src/problems/analytical_problems.jl \
    src/problems/bvp_problems.jl \
    src/problems/dde_problems.jl \
    src/problems/discrete_problems.jl \
    src/problems/implicit_discrete_problems.jl \
    src/problems/integral_problems.jl \
    src/problems/linear_problems.jl \
    src/problems/nonlinear_problems.jl \
    src/problems/ode_problems.jl \
    src/problems/sde_problems.jl \
    src/scimlfunctions.jl \
    test/downstream/ensemble_zero_length.jl \
    test/inference_tests.jl
Runic exit: 0

Runic made no edits. Spelling was checked over added lines from the final PR diff:

git diff --cached upstream/master --unified=0 | awk '/^\+\+\+/{next} /^\+/{print substr($0,2)}' | typos - --format brief
typos exit: 0

Default-branch comparison and limits

The latest default-branch push runs at f75f097ea713f757a257078051032f4936dd5b20 pass SymbolicIndexingInterface on LTS/release, Reactant, and SciMLSensitivity Core8. The old Reactant job failed during package setup with Unknown package: GPUCompiler; the local Reactant run reached and passed its tests.

SciMLSensitivity Core4 still fails on default master with the same Enzyme AssertionError: mi2 !== nothing as the old PR job. Catalyst ReleaseTest still fails on default master with the same permission error writing its extension project. These pre-existing failures were left unchanged. Their comparison uses inspected push-event CI logs, not local reproductions or a completed source bisect.

LTS, GPU, other downstream/sensitivity groups, a local docs build, and fresh performance benchmarks were not run. The new-head CI check observed 53 jobs in progress, 16 queued, and four successful completed checks; CI completion was not awaited.

Links

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

Risk assessment

  • Risk: high, retaining the previous counted review's medium-high concern conservatively pending review of this merge head.
  • Blast radius: the PR's existing public constructor, wrapper, and serial/threaded ensemble paths can affect downstream solves and AD.
  • Evidence: full local Core, QA, SymbolicIndexingInterface, Reactant, and SciMLSensitivity Core8 pass; the indexing group fails before the upstream correction and passes after it.
  • Independent review: pending for this new head. The previous Codex CLI 0.166.0 / gpt-6.1-sol review covered a680324161cced23fffb86090a9754288788bfa0: Branch remaining isinplace constructors for static dispatch #1638 (comment)
  • Merge: needs human review; the prior medium-high concern remains and a fresh counted review is required.

🤖 Posted by an AI agent — harness: Codex CLI 0.164.0 · model: gpt-6.1-sol
Conversation: local fixer job SciML__SciMLBase.jl__1638 (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 1206ac8)

The threaded ensemble mapper buffers indexed type mismatches per work chunk. It specializes matching-result stores on the initial vector's element type and widens in input order after the thread barrier. Tests check the exact inferred Vector{Float64} type for homogeneous output, ordering and evaluation count for mixed output, and both in-place conventions for the 16 constructors in the PR summary.

Failing before and passing after

I ran include("test/inference_tests.jl") with the original head and the candidate in scratch Julia environments. The same four-thread test measured warmed allocations for tmap(identity, Any[i for i in 1:100_000]).

Julia Original head, exit 1 Candidate, exit 0
1.10.12 Evaluated: 3196704 < 1200000 Warmed bytes: 805008
1.12.4 Evaluated: 1603280 < 1200000 Warmed bytes: 803272

The focused file passed all 82 assertions on both versions after the change. A separate Julia 1.13.3 Zygote probe with a heterogeneous constant tuple returned the analytic gradient -228.0.

The warmed @allocations LinearProblem(A!, b) count is 25 at stacked parent 9875b30f and 17 here, on both Julia 1.10.12 and 1.12.4. This confirms the prior review's correction to the summary table's allocation count. The timing cells were outside this measurement.

Local validation

The groups ran on Julia 1.13.3 with JULIA_NUM_THREADS=4, OPENBLAS_NUM_THREADS=1, JULIA_NUM_PRECOMPILE_TASKS=1, JULIA_PKG_PRECOMPILE_AUTO=0, and CONDA_OVERRIDE_GLIBC=2.35.

for group in Core QA Downstream; do
    GROUP="$group" timeout 7200 julia +1 --startup-file=no --compiled-modules=existing --project -e 'using Pkg; Pkg.test()'
done
Core exit: 0
Compile-time trait inference |   82     82  5.8s
Remake        | 4631   4631  3m18.0s
     Testing SciMLBase tests passed

QA exit: 0
QA            |  123    123  6m43.3s
     Testing SciMLBase tests passed

Downstream exit: 0
Ensembles of Zero Length Solutions |    5      5  1m03.1s
Scalar RODESolution calculate_solution_errors! |   17     17  4.8s
     Testing SciMLBase tests passed

Core reported 7,131 passing assertions, QA reported 123, and Downstream reported 722.

julia --startup-file=no --project=@runic -m Runic --inplace src/ensemble/basic_ensemble_solve.jl test/inference_tests.jl
git diff --cached --unified=0 | awk '/^\+\+\+/{next} /^\+/{print substr($0,2)}' | typos - --format brief
git diff --cached --check
Runic exit: 0
typos exit: 0
git diff --cached --check exit: 0

CI comparison

Core8, Reactant, and both SymbolicIndexingInterface jobs pass at the starting head cea270951 and current master. Catalyst ReleaseTest, SciMLSensitivity Core2, and DownstreamAD LTS have matching errors on both. The ModelingToolkit Extensions CI jobs hit different errors. I reproduced the PR's TaylorDiff TypeError: non-boolean (Symbolics.Num) used in boolean context on clean master with the PR job's dependency versions, then loaded the same extension dependency successfully after upgrading TaylorDiff from 0.3.5 to 0.3.6.

The CI comparison covers the prior head. The full DownstreamAD group, the full ModelingToolkit Extensions group, GPU paths, and dense-mismatch performance were outside local validation.

Links

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


🤖 Posted by an AI agent — harness: Codex CLI 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a2000b-a555-78a2-bbb4-4b21a3ab70f8 (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 a902960)

The threaded mapper now infers its fast-path input types from integer getindex calls. The keyed regression requires exact identity for the large integer and the neighboring float. The threaded ensemble inference test now requires a concrete EnsembleSolution subtype.

Failing before and passing after

The temporary project loaded the active checkout. The test script contained the same testset as test/inference_tests.jl.

timeout 7200 julia +1 --startup-file=no --compiled-modules=existing --project="$INFERENCE_ENV" "$KEYED_TEST"
1206ac836, exit 1
Expression: output[2] === big
 Evaluated: 9.007199254740992e15 === 9007199254740993
tmap indexes keyed collections |    1     1      2  2.5s

Candidate, exit 0
tmap indexes keyed collections |    2      2  0.6s

Local validation

The groups ran on Julia 1.13.3 with four Julia threads, one OpenBLAS thread, JULIA_NUM_PRECOMPILE_TASKS=1, JULIA_PKG_PRECOMPILE_AUTO=0, and CONDA_OVERRIDE_GLIBC=2.35.

for group in Core QA Downstream; do
    GROUP="$group" timeout 7200 julia +1 --startup-file=no --compiled-modules=existing --project -e 'using Pkg; Pkg.test()'
done
Core exit: 0
Compile-time trait inference |   84     84  6.6s
Remake        | 4631   4631  2m29.1s
     Testing SciMLBase tests passed

QA exit: 0
QA            |  123    123  5m15.4s
     Testing SciMLBase tests passed

Downstream exit: 0
Ensembles of Zero Length Solutions |    6      6  1m05.7s
Scalar RODESolution calculate_solution_errors! |   17     17  5.0s
     Testing SciMLBase tests passed 

The focused Julia 1.10.12 run passed all 84 inference assertions. The Zygote probe over tmap with heterogeneous inputs returned the expected gradient.

timeout 7200 julia +lts --startup-file=no --compiled-modules=no --project="$LTS_INFERENCE_ENV" test/inference_tests.jl
timeout 7200 julia +1 --startup-file=no --compiled-modules=existing --project="$ZYGOTE_ENV" "$ZYGOTE_PROBE"
LTS inference exit: 0
optimization cache u0/p inference |    5      5  0.0s

Zygote probe exit: 0
Gradient: -228.0
Heterogeneous tmap pullback |    1      1  3.1s
timeout 7200 julia --startup-file=no --project=@runic -m Runic --inplace src/ensemble/basic_ensemble_solve.jl test/inference_tests.jl test/downstream/ensemble_zero_length.jl
git diff --cached upstream/master --unified=0 | awk '/^\+\+\+/{next} /^\+/{print substr($0,2)}' | typos - --format brief
git diff --cached --check
Runic exit: 0
typos exit: 0
git diff --cached --check exit: 0

Default-branch comparison

Catalyst ReleaseTest, SciMLSensitivity Core2, and DownstreamAD LTS have the same failures in the latest master push logs and the starting PR logs. OrdinaryDiffEq Downstream and SciMLSensitivity Core7 pass on older hosted master environments and reproduce with the newer dependency versions on clean master. The Core7 failure was bisected to a Zygote change. Master release logs · Master integration logs · Master test logs · Zygote bisect commit

The full external integration matrix, GPU and prerelease Julia jobs, and fresh performance benchmarks were outside local validation.

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


🤖 Posted by an AI agent — harness: Codex CLI 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a2019d-9472-76a3-a893-884b26b0183c (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 60336d5)

Enzyme records a tape for each work item while the forward pass runs on multiple threads. It applies the pullbacks in sequence so trajectories sharing a parameter shadow contribute to the same gradient safely. The SDE regression covers three and five trajectories in both ensemble modes, and the keyed-input regression still tests exact integer indexing.

Failing before and passing after

Both projects used Julia 1.13.4, Enzyme 0.13.221, and SciMLSensitivity 7.119.14, with the SciMLBase source path set to the revision under test. The SDE probe runs reverse mode 100 times on the three fixed-seed threaded trajectories from test/downstream/ensemble_enzyme_sde.jl and compares each gradient with ForwardDiff at the fixture's original tolerance. The smaller probe maps eight work items whose reverse rules update a shared parameter shadow.

JULIA_NUM_THREADS=4 timeout 7200 "$JULIA" --startup-file=no --compiled-modules=existing --project="$PROBE_ENV" "$SDE_STRESS_TEST"
JULIA_NUM_THREADS=4 timeout 7200 "$JULIA" --startup-file=no --compiled-modules=existing --project="$PROBE_ENV" "$SHARED_SHADOW_TEST"
Starting head a90296016, SDE probe exit 1
Trial 2 first component: 19.419210065481295 versus 29.4412769177571
Julia 1.13.4, threads 4, mismatches 1/100
Expression: iszero(mismatches)
 Evaluated: iszero(1)

Fix 60336d5fd, SDE probe exit 0
Julia 1.13.4, threads 4, mismatches 0/100

Starting head a90296016, shared-shadow probe exit 1
Julia 1.13.4, threads 4, gradient 11.0, expected 36.0
 Evaluated: 11.0 == 36.0

Fix 60336d5fd, shared-shadow probe exit 0
Julia 1.13.4, threads 4, gradient 36.0, expected 36.0

The one-shot four-thread SDE fixture passed on clean master and on the starting head. The repeated run reproduced the same missing contribution as the hosted release job and blocking review. Hosted failure · Blocking review

Local validation

Package groups ran on Julia 1.13.4 with JULIA_NUM_THREADS=4 OPENBLAS_NUM_THREADS=1 JULIA_NUM_PRECOMPILE_TASKS=1 JULIA_PKG_PRECOMPILE_AUTO=0 CONDA_OVERRIDE_GLIBC=2.35.

for group in DownstreamAD Core QA Downstream; do
    GROUP="$group" timeout 7200 "$JULIA" --startup-file=no --compiled-modules=existing --project -e 'using Pkg; Pkg.test(; julia_args = `--compiled-modules=existing`)'
done
DownstreamAD exit 0
Enzyme through ensembles of SDEs |    4      4  9m11.4s
PDE solution adjoints |   87     87  4m56.5s
Symbolic solution getindex adjoints |   96     96  6m07.3s
     Testing SciMLBase tests passed

Core exit 0
Compile-time trait inference |   84     84  5.7s
Remake        | 4631   4631  2m26.0s
     Testing SciMLBase tests passed

QA exit 0
QA            |  123    123  6m17.9s
     Testing SciMLBase tests passed

Downstream exit 0
Ensembles of Zero Length Solutions |    6      6  58.5s
Scalar RODESolution calculate_solution_errors! |   17     17  4.8s
     Testing SciMLBase tests passed
timeout 7200 "$JULIA" --startup-file=no --compiled-modules=existing --project="$PROBE_ENV" test/inference_tests.jl
timeout 7200 "$JULIAUP" +lts --startup-file=no --compiled-modules=no --project="$LTS_INFERENCE_ENV" -e 'println("Julia ", VERSION, ", threads ", Threads.nthreads()); include("test/inference_tests.jl")'
timeout 7200 julia --project=@runic -m Runic --inplace ext/SciMLBaseEnzymeExt.jl src/ensemble/basic_ensemble_solve.jl test/downstream/ensemble_enzyme_sde.jl test/qa/qa.jl
git diff upstream/master --unified=0 | awk '/^\+\+\+/{next} /^\+/{print substr($0,2)}' | typos - --format brief
git diff --check upstream/master...HEAD
Release inference exit 0
tmap indexes keyed collections |    2      2  0.4s
LTS inference exit 0
Julia 1.10.12, threads 4
tmap indexes keyed collections |    2      2  0.3s
optimization cache u0/p inference |    5      5  0.0s
Runic exit 0
typos exit 0
git diff --check exit 0

Default branch and validation limits

Catalyst ReleaseTest, SciMLSensitivity Core2, and DownstreamAD LTS show matching failures in master CI. Clean-master replays also exited 1 for the Core7 Zygote tuple-thunk error and the four OrdinaryDiffEq Downstream Enzyme loss_mixed errors. The Julia LTS AD group, external integration matrix, GPU and prerelease jobs, and reverse-pass performance were outside local validation. Master release · Master integration · Master tests

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


🤖 Posted by an AI agent — harness: Codex CLI 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a2022a-e148-7f42-baff-50ad68184f5e (no session URL)

ChrisRackauckas and others added 7 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
SciML#1636 missed sites written as `iip = isinplace(f, N); T{iip}` or
`{isinplace(f1|f2|A, N)}`; apply the same literal true/false branch so
SDEProblem, BVProblem, DiscreteProblem, SplitFunction, and friends stop
paying runtime-Bool type-parameter dispatch.

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-rest/log.txt on amdci2
@ChrisRackauckas

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

Scope: the PR's own commit is ae607eee (11 files, +73/−31). PR #1636 is still OPEN and this branch is stacked on it, so git diff origin/master...HEAD also carries #1636's 6 commits, including the responsible_map/tmap ensemble rewrite. Taken alone, ae607eee is low risk. RISK is medium because merging this PR before #1636 would land the ensemble change too. I reviewed ae607eee in depth and only skimmed #1636's part.

Blocking findings

None.

Non-blocking findings

  1. The PR body's LinearProblem row doesn't match what I measured, and it contradicts the body's own fail-before numbers (confirmed by running). The table says LinearProblem(A!) was "15.2 µs / 69" before and "4.6 µs / 17" after. The same body's fail-before list says 25, and 25 is what I get: @benchmark minimum, Julia 1.12, -t1, OPENBLAS_NUM_THREADS=1, scratch/bench.jl gives base 9875b30f 3.22 µs / 25 allocs and head 1.45 µs / 17 allocs. @allocations gives 25 → 17 on 1.10, 1.12 and 1.13. The improvement is real, but the "69" is wrong. The SDEProblem row did reproduce: 74 → 37 allocs.

  2. The new tests only cover the true arm, and only 6 of the 16 changed constructors (test/inference_tests.jl:122-127). If someone swapped {true}/{false} in an untested arm (for example the OOP arm of SecondOrderBVProblem, HomotopyProblem, AnalyticalProblem, SplitSDEFunction or DynamicalSDEFunction), this file would not catch it. I checked by hand instead. scratch/probe.jl builds 34 constructions, both the IIP and OOP arm of every changed constructor plus a matrix LinearProblem, and compares typeof(result) on base vs head. Result: 0 differences on 1.12 and 1.10. So there's no defect today. Looping the type assertions over both arms would make the suite enforce what I checked manually.

  3. Two of the rewritten constructors can't be reached on master, base or head (confirmed by running): DynamicalDDEFunction(f1, f2) and bare-function SecondOrderDDEProblem. Both throw UndefVarError: f not defined in SciMLBase from src/scimlfunctions.jl:4575, where the default is written initialization_data = __has_initialization_data(f) ? f.initialization_data : nothing but the only positional argument is f1. The same line exists on master at :4572. So the PR's "error behaviour identical" claim is true for these two only in the sense that both sides throw the same error. The rewrite was never exercised. This bug predates the PR and should be a separate issue/PR, not folded into this one.

  4. Some sites still don't infer cleanly (confirmed with Base.return_types). SplitFunction(f, f) and SplitSDEFunction still infer to a type with free parameters (SplitFunction{iip, …, F1, F2, …}). SplitSDEFunction still makes 70–78 allocations and DynamicalSDEFunction 48–56 (down from 92–100 and 76–84). Everything else now infers to a 2-element Union{T{true}, T{false}}. The PR doesn't claim more than this, so this is a possible follow-up, not a defect.

  5. The allocation thresholds hold, though < 22 has a small margin. Head measurements on macOS arm64:

    Call 1.12 1.10 Threshold
    SDEProblem 37 36 < 50
    BVProblem 38 37 < 60
    DiscreteProblem 17 17 < 22
    SplitFunction 33 35 < 45
    DynamicalODEFunction 16 17 < 30
    LinearProblem 17 17 < 22

    Base values are 73/74, 88/89, 26, 58, 39, 25. Every threshold sits between head and base. The < 22 bounds have only 5 allocations of headroom, but CI Core passed on lts, 1 (1.13.1) and x86 32-bit (read from gh pr checks).

  6. Merge order. The PR targets master but contains all of Branch on isinplace so convenience constructors dispatch statically #1636. It should land after Branch on isinplace so convenience constructors dispatch statically #1636, or be rebased once Branch on isinplace so convenience constructors dispatch statically #1636 merges, so that it stays a single concern. The PR body says "Stacked on Branch on isinplace so convenience constructors dispatch statically #1636", so this is disclosed.

  7. CI failures are all pre-existing; none come from this PR (I read the logs).

    • OrdinaryDiffEq.jl/Regression (new compared with Branch on isinplace so convenience constructors dispatch statically #1636's run): fails with "Waltman Problem Tests: ArgumentError: matrix contains Infs or NaNs". Master run 38134190296 (75c15fde) fails with the identical error.
    • SymbolicIndexingInterface lts/1: fails on master's latest Tests run 38430497911.
    • SciMLSensitivity Core1 and MTK Extended: fail on master Downstream runs.
    • Catalyst/All/1 (ReleaseTest): fails on master's last two ReleaseTest runs.
    • Core (julia pre) "passed" in 39 s; it looks like no tests ran (I didn't confirm from the log). That's a CI config matter.

What I ran

Confirmed by running, all on macOS arm64, M2 Max:

  • Fail-before / pass-after of the new test/inference_tests.jl cases. I ran the head test file against base 9875b30f (Branch on isinplace so convenience constructors dispatch statically #1636 head, extracted with git archive) and against head, in scratch envs that Pkg.develop each tree.
    • Julia 1.10.x, 1.12.6, 1.13.0: base gives 6 Fail with 74|73 < 50, 89|88 < 60, 26 < 22, 58 < 45, 39 < 30, 25 < 22.
    • Head gives 52/52 Pass on all three versions.
  • scratch/probe.jl on 1.12 and 1.10, base vs head: 34 constructions covering both arms of every changed constructor. Result types are identical between base and head, and allocations and return types are as summarised above.
  • scratch/probe2.jl: ImmutableODEProblem IIP, OOP, and scalar u0 with Int tspan plus a kwarg. On head: u0/tspan are unchanged (no promotion; tspan stays (0, 1)), kwargs are carried through, ODEFunction{iip, AutoSpecialize} as before, 16–17 allocations. Delegating to ImmutableODEProblem{iip} runs the same body as the old inline code. The probe also reproduced the pre-existing DynamicalDDEFunction UndefVarError, with its stack trace.
  • scratch/bench.jl: BenchmarkTools minima for LinearProblem and SDEProblem, base vs head, on 1.12.
  • Head, 1.12, other test files:
    • problem_building_test.jl, homotopy_problem_tests.jl, function_wrappers.jl, ensemble_tests.jl: all pass.
    • function_building_error_messages.jl: 406 pass, 3 errors. All 3 are Package FunctionWrappersWrappers not found because of my env, not the code.
  • Runic --check on every file in the diff: clean. typos over the added lines: clean.
  • grep for remaining {isinplace( and iip = isinplace( sites in src/. What's left is:
    • typed isinplace(f::AbstractSciMLFunction) calls, which are already static;
    • ConstructionBase/remake paths and IntegralFunction calculated_iip, which the PR body discloses;
    • the SDEFunction per-field giip checks, which are not constructor dispatch.
  • CI: gh pr checks 1638 and gh pr checks 1636, plus the failing-job logs and the matching master runs.

What I did not verify

  • I did not run the full GROUP=Core, GROUP=QA, or any Downstream group locally. I relied on CI: Core lts, 1 and x86 are green; downstream failures match master.
  • I did not run anything on Linux x86_64, so the PR body's absolute µs numbers are unreproduced. Only the before/after direction reproduced here.
  • I didn't review Branch on isinplace so convenience constructors dispatch statically #1636's ensemble tmap/responsible_map changes (they're in this diff) beyond a read-through. Suspected from reading only: the threaded misfit path writes to distinct indices, so it looks race-free.
  • I didn't check how this fits with sibling work: neither the PR nor Branch on isinplace so convenience constructors dispatch statically #1636 links an issue or tracking issue (closingIssuesReferences is empty).

🤖 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 01a1972e-b0bc-7d01-94ce-7c60ee15bb6d, reviewed head a680324

  • Verdict: MERGE
  • Risk: medium-high (MH1: broad constructor performance changes and ensemble result-container handling touch main lanes; retain this rating because IntegrationTest has failures even though their exact signatures also occur on master.)
  • 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: Literal Boolean branches improve convenience-constructor inference, while ensemble maps widen heterogeneous result containers safely. The focused tests pass on head, allocation assertions fail on base, and inspected downstream failures also occur on master; I found no blocking defect.

Blast radius: Bare-function problem and SciMLFunction constructors, derivative-wrapper construction, and serial/threaded ensemble collection. Explicit in-place conventions, specialization defaults, keyword forwarding, and numerical algorithms remain equivalent in the inspected code.

Evidence: Head test/inference_tests.jl: 52 passes, exit 0. The same head test file against the merge-base package: 11 allocation failures, exit 1; its nine heterogeneous-map assertions and homogeneous inference assertion pass on both. Independent four-thread mapping checks against Base.map pass, as do 43 constructor/wrapper assertions; one scalar-parameter wrapper probe errors in unchanged code. CI: 67 successful checks and six failures; five failures match inspected master logs exactly, while Reactant aborts during package setup. Benchmark logs show constructor gains and unchanged measured remake/ensemble construction paths.

Blocking findings

None.

Non-blocking findings

None.

What I ran

All package-source inspection was read-only. Initial diff-based risk was written to INITIAL.md and sealed with sha256sum INITIAL.md > INITIAL.sha256 before reading the PR body or commit messages. No previous-review file was opened.

Git and metadata commands:

gh pr view 1638 --repo SciML/SciMLBase.jl --json number,url,state,isDraft,headRefOid,baseRefName,baseRefOid
git -C src fetch origin "+refs/pull/1638/head:refs/remotes/pr/1638" master
git -C src rev-parse HEAD
git -C src diff --stat origin/master...HEAD
git -C src diff origin/master...HEAD
git -C src merge-base origin/master HEAD
git -C src log --first-parent --no-merges -1 --format='%H%n%B'
git -C src log -1 --format=%B ae607eee84dc0a48de2c59a82d14c9705f707b06
gh pr checks 1638 --repo SciML/SciMLBase.jl
gh run list --repo SciML/SciMLBase.jl --branch master --event push --limit 5 --json databaseId,workflowName,conclusion,headSha,url
gh run list --repo SciML/SciMLBase.jl --branch master --event push --workflow IntegrationTest --limit 5 --json databaseId,conclusion,headSha,url

The live head matched TARGET.md, and the merge-base was the reported base SHA above. The first-parent non-merge commit is ae607eee84dc0a48de2c59a82d14c9705f707b06; its trailers supply the author metadata. A plain ancestry-wide git log -1 --no-merges --format=%B instead visits an imported master commit, so that unrelated commit was not used for author grading. Root AGENTS.md and CLAUDE.md were absent.

Exactly three sequential Julia processes ran on Julia 1.13.2, aarch64. Each used JULIA_NUM_THREADS=4 OPENBLAS_NUM_THREADS=1 JULIA_NUM_PRECOMPILE_TASKS=1 JULIA_PKG_PRECOMPILE_AUTO=0, an isolated TMPDIR, and JULIA_DEPOT_PATH set to the TARGET shared depot followed by a colon. Command paths below are relative to the review directory; machine-specific environment paths are represented by their roles.

timeout 3600 julia +1.13.2 --startup-file=no run_head.jl
timeout 3600 julia +1.13.2 --startup-file=no run_base.jl
timeout 3600 julia +1.13.2 --startup-file=no --project=env probe.jl

Head runner activated env, developed the head checkout, added StaticArrays, instantiated without automatic precompilation, and included the complete test/inference_tests.jl. Exit 0; summaries: parameterless_type 4/4, compile-time traits 4/4, ensemble element types 3/3, heterogeneous maps 9/9, homogeneous tmap inference 1/1, static totallength 3/3, convenience constructors 22/22, integrator iteration 1/1, optimization cache inference 5/5.

Base sources were extracted with git -C src archive 365283c66ec24db40c3fae1f2694693070dd7a46 into an isolated directory. Base runner used a separate temporary environment with the same dependency manifest, developed those sources, and included the unchanged head test file. Exit 1: all 11 allocation bounds fail in test/inference_tests.jl:112 through test/inference_tests.jl:122; the constructor testset reports 11 pass / 11 fail. For example, ODEFunction allocates 60 against < 40, BVProblem 88 against < 60, DiscreteProblem 26 against < 22, SplitFunction 101 against < 45, DynamicalODEFunction 39 against < 30, and LinearProblem 25 against < 22. Earlier testsets, including the heterogeneous-map and homogeneous-tmap additions, pass on base. Therefore the added allocation regression fails before and passes after; the added heterogeneous-map tests do not establish a pre-existing base failure. Testsets after the failing constructor set do not execute on base.

The independent probe compared both maps with Base.map using 4,096 mixed values, one and two input collections, and the threaded fallback with no actual misfit: 5/5 pass. It also compared ODEProblem, ImmutableODEProblem, DiscreteProblem, and SDEProblem with explicit typed constructors, checking types, initial states, promoted timespans, keywords, and in-place traits; derivative wrappers were checked against the algebraic value 3 * 2 + 0.5 = 6.5. Constructor/wrapper summary: 43 pass / 1 error, exit 1. The error is MethodError: no method matching similar(::Float64, ::Tuple{Int64}) from passing scalar parameters to the allocating in-place ParamJacobianWrapper call at src/function_wrappers.jl:216. Its allocation body is unchanged by this diff, so this probe error is not evidence of a PR regression. It was not rerun.

CI logs were inspected with gh run view <ID> --repo SciML/SciMLBase.jl --log-failed for each failed head workflow and corresponding master workflows; the benchmark workflow used --log. The first log download failed because the default CLI cache was read-only; subsequent downloads used a writable isolated XDG_CACHE_HOME.

  • Head Run Tests: Core, Downstream, and DownstreamAD pass on release/LTS; two SymbolicIndexingInterface jobs fail with a one-element vector indexed by [1, 2] in test/downstream/comprehensive_indexing.jl:127 and test/downstream/comprehensive_indexing.jl:164. Master Run Tests shows the same failures and 3747 pass / 2 error summaries. Head Reactant fails before tests with Unknown package: GPUCompiler during package setup.
  • Head IntegrationTest: OrdinaryDiffEq core, interface, integrator, regression, and downstream groups pass, as do LinearSolve, NonlinearSolve, Integrals, JumpProcesses, and multiple AD integration groups. SciMLSensitivity Core4 fails with AssertionError: mi2 !== nothing in Enzyme threaded differentiation; Core8 fails with a 3600-element vector indexed at 3601 in the MTK Forward Mode test. Master IntegrationTest shows those same two test failures and error signatures. This comparison establishes matching baseline symptoms, not a proof that every downstream configuration is unaffected.
  • Head ReleaseTest and master ReleaseTest both fail opening Catalyst's test/extensions/Project.toml with Permission denied.
  • Head benchmark workflow: release ODEProblem in-place 18.2 microseconds to 2.38, out-of-place 17.7 to 2.4, SDEProblem 12.2 to 5.4. Measured explicit-ODEFunction construction, ensemble construction, and remake paths are unchanged within reported uncertainty. LTS also shows constructor gains. These are inspected CI measurements, not reviewer timing runs.

What I did not verify

I did not run a full package suite, Pkg.test(), heavy downstream suites locally, GPU, MPI, Reactant tracing, or local AD differentiation. The changed code does not add or alter an AD rule, GPU kernel, MPI implementation, or tracing implementation; existing DownstreamAD and AD integration jobs provide exercised constructor coverage. The separate Reactant job never reached its tests, so Reactant compatibility is unverified rather than claimed passing. The local probe checks wrapper values, not differentiated values.

I did not rerun on Julia 1.10/1.12, x86, Windows, or macOS; CI supplies some release/LTS/x86 coverage. I did not run the added downstream ensemble-solution inference assertion locally; its containing Downstream group passes in CI. The third probe's scalar-parameter wrapper error was not reproduced on base; its unchanged allocation code, rather than a before/after run, supports treating it as outside this PR. I did not separately measure wall-clock performance or prove unchanged behavior for every specialized constructor and custom extension type. No numerical integration algorithm or tolerance changes were identified, so G1 does not require a new convergence study for this diff.

🤖 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:05
Include the upstream SymbolicIndexingInterface fixture correction while preserving the constructor and ensemble changes.

SciML#1657

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__1638 (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: #1638

Reviewed head: cea2709
Raw SHA-256: 88e26b4523c67c7b099107deb045f0d1524f14b6075136bb3fd158e5393e9dde
Source SHA-256: db5540fe6b71bc4d2d86e5d77be54ab046b3f04e86e4c20f59ee71d6b8204ea2
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1ffc4-6c46-7f11-9cd4-6090d38e9307
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: medium-high (MH1)
  • Verdict: MERGE
  • Reviewed head: cea2709

Review report

VERDICT: MERGE
Round: 1
Head: cea2709
Slot: 1
CI: CI unreadable; review only; merge gates unchanged
Session: 01a1ffc4-6c46-7f11-9cd4-6090d38e9307
Reviewer: codex-cli 0.170.0; model: gpt-6.2-sol

Risk

medium-high (MH1: main-lane problem constructors and default ensemble result collection change, with a measured allocation regression for abstractly typed mapper inputs and incomplete performance coverage across dependents)

Blocking findings

None.

Non-blocking findings

  • src/ensemble/basic_ensemble_solve.jl:596 allocates a scratch vector for the entire input whenever inference cannot prove the element types fit. On Julia 1.12.4 with 11 threads, warmed tmap(identity, Any[i for i in 1:100_000]) allocated 809,536 bytes on the base and 1,606,016 on the head. Both returned the same Vector{Int}. Consider buffering only indexed mismatches in task-local storage and widening after the barrier.
  • test/inference_tests.jl:65 accepts Vector{Any} because Julia considers it concrete. The probe inferred Vector{Float64} on the head. Assert that exact type to guard the homogeneous path's element type.

What I ran

  • GROUP=Core julia --startup-file=no --project -t 11 -e 'using Pkg; Pkg.test(; julia_args=["-t11"])' passed 7,101/7,101 on Julia 1.12.4. The LTS invocation passed 6,646/6,646 on Julia 1.10.12. The same runner with GROUP=QA and GROUP=Downstream passed 123/123 and 722/722 on 1.12.4. The changed zero-length downstream test passed 5/5.
  • Ran the head's inference test file against both revisions under the same Julia 1.12.4 dependency versions. The base passed 41/52 and failed all 11 allocation limits. The head passed 52/52 on 1.12.4 and 1.13.3. Warmed ODEFunction allocations went from 60 to 17 and ODEProblem from 63 to 20 for both mutation conventions. With the head constructors and base mappers, the mixed-shape fixture raised MethodError in the serial mapper and CompositeException in the threaded mapper. Both passed on the full head.
  • The 11-thread comparison probe passed 171/171 on the head. Serial and threaded Tsit5 ensembles with alternating scalar and matrix states matched the analytic solution exp(t) * u0 on both revisions. Across 800 mixed values, both head mappers preserved order and value identity and evaluated each item once. A separate Zygote probe with inputs (2, 3.0, 5f0) returned the analytic derivative -228.0 at p = -3 for both mappers. The base failed both gradient calls with pullback conversion errors.
  • Runic 1.7.0, typos, and git diff --check origin/master...HEAD all exited zero. uv run --locked python --version reported Python 3.13.13. The checkout has no uv.lock, and uv reported that the lock flag had no effect outside a project.

What I did not verify

The full DownstreamAD group, the dependent repositories' own test matrices, 32-bit or prerelease Julia, and remote CI.

AUTHOR_GRADE: {"task": "perf", "score": 4, "difficulty": 3, "rounds": 1, "author_harness": "Codex CLI 0.164.0", "author_model": "gpt-6.1-sol", "note": "The constructor allocation tests discriminate, the mixed mapper and pullback probes pass, and the abstract-input threaded fallback adds a measurable allocation cost."}

Head link: cea2709


🤖 Posted by an AI agent — harness: codex-cli 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a1ffc4-6c46-7f11-9cd4-6090d38e9307 (no session URL)

ChrisRackauckas and others added 2 commits November 21, 2026 17:21
Buffer indexed mismatches per work chunk and widen in input order
after the thread barrier. Specialize the fallback on the result
element type to keep matching stores allocation-free per item.

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__1638--20261121T213807Z-codex-gpt-6.2-sol
Agent-Session: local session 01a2000b-a555-78a2-bbb4-4b21a3ab70f8 (no session URL)
Use the types returned by integer indexing to decide whether threaded
results fit the initial vector. Cover keyed inputs with an exact
mixed-numeric regression and check the inferred ensemble solution type.

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__1638--20261122T045707Z-codex-gpt-6.2-sol
Agent-Session: local session 01a2019d-9472-76a3-a893-884b26b0183c (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: #1638

Reviewed head: a902960
Raw SHA-256: ab9953e22626904a099eb6bfd14a509cfefe9d36d203b8cd7c89349e41778929
Source SHA-256: 1a60e0f569789a1de94d6cf1acb0356585b4e95391e9cd73bb58c3ce4b9ee263
Source: standard-review-v1 (harness-log)
Reviewer session: 01a2020d-f643-7582-b715-63d11083a645
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: a902960

Review report

VERDICT: CHANGES
Round: 3
Head: a902960
Slot: 1
CI: CI is not green (regress:OrdinaryDiffEq.jl/Downstream / Downstream Tests - Downstream; SciMLSensitivity.jl/Core7 / Downstream Tests - Core7)
Session: 01a2020d-f643-7582-b715-63d11083a645
Reviewer: codex-cli 0.170.0; model: gpt-6.2-sol

Risk

medium-high (MH1: threaded ensemble solve silently drops part of a reverse-mode gradient)

Blocking findings

  • [P1] src/ensemble/basic_ensemble_solve.jl:589 — The new tmap guard is the delta's only production change. With identical dependency versions, Julia 1.13.4 and 11 threads, the unchanged test at test/downstream/ensemble_enzyme_sde.jl:42 passed on the prior head and on the base. It failed on this head under EnsembleThreads, with a first gradient component of 19.419210065481295 versus ForwardDiff's 29.4412769177571. The serial case passed on all three revisions. A separate ForwardDiff probe differentiated each of the three fixed-seed trajectories individually. Summing all three reproduced the reference, and summing trajectories 1 and 2 reproduced the incorrect Enzyme vector within 8.9e-16 in every component. Preserve all trajectory adjoints in the threaded path and rerun the gradient test alongside the keyed-input regression. Reviewed-head CI log · Prior-head CI log
  • Blocking priorities: P1

Non-blocking findings

None.

What I ran

  • Ran GROUP=Core julia --startup-file=no --threads=11 --project=. -e 'using Pkg; Pkg.test()' and the same command with GROUP=Downstream on Julia 1.13.3. Both ended with Testing SciMLBase tests passed. Core reported 84/84 inference assertions, and Downstream reported 6/6 zero-length ensemble assertions.
  • Ran the current test/inference_tests.jl against both heads. The prior head passed 83/84 and failed 9.007199254740992e15 === 9007199254740993. The reviewed head passed 84/84 and preserved the exact integer. A separate keyed and multi-input indexing probe passed 5/5 on the reviewed head. The prior head rounded the large integer and tried to convert a returned Symbol to Float64. The strengthened EnsembleSolution subtype check passed on both heads. A constant ODE probe returned all 13 expected trajectory outputs in order in both serial and threaded modes.
  • Ran test/downstream/ensemble_enzyme_sde.jl locally on the reviewed head, prior head and base with Julia 1.13.4, Enzyme 0.13.221, SciMLSensitivity 7.119.14 and matching transitive manifests. The prior head and base exited 0 with two passes each. The reviewed head exited 1 with one pass and the threaded failure above. Ran the per-trajectory ForwardDiff probe in the same head environment.
  • Read the two failures named in the header. The failing DiffEqBase test sandbox in the OrdinaryDiffEq job loaded registry SciMLBase 3.58.0 and reported four Enzyme illegal type analysis errors. I reproduced the Core7 adjoint_oop.jl:25 Zygote thunk error on the reviewed head and base with matched Julia 1.13.4 environments. The Core2, Catalyst and Julia LTS DownstreamAD errors also matched base log signatures. OrdinaryDiffEq log · Core7 log
  • Runic check, typos on added lines and git diff --check origin/master...HEAD exited zero. uv run --locked python --version printed Python 3.13.13 and warned that --locked had no effect outside a Python project. The checkout has no uv.lock.

What I did not verify

The specific Enzyme transformation that drops the contribution, the complete external downstream suites and the exact hosted transitive manifests.

AUTHOR_GRADE: {"task":"bugfix","score":3,"difficulty":4,"rounds":3,"author_harness":"Codex CLI 0.170.0","author_model":"gpt-6.2-sol","note":"The keyed-index regression fails before and passes after. The delta also drops one of three trajectory contributions from the threaded Enzyme gradient, which passes on the prior head and base."}

Head link: a902960


🤖 Posted by an AI agent — harness: codex-cli 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a2020d-f643-7582-b715-63d11083a645 (no session URL)

Capture a split tape for each threaded map work item and apply its
pullback sequentially so trajectories sharing parameter shadows keep
every contribution. Exercise ensembles with three and five trajectories.

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__1638--20261122T073128Z-codex-gpt-6.2-sol
Agent-Session: local session 01a2022a-e148-7f42-baff-50ad68184f5e (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: #1638

Reviewed head: 60336d5
Raw SHA-256: 06e7f111f265e9e79d3360bed1ffc3f65c2ce79dcb44484b847c31442d226ae7
Source SHA-256: 1790d4f3c33ac9e709d52af26578d911abd8b234cd76bf966718290829b52468
Source: standard-review-v1 (harness-log)
Reviewer session: 01a2031a-3e5e-7690-a23e-56f62cda6b90
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: medium-high (MH1)
  • Verdict: MERGE
  • Reviewed head: 60336d5

Review report

VERDICT: MERGE
Round: 4
Head: 60336d5
Slot: 1
CI: CI is not green (regress:OrdinaryDiffEq.jl/Downstream / Downstream Tests - Downstream; SciMLSensitivity.jl/Core7 / Downstream Tests - Core7)
Session: 01a2031a-3e5e-7690-a23e-56f62cda6b90
Reviewer: codex-cli 0.170.0; model: gpt-6.2-sol

Risk

medium-high (MH1: changes widely used constructor and solve paths with incomplete external downstream validation)

Blocking findings

None.

Non-blocking findings

  • test/downstream/ensemble_enzyme_sde.jl:31 — The previous head passed all four checked-in cases in one local run. Repeating the threaded cases exposed intermittent wrong gradients. Add a small test that yields between reading and updating a shared parameter shadow in the pullback. That probe returned [11.0] on the previous head and the analytic [36.0] on the reviewed head.

What I ran

  • Ran Pkg.test() with GROUP=Core, QA, Downstream and DownstreamAD on Julia 1.13.3 with --startup-file=no --threads=11 --project=.. All four ended with Testing SciMLBase tests passed. Inference passed 84/84, QA 123/123, zero-length ensembles 6/6 and Enzyme SDE ensembles 4/4. DownstreamAD reported one existing skip at test/downstream/ensemble_adjoints.jl:8.
  • Ran the checked-in seeded SDE test on the reviewed head, the previous head and the base with matching local manifests, including Enzyme 0.13.221 and SciMLSensitivity 7.119.14. Each passed 4/4 in a single run. With 100 threaded repeats each at 3, 5, 17 and 37 trajectories, the previous head disagreed with ForwardDiff in 14/400 runs and the reviewed head in 0/400. The reviewed head's maximum absolute component error was 2.84e-14. Analytic probes covering shared parameters, active scalar captures, overwritten inputs and two reverse lanes passed 28/28. The mixed-output path passed 4/4. The 28 analytic checks also passed with Julia 1.10.12 and Enzyme 0.13.100.
  • Ran the keyed-input regression against the pre-fix revision and the reviewed head. The pre-fix run rounded 9007199254740993 to 9.007199254740992e15. The reviewed head preserved the exact integer and passed a separate 12/12 keyed-input and sparse-widening probe. The constructor checks went from 37/48 on base to 48/48 on the reviewed head.
  • Compared the captured downstream logs with the clean-base reproduction logs. OrdinaryDiffEq records four IllegalTypeAnalysisException errors at enzyme_solve_up_rule.jl:169 in both, with DiffEqBase 7.22.0 and Enzyme 0.13.221. The failing hosted sandbox loaded registry SciMLBase 3.58.0. Core7 and its base reproduction both report Gradient Thunk(...) should be a tuple at adjoint_oop.jl:25 with Zygote 0.7.18 and ChainRules 1.74.14. OrdinaryDiffEq log · Core7 log
  • Runic 1.7.0, typos on added lines and git diff --check origin/master...HEAD exited zero. uv run --locked python --version printed Python 3.13.13 and warned that --locked had no effect outside a Python project. The checkout has no uv.lock.

What I did not verify

Complete reruns of the two external downstream jobs and exact equality of their hosted transitive manifests.

AUTHOR_GRADE: {"task":"bugfix","score":4,"difficulty":4,"rounds":4,"author_harness":"Codex CLI 0.170.0","author_model":"gpt-6.2-sol","note":"Matched-environment stress and forced overlap reproduced the dropped adjoints before the fix and passed afterward. The checked-in SDE test remains scheduling-sensitive as a negative control."}

Head link: 60336d5


🤖 Posted by an AI agent — harness: codex-cli 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a2031a-3e5e-7690-a23e-56f62cda6b90 (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: #1638

Reviewed head: 60336d5
Raw SHA-256: 3c32ff4a00825af2ade399d7083b2f51b76cc23bdfa1fcf924c3455d572542b9
Source SHA-256: d4b0065eccc276b35d7fb58894953a0d28ef211157e51ff83909b548e5f2f85d
Source: standard-review-v1 (harness-log)
Reviewer session: 01a216f6-cadf-7a41-8e16-5d57535614b5
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: 60336d5

Review report

VERDICT: CHANGES
Round: 5
Head: 60336d5
Slot: 1
CI: CI unreadable; review only; merge gates unchanged
Session: 01a216f6-cadf-7a41-8e16-5d57535614b5
Reviewer: codex-cli 0.170.0; model: gpt-6.2-sol

Risk

medium-high (MH1: performance changes reach public problem constructors and ensemble solve. SciMLBase’s downstream groups passed locally, and key dependents’ standalone suites remain unverified.)

Blocking findings

  • Blocking priorities: P2
  • [P2] src/ensemble/basic_ensemble_solve.jl:522 and src/ensemble/basic_ensemble_solve.jl:627 extend use of the private Base.promote_typejoin to both ensemble map paths. On Julia 1.12.4, Base.ispublic(Base, :promote_typejoin) returned false. Public typejoin(Float64, Int64) returned Real, the same join as the private helper for the exact-integer regression. The existing QA exception cites narrow unions, which these two functions can handle locally.
    Implementation fix: Use public typejoin when widening the batch type in responsible_map and tmap_widen!. If preserving narrow Missing or Nothing unions is required, join the payload types with typejoin in a local helper and add the sentinel alternatives explicitly. In test/inference_tests.jl, exercise both maps with Any[1.5, Int64(2)^53 + 1, missing, nothing] and assert the order and exact value and type of each result with ===. If the helper preserves sentinel unions, also assert the intended eltype. The callers to cover are serial and threaded solve_batch and the map adjoints in ext/SciMLBaseZygoteExt.jl. No public documentation change is needed.

Non-blocking findings

  • src/ensemble/basic_ensemble_solve.jl:515 — the warmed responsible_map(FloatMap, data) probe on 100,000 Int values stored in a Vector{Any}, with FloatMap(i) = Float64(i), allocated 7,193,224 bytes on head and 3,993,224 on the base. In the public serial ensemble probe, both revisions allocated 160,824 bytes with typed callback data and 321,456 bytes with abstract callback data.
    Implementation fix: Move the serial fill into a helper specialized on Vector{T} that stops at the first misfit and returns its index and value to responsible_map. Widen in the outer function and resume after the already evaluated element. Add a warmed test/inference_tests.jl probe that checks exact output, one callback invocation per index, and allocation growth against a typed-fill loop as the input length doubles. Keep the existing solve_batch and Zygote map adjoint entry points.

What I ran

  • git diff --name-status -M origin/master...HEAD and git diff --check origin/master...HEAD. Inspected all 18 changed paths. There were no renames or changes to authority or security paths. Runic’s --check and typos both exited 0 on the changed files. The checkout was clean at the reviewed head.
  • GROUP=<group> JULIA_NUM_THREADS=11 JULIA_NUM_PRECOMPILE_TASKS=3 julia --startup-file=no --project -e 'using Pkg; Pkg.test()' on separate scratch exports with Julia 1.12.4. Core, QA, Downstream, and DownstreamAD all printed Testing SciMLBase tests passed. QA passed 123/123, zero-length ensembles passed 6/6, and the Enzyme SDE cases passed 4/4. Running test/downstream/ensemble_enzyme_sde.jl with the base revision and the same resolved dependencies also passed 4/4.
  • Focused rerun with Julia 1.12.4 and 11 threads passed inference 84/84, wrappers 28/28, and problem building 194/194. test/inference_tests.jl also passed 84/84 on Julia 1.10.12.
  • Four-thread reviewer-map-probes.jl against the same dependency resolution on both revisions. The order, identity, and exactly-once probe passed 12/12 on head. The base passed 2/12, with conversion errors. The public mock-solver probe passed 12/12 on each revision across both ensemble algorithms and three batch sizes. The warmed constructor probe measured 19 allocations on head and 62 on the base for each in-place convention.
  • reviewer-ad-probes-v2.jl passed 8/8 closed-form reverse-mode assertions on Julia 1.12.4 with Enzyme 0.13.221 and on Julia 1.10.12 with Enzyme 0.13.100. The cases covered shared parameter shadows, batched cotangents, and scalar captures. reviewer-widen-ad-probes.jl returned primal 20.0 and gradient [10.0] on head. Its base run returned primal 20.0 and failed gradient compilation with IllegalTypeAnalysisException.
  • uv run --locked python --version printed Python 3.13.13 and warned that --locked had no effect outside a project. The checkout has no uv.lock.

What I did not verify

  • Standalone suites of dependent packages, other Julia versions, and distributed or GPU runs. Enzyme 0.13.100 warned that Julia 1.12 support was in progress and errored in the closed-form probes on Julia 1.12.4. The lower-bound verification used Julia 1.10.12.

AUTHOR_GRADE: {"task":"perf","score":4,"difficulty":4,"rounds":5,"author_harness":"Codex CLI 0.170.0","author_model":"gpt-6.2-sol","note":"All four local groups passed. Probes confirmed lower constructor allocations, exact mixed results, and correct threaded gradients. Two widening sites extend avoidable use of a private Base function, and abstract-input serial mapping allocates more."}

REVIEWER_GRADE: {"task": "perf", "score": 3, "rounds": 5, "reviewer_harness": "codex", "reviewer_model": "gpt-6.2-sol", "verdict": "missed", "note": "The earlier review reproduced lost threaded gradients in 14/400 runs on the previous head and 0/400 on the reviewed head. It missed the blocking use of private Base.promote_typejoin in both map paths and the 3,200,000-byte increase in serial allocations on abstract input."}

Head link: 60336d5


🤖 Posted by an AI agent — harness: codex-cli 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a216f6-cadf-7a41-8e16-5d57535614b5 (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.

2 participants