Repository navigation
Branch on isinplace so convenience constructors dispatch statically - #1636
ChrisRackauckas-Claude wants to merge 9 commits into
Conversation
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
Independent review (Devin CLI 3000.11.3, model fusion-claude-opus-5-5-high-sidekick-swe-2-medium): MERGE, risk medium. Full reviewVERDICT: MERGE 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 Blocking findingsNone. Non-blocking findings
What I ranClones at PR head
What I did not verify
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 |
Independent review (Codex CLI 0.166.0 / gpt-6.1-sol), session 01a19723-978f-7033-8cfe-42971751a2da, reviewed head d581bf5
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 findingsNone. Non-blocking findingsNone. What I ranAll 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 365283c66ec24db40c3fae1f2694693070dd7a46These 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>&1The 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. 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,createdAtThe 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.
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 verifyI 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 |
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)
PR: #1636 Reviewed head: d621b9a Risk assessment
Review reportVERDICT: CHANGES Riskmedium-high (MH1: core constructor inference changes, and heterogeneous ensemble mapping under Mooncake can produce different forward values from ordinary execution) Blocking findings
Non-blocking findings
What I ran
What I did not verify
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 |
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)
PR: #1636 Reviewed head: cc29a24 Risk assessment
Review reportVERDICT: CHANGES Riskmedium-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
Non-blocking findingsNone. What I ran
What I did not verify
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 |
Summary
Convenience constructors such as
ODEFunction(f),ODEProblem(f, u0, tspan, p), andNonlinearFunction(f)were written asT{isinplace(f, N), ...}(f; kwargs...). The runtimeBooltype 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 undersrc/(Discrete/SDE/RODE/DAE/DDE/SDDE/… functions, IntegralProblem, function wrappers). This does not touch the broaderisinplacerewrite 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-Boolpath.Ensemble follow-up (CI regression)
Concrete
ODEProbleminference maderesponsible_map/tmapallocate a narrowVector{T}from the first trajectory's inferred return type. On master that inference wasAny, so mixed-u0 ensembles worked by accident. DownstreamEnsembles of Zero Length Solutions(and any ensemble whoseprob_funcchangesu0type) then hitMethodErrorconvertingODESolution{…Matrix…}intoVector{ODESolution{…Float64…}}.Fix: widen the container when a later element does not fit (Base
map/collectstyle) inresponsible_map;tmapcollects intoAnythentighten_container_eltype(threaded widening is racy). Constructor changes and their numbers are unchanged.Regression in
test/inference_tests.jl(responsible_mapover[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,@benchmarkminima, warmed)ODEFunction(f!)ODEProblem(f!,…)IIPODEProblem(fo,…)OOPNonlinearProblem(nf,…)Constructor allocation regression (
@allocations … < 40after warmup intest/inference_tests.jl): fails on master, passes with the fix.Test plan
Testing SciMLBase tests passed(incl. new ensemble widen regression)GROUP=QAwithCONDA_OVERRIDE_GLIBC=2.35:QA | 123 123,Testing SciMLBase tests passedEnsembles of Zero Length Solutionson Julia 1.10: fail unfixed / pass fixed; pass on masterODEProblemvia changed constructorsWhat was NOT verified
isinplaceinference and add inference tests #1019 (left untouched)@inferredon these constructors still returns aUnion{…true…, …false…}becauseisinplaceitself is not constant-folded; the win is runtime static dispatch / allocsFollow-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)thenT{iip}:SDEProblem,BVProblem,SecondOrderBVProblem,DiscreteProblem, bare-functionImplicitDiscreteProblem,ImmutableODEProblem,SecondOrderODEProblem,SecondOrderDDEProblem,HomotopyProblem,AnalyticalProblem{isinplace(f1|f2, N)}:SplitFunction,DynamicalODEFunction,SplitSDEFunction,DynamicalSDEFunction,DynamicalDDEFunction{isinplace(A, 4)}:LinearProblemReviewer pushback
< 40allocation bound is tight enough across Julia versions / GC noisetmapalways going throughVector{Any}+ tighten is acceptable vs a typed fast path with mismatch fallbackODEProblem(f,…)should keep the old inlineprepare_initial_statepath instead of delegating toODEProblem{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)
ODEFunction,ODEProblem,NonlinearFunction, integral / SDE / DAE / DDE / BVP function wrappers, and the Jacobian wrappers) and the ensembleresponsible_map/tmapcontainers. Return values I checked match master. Homogeneous ensemble maps stay in a concreteVector{T}; a later element that is notisathatTwidens the container withpromote_typejoin. No public name is removed or renamed. NoProject.tomlchange and no new dependency. Every downstream solver that builds problems through these constructors is in the inference blast radius.d581bf59255efb780a96f23f6b274287e77660e1.test/inference_tests.jlpassed onjulia +release1.13.0 andjulia +lts1.10.12 (all testsets, including 10/10 convenience-constructor checks and 9/9 ensemble-widen checks).@allocationsafter warmup on 1.13.0:ODEFunction(f!)60 on master365283c6, 17 on this head;ODEProblemin-place 63 → 20;NonlinearProblem59 → 19. The new< 40bounds therefore fail on master and pass here.ODEProblem(f!, 1, (0, 1), 2)andODEProblem(fo, [1, 2], (0, 1))matched master foru0type,tspan,isinplace, andp. Head CI is 55 pending, 0 failing. The previous SHA9875b30failed 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.🤖 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
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: GPUCompilerdependency-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
d581bf592and ran it against the same merged source and downstream dependencies used by the corrected group. The original test command wastimeout 7200 julia --project=test/downstream -e 'using Test; @testset "Original indexing regression" begin include("../scratch/comprehensive_indexing_before.jl"); end'(Julia 1.12.4).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 --cachedandgit diff --check: exit 0.timeout 7200 env GROUP=Core julia --project -e 'using Pkg; Pkg.test()'(Julia 1.12.4):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 throughJULIA_PYTHONCALL_EXE, withJULIA_CONDAPKG_BACKEND=Null; all assertions remained enabled.timeout 7200 env GROUP=SymbolicIndexingInterface julia --project -e 'using Pkg; Pkg.test()'(Julia 1.12.4):timeout 7200 env GROUP=SymbolicIndexingInterface julia +lts --project -e 'using Pkg; Pkg.test()'(Julia 1.10.12):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):timeout 7200 julia --project=docs docs/make.jl: exit 0.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)
Fix by Codex CLI 0.170.0 gpt-6.2-sol (head cc29a24)
The Mooncake
responsible_mapandtmaprules 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_ENVandLTS_ENVare scratch Julia projects developed against the checkout.timeout 7200 julia +1 --startup-file=no --project="$MOONCAKE_ENV" "$PROBE"usedprepare_pullback_cacheandvalue_and_pullback!!on a scalar loss over each mapper. The probe exited 0 withMooncake differentiation through ensemble maps | 4 4 10.4s.Full local checks
Julia ran with four threads and one OpenBLAS thread.
juliawas 1.12.4 andjulia +1was 1.13.3. QA used the system Python viaJULIA_PYTHONCALL_EXEandJULIA_CONDAPKG_BACKEND=Null.Each command exited 0 with no output.
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)