Repository navigation
Make AutoDespecialize initialization data model-independent - #5221
Merged
ChrisRackauckas merged 2 commits intoOct 31, 2026
Merged
ChrisRackauckas merged 2 commits into
ChrisRackauckas merged 2 commits into
Conversation
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/ModelingToolkit.jl
that referenced
this pull request
Sep 30, 2026
Address independent review of SciML#5221: leave the Homotopy SCC container policy to SciML#5202, return InitializeprobParameterMap only under AutoDespecialize, retarget type-equality to DAE sizes (6, 9), and cover non-tunable array-parameter indices in CopyParamsByTemplate. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Cursor Agent <[email protected]> Agent-Harness: Cursor Agent CLI Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/initdata/log.txt on amdci2.julia.csail.mit.edu
Member
Merged the default branch into this PR (clean merge, no conflicts; head 563c24f) so CI runs on current master. 🤖 Posted by an AI agent — harness: Devin CLI 3000.11.3 (merge), Claude Code 2.1.285 (posting) · model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium |
Keep CopyParamsByTemplate index containers as Vectors, erase ObservedWrapper to Any, and replace the split initprobpmap closure with a named callable so chain DAE OverrideInitData types match across model sizes. Also vectorize SCC blocks under AutoDespecialize (HomotopyProblem exception), overlapping SciML#5202. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Cursor Agent <[email protected]> Agent-Harness: Cursor Agent CLI Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/initdata/log.txt on amdci2.julia.csail.mit.edu
Address independent review of SciML#5221: leave the Homotopy SCC container policy to SciML#5202, return InitializeprobParameterMap only under AutoDespecialize, retarget type-equality to DAE sizes (6, 9), and cover non-tunable array-parameter indices in CopyParamsByTemplate. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Cursor Agent <[email protected]> Agent-Harness: Cursor Agent CLI Agent-Model: auto Agent-Session: local session, transcript at /home/crackauc/sandbox/agent-jobs/mtk-ttfx/jobs/initdata/log.txt on amdci2.julia.csail.mit.edu
ChrisRackauckas-Claude
force-pushed
the
ttfx-model-independent-initdata
branch
from
October 31, 2026 11:53
8a51896 to
ff5f5d4
Compare
ChrisRackauckas
marked this pull request as ready for review
October 31, 2026 12:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ignore until reviewed by @ChrisRackauckas.
Summary
Under
AutoDespecialize, MTK initialization data for DAE chains differed by model size because (1)CopyParamsByTemplatepacked small index lists into tuples, (2)ObservedWrappercarried a per-model RGF in its type, and (3) the split init parameter map was an anonymous closure. This PR keeps Vector templates (including recording non-tunable array-parameter index types inelem_types), erases the observed getter toObservedWrapper{TD,Any}, and replaces the closure withInitializeprobParameterMaponly under AutoDespecialize. AutoSpecialize and FullSpecialize keep the previous#initprobpmap_splitclosure and types.The Homotopy tuple guard for SCC containers is left to #5202. This PR no longer touches
sccnonlinearproblem.jl.Related to #5211. Type-equality regression uses DAE sizes
(6, 9)(both >5 SCC blocks) so it does not depend on the ≤5-block tuple container.Also related: #5238 adds the identical
push!(elem_types, typeof(symidx))line with its own test. Merging both is clean; whichever lands first makes the other's line a no-op, and both tests remain valid.Verification
Fresh A/B on base
f19f4bc917vs headf709f61581(round-2 independent review). Julia 1.12.7. MethodInstances exclude ROOT. Load ~220–300. Build and total MIs are too noisy to claim; only solve and init-family counts are reported.typeof(prob.f.initialization_data)forchain_dae(6)vschain_dae(9): false → true. ODE AutoDespecialize type match for compatible chains was already true on master; only the DAE half changes.Init-family MethodInstances (all n): build 4 → 0, solve 11 → 1.
Solve MethodInstances (fresh A/B on
f709f61581):Fail-on-base: DAE type equality and the N2
CopyParamsByTemplatenon-tunable array-index test fail onf19f4bc917and pass on head.Tests:
GROUP=Initialization: Pass 974, Broken 12, Total 986, exit 0 (~85 min).test/linearize.jl: exit 0 on base and head.linearization_functionbuildsODEProblem{true}, which defaults toAutoDespecialize, so InterfaceII's linearization path is touched by this PR; the tests still pass.GROUP=InterfaceIItimeout under high load is host contention (same stall point on base); CI InterfaceII is green on PR and master (Julia 1 and LTS).--checkon changed files: clean.CI
Failing checks match pre-existing failures on master: SII
SCCNonlinearProblemu0, QA reexports, Optimization, NNPDE2 Enzyme, sublibrary JET.Benchmarks (1)fails resolving the master side (ModelingToolkitBase1.77.1 registry), not this PR. Relevant groups (Initialization, InterfaceII, SymbolicIndexingInterface, Downstream) are green.Not verified
Risk assessment
push!).Reviewer pushback
ObservedWrapper{TD,Any}is the right erasure vs FunctionWrappersWrapper.Part of the MTK TTFX effort.
Harness: Cursor Agent CLI · Model: auto
Risk assessment (independent review, codex-cli gpt-6.1-sol, reviewed head 8a51896)
model_independent_initialization.jlwith Julia 1.13.0, four Julia threads, and registered dependencies: 28/28 model-independent initialization assertions and 2/2 non-tunable array-index assertions passed, exit 0. This checks DAE and ODE type equality at sizes 6 and 9, solves against FullSpecialize, remake/solve equivalence, AutoSpecialize map selection, and non-tunable array values. CI has 43 pass, 2 fail, 63 pending, 1 skipped; both failed jobs match master. SciMLSensitivity Core8 succeeds: https://github.com/SciML/ModelingToolkit.jl/actions/runs/38856295175/job/116828397007 .🤖 Posted by an AI agent — harness: codex-cli · model: gpt-6.1-sol (independent reviewer; appended by Claude Code 2.1.301 · claude-opus-5-5)
Conversation: https://claude.ai/code/session_01VZjwf7Ux9YtTzwHGHMqnsq
Risk assessment (independent review, Codex CLI 0.164.0 gpt-6.1-sol, slot 1, head 8a51896)
Review round 2, written by the reviewer named above (Codex CLI 0.164.0 / gpt-6.1-sol) 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: Makes AutoDespecialize initialization mapping data independent of model-specific callable types. The original tests and independent solution, residual and nonlinear ForwardDiff checks pass locally; broad core initialization scope keeps the medium-high classification.
Blast radius: CopyParamsByTemplate, concrete_getu, parameter reconstruction and initialization maps for AutoDespecialize.
Evidence: Julia 1.13.2: the exact new file passes 28+2 assertions on the head; its first testset has 25 passes / 1 failure / 2 errors on origin/master because model-specific types remain and the new wrapper type is absent. Independent physical-variable ODE matrix-exponential and DAE residual checks pass 10/10 on both refs, as do 2/2 analytic ODE sensitivity checks and 2/2 ForwardDiff-through-nonlinear-initialization checks (0.09196986029320084 versus exp(-1)/4). Six new-model solve benchmarks pass on both refs. G1 has independent linear solutions, algebraic residuals and analytic sensitivities; G2 is exercised locally and in cited same-head Core8 CI; G3 includes different model sizes, remake and explicit non-tunable buffer checks. Complete IntegrationTest green and a comprehensive isolated performance study are not established, so MH1 is retained rather than ML11.
Blocking findings
None.
Non-blocking findings
What I ran
First-round read-only inspection, retained for this unchanged head. Repository commands below ran in the isolated checkout and exited 0; rev-parse HEAD matched the live head metadata. Base is the fetched target-branch tip at review time, while the three-dot diff uses the merge base. Newest non-merge commit trailers, rather than body attribution, supply AUTHOR_GRADE provenance.
Read-only GitHub inspection (PR views exit 0; pr checks exits 1 because failures exist):
CI check rollup at the captured head: {"CANCELLED": 1, "FAILURE": 6, "SKIPPED": 3, "SUCCESS": 101}. Log-retrieval exit codes are retrieval status, not test exit codes: successful retrieved jobs report
tests passed; failed jobs remain failed. Failed-run logs were retrieved with a writable scratch XDG_CACHE_HOME. Unavailable logs are disclosed above. The recent default-branch five-run listing was also read; exact historical comparisons are identified in the evidence paragraph.Outer Initialization CI passed 979 assertions with 12 existing broken markers, exercising model_independent_initialization.jl. Sublibrary Initialization also passes; Core8 and Downstream are green. SII BoundsErrors match historical master 38846662285; the separate Parsing/Latexify failures have no fully verified historical match here. Earlier author MethodInstance measurements were inspected, not rerun.
Inspected CI URLs: https://github.com/SciML/ModelingToolkit.jl/actions/runs/38856295016, https://github.com/SciML/ModelingToolkit.jl/actions/runs/38856295175, https://github.com/SciML/ModelingToolkit.jl/actions/runs/38856295864, https://github.com/SciML/ModelingToolkit.jl/actions/runs/38856295864/job/116884038717, https://github.com/SciML/ModelingToolkit.jl/actions/runs/38856295779/job/116869194109, https://github.com/SciML/ModelingToolkit.jl/actions/runs/38846662285.
Round 2 local execution:
All 20 live PRs were checked OPEN with unchanged reviewed heads before Julia execution. Each run checked out the exact detached SHA shown below. Julia 1.13.2 ran directly inside the inherited resource scope, with one Julia invocation at a time, four Julia threads and one BLAS thread. The isolated environment was created with
Pkg.activate(temp=true)andPkg.develop(path=...)for the checkout and its MTKBase subpackage, then persisted outside the checkout for dependency reuse. No test project or source was edited in the checkout.The driver activates that environment, resolves compatible registered dependencies without updating registries, and includes each selected script in a fresh module. It catches only at the test-file boundary to record every selected result, then exits nonzero if any selected case failed. Assertions and tolerances are unchanged.
--compiled-modules=existingreuses available dependency caches and loads uncached PR source; it does not disable tests.head-5221: detached8a518968fee8f493ddc28059cf04eadb810d863a(pr/5221), process exit 0, 277.92 s.Resolution failed before the dependency-version report and test inclusion.
base-master-rootcontext-retry: detached550a27cca63cbe6d7b64bcb2920440aaff9eaa55(origin/master), process exit 1, 487.54 s.Resolved versions: SymbolicUtils 4.54.0, Symbolics 7.47.0, SciMLBase 3.58.0, JumpProcesses 10.0.1, NonlinearSolve 4.32.0, ModelingToolkit 11.47.0, ModelingToolkitTearing 1.20.7, ModelingToolkitBase 1.79.0, OptimizationBase 5.10.0.
extra-head-5221: detached8a518968fee8f493ddc28059cf04eadb810d863a(pr/5221), process exit 0, 247.41 s.Resolved versions: SymbolicUtils 4.54.0, Symbolics 7.47.0, SciMLBase 3.58.0, JumpProcesses 9.33.1, NonlinearSolve 4.32.0, ModelingToolkit 11.45.4, ModelingToolkitTearing 1.20.7, ModelingToolkitBase 1.77.4, OptimizationBase 5.10.0.
rerun-base-5190-elements: detached550a27cca63cbe6d7b64bcb2920440aaff9eaa55(origin/master), process exit 0, 260.37 s.Resolved versions: SymbolicUtils 4.54.0, Symbolics 7.47.0, SciMLBase 3.58.0, JumpProcesses 10.0.1, NonlinearSolve 4.32.0, ModelingToolkit 11.47.0, ModelingToolkitTearing 1.20.7, ModelingToolkitBase 1.79.0, OptimizationBase 5.10.0.
extra-head-5221-ad: detached8a518968fee8f493ddc28059cf04eadb810d863a(pr/5221), process exit 0, 214.46 s.Resolved versions: SymbolicUtils 4.54.0, Symbolics 7.47.0, SciMLBase 3.58.0, JumpProcesses 9.33.1, NonlinearSolve 4.32.0, ModelingToolkit 11.45.4, ModelingToolkitTearing 1.20.7, ModelingToolkitBase 1.77.4, OptimizationBase 5.10.0.
Included unchanged
test/model_independent_initialization.jl: head 28+2 passes; base first testset 25 passes / 1 failure / 2 errors. Independent numerical checks use the physical x[i] selectors when comparing against exp(A)*x0, avoiding assumptions about MTK internal state order. The corrected oracle has 10 solution/residual assertions plus two analytic ODE ForwardDiff assertions, all passing on both refs. A separate nonlinear initialization x(0)^2=a, x′=-x has endpoint sqrt(a)*exp(-1), and its derivative at a=4 matches exp(-1)/4 on each ref (2/2 passes).The first base oracle compared raw reversed solver storage with physical variable order and failed two checks; those reviewer-harness indexing errors were corrected by symbolic selection and the full oracle rerun. No numerical tolerance or PR assertion was changed.
New-model solve compilation measurements at n=11/13 after n=9 warmup:
These measure complete solve calls and include model-generated code outside initialization. Dedicated corrected base/head numerical/AD runs exit 0; the original base type-regression batch exits 1 for the requested regressions.
Exact reviewer script
5221-oracle.jl:Exact reviewer script
5221-ad-nonlinear.jl:The unchanged model helpers used by the independent oracle (copied from the prefix of test/model_independent_initialization.jl) are:
What I did not verify
No whole suite, GPU, Reactant, MPI, local Enzyme/Mooncake run or exhaustive template/parameter-type matrix was performed. Cited same-head Core8 CI supplies additional AD integration evidence. A full final-head MethodInstance census and isolated small-template compilation study were not run; end-to-end timings do not prove all compilation originates in initialization maps. MH1 retains the required caution for broad core representation changes. A clean native-precompile cycle was not verified: the initial batch dependency workload errored during NonlinearSolveFirstOrder AD-backend selection. The recorded test commands use existing caches and JIT-load uncached PR source; no assertion was disabled.
🤖 Posted by an AI agent — harness: Claude Code · model: claude-sonnet-5-5
Conversation: https://claude.ai/code/session_01379heiiB35TtywhR7uSU74