Skip to content

Fix symbolic derivatives of multi-source stream mixing - #5213

Draft
ChrisRackauckas-Claude wants to merge 6 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/5192-instream-rt-derivative
Draft

ChrisRackauckas-Claude wants to merge 6 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/5192-instream-rt-derivative

Conversation

@ChrisRackauckas-Claude

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

Copy link
Copy Markdown
Member

Register symbolic derivatives for instream_rt and its regularized positive-part weights, including the dependence of every weight on total inflow. Multi-source stream problems now evaluate generated Jacobians with jac = true; regression tests cover constant and state-dependent flows, reversal, inner/outer layouts, and smoothing boundaries.

Closes #5192 (#5192).

Derivative

For inner flows let s = Σ max(-mᵢ, 0), adding Σ max(mⱼ, 0) for outer flows. The existing runtime uses pₖ = max(-mₖ, 0) in each weight, for both connector layouts. With ε = 1e-4, it computes

α(s) = 0                              if s ≤ 0
       (s/ε)² (3 - 2s/ε)              if 0 < s < ε
       1                              if s ≥ ε
wₖ = α(s)pₖ + (1 - α(s))ε
W = Σ wₖ,    F = Σ wₖhₖ / W

The derivative registrations apply the chain and quotient rules:

α′(s) = 6s/ε² (1 - s/ε)    for 0 < s < ε; otherwise 0
∂s/∂mᵢ = -1[mᵢ < 0]       for an inner flow
         +1[mᵢ > 0]       for an outer flow
∂wₖ/∂mᵢ = -δₖᵢ α(s)1[mₖ < 0] + α′(s)(pₖ - ε) ∂s/∂mᵢ
∂F/∂mᵢ = Σ (hₖ - F)(∂wₖ/∂mᵢ) / W
∂F/∂hᵢ = wᵢ / W

@register_derivative registers the two partials of _positivemax and a variadic rule for instream_rt; the latter assembles these expressions for each argument. Including ∂s/∂mᵢ is essential inside the regularization interval because changing one flow changes every weight. At s = 0 and s = ε, α′ = 0 is the continuous derivative. At a positive-part kink, the rule chooses the inactive branch's derivative, zero; a unique classical derivative need not exist there. Mixing retains the existing runtime's flow signs and denominator, including its existing domain restrictions.

Verification

Julia 1.12.4, Symbolics 7.41.1, SymbolicUtils 4.48.0, SciMLBase 3.56.0. Local package paths point to this checkout; the first depot and all environments/temporary files are under the job directory, with the shared depot used as a read-only fallback.

export TMPDIR=<job>/tmp
export JULIA_DEPOT_PATH=<job>/scratch/depot:~/.julia
export JULIA_PKG_PRECOMPILE_AUTO=0
export JULIA_NUM_PRECOMPILE_TASKS=4

Before / after

The issue's unmodified reproducer failed before the fix:

ERROR: LoadError: MethodError: no method matching Float64(::Num)

The final runtime regression file was also run against a clean git archive of the unfixed source, developed only in scratch/before-env:

julia +1.12.4 --compiled-modules=existing --project=<job>/scratch/before-env -e 'using Test, ModelingToolkitBase, Symbolics, SciMLBase; using ModelingToolkitBase: t_nounits as t, D_nounits as D; import SymbolicUtils as SU; include("lib/ModelingToolkitBase/test/instream_jacobian.jl")'
Test Summary:                | Pass  Error  Total   Time
instream runtime derivatives |   32     24     56  41.7s

With the fix, scratch/regression.jl imports Test, ModelingToolkit, ModelingToolkitBase, Symbolics, SciMLBase, imports t_nounits, D_nounits, and SymbolicUtils as SU, then includes the same regression file:

julia +1.12.4 --project=<job>/scratch/env <job>/scratch/regression.jl
Test Summary:                | Pass  Total   Time
instream runtime derivatives |   56     56  27.5s
Test Summary:                | Pass  Total   Time
Multi-source stream Jacobian |    5      5  18.3s

The mixer Jacobians use atol=1e-8, rtol=0 against central differences; the constant-flow case also checks exact mixing weights 1/3 and 2/3. At the C¹ smoothing cutoff, the high-precision difference error converged from approximately 3.4e-6 at step 1e-14 to 3.7e-12 at step 1e-20; assertion tolerances were unchanged. A separate comparison of original and refactored primal weights passed 147 exact checks across Float32, Float64, and BigFloat.

Relevant group and QA

