Skip to content

Preserve projected function array shapes#331

Merged
jgoppert merged 2 commits into
mainfrom
fix-function-projection-array-shapes
Jul 23, 2026
Merged

Preserve projected function array shapes#331
jgoppert merged 2 commits into
mainfrom
fix-function-projection-array-shapes

Conversation

@jgoppert

Copy link
Copy Markdown
Member

What changed

  • Preserve multidimensional array shapes across nested projected Modelica function calls.
  • Support record-valued function outputs and matrix slice assignments during Solve lowering.
  • Extend dimension inference for ranges, subscripts, builtins, dynamic parameters, and projected call results.
  • Consolidate declared-array scope initialization and shared slice helpers.
  • Add focused unit and end-to-end regressions for nested array-returning calls and record matrix projections.
  • Make the verification environment reproducible for GALEC schema checks, coverage, CasADi template runtimes, and WASM builds.
  • Resolve vulnerable VS Code build-time transitive dependencies.

Root cause and impact

Function projection could lose the declared shape of array-valued intermediate call results. Downstream dimension-generic functions and record field slice assignments then observed incomplete scalar bindings or dimensions, causing valid models to fail during Solve lowering. The projection scope now retains and materializes the complete array shape through nested calls and record fields.

Validation

  • nix develop --command cargo xtask verify quick
  • nix develop --command cargo xtask verify full
  • Coverage gate: PASS for 26 packages
  • MSL gates: PASS; 566/566 parse, 565/566 flatten, 545/566 DAE, 209/566 simulate
  • VS Code tests: 73 passed; npm audit reports 0 vulnerabilities
  • git diff --check

Signed-off-by: James Goppert <james.goppert@gmail.com>
@jgoppert
jgoppert force-pushed the fix-function-projection-array-shapes branch from 605056f to 4a80d59 Compare July 23, 2026 16:53
Signed-off-by: James Goppert <james.goppert@gmail.com>
@github-actions

Copy link
Copy Markdown

MSL Quality Gate Summary

Generated by cargo xtask repo msl pr-comment from CI result artifacts.

Scope MSL OMC Compile Balance Initial Balance Simulation
full v4.1.0 a96aa1a-cmake 545/532 (Δ0/0) 532/532 (Δ0/0) 532/532 (Δ0/0) 209/566 (Δ+39/0)

Deltas compare numerator/denominator against the resolved MSL quality baseline.
Baseline: quality gate v1, commit 08fac54, MSL v4.1.0, OMC OpenModelica 1.27.0~dev.beta.3.
Trace agreement vs baseline: high+near Δ+40, deviation Δ-2.

CI Gate Snapshot

These are the baseline-relative MSL stats checked by CI; IC progress is contextual unless simulation successes regress, and speed metrics are informational only.

Gate area Current (Δ vs baseline)
Structural floors parse 566 (0), flat 565 (0), DAE 545 (0), solve 446 (+65)
Balance floors balance 532/532 (0), init 532/532 (0)
Runtime gate IC progress 254/566 (+15), sim 209/566 (+39)
Trace floors acceptable 190/566 (+40), no-severe 165/566 (+16), compared 204 (+38)
CI gate details
CI gate metric Current Baseline Δ
Parse floor 566/566 566/566 0
Flatten floor 565/566 565/566 0
DAE/compile floor 545/566 545/566 0
Solve-IR floor 446/566 381/566 +65
Balance floor 532/532 532/532 0
Initial balance floor 532/532 532/532 0
IC progress 254/566 239/566 +15
Simulation floor 209/566 170/566 +39
Partial models ceiling 13 13 0
Unbalanced models ceiling 0 0 0
Trace acceptable floor 190/566 150/566 +40
Trace no-severe floor 165/566 149/566 +16
Trace compared floor (drop ≤2) 204 166 +38

Package Pass Rates

