Skip to content

test: cover equivalent scalar DAE residual Jacobians - #5142

Merged
ChrisRackauckas merged 2 commits into
SciML:array-dae-jacobian-residualsfrom
ChrisRackauckas-Claude:codex/dae-residual-regression-coverage
Oct 31, 2026
Merged

ChrisRackauckas merged 2 commits into
SciML:array-dae-jacobian-residualsfrom
ChrisRackauckas-Claude:codex/dae-residual-regression-coverage

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

Adds scalar DAE regression coverage for #5136. Equivalent differential and algebraic equation forms must produce the same residual, sparse structure, and Jacobian across numerical/analytical and dense/sparse modes, including several values of the derivative coefficient. Also corrects the DAE Jacobian docstring's stale statement that its keywords are forwarded to calculate_jacobian.

This adds 80 assertions to the existing official dae_jacobian.jl test. The prerequisite already covers cancelling state/derivative entries and empty array residuals; those tests are not duplicated here. No implementation or dependency changes.

The completed GitHub checks report 28 successes and two downstream failures. I read both failing logs: SciMLSensitivity Core8 reports the existing CacheWriter EnzymeNoTypeError tracked at #5140 (https://github.com/SciML/ModelingToolkit.jl/actions/runs/34754663479/job/103716902119), and NeuralPDE reports the two PDE-IV assertions tracked at SciML/NeuralPDE.jl#1164 (https://github.com/SciML/ModelingToolkit.jl/actions/runs/34754663479/job/103716902060). The separate clean-base investigations reproduce these failures; neither is hidden or treated as a passing check.

Please ignore this draft until reviewed by @ChrisRackauckas. It targets the prerequisite's array-dae-jacobian-residuals branch and should be retargeted after that branch merges.