The complete ModelingToolkitBase InterfaceI group exited zero:

GROUP=InterfaceI julia +1.12.4 --project=<job>/scratch/env -e 'using Pkg; Pkg.test("ModelingToolkitBase")'
Test Summary: | Pass  Broken  Total      Time
InterfaceI    | 1802       5   1807  59m44.5s
3585.158969 seconds (1.73 G allocations: 85.664 GiB, 2.65% gc time, 90.68% compilation time: 15% of which was recompilation)
     Testing ModelingToolkitBase tests passed

All five broken markers belong to existing tests; this change adds none. This complete run supersedes an earlier interrupted attempt.

Package-wide JET QA was compared against unmodified baseline 0459027b in a separate worktree (scratch/baseline-worktree). Both checkouts report the same package-wide finding count; after normalizing absolute checkout paths and Moshi-generated ##And#N / ##Call#N counters, the diagnostic lists are identical:

Baseline package-wide JET errors: 234
Branch package-wide JET errors: 234
Normalized error-list diff: 0 bytes
Added errors: 0
Removed errors: 0
# branch
JET Tests     |   54     54  21m04.4s
Quality Assurance: JET-test failed
  ═════ 234 possible errors found ═════

# baseline worktree
JET Tests     |   54     54  11m37.1s
Quality Assurance: JET-test failed
  ═════ 234 possible errors found ═════

No report names the new derivative helpers. Raw lists differ only by worktree path and process-local generated-match counters; those are not new errors introduced by this branch.

Formatting and spelling

julia +1.12.4 --project=@runic -e 'using Runic; exit(Runic.main(ARGS))' -- --check lib/ModelingToolkitBase/src/systems/connectors.jl lib/ModelingToolkitBase/test/instream_jacobian.jl lib/ModelingToolkitBase/test/stream_connectors.jl
typos lib/ModelingToolkitBase/src/systems/connectors.jl lib/ModelingToolkitBase/test/instream_jacobian.jl lib/ModelingToolkitBase/test/stream_connectors.jl
git diff --check

All exited 0 with no diagnostics.

Not verified / reviewer judgment

The full repository suite, other Julia versions, GPU and downstream groups, and documentation build were not run. Review the inactive-branch (zero) derivative convention at positive-part kinks, where a unique classical derivative does not exist. The cubic smoothing boundaries use their continuous derivative. The runtime's existing inner/outer flow weighting is preserved.

Risk assessment

  • Risk: medium
  • Blast radius: symbolic derivatives of stream mixing and its positive-part regularization; models requesting generated Jacobians or derivatives through these operations.
  • Evidence: failing-before/passing-after tests, finite-difference Jacobians, switching-point checks, and 147 exact primal-weight comparisons; group results above.
  • Independent review: not performed under the working-alone assignment; requires review by @ChrisRackauckas.
  • Merge: needs human review; draft only, no merge requested.

Please ignore this draft until reviewed by @ChrisRackauckas.

Codex gpt-6-astra wrote the derivative, Cursor Agent auto finished it. Transcripts: <job>/log.txt (Codex) and <job>/log-cursor.txt (Cursor Agent).

Risk assessment (independent review, codex-cli gpt-6-astra, reviewed head 2ee26d9)

  • Risk: medium
  • Blast radius: generated derivatives/Jacobians for multi-source stream connections and their regularized positive-part weights. The primal mixing formula and inner/outer flow signs are preserved.
  • Evidence: Julia 1.13.1 local regression run exited 0: runtime derivatives 56/56; generated multi-source mixer Jacobians 5/5. It covers reversed flow, the smoothing interval/cutoff, zero flow, inner/outer layouts, finite differences, and analytic mixing weights. Current three CI failures match master; 63 checks are pending. Run URLs and command are below.
  • Independent review: codex-cli 0.163.0 gpt-6-astra rated it medium, high confidence: the chain/quotient rules include every weight's dependence on total inflow, and the generated Jacobians pass independent local validation.
  • Merge: needs human review — numerical derivative policy at nonsmooth kinks and medium blast radius; no blocking correctness finding.