MSL Package n Ast Flat Dae Solve IC Sim
Overall 566 100% 100% 96% 81% 39% 34%
Per-package pass rates
MSL Package n Ast Flat Dae Solve IC Sim
Blocks 32 100% 100% 97% 84% 41% 47%
Clocked 76 100% 100% 100% 100% 82% 80%
ComplexBlocks 2 100% 100% 100% 100% 50% 50%
Electrical.Analog 65 100% 100% 100% 88% 57% 37%
Electrical.Batteries 8 100% 100% 50% 50% 13% 13%
Electrical.Digital 23 100% 100% 100% 100% 96% 91%
Electrical.Machines 43 100% 100% 100% 98% 5% 2%
Electrical.Polyphase 5 100% 100% 100% 100% 60% 40%
Electrical.PowerConverters 59 100% 100% 100% 76% 37% 44%
Electrical.QuasiStatic.Machines 1 100% 100% 100% 100% 0% 0%
Electrical.QuasiStatic.Polyphase 4 100% 100% 100% 100% 0% 0%
Electrical.QuasiStatic.SinglePhase 6 100% 100% 100% 100% 0% 0%
Electrical.Spice3 14 100% 100% 93% 86% 7% 7%
Fluid 23 100% 100% 57% 4% 0% 0%
Magnetic.FluxTubes 20 100% 100% 100% 95% 15% 0%
Magnetic.FundamentalWave 27 100% 100% 100% 4% 0% 0%
Magnetic.QuasiStatic.FluxTubes 9 100% 100% 100% 100% 0% 0%
Magnetic.QuasiStatic.FundamentalWave 21 100% 100% 95% 86% 0% 0%
Math.FastFourierTransform 2 100% 100% 100% 100% 0% 0%
Math.Nonlinear 1 100% 100% 100% 100% 100% 100%
Math.Random 1 100% 100% 100% 100% 0% 0%
Mechanics.MultiBody 42 100% 100% 100% 83% 14% 14%
Mechanics.Rotational 17 100% 100% 100% 100% 82% 53%
Mechanics.Translational 16 100% 100% 100% 100% 81% 63%
Media 22 100% 100% 100% 59% 5% 0%
Media.Incompressible 1 100% 100% 100% 0% 0% 0%
StateGraph 7 100% 100% 57% 57% 57% 57%
Thermal.FluidHeatFlow 12 100% 100% 100% 100% 75% 25%
Thermal.HeatTransfer 4 100% 100% 100% 100% 75% 75%
Utilities 3 100% 67% 67% 67% 67% 33%
MLS Contract Coverage
MLS Category n Compile Solve IR Balance Sim Phases Errors
ARR 9 89% 89% 89% 89% Flatten:1, Success:8 -
CLK_SM 77 100% 96% 96% 84% Success:74, ToDae:3 -
CONN_STRM 339 100% 79% 96% 34% Success:324, ToDae:15 -
EQN_ALG_SIM 2 100% 50% 100% 0% Success:2 -
FUNC 1 100% 100% 100% 0% Success:1 -
OTHER 138 100% 67% 99% 16% Success:136, ToDae:2 -
Trace Accuracy vs OMC
MSL Package n Compared Trace High Near Channel OK No Severe
Blocks 32 47% 47% 31% 16% 97% 44%
Clocked 76 86% 80% 68% 12% 89% 84%
ComplexBlocks 2 50% 50% 50% 0% 100% 50%
Electrical.Analog 65 42% 37% 25% 12% 95% 34%
Electrical.Batteries 8 13% 13% 13% 0% 100% 13%
Electrical.Digital 23 96% 91% 91% 0% 85% 96%
Electrical.Machines 43 2% 2% 0% 2% 96% 0%
Electrical.Polyphase 5 40% 40% 0% 40% 98% 0%
Electrical.PowerConverters 59 49% 44% 15% 29% 96% 8%
Electrical.QuasiStatic.Machines 1 0% 0% 0% 0% 0% 0%
Electrical.QuasiStatic.Polyphase 4 0% 0% 0% 0% 0% 0%
Electrical.QuasiStatic.SinglePhase 6 0% 0% 0% 0% 0% 0%
Electrical.Spice3 14 7% 7% 7% 0% 100% 7%
Fluid 23 0% 0% 0% 0% 0% 0%
Magnetic.FluxTubes 20 5% 0% 0% 0% 67% 0%
Magnetic.FundamentalWave 27 0% 0% 0% 0% 0% 0%
Magnetic.QuasiStatic.FluxTubes 9 0% 0% 0% 0% 0% 0%
Magnetic.QuasiStatic.FundamentalWave 21 0% 0% 0% 0% 0% 0%
Math.FastFourierTransform 2 0% 0% 0% 0% 0% 0%
Math.Nonlinear 1 100% 100% 100% 0% 100% 100%
Math.Random 1 0% 0% 0% 0% 0% 0%
Mechanics.MultiBody 42 17% 14% 12% 2% 98% 14%
Mechanics.Rotational 17 59% 53% 47% 6% 98% 47%
Mechanics.Translational 16 63% 63% 63% 0% 100% 63%
Media 22 0% 0% 0% 0% 0% 0%
Media.Incompressible 1 0% 0% 0% 0% 0% 0%
StateGraph 7 57% 57% 43% 14% 100% 57%
Thermal.FluidHeatFlow 12 25% 25% 25% 0% 100% 25%
Thermal.HeatTransfer 4 75% 75% 50% 25% 99% 50%
Utilities 3 33% 33% 33% 0% 100% 33%
Overall 566 36% 34% 25% 8% 95% 29%

