Problem
Repeated LoadedEngine construction and destruction in one CUDA process can reuse a MoeBlockWeights address while MoeBf16ResidentFor retains the previous engine's device-pointer array in a process-lifetime static map. A later engine can therefore execute the BF16 fast MoE path with stale resident pointers.
Reproduction
On current main plus issue #206's exact pretokenized benchmark fixture, run the focused tests in this order:
nix develop .#cuda -c ctest --test-dir build-nix-cuda \
-R '^(test_engine_core_proc|test_async_llm|test_bench|test_gdn_decode_fused|test_gdn_prefill_conv|test_ops_gdn)$' \
--output-on-failure
The ordered suite intermittently fails test_bench: later synthetic Qwen3.5 engines emit corrupted or zero output-token IDs. The target case alone passed 50/50. Setting VT_MOE_BF16_FAST=0 made the full test_bench suite pass 50/50, isolating the fault to the fast resident-weight path.
Expected
Resident CUDA MoE state must be owned by, or invalidated with, the engine/weights lifetime. Recreating an engine in the same process must never reuse stale device pointers, and the default fast path must remain enabled.
Scope
Problem
Repeated
LoadedEngineconstruction and destruction in one CUDA process can reuse aMoeBlockWeightsaddress whileMoeBf16ResidentForretains the previous engine's device-pointer array in a process-lifetime static map. A later engine can therefore execute the BF16 fast MoE path with stale resident pointers.Reproduction
On current main plus issue #206's exact pretokenized benchmark fixture, run the focused tests in this order:
The ordered suite intermittently fails
test_bench: later synthetic Qwen3.5 engines emit corrupted or zero output-token IDs. The target case alone passed 50/50. SettingVT_MOE_BF16_FAST=0made the fulltest_benchsuite pass 50/50, isolating the fault to the fast resident-weight path.Expected
Resident CUDA MoE state must be owned by, or invalidated with, the engine/weights lifetime. Recreating an engine in the same process must never reuse stale device pointers, and the default fast path must remain enabled.
Scope