You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Specialize feedback index keywords for strict compilation - #1097
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.
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.
baggepinnen
changed the title
Improve constant propagation for WebAssembly control analyses
Specialize feedback indices and propagate scalar frequency-response options
Oct 26, 2026
baggepinnen
changed the title
Specialize feedback indices and propagate scalar frequency-response options
Specialize feedback index keywords for strict compilation
Oct 26, 2026
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.
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.
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.
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
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.
The objective is to compile numerical state-space interconnections to WebAssembly with strict trim verification. This draft specializes the state-space
feedbackindex keywords explicitly, for exampleU1::TU1=:withwhere 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 abstractFunction. Strict trim verification then fails into_index(::Function)and generic function display. Explicit keyword type parameters remove this abstract indexing path without inliningfeedbackor adding a constant-propagation annotation.A separate diagnostic path still interpolates
Colonvalues 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:
feedbackfails 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.Additional investigation, outside this diff:
extended_gangoffour(P, C, false)instead ofgangoffour. The unusedpos=truebranch exposes an inference failure through block concatenation (typed_hvcatstores block rows inVector{Any}). A call-site@inlineonextended_gangoffourmakes the small example and the motor analysis compile, but both trap during execution invcat. Consequently the extended-system replacement is not yet validated for the application. Nogangoffourorextended_gangoffourannotation is proposed here.freqresploop 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 LAPACKdgehrd_64_anddorghr_64_. A static-matrix example encounters inference failure through the balancing path. These are separate from feedback specialization.@constprop :aggressiveon scalarfreqrespmakes a small scalar entry point compile without inlining eitherfreqrespor_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