Speed vs OMC

Compilation and simulation are reported separately for the 187 trace-agreeing models with valid timings on both tools. Speedup = OMC / Rumoca (>1 means rumoca faster).

Aggregate speed summary
Phase Models Rumoca total (s) OMC total (s) Throughput speedup (×) Median per-model speedup (×)
Total 187 808.7 766.4 0.95 4.85
Compilation 187 294.1 712.2 2.42 5.49
Simulation 187 514.6 54.1 0.11 1.55
Speed breakdown
Where rumoca's time goes
Scalar eqns Models front→DAE Solve-IR + JIT integration
1–9 28 0.355 0.007 0.0008
10–24 32 0.466 0.010 0.0022
25–49 26 0.486 0.018 0.0066
50–99 45 0.525 0.139 0.0559
100–249 31 0.824 0.319 0.3277
250+ 25 1.528 2.322 9.4564
Rumoca stage Total seconds Share of rumoca total
front→DAE 137.4 17%
Solve-IR + JIT 156.7 19%
integration 514.6 64%
Speed by system size
Table 1 — Total (model → simulated results)

Rumoca = front-end compile + Solve-IR/JIT build + integration; OMC = timeTotal.

Scalar eqns Models Rumoca (s) OMC (s) Speedup (×)
1–9 28 0.3635 2.9561 7.89
10–24 32 0.4792 3.1330 6.52
25–49 26 0.5633 3.2539 5.95
50–99 45 0.8439 3.6705 4.60
100–249 31 1.5475 4.4902 2.70
250+ 25 13.0516 6.1187 0.39

Per-model speedup: min 0.10, median 4.85, max 10.37.

Table 2 — Compilation (build-to-runnable)

Rumoca = front-end compile + Solve-IR/JIT build; OMC = timeTotal - timeSimulation.

Scalar eqns Models Rumoca (s) OMC (s) Speedup (×)
1–9 28 0.3624 2.9412 7.88
10–24 32 0.4770 3.1179 6.52
25–49 26 0.5055 3.2396 6.27
50–99 45 0.6719 3.4762 5.30
100–249 31 1.1859 4.2752 3.61
250+ 25 3.7246 5.8012 1.28

Per-model speedup: min 0.22, median 5.49, max 10.34.

Table 3 — Simulation (integration only)

Rumoca = sim_run_seconds; OMC = timeSimulation.

Scalar eqns Models Rumoca (s) OMC (s) Speedup (×)
1–9 28 0.0008 0.0128 16.73
10–24 32 0.0022 0.0158 6.89
25–49 26 0.0066 0.0211 2.65
50–99 45 0.0559 0.0498 1.32
100–249 31 0.3277 0.0731 0.20
250+ 25 9.4564 0.1802 0.02

Per-model speedup: min 0.00, median 1.55, max 47.53.

Top 10 slowest models
Top 10 slowest rumoca compilation models

Trace-agreeing models ranked by rumoca time.

Model Scalar eqns Rumoca compile (s) OMC compile (s) Speedup (×)
Modelica.Mechanics.MultiBody.Examples.Elementary.FreeBody 1330 33.4145 7.4015 0.22
Modelica.Mechanics.MultiBody.Examples.Elementary.PointGravity 911 24.0373 8.3635 0.35
Modelica.Mechanics.MultiBody.Examples.Elementary.PendulumWithSpringDamper 1349 15.3626 8.4416 0.55
Modelica.Mechanics.MultiBody.Examples.Elementary.SpringMassSystem 1469 15.2155 6.7610 0.44
Modelica.Electrical.Machines.Examples.Transformers.TransformerTestbench 775 11.4025 5.8294 0.51
Modelica.Electrical.PowerConverters.Examples.ACDC.RectifierCenterTap2mPulse.ThyristorCenterTap2mPulse_R 492 8.1043 6.4473 0.80
Modelica.Electrical.PowerConverters.Examples.ACDC.RectifierCenterTap2mPulse.ThyristorCenterTap2mPulse_RLV 504 6.1615 5.6916 0.92
Modelica.Electrical.PowerConverters.Examples.ACDC.RectifierBridge2mPulse.ThyristorBridge2mPulse_R 491 5.8229 6.0873 1.05
Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum 934 5.6259 6.2962 1.12
Modelica.Electrical.PowerConverters.Examples.ACDC.RectifierBridge2mPulse.ThyristorBridge2mPulse_RL 497 5.6079 5.9153 1.05
Top 10 slowest rumoca simulation models

Trace-agreeing models ranked by rumoca time.

Model Scalar eqns Rumoca simulation (s) OMC simulation (s) Speedup (×)
Modelica.Mechanics.Rotational.Examples.OneWayClutchDisengaged 56 40.7900 0.0879 0.00
Modelica.Mechanics.Rotational.Examples.OneWayClutch 58 35.2642 0.0865 0.00
Modelica.Electrical.Machines.Examples.Transformers.TransformerTestbench 775 32.6926 0.5600 0.02
Modelica.Electrical.PowerConverters.Examples.ACDC.RectifierCenterTap2Pulse.ThyristorCenterTap2Pulse_RLV_Characteristic 180 32.5897 6.1766 0.19
Modelica.Mechanics.MultiBody.Examples.Elementary.PendulumWithSpringDamper 1349 30.9768 0.1902 0.01
Modelica.Electrical.PowerConverters.Examples.ACDC.RectifierCenterTap2mPulse.ThyristorCenterTap2mPulse_R 492 29.0246 0.3652 0.01
Modelica.Mechanics.MultiBody.Examples.Elementary.PointGravity 911 26.3468 0.1055 0.00
Modelica.Electrical.PowerConverters.Examples.DCDC.ChopperStepDown.ChopperStepDown_RL 140 25.7124 0.7580 0.03
Modelica.Electrical.PowerConverters.Examples.ACDC.RectifierCenterTap2mPulse.ThyristorCenterTap2mPulse_RLV 504 23.0163 0.3024 0.01
Modelica.Electrical.PowerConverters.Examples.ACDC.Rectifier1Pulse.Thyristor1Pulse_R_Characteristic 121 21.2190 3.7915 0.18

Additional Artifacts

  • msl_compatibility_report.md

@jgoppert
jgoppert marked this pull request as ready for review July 23, 2026 19:43
@jgoppert
jgoppert merged commit 1acf364 into main Jul 23, 2026
41 checks passed
@jgoppert
jgoppert deleted the fix-function-projection-array-shapes branch July 23, 2026 19:43
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.

1 participant