🤖 Posted by an AI agent — harness: codex-cli · model: gpt-6-astra (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.

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

  • Risk: medium (M2: Changes generated stream-mixing Jacobians on existing models, with independent analytic and finite-difference accuracy evidence.)
  • 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: Registers smoothing and quotient-rule derivatives for multi-source stream mixing. The complete stream connector file passes locally on the head, including independent high-precision finite-difference and analytic-weight checks that error on the target base.

Blast radius: instream_rt and _positivemax symbolic derivative lowering, including state-dependent flow reversal and smoothing boundaries.

Evidence: Julia 1.13.2: the entire changed stream_connectors.jl runs with full ModelingToolkit loaded, including instream_jacobian.jl. Head runtime derivative checks pass 56/56 and guarded full-system mixer checks pass 5/5; existing array/scalarization checks and top-level assertions also pass. Base runtime derivative checks have 32 passes / 24 errors and stop before the mixer block. G1 uses high-precision finite differences and exact mixing weights 1/3 and 2/3. G2 is exercised locally and in the cited same-head InterfaceI CI. G3 has no mutable global-default change: STREAM_EPS retains the prior constant value.

Blocking findings

None.

Non-blocking findings

  1. lib/ModelingToolkitBase/test/instream_jacobian.jl:27: Commit the reported primal-value/type comparison across Float32, Float64 and BigFloat so future edits to smoothing constants cannot silently change supported scalar behavior.

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/5213/head:refs/remotes/pr/5213 +refs/heads/master:refs/remotes/origin/master
git checkout --detach pr/5213
git rev-parse HEAD
git rev-parse origin/master
git diff --check origin/master...HEAD
git log -1 --no-merges --format=%B
git diff origin/master...HEAD

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

gh pr view 5213 --repo SciML/ModelingToolkit.jl --json number,url,state,isDraft,headRefOid,baseRefName,baseRefOid,title,files,commits,statusCheckRollup
gh pr view 5213 --repo SciML/ModelingToolkit.jl --json body,closingIssuesReferences
gh pr checks 5213 --repo SciML/ModelingToolkit.jl
gh issue view 5192 --repo SciML/ModelingToolkit.jl --json number,title,body,state,url
gh run view 38856282076 --repo SciML/ModelingToolkit.jl --log-failed
gh run view 38856282078 --repo SciML/ModelingToolkit.jl --log-failed
gh run view 38856282685 --repo SciML/ModelingToolkit.jl --log-failed
gh run list --repo SciML/ModelingToolkit.jl --branch master --event push --limit 5 --json databaseId,headSha,conclusion,url,name
gh run view 38846662285 --repo SciML/ModelingToolkit.jl --log-failed
gh run view 38894707737 --repo SciML/ModelingToolkit.jl --log-failed
gh run view --repo SciML/ModelingToolkit.jl --job 116866101283 --log
gh run view --repo SciML/ModelingToolkit.jl --job 116868104008 --log

CI check rollup at the captured head: {"FAILURE": 7, "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 InterfaceI CI passed 1652 assertions with 3 existing broken markers and includes stream_connectors.jl with ModelingToolkit loaded, so both the runtime derivative and guarded full-system mixer testsets are reachable. MTKBase InterfaceI logs also show Stream Connect Test 76/76 before unrelated Parsing/Latexify errors. Historical master 38846662285 matches SII/MTK Forward Mode failures; no exact historical base match for all Parsing/Latexify errors was established from available logs.

Inspected CI URLs: https://github.com/SciML/ModelingToolkit.jl/actions/runs/38856282076, https://github.com/SciML/ModelingToolkit.jl/actions/runs/38856282078, https://github.com/SciML/ModelingToolkit.jl/actions/runs/38856282685, https://github.com/SciML/ModelingToolkit.jl/actions/runs/38856282685/job/116866101283, https://github.com/SciML/ModelingToolkit.jl/actions/runs/38856282669/job/116868104008, https://github.com/SciML/ModelingToolkit.jl/actions/runs/38846662285, https://github.com/SciML/ModelingToolkit.jl/actions/runs/38894707737.

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-master-rootcontext-retry: detached 550a27cca63cbe6d7b64bcb2920440aaff9eaa55 (origin/master), process exit 1, 487.54 s.

git -C ModelingToolkit.jl checkout --detach origin/master
REVIEW_CASES='5182,5190,5190-bench,5202,5205-root,5205-contract,5205-ad,5213,5221,5202-bench,5221-bench' \
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 10.0.1, NonlinearSolve 4.32.0, ModelingToolkit 11.47.0, ModelingToolkitTearing 1.20.7, ModelingToolkitBase 1.79.0, OptimizationBase 5.10.0.

head-5213: detached 2ee26d9a16520d1ef6a9ac2184c6537b2de5ce00 (pr/5213), process exit 0, 227.63 s.

git -C ModelingToolkit.jl checkout --detach pr/5213
REVIEW_ENV_DIR=tmp/rerun/env-extra \
REVIEW_CASES='5213' \
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.

Exported the full lib/ModelingToolkitBase/test/stream_connectors.jl and its included new instream_jacobian.jl, then included them with ModelingToolkit loaded on both refs. Base: runtime derivatives 32 passes / 24 errors, because derivative expressions remain symbolic in numeric comparisons; the file stops there. Head: existing named testsets pass 2+1 assertions, runtime derivatives 56/56, full-system mixer 5/5, and all intervening top-level assertions pass; process exit 0. The head uses the temporary extra environment for the existing StandardLibrary examples. No assertion was removed, skipped or loosened.

What I did not verify

No whole suite, GPU, Reactant, MPI or exhaustive floating-type/backend matrix was run. The symbolic derivative rules themselves and the guarded full-system Jacobian path were executed locally. A dedicated Float32/Float64/BigFloat primal-type comparison remains a nonblocking coverage suggestion, not a claimed reviewer run. 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

🤖 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 15dbf2d)

Merged current master normally, without conflicts or rewritten commits. This imports the upstream Symbolics parsing/Latexify compatibility fix and current indexing/sensitivity integration fixes. The derivative implementation is unchanged; the diff against master remains the original three files.

Before changing code, read all seven failed checks and compared their latest executed default-branch push jobs. Documentation, downstream SciMLBase/SymbolicIndexingInterface, downstream SciMLSensitivity/Core8, and ModelingToolkitBase InterfaceI/RegressionI on Julia lts and 1 all pass there. The newest Sublibrary CI run skipped its test matrix, so the comparison uses the preceding executed matrix. The exact Parsing and Latexify failures are addressed by the upstream compatibility commit linked below. The earlier documentation link timeout did not recur locally.

Local validation

Julia 1.12.4, four Julia threads, one BLAS thread, automatic package precompilation disabled. Temporary environment/file operands below are abbreviated with descriptive shell variables; no machine-specific paths are included.

GROUP=InterfaceI julia --compiled-modules=existing --project -e 'using Pkg; Pkg.test("ModelingToolkitBase"; julia_args = ["--compiled-modules=existing"])'
Test Summary: | Pass  Broken  Total      Time
InterfaceI    | 2182       5   2187  34m26.9s
     Testing ModelingToolkitBase tests passed

The five broken markers are existing tests; this fix adds none.

GROUP=QA julia --compiled-modules=existing --project -e 'using Pkg; Pkg.test(; julia_args = ["--compiled-modules=existing"])'
Test Summary: | Pass  Total      Time
QA            |   40     40  15m31.8s
     Testing ModelingToolkit tests passed
CI=true GROUP=RegressionI julia --compiled-modules=existing --project -e 'using Pkg; Pkg.test("ModelingToolkitBase"; julia_args = ["--compiled-modules=existing"])'
Test Summary:         | Pass  Total     Time
Latexify recipes Test |    5      5  1m00.0s
     Testing ModelingToolkitBase tests passed

The first RegressionI run passed the committed 50.tex comparison and initialized four ignored, untracked fixtures. The confirmation above compared all five. Those generated fixtures were removed from the checkout afterward; no committed reference was edited by this session.

julia --compiled-modules=existing --project="$ROOT_TEST_ENV" -e 'using Test, ModelingToolkit; @testset "Full stream connectors with ModelingToolkit" begin include("lib/ModelingToolkitBase/test/stream_connectors.jl") end'
Test Summary:                               | Pass  Total     Time
Full stream connectors with ModelingToolkit |   83     83  3m28.0s

ROOT_TEST_ENV is the captured root Pkg.test environment, with both packages developed from the checkout. This executes the guarded generated mixer Jacobian tests with ModelingToolkit loaded.

DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --compiled-modules=existing --project=docs docs/make.jl

Exit 0, with doctests and link checking enabled:

[ Info: Doctest: running doctests.
[ Info: ExpandTemplates: expanding markdown templates.
[ Info: CrossReferences: building cross-references.
[ Info: CheckDocument: running document checks.
[ Info: Populate: populating indices.
[ Info: RenderDocument: rendering document.
[ Info: HTMLWriter: rendering HTML pages.

Dependency world-age/compiler warnings, a redirect warning, and HTML size warnings were emitted; no fatal build error occurred. Docs was paused while QA's nested precompile checks ran, then resumed in the same process.

julia --project=@runic -m Runic --inplace lib/ModelingToolkitBase/src/systems/connectors.jl lib/ModelingToolkitBase/test/instream_jacobian.jl lib/ModelingToolkitBase/test/stream_connectors.jl
typos lib/ModelingToolkitBase/src/systems/connectors.jl lib/ModelingToolkitBase/test/instream_jacobian.jl lib/ModelingToolkitBase/test/stream_connectors.jl
git diff --check
git diff --cached --check

All exited 0 with no diagnostics; Runic made no edits.

Before / after compatibility evidence

Archived the pre-merge Parsing test and Latexify test/fixtures from head 2ee26d9a16520d1ef6a9ac2184c6537b2de5ce00, and ran them in the same resolved ModelingToolkitBase test environment as the merged files:

julia --compiled-modules=existing --project="$BASE_TEST_ENV" -e 'using Test; @testset "Unfixed Parsing Test" begin include(ENV["UNFIXED_PARSING_FILE"]) end'
julia --compiled-modules=existing --project="$BASE_TEST_ENV" -e 'using Test; @testset "Updated Parsing Test" begin include("lib/ModelingToolkitBase/test/variable_parsing.jl") end'
CI=true julia --compiled-modules=existing --project="$BASE_TEST_ENV" -e 'using Test; @testset "Unfixed Latexify Reference Test" begin include(ENV["UNFIXED_LATEXIFY_FILE"]) end'

The archived-file operands above use equivalent environment lookups to avoid publishing temporary paths. Observed output:

# pre-merge Parsing file: exit 1
ArgumentError: Variable x must have default of matching size. Got [1, 2] with size (2,).
Unfixed Parsing Test |   17      1     18  50.2s

# merged Parsing file: exit 0
Updated Parsing Test |   48     48  51.5s

# pre-merge Latexify fixture: exit 1
Reference Test for "50.tex" failed:
Unfixed Latexify Reference Test |     1      1  1m36.0s

The merged committed Latexify fixture passes in both complete RegressionI runs. This session changes no assertions or tolerances; it imports the already merged upstream compatibility fix.

Post-push CI check

CI started for this exact head; no wait for completion was performed. Spell Check had already failed: typos 1.50.1 flags four uses of the local identifier anc in lib/ModelingToolkitBase/src/atomic_array_dict.jl:553-555. That file is identical to master. Running the same typos version over a clean master checkout at d6e93c5bbe0484ad6ee155b860a617af38f963cd reproduces all four diagnostics (exit 2); the branch produces the identical diagnostic list. All three PR-diff files pass typos 1.50.1 (exit 0), as they did the installed 1.47.0 version. A separate read-only baseline investigation traced the identifier to commit 0bdc42b077645263c2c7e161eabed412be92b2ec: its parent passes the same checker, while that commit has the four diagnostics. This pre-existing failure is left unchanged under the fix assignment's instructions. Dependabot Auto-merge also reported a startup failure; no merge was requested or attempted.

Limits and review

No local downstream package suites, other Julia versions, GPU tests, complete repository suite, or package-wide JET analysis were run. The official root QA runner has JET disabled. The optional reviewer suggestion to commit the additional primal-type matrix was outside this CI refresh. Existing medium risk remains; the new head needs an independent review. No merge or approval was performed.

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__ModelingToolkit.jl__5213 (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 b49e36b)

Merged current upstream master into the PR branch. This imports the upstream ancestor identifier spelling that clears the four Typos diagnostics in record_ancestor_value. The stream-derivative patch has the same stable patch ID against the updated base.

Local validation

"$TYPOS" . with Typos 1.50.1 matched the failed CI job. The starting head and its clean base each exited 2 with four diagnostics reporting that anc should be and. Current master and the merged head each exited 0 with no diagnostics. "$TYPOS" "${PR_FILES[@]}", julia --project=@runic -m Runic --inplace "${CHECK_FILES[@]}", and git diff --check upstream/master...HEAD all exited 0. Runic made no edits. The file arrays contain the PR diff and, for Runic, the source file carrying the spelling fix.

GROUP=InterfaceI timeout 7200 julia --compiled-modules=existing --project -e 'using Pkg; Pkg.test("ModelingToolkitBase"; julia_args = ["--compiled-modules=existing"])'
Test Summary: | Pass  Broken  Total      Time
InterfaceI    | 2263       5   2268  34m01.6s
     Testing ModelingToolkitBase tests passed
GROUP=QA timeout 7200 julia --compiled-modules=existing --project -e 'using Pkg; Pkg.test(; julia_args = ["--compiled-modules=existing"])'
GROUP=QA JULIA_LOAD_PATH="@:$QA_SANDBOX" timeout 7200 julia --startup-file=no --compiled-modules=existing --check-bounds=yes --project="$QA_SANDBOX" runtests.jl

Aqua briefly spawned a fourth Julia process during the first command. I stopped that invocation (exit 143) and ran the official runner from the test directory with the resolved test sandbox and the three-process limit. The full QA retry on Julia 1.12.4 exited 1.

Test Summary:                                  | Pass  Fail  Total      Time
QA                                             |   38     2     40  45m28.2s
    Persistent tasks                           |          1      1  28m34.3s
    No unapproved public reexports             |          1      1      1.1s

The six reexports match current master CI. The clean master control ran Aqua 0.8.19 with the same Julia flags and the official persistent-task threshold.

GROUP=QA JULIA_LOAD_PATH="@:$BASE_SANDBOX" timeout 7200 julia --startup-file=no --compiled-modules=existing --check-bounds=yes --project="$BASE_SANDBOX" "$QA_CONTROL"
Test Summary:    | Fail  Total     Time
Persistent tasks |    1      1  8m00.2s

It exited 1 with the same 60-second precompile-process exit timeout after loading ModelingToolkit. Standard master CI passed that Aqua check. The prior ModelingToolkitBase ExplicitImports failure reproduced on master with Symbolics 7.48.0, and the ModelOrderReduction failure reproduced on master before its downstream fix landed.

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 01a20191-564a-7da2-b044-a1e4f5e3bd1e (no session URL)

ChrisRackauckas and others added 2 commits September 26, 2026 14:39
Differentiate flow-weighted streams through the cubic inflow regularization
and use the inactive branch at positive-part kinks. Cover the runtime rule
and generated mixer Jacobians, including reversed flow.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Codex <noreply@openai.com>
Agent-Harness: Codex CLI 0.157.1
Agent-Model: gpt-6-astra
Agent-Session: local session, transcript at /home/crackauc/sandbox/pm-agents/mtk/jobs/5192-codex/log.txt on amdci2.julia.csail.mit.edu
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Codex <noreply@openai.com>
Agent-Harness: Codex CLI 0.157.1
Agent-Model: gpt-6-astra
Agent-Session: local session, transcript at /home/crackauc/sandbox/pm-agents/mtk/jobs/5192-codex/log.txt on amdci2.julia.csail.mit.edu
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Devin <noreply@cognition.ai>
Agent-Harness: Devin CLI 3000.11.3 (conflict resolution), Claude Code 2.1.285 (orchestration)
Agent-Model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium
Agent-Session: local Claude session 3c311569-dda6-4687-bc9f-65febb212c33 (fleet master); Devin log /Users/chrisrackauckas/sandbox/master/fusion-fixes/SciML_ModelingToolkit.jl-5213/log.txt
@ChrisRackauckas

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

Merged the default branch into this PR (clean merge, no conflicts; head 2ef6ba7) 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
Conversation: local Claude session 3c311569-dda6-4687-bc9f-65febb212c33 (fleet master)

ChrisRackauckas and others added 2 commits October 16, 2026 05:32
Bring in the Symbolics parsing and Latexify compatibility fixes and the
current indexing and sensitivity integrations. Preserve the stream-mixing
derivative implementation and its regression coverage.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Codex <noreply@openai.com>
Agent-Harness: Codex CLI 0.164.0
Agent-Model: gpt-6.1-sol
Agent-Session: local fixer job SciML__ModelingToolkit.jl__5213 (no session URL)
@ChrisRackauckas

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

PR: #5213

Reviewed head: 15dbf2d
Raw SHA-256: 3029d06a4394dadc1dc8722ed05eb1ae2e803aa44b08e2e7e235749e7499e945
Source SHA-256: 277542f8d2a1ff65008b668fc4a8568ec1f1b2f5bfc13c93a20b34a4fe4643fb
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1d260-a9eb-71d1-8a9a-0cf87e861208
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes

Risk assessment

  • Risk: medium (M1)
  • Verdict: MERGE
  • Reviewed head: 15dbf2d

Review report

VERDICT: MERGE
Round: 1
Head: 15dbf2d
Slot: 1
CI: formatter or lint is not green
Session: 01a1d260-a9eb-71d1-8a9a-0cf87e861208

Risk

medium (M1: new Symbolics derivative methods change differentiation of existing stream-mixing expressions; the affected path is stream connector Jacobians).

Blocking findings

None.

  • Verdict: MERGE
  • Round: 1
  • Blocking priorities: none

Non-blocking findings

  • lib/ModelingToolkitBase/src/systems/connectors.jl:350: An isolated helper loop over 5.12 million calls took 4.09 ms on merge-base and 6.24 ms on HEAD outside the smoothing interval (minimum of five runs); inside it, 9.41 versus 9.46 ms. This shared-machine microbenchmark does not establish a solver slowdown. A representative stream-model RHS benchmark would establish whether the additional eager arithmetic matters.

What I ran

Review produced by an AI agent: codex-cli 0.164.0, model gpt-6.1-sol; local session 01a1d260-a9eb-71d1-8a9a-0cf87e861208 (no session URL).

Used Julia 1.13.2 and a scratch environment containing the exact HEAD sources, Symbolics 7.48.0, SymbolicUtils 4.56.1, and OrdinaryDiffEq 7.8.1. The checkout has no interpreter lock or Julia manifest. Preserved JULIA_DEPOT_PATH and used the requested TMPDIR.

  • Inspected git diff origin/master...HEAD, repository instructions, test groups, runner loading contexts, and newest commit attribution. git diff --check origin/master...HEAD, Runic --check, and typos on all three changed files exited 0.
  • julia --startup-file=no --check-bounds=yes --project=../scratch/env ../scratch/affected.jl: complete affected stream suite passed in both official loading contexts: base 76/76; full ModelingToolkit 83/83.
  • Same Julia invocation with ../scratch/probes.jl: 954 mixed-sign gradient/Hessian and normalization assertions, 31 smoothing-partial checks, and 3 independently derived mixer checks passed. Covered up to three inner and two outer streams, both flow directions, and smoothing scales, using ForwardDiff as the independent derivative implementation.
  • Same invocation with ../scratch/before.jl: separate first-order checks passed 954/954 plus 31/31; forward parity against extracted merge-base runtime functions passed 1764/1764 across Float32, Float64, and BigFloat. The merge-base analytic-gradient comparison then failed as expected: unresolved Differential expressions produced TypeError: non-boolean (Num) used in boolean context. The HEAD comparison against [0.48, -0.32, 0.4, 0.6] passed in probes.jl. An initial scratch-harness missing-import error was corrected before this replay; it was not a product failure.
  • uv run --locked python --version: Python 3.15.0; uv warned that --locked has no effect outside a Python project. No Python project/lock exists in this checkout.
  • Final git status --short was empty. No checkout edits, commits, pushes, or GitHub posts.

What I did not verify

Full InterfaceI/QA/downstream groups, other Julia or minimum dependency versions, documentation builds, end-to-end performance, or remote CI. The supplied CI status remains unverified; local formatting checks passed.

AUTHOR_GRADE: {"task":"bugfix","score":4,"difficulty":3,"rounds":1,"author_harness":"Codex CLI 0.164.0","author_model":"gpt-6.1-sol","note":"Affected suites and adversarial first/second derivative checks pass; forward values match merge-base across three numeric types, and the merge-base gradient remains unresolved. No blocking code findings; isolated helper timing warrants representative performance measurement."}

Head link: 15dbf2d


🤖 Posted by an AI agent — harness: codex-cli 0.164.0 · model: gpt-6.1-sol
Conversation: local session 01a1d260-a9eb-71d1-8a9a-0cf87e861208 (no session URL)

@ChrisRackauckas

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

PR: #5213

Reviewed head: 15dbf2d
Raw SHA-256: 1120eba5db2ee5867e1cc5176c0b88442c7d4f51e54f0185f67447a0ea5fdb0a
Source SHA-256: e5a33bcd7e869212045bfe7865c16028a856697933b8d1b085922b704937ab19
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1d328-7f2d-79d3-973e-5501a45183f5
Slot: 2
Confidence: unknown
Own risk fixed before author rating/discussion: yes

Risk assessment

  • Risk: medium (M1)
  • Verdict: MERGE
  • Reviewed head: 15dbf2d

Review report

VERDICT: MERGE
Round: 2
Head: 15dbf2d
Slot: 2
CI: formatter or lint is not green
Session: 01a1d328-7f2d-79d3-973e-5501a45183f5

Risk

medium (M1: new Symbolics derivative-rule methods change differentiation of stream-mixing terms and generated stream-model Jacobians; this is a peripheral connector path).

Blocking findings

None found.

  • Verdict: MERGE
  • Round: 2
  • Blocking priorities: none
  • Deferred P2 issues: none applicable

Non-blocking findings

None found. Inspection found no weakened assertions, self-derived expected Jacobian entries, added dependencies, or undocumented exports.

What I ran

Review harness: Codex CLI 0.164.0; requested reviewer model: gpt-6.1-sol. All runtime commands preserved the supplied layered JULIA_DEPOT_PATH and used the requested TMPDIR and scratch directory. The checkout remained clean.

  • git diff origin/master...HEAD, repository instructions, surrounding implementation, official test macro and group wiring. Merge base: d6e93c5bbe0484ad6ee155b860a617af38f963cd.
  • julia --version: 1.13.2. Created an isolated scratch environment referencing this checkout and matching repository compat constraints: ModelingToolkit 11.47.0, ModelingToolkitBase 1.80.0, Symbolics 7.48.0, SymbolicUtils 4.56.1, ForwardDiff 1.4.7, OrdinaryDiffEq 7.8.1.
  • julia --startup-file=no --compiled-modules=existing --check-bounds=yes --project=../scratch/env ../scratch/runtime.jl "$PWD": 1,623/1,623 assertions passed, exit 0. This ran the entire stream_connectors.jl through the official @mtktestset, including instream_jacobian.jl, with OrdinaryDiffEq initialization extensions loaded.
  • The same run checked forward-value and return-type identity against the original positive-max implementation for Float16, Float32, Float64 and BigFloat; 240 asymmetric-flow cases across five connector layouts and six flow scales against ForwardDiff; constant-stream preservation and stream-weight normalization; and Hessians inside and outside smoothing. Maximum scaled gradient discrepancy: 1.4283090652446732e-12.
  • julia --startup-file=no --compiled-modules=existing --check-bounds=yes --project=../scratch/env ../scratch/baseline.jl: isolated, unchanged merge-base stream functions retained unexpanded derivatives. Evaluating their generated gradient at [-1,-2,2,4] returned Num[0,0,0,0]; the analytic derivative is [4/9,-2/9,1/3,2/3]. This control exited 0: the observed failure is a wrong result, not a process error. The head's generated mixer Jacobian tests passed the independent 1/3 and 2/3 expectations.
  • julia --startup-file=no --project=@runic -m Runic --check --diff on all three changed files: exit 0. typos on those files and git diff --check origin/master...HEAD: exit 0.
  • uv run --locked python --version: Python 3.15.0, with the warning that --locked has no effect outside a project.

What I did not verify

No tracked Julia manifest, interpreter pin, Python project, or uv.lock exists; dependencies were resolved into the scratch manifest, and no locked project Python interpreter could be verified. I did not run the whole InterfaceI group, QA, downstream suites, or other Julia versions. I did not inspect PR discussion, author ratings, earlier reviews, or remote CI; the supplied non-green CI status still requires resolution by the owning head.

AUTHOR_GRADE: {"task":"bugfix","score":5,"difficulty":3,"rounds":2,"author_harness":"Codex CLI 0.164.0","author_model":"gpt-6.1-sol","note":"Affected stream suite and independent derivative, Hessian, smoothing and forward-preservation probes passed 1623 assertions. A merge-base control reproduced silently zero generated gradients despite nonzero analytic derivatives. Local formatting, spelling and whitespace checks passed; remote CI and broader suites were not verified."}

REVIEWER_GRADE: {"task":"bugfix","score":5,"rounds":2,"reviewer_harness":"codex","reviewer_model":"gpt-6.1-sol","verdict":"agree","note":"Both reviews find no blockers and medium M1 risk. The frozen independent 1623-assertion run corroborates the earlier affected-suite, derivative/Hessian, forward-parity, and merge-base failure evidence. The earlier helper microbenchmark is explicitly non-blocking and makes no unsupported solver-slowdown claim."}

Head link: 15dbf2d


🤖 Posted by an AI agent — harness: codex-cli 0.164.0 · model: gpt-6.1-sol
Conversation: local session 01a1d328-7f2d-79d3-973e-5501a45183f5 (no session URL)

Bring in the upstream ancestor identifier spelling in record_ancestor_value.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Codex <noreply@openai.com>
Agent-Harness: Codex CLI 0.170.0
Agent-Model: gpt-6.2-sol
Agent-Job: SciML__ModelingToolkit.jl__5213--20261122T044148Z-codex-gpt-6.2-sol
Agent-Session: local session 01a20191-564a-7da2-b044-a1e4f5e3bd1e (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.

No derivative rule for instream_rt: jac = true fails with Float64(::Num) on multi-source stream connections

2 participants