Repository navigation
Preserve array derivative views in implicit residual code generation - #5121
ChrisRackauckas wants to merge 3 commits into
Conversation
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Codex <noreply@openai.com> Agent-Harness: Codex CLI 0.153.4 Agent-Model: gpt-6-astra Agent-Session: local session 01a08018-78ff-7e42-a964-f5174f3f763b
Benchmark Results (Julia v1)Time benchmarks
Memory benchmarks
|
Benchmark Results (Julia vlts)Time benchmarks
Memory benchmarks
|
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Codex <noreply@openai.com> Agent-Harness: Codex CLI 0.153.4 Agent-Model: gpt-6-astra Agent-Session: local session 01a08018-78ff-7e42-a964-f5174f3f763b
The array-equation DAE test solves a DAEProblem with DFBDF and BrownFullBasicInit, which passes unwrapped parameters through the despecialization barrier. DiffEqBase < 7.18.1 rejects that with "a parameter-despecialization barrier requires exactly one parameter wrapper", which is what the downgrade-mtkbase CI job hit. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Agent-Harness: Claude Code 2.1.270 Agent-Model: claude-fable-5-1 Agent-Session: local Claude Code session 9b5c3ae5-6a0f-41b8-bd69-03bf3b5e7083
Pushed two commits on top of 7bb83a3 (
Observed on the final head (Julia 1.12.6, aarch64 Linux; fresh env with Runic 1.10.0 Not verified: the full Core/InterfaceI/QA suites on this head, x86, and whether the downgrade job now resolves — the CI run on this push is the check for that. 🤖 Posted by an AI agent — harness: Claude Code 2.1.270 · model: claude-fable-5-1 |
|
This PR's commit has been carried forward, with its authorship kept, onto current master in #5242. That PR has fresh fail-before/pass-after evidence and an independent review (Opus 5.5: MERGE, low). If #5232 is the one to merge, this one can be closed. 🤖 Generated with Claude Code (model: claude-opus-5-5[1m]), https://claude.ai/code/session_01H4fXBChQshAwfpLMCpEvAX |
Implicit DAE residuals currently expand an array derivative into an expression containing every scalar derivative. Bind contiguous derivative blocks to reshaped views of the
duargument so the residual code stays bounded as the array grows. Noncontiguous/interleaved state layouts retain the scalar fallback; the same substitution handles observed expressions and assertions.Fixes #5097.
The regression suite covers 1D and 2D arrays, slices, analytic heat-equation solutions, derivative observations, interleaved indices and a collision with the deterministic internal sentinel name. A collision is rejected explicitly; reviewers should consider whether reserving this name is preferable to generating a different stable name.
Validation on Julia 1.12.6, aarch64 Linux, ModelingToolkitBase 1.70.0 development tree:
lib/ModelingToolkitBase/test/array_equation_dae.jlwith the unfixed code loaded, then with this implementation. Before:Pkg.test("ModelingToolkitBase"; allow_reresolve=false)ran the full test entry point. InterfaceI passed 1706 tests, with 5 existing broken tests; all subsequent groups reached before C compilation also passed. The run stopped at C compilation because GCC on ARM rejects the existing-msse3flag. Groups after that failure were not reached. This is not a claim that the full suite is green.GROUP=QA: targeted JET 54/54, other QA checks 20 passed/1 failed. Package-wide JET reports 234 possible errors. A separate run on unchanged basef54dc8fproduced the same 54/54 + 20/1 and 234 errors.git diff --checkpassed.Not verified: x86 execution, the full suite past the ARM C-compilation failure, or large-array solver/factorization scaling. This change bounds generated derivative expressions, not numerical storage or solve cost. It changes the implicit DAE path; the separate array ODE work in #5101 may overlap this file and should be reconciled at merge time.
Follow-up commits (2026-09-12)
Two commits were added on top of 7bb83a3 (harness: Claude Code 2.1.270 · model: claude-fable-5-1; local session
9b5c3ae5-6a0f-41b8-bd69-03bf3b5e7083, no shareable URL):build_explicit_observed_functioncollects the differentiated variables of everyisdiffeqequation intodervars; when an equation's LHS is an array-shaped derivative (aD(u[2:(n-1)])slice, as the array residual path now preserves), pushing it intodervarsbroke observation of expressions over that array. The fix skips array-shaped LHSs there (SU.is_array_shape(SU.shape(eq.lhs)) && continue); the test file gains two assertions thatbuild_explicit_observed_function(sys, sum(u))andbuild_explicit_observed_function(sys, u[2:(n-1)])evaluate correctly on the array-equation heat system.DAEProblemwithDFBDF()andinitializealg = BrownFullBasicInit(). That path passes unwrapped parameters through the despecialization barrier, which DiffEqBase < 7.18.1 rejects witha parameter-despecialization barrier requires exactly one parameter wrapper(fixed in fix: let the despecialization barrier accept unwrapped parameters OrdinaryDiffEq.jl#4297). Thedowngrade-mtkbase (InterfaceI)job resolved DiffEqBase 7.15.0 and hit exactly that error (https://github.com/SciML/ModelingToolkit.jl/actions/runs/34698852412/job/103567159695).DiffEqBase = "7.14"is raised to"7.18.1"inlib/ModelingToolkitBase/Project.tomland, for consistency, in the top-levelProject.toml.Validation of the final head (Julia 1.12.6, aarch64 Linux), in a fresh environment with
ModelingToolkitBaseandModelingToolkitPkg.developed from this branch and DiffEqBase resolved to 7.21.1:include("lib/ModelingToolkitBase/test/array_equation_dae.jl")in a fresh process:--check --diffon the three changed.jlfiles: clean.typos1.50.1 over all five changed files with the repo.typos.toml: clean.git diff --check: clean.Not verified on the final head: the full Core/InterfaceI/QA suites (only the branch's own test file was rerun after e19beae and the compat bump), x86 execution, and whether the downgrade job now resolves; the last is what CI on this push will show.
🤖 Posted by an AI agent — harness: Codex CLI 0.153.4 · model: gpt-6-astra
Conversation: local session 01a08018-78ff-7e42-a964-f5174f3f763b (no shareable session URL)