Skip to content

Specialize feedback index keywords for strict compilation - #1097

Merged
baggepinnen merged 3 commits into
masterfrom
codex/wasm-control-analysis
Oct 26, 2026
Merged

baggepinnen merged 3 commits into
masterfrom
codex/wasm-control-analysis

Conversation

@baggepinnen

@baggepinnen baggepinnen commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

The objective is to compile numerical state-space interconnections to WebAssembly with strict trim verification. This draft specializes the state-space feedback index keywords explicitly, for example U1::TU1=: with where TU1. It contains no inlining annotations and no frequency-response changes.

Colon <: Function. Without explicit keyword type parameters, the tested feedback entry point reaches indexing with arguments inferred as abstract Function. Strict trim verification then fails in to_index(::Function) and generic function display. Explicit keyword type parameters remove this abstract indexing path without inlining feedback or adding a constant-propagation annotation.

A separate diagnostic path still interpolates Colon values into the dimension errors, which reaches generic function display. The two dimension errors therefore identify the argument names without interpolating their values.

Validation of this revision:

  • A small entry point using feedback fails strict trim verification with the original implementation. Typed keywords remove the abstract indexing diagnostics; typed keywords plus the reduced error messages compile and execute in Node.
  • Ten native checks pass: feedback matrices for scalar/vector/Colon indices, input/output permutations and nonzero direct feedthrough; both dimension errors. Three native/WebAssembly feedback results agree exactly.
  • The package test suite was not run. The earlier 36,000 motor-response comparisons used the previous dependency patch and do not validate this revision of the complete application.

Additional investigation, outside this diff:

  • The application was tested with extended_gangoffour(P, C, false) instead of gangoffour. The unused pos=true branch exposes an inference failure through block concatenation (typed_hvcat stores block rows in Vector{Any}). A call-site @inline on extended_gangoffour makes the small example and the motor analysis compile, but both trap during execution in vcat. Consequently the extended-system replacement is not yet validated for the application. No gangoffour or extended_gangoffour annotation is proposed here.
  • The application's scalar freqresp loop was a workaround using StaticArrays linear algebra. The vector method is the intended performance direction: one Hessenberg reduction followed by workspace reuse across frequencies. A small vector-frequency example with dense matrices fails WasmCodegen compilation on unsupported foreign calls, including LAPACK dgehrd_64_ and dorghr_64_. A static-matrix example encounters inference failure through the balancing path. These are separate from feedback specialization.
  • @constprop :aggressive on scalar freqresp makes a small scalar entry point compile without inlining either freqresp or _balance, but that exploratory change is excluded from this PR because the vector method should be investigated instead.

Related: ModelingToolkit.jl issue 5316, ModelingToolkit.jl PR 5320, ModelingToolkit.jl PR 5324, and WasmCodegen.jl issue 5.


Host: demeter2
Session: Codex 01a16eb7-f44a-7760-b6e2-65dd2fa345bd
Working directory: /home/baggepinnen/repos/ControlSystems-wasm-pr

@JuliaControlBot

Copy link
Copy Markdown

This is an automated message.
Plots were compared to references. 6/11 images have changed, see differences below.
After pulling this PR, please update the reference images by creating a PR to ControlExamplePlots.jl here.

Difference Reference Image New Image
✔️ 0.0 Reference New
⚠️ 0.021 Reference New
✔️ 0.0 Reference New
✔️ 0.0 Reference New
✔️ 0.0 Reference New
✔️ 0.013 Reference New

@baggepinnen baggepinnen changed the title Improve constant propagation for WebAssembly control analyses Specialize feedback indices and propagate scalar frequency-response options Oct 26, 2026
@baggepinnen baggepinnen changed the title Specialize feedback indices and propagate scalar frequency-response options Specialize feedback index keywords for strict compilation Oct 26, 2026
@JuliaControlBot

Copy link
Copy Markdown

This is an automated message.
Plots were compared to references. 6/11 images have changed, see differences below.
After pulling this PR, please update the reference images by creating a PR to ControlExamplePlots.jl here.

Difference Reference Image New Image
✔️ 0.0 Reference New
⚠️ 0.021 Reference New
✔️ 0.0 Reference New
✔️ 0.0 Reference New
✔️ 0.0 Reference New
✔️ 0.013 Reference New

@JuliaControlBot

Copy link
Copy Markdown

This is an automated message.
Plots were compared to references. 6/11 images have changed, see differences below.
After pulling this PR, please update the reference images by creating a PR to ControlExamplePlots.jl here.

Difference Reference Image New Image
✔️ 0.0 Reference New
⚠️ 0.021 Reference New
✔️ 0.0 Reference New
✔️ 0.0 Reference New
✔️ 0.0 Reference New
✔️ 0.013 Reference New

@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.29%. Comparing base (973f8d1) to head (836140f).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1097   +/-   ##
=======================================
  Coverage   92.29%   92.29%           
=======================================
  Files          42       42           
  Lines        6177     6177           
=======================================
  Hits         5701     5701           
  Misses        476      476           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@baggepinnen
baggepinnen marked this pull request as ready for review October 26, 2026 08:20
@baggepinnen
baggepinnen merged commit c39b57d into master Oct 26, 2026
7 checks passed
@JuliaControlBot

Copy link
Copy Markdown

This is an automated message.
Plots were compared to references. 6/11 images have changed, see differences below.
After pulling this PR, please update the reference images by creating a PR to ControlExamplePlots.jl here.

Difference Reference Image New Image
✔️ 0.0 Reference New
⚠️ 0.021 Reference New
✔️ 0.0 Reference New
✔️ 0.0 Reference New
✔️ 0.0 Reference New
✔️ 0.013 Reference New

baggepinnen referenced this pull request Oct 26, 2026
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
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