Repository navigation
Preserve array flow balances when expanding connections - #5239
Draft
ChrisRackauckas-Claude wants to merge 3 commits into
Draft
ChrisRackauckas-Claude wants to merge 3 commits into
ChrisRackauckas-Claude wants to merge 3 commits into
Conversation
`expand_connections` expanded an array flow balance into one scalar equation per element, so a network with array-valued flow connectors grew its symbolic equation count with the array size (4 -> 103 equation blocks from 1 to 100 rows in the reproducer of SciML#5119). When every flow variable in a connection set has the same shape, emit a single broadcast conservation equation instead. Connection sets with mixed axes keep the existing element-wise construction. The existing stream-connector assertion compared against scalarized equations, so it now scalarizes the array flow equation before comparing. Adds `test/array_flow_connections.jl`, which checks that the connection equation count and symbolic size are independent of the array shape and that the generated equations still express flow conservation. Fixes SciML#5119. 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
AayushSabharwal
left a comment
Member
There was a problem hiding this comment.
What's the point? TearingState will immediately scalarize anyway?
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-5239/log.txt
Member
Merged the default branch into this PR (clean merge, no conflicts; head 6a42339) 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 |
This branch has not been deployed
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.
Adopts stalled #5135 onto current master:
expand_connectionswas expanding identical-shape array flow balances into one scalar equation per element (4→103 blocks for 1→100 rows). When every flow variable in a connection set shares the same axes, emit one broadcast conservation equation instead; mixed layouts keep the elementwise fallback. Cherry-pickedf393dd60with original authorship; no further code changes.Review comments on #5135
Only bot benchmark comments (Julia v1 / vlts); no human review comments. Benchmarks were roughly neutral vs master at the time.
Fail-before / pass-after
Issue reproducer (Julia 1.12.7, scratch env with this checkout's ModelingToolkitBase):
Regression
lib/ModelingToolkitBase/test/array_flow_connections.jl:Verification commands
InterfaceI tail:
The single InterfaceI failure is unrelated:
`full_equations` doesn't recurse infinitelyinodesystem.jl:1681(!(process_running(proc))after ~3 min under heavy machine load). Stream Connect and Array Flow Connections both passed fully.Not verified
GROUP=All/ QA / other Interface groupsodesystem.jlrecursion-guard flake reproduces on clean master (strongly suspected load flake; not touched by this PR)Reviewer pushback
0 .* wrap(v) ~ ±f₁ .+ ±f₂ …the preferred array form vs keeping scalarized equations and fixing structure later in Compile and generate code for whole-array equation models without scalarizing per element (tracking) #5139?Fixes #5119
Please ignore this draft until reviewed by @ChrisRackauckas.
Risk assessment
expand_connectionsFlow branch /_flow_equations_from_idxs!onlyHarness: Cursor Agent CLI 2026.09.28-64d2043 · Model: auto · Transcript: /log.txt
Risk assessment (orchestrator)
expand_connectionschanges its pre-compile form (e.g.broadcast(*, 0, Q) ~ broadcast(+, Q, Q')), which reverses the earlier deliberate choice of scalar equations.Head orchestration and review routing: Claude Code (model: claude-opus-5-5[1m]), https://claude.ai/code/session_01H4fXBChQshAwfpLMCpEvAX
Risk assessment (independent review, codex-cli gpt-6.1-sol, reviewed head d24d090)
expand_connections. Equation blocks change from scalar balances to a broadcast balance for matching shapes. Scalar flows and the mixed-shape fallback retain their construction. Numerical conservation is preserved; consumers inspecting unscalarized equations see the intended representation change.JULIA_NUM_THREADS=4, the committed array-flow regression passed 1250/1250, and the extracted VecPin assertion fromstream_connectors.jlpassed (process exit 0). Loading the exact base_flow_equations_from_idxs!implementation into the same package and running the unchanged regression produced 1248 passes, 2 failures, atallequal(counts)andallequal(sizes)(exit 1). Additional local probes passed 10/10 for a three-component connection and 4/4 for mixed inner/outer signs. CI: 42 pass, 3 fail, 63 pending, 1 skipped; the failed jobs match master as detailed below.🤖 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