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
engine: VM applies one override to every instance of a shared module #616
When a model uses the same submodel twice, setting a constant inside each instance to a different value does not work on the VM: the last set_value wins for both instances.
The wasm backend gets it right.
Example
A submodel with constant k and out = in + k, instantiated as sub0 and sub1, with in wired to 7.
Set sub0.k = 100 and sub1.k = 200:
sub0.out
sub1.out
expected (wasm)
107
207
VM
207
207
Setting both instances to the same value works.
Why it matters
It needs a model that instantiates one module more than once and a host that overrides a constant inside it differently per instance.
No in-repo caller does this, and it has not been seen in a real model; it came from a constructed wasm-backend test.
But the result is a silently wrong number, which is worse than an error.
Fix
The VM applies an override by rewriting the constant's literal in the module's bytecode, and two instances of one module share that bytecode.
Recommended: make set_value return an error when the constant lives in a module that is instantiated more than once, instead of silently overwriting the other instance.
This is a check at override time, off the hot path.
Alternative: keep overrides per instance, as the wasm backend does (an override table addressed by absolute slot).
On the VM that means an extra branch in the constant-assignment opcode, and the perf notes in docs/design/engine-performance.md show small changes to that loop can cost more than expected; measure it.
changed the title [-]engine: VM set_value cannot apply distinct per-instance overrides to two instances of the same shared CompiledModule[/-][+]engine: VM applies one override to every instance of a shared module[/+]on Oct 12, 2026
Activity
engine: WebAssembly simulation backend with full VM parity (#620)
[-]engine: VM set_value cannot apply distinct per-instance overrides to two instances of the same shared CompiledModule[/-][+]engine: VM applies one override to every instance of a shared module[/+]