Verification (Julia 1.12.7):

  • The same scalar regression block on clean master 74fb6a330241be0de12e379657830c66b52cbd35 failed with missing algebraic LHS sparsity and an unsupported mass-matrix conversion:

    ERROR: LoadError: Some tests did not pass: 59 passed, 3 failed, 2 errored, 0 broken.
    
  • With the prerequisite implementation, the exact scalar block passes:

    DAE Jacobians include both sides of scalar equations | 80 80
    
  • Runic.jl --check, typos over both changed files, and git diff --check passed.

  • Full GROUP=InterfaceI julia +1.12 --project=lib/ModelingToolkitBase -e 'using Pkg; Pkg.test()' passed:

    Test Summary: | Pass  Broken  Total      Time
    InterfaceI    | 1761       5   1766  47m43.5s
         Testing ModelingToolkitBase tests passed
    

    The five broken assertions already exist in the prerequisite; this follow-up adds none.

  • Full GROUP=QA julia +1.12 --project=lib/ModelingToolkitBase -e 'using Pkg; Pkg.test()': dedicated JET tests passed 54/54; Aqua returned 20 passes/1 failure from the known package-wide JET/Moshi issue, with 234 generated-variable reports. Persistent tasks, ExplicitImports (6/6), and public API documentation (2/2) passed. Proceeding with this known failure was explicitly authorized; no assertions were changed or skipped.

    JET Tests     | 54 54 1m08.5s
    Aqua Tests    | 20 1 21 24m23.8s
    
  • Normal docs build, julia +1.12 --project=docs docs/make.jl, passed (exit 0) with doctests, exported-name documentation checking, and external link checking enabled:

    [ Info: Doctest: running doctests.
    [ Info: CheckDocument: running document checks.
    [ Info: RenderDocument: rendering document.
    [ Info: HTMLWriter: rendering HTML pages.
    

The sublibrary CI workflow's base-branch filter does not run against this intermediate branch; it will apply after retargeting to master. Formatting CI is unrestricted. GPU, downstream, and other excluded test groups were not run for this test/docstring-only follow-up.

Links:

🤖 Generated with Codex CLI 0.154.0 (model: gpt-6-astra; local session ID: 01a099aa-308a-7fd3-91bd-9fb2dc357b91).

Review findings addressed

  1. Blocked on the prerequisite WIP: build implicit DAE Jacobians and sparsity from scalarized array residuals #5136: not fixable on this branch. This branch already contains the current base head b1c432dc and has nothing to integrate. Bringing WIP: build implicit DAE Jacobians and sparsity from scalarized array residuals #5136 up to master is a change to WIP: build implicit DAE Jacobians and sparsity from scalarized array residuals #5136's own branch: a trial merge of master into array-dae-jacobian-residuals conflicts in lib/ModelingToolkitBase/src/problems/daeproblem.jl (1 hunk), lib/ModelingToolkitBase/src/systems/codegen.jl (2 hunks) and lib/ModelingToolkitBase/test/runtests.jl (1 hunk). After WIP: build implicit DAE Jacobians and sparsity from scalarized array residuals #5136 is refreshed and merged, retarget this PR to master so the Sublibrary CI runs the new testset.
  2. Docstring is correct only together with WIP: build implicit DAE Jacobians and sparsity from scalarized array residuals #5136: confirmed. On master, generate_dae_jacobian still calls calculate_jacobian(sys; simplify = simplify, sparse = sparse). The edit stays in this stacked PR and must not be cherry-picked to master alone. No code change.
  3. Test quality: no change requested.
  4. Authorship note (base commit b1c432dc not reviewed here): informational. That commit belongs to WIP: build implicit DAE Jacobians and sparsity from scalarized array residuals #5136 and needs its own review there.

No commits were added for this review, so the head is still a24df9d1.


🤖 Posted by an AI agent — harness: Claude Code 2.1.301 · model: claude-opus-5-5
Conversation: local session ID 397bfc12-8938-412e-8c82-6bfff99b28b2 (headless, no URL)

Risk assessment (independent review, codex-cli gpt-6.1-sol, reviewed head a24df9d)

  • Risk: low
  • Blast radius: 31 added test lines and a two-line keyword-description update in an existing docstring. No runtime implementation, public API, compatibility, dependency, or license changes. This verdict covers merging into the declared array-dae-jacobian-residuals base; it does not approve the prerequisite implementation or delivery to master.
  • Evidence: I ran the complete official lib/ModelingToolkitBase/test/dae_jacobian.jl against the reviewed checkout on Julia 1.13.0 with JULIA_NUM_THREADS=4: 81 passed, 0 failures/errors, exit 0, including all 80 new assertions. git diff --check HEAD^ HEAD passed. Head CI remains 28 passing and two failing checks: NeuralPDE NNPDE1 and SciMLSensitivity Core8. I read both failing logs and compared the latest completed default-branch IntegrationTest run; details below. Sublibrary CI is absent because the declared feature-branch base is excluded by its trigger.
  • Independent review: codex-cli 0.163.0 gpt-6.1-sol rated it low, high confidence: the added assertions match the hand-derived residual and Jacobian, and the complete affected test file passes locally.
  • Merge: needs human review — the draft explicitly reserves review by @ChrisRackauckas, and the code author and this reviewer both use Codex, so this pass does not fulfill the separate-harness automatic-merge requirement. Merging this coverage into its feature-branch base is suitable; the prerequisite still needs its own review and validation before master delivery.

Head reviewed: a24df9d11379041b98fa7659597ccf6030f2f47e. Recorded at review start in ModelingToolkit.jl-5142.head and checked again after testing; unchanged.

Authorship: the sole PR commit attributes the code to Codex CLI 0.154.0 / gpt-6-astra, with Chris Rackauckas and Codex co-author trailers, session 01a099aa-308a-7fd3-91bd-9fb2dc357b91. The original body footer agrees. The later review-response section attributes its prose to Claude Code 2.1.301 / claude-opus-5-5. The prerequisite commit is Claude Code 2.1.270 / claude-fable-5-1 and is outside this PR's diff. I reviewed normally under the task's explicit override of the Claude-authorship skip rule.


🤖 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

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

Fix by Grok Build 1.0.70 grok-4.7 (head 8b10f5c)

Merged the prerequisite branch array-dae-jacobian-residuals (tip b984e003fe32) into this branch. The previous head a24df9d11379 was that branch's old tip plus the scalar DAE coverage commit, and its IntegrationTest run was from 2026-09-13. NeuralPDE.jl/NNPDE1/1/ failed there on nnpde__pde_iv_system_of_pdes.jl lines 105 and 106. The same two assertions failed on master at the merge-base 8875e771ab06 (https://github.com/SciML/ModelingToolkit.jl/actions/runs/34728172821, job https://github.com/SciML/ModelingToolkit.jl/actions/runs/34728172821/job/103655674398). The prerequisite head already contains a merge of master and its NeuralPDE.jl/NNPDE1/1/ job is success (https://github.com/SciML/ModelingToolkit.jl/actions/runs/39040829882/job/117419831776). After this merge, the diff against that prerequisite head is still only the scalar DAE residual test and the generate_dae_jacobian keyword docstring.

SciMLSensitivity.jl/Core8/1/ still fails on current master (https://github.com/SciML/ModelingToolkit.jl/actions/runs/41121219002) and on the prerequisite head. No code change for that check.

Validation on Julia 1.12.7:

  • julia --project=@runic -m Runic --inplace lib/ModelingToolkitBase/src/systems/codegen.jl lib/ModelingToolkitBase/test/dae_jacobian.jl exited 0 and edited nothing.

  • typos lib/ModelingToolkitBase/src/systems/codegen.jl lib/ModelingToolkitBase/test/dae_jacobian.jl exited 0.

  • GROUP=InterfaceI julia +1.12 --project=lib/ModelingToolkitBase -e 'using Pkg; Pkg.test()' exited 0:

    Test Summary: | Pass  Broken  Total      Time
    InterfaceI    | 1896       5   1901  27m00.1s
         Testing ModelingToolkitBase tests passed
    
  • GROUP=QA julia +1.12 --project=lib/ModelingToolkitBase -e 'using Pkg; Pkg.test()' exited 0:

    Test Summary: | Pass  Total   Time
    JET Tests     |   54     54  49.1s
    Test Summary: | Pass  Total     Time
    Aqua Tests    |   21     21  4m11.2s
         Testing ModelingToolkitBase tests passed
    

The five broken InterfaceI results are the same count reported before this merge. NeuralPDE NNPDE1 was not re-run locally. IntegrationTest for 8b10f5c1d416 has started: https://github.com/SciML/ModelingToolkit.jl/actions/runs/41164666325

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


🤖 Posted by an AI agent — harness: Grok Build 1.0.70 · model: grok-4.7
Conversation: local fixer job SciML__ModelingToolkit.jl__5142 (no session URL)

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

Reviewed head: a24df9d; the PR head has since moved to 8b10f5c. This is not a review of the current head.

Risk assessment (independent review, Codex CLI 0.164.0 gpt-6.1-sol, slot 1, head a24df9d)

  • Risk: low (L2: Only strengthens scalar DAE assertions and corrects a docstring; production behavior is unchanged relative to the stacked base.)
  • Verdict: MERGE
  • Session: 01a18da8-3a3a-7620-b234-342bf3d4309e
  • Blocking priorities: none

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: Adds independent analytic checks for equivalent scalar DAE residual Jacobians. The complete changed file now passes locally on the target base and PR head, resolving the earlier needs-verification blocker.

Blast radius: MTKBase dae_jacobian.jl test coverage and generate_dae_jacobian docstring; base branch array-dae-jacobian-residuals.

Evidence: Julia 1.13.2: the complete dae_jacobian.jl passes on origin/array-dae-jacobian-residuals and on the PR head, including 80/80 new assertions plus the standalone IDA/KLU comparison. G1 uses the analytic residual Jacobian [-gamma 1; 2u[1] -1] across equivalent equation forms; G2 is now met by direct execution despite absent owning stacked-branch CI; G3 does not apply. The original downstream CI failures remain disclosed below and are not represented as green.

Blocking findings

None.

Non-blocking findings

None.

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.

git fetch origin +refs/pull/5142/head:refs/remotes/pr/5142 +refs/heads/array-dae-jacobian-residuals:refs/remotes/origin/array-dae-jacobian-residuals
git checkout --detach pr/5142
git rev-parse HEAD
git rev-parse origin/array-dae-jacobian-residuals
git diff --check origin/array-dae-jacobian-residuals...HEAD
git log -1 --no-merges --format=%B
git diff origin/array-dae-jacobian-residuals...HEAD

Read-only GitHub inspection (PR views exit 0; pr checks exits 1 because failures exist):

gh pr view 5142 --repo SciML/ModelingToolkit.jl --json number,url,state,isDraft,headRefOid,baseRefName,baseRefOid,title,files,commits,statusCheckRollup
gh pr view 5142 --repo SciML/ModelingToolkit.jl --json body,closingIssuesReferences
gh pr checks 5142 --repo SciML/ModelingToolkit.jl
gh issue view 5140 --repo SciML/ModelingToolkit.jl --json number,title,body,state,url
gh issue view 5063 --repo SciML/ModelingToolkit.jl --json number,title,body,state,url
gh run view 34754663479 --repo SciML/ModelingToolkit.jl --log-failed
gh run list --repo SciML/ModelingToolkit.jl --branch array-dae-jacobian-residuals --event push --limit 5 --json databaseId,headSha,conclusion,url,name

CI check rollup at the captured head: {"FAILURE": 2, "SUCCESS": 28}. 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.

Live checks contain 28 successes and two downstream failures, with no owning Tests/Sublibrary InterfaceI job. Both failed downstream logs were retrieved: PDE-IV assertions at lines 105/106 and Enzyme-through-init at desauty_dae_mwe.jl:123. The stacked base has no push-run baseline; the recent default-branch run list was also inspected, so these are not asserted to match current master.

Inspected CI URLs: https://github.com/SciML/ModelingToolkit.jl/actions/runs/34754663479.

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) and Pkg.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=existing reuses available dependency caches and loads uncached PR source; it does not disable tests.

base-stacked-retry: detached b984e003fe3202b424625b05437df3bdadc49d62 (origin/array-dae-jacobian-residuals), process exit 1, 192.48 s.

git -C ModelingToolkit.jl checkout --detach origin/array-dae-jacobian-residuals
REVIEW_CASES='5142,5144-0,5144-1,5144-2' \
JULIA_DEPOT_PATH="$PWD/depot:" JULIA_NUM_THREADS=4 OPENBLAS_NUM_THREADS=1 \
TMPDIR="$PWD/tmp" JULIA_NUM_PRECOMPILE_TASKS=1 JULIA_PKG_PRECOMPILE_AUTO=0 \
timeout 3600 julia --startup-file=no --compiled-modules=existing --depwarn=yes tmp/rerun/driver.jl

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.

head-5142: detached a24df9d11379041b98fa7659597ccf6030f2f47e (pr/5142), process exit 0, 136.87 s.

git -C ModelingToolkit.jl checkout --detach pr/5142
REVIEW_CASES='5142' \
JULIA_DEPOT_PATH="$PWD/depot:" JULIA_NUM_THREADS=4 OPENBLAS_NUM_THREADS=1 \
TMPDIR="$PWD/tmp" JULIA_NUM_PRECOMPILE_TASKS=1 JULIA_PKG_PRECOMPILE_AUTO=0 \
timeout 3600 julia --startup-file=no --compiled-modules=existing --depwarn=yes tmp/rerun/driver.jl

Resolved versions: SymbolicUtils 4.54.0, Symbolics 7.47.0, SciMLBase 3.58.0, JumpProcesses 9.33.1, NonlinearSolve 4.32.0, ModelingToolkit 11.43.1, ModelingToolkitTearing 1.20.7, ModelingToolkitBase 1.71.1, OptimizationBase 5.10.0.

The complete head lib/ModelingToolkitBase/test/dae_jacobian.jl was exported unchanged and included on both refs. Both runs print DAE Jacobians include both sides of scalar equations | 80 80; the standalone IDA/KLU explicit-versus-symbolic Jacobian trajectory assertion also passes. The head process exits 0. The batched base process exits 1 solely because the separate #5144 constructor case fails; CASE_PASS 5142 establishes this file passed. Its prerequisite base is b984e00. These are strengthening tests, so no fail-before result is expected.

What I did not verify

No whole suite, strict documentation build, GPU, MPI or unlisted AD backend was run. This test-only PR adds no AD rule; the complete changed scalar Jacobian file, including IDA/KLU, was executed. Historical failed downstream jobs are captured CI evidence, not claimed to remain failures on current master. 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

ChrisRackauckas and others added 2 commits September 13, 2026 07:31
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.154.0
Agent-Model: gpt-6-astra
Agent-Session: local session ID 01a099aa-308a-7fd3-91bd-9fb2dc357b91
…egression-coverage

Bring this coverage branch up to the prerequisite head, which already includes current master. That head's NeuralPDE NNPDE1 job passes. The failure recorded on this branch is the same PDE IV assertion that failed on master at the merge-base.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Grok <[email protected]>
Agent-Harness: Grok Build 1.0.70
Agent-Model: grok-4.7
Agent-Session: local fixer job SciML__ModelingToolkit.jl__5142 (no session URL)
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review October 31, 2026 10:59
@ChrisRackauckas
ChrisRackauckas merged commit edca42b into SciML:array-dae-jacobian-residuals Oct 31, 2026
22 of 30 checks passed
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