Skip to content

Bump tract 0.21.4 → 0.23 (WASM SIMD kernels)#695

Open
chsotelo wants to merge 1 commit into
Rikorose:mainfrom
chsotelo:pr/bump-tract-0.23
Open

Bump tract 0.21.4 → 0.23 (WASM SIMD kernels)#695
chsotelo wants to merge 1 commit into
Rikorose:mainfrom
chsotelo:pr/bump-tract-0.23

Conversation

@chsotelo

@chsotelo chsotelo commented Jul 9, 2026

Copy link
Copy Markdown

What

Bumps tract from 0.21.4 to 0.23 and migrates libDF to the new API.

tract 0.23 ships hand-written WASM SIMD kernels (matmul / GEMV / sigmoid / tanh); 0.21 fell back to generic scalar code on wasm32. Those kernels dominate the enc / erb_dec / df_dec inference cost, so this is a large real-time win for browser / AudioWorklet deployments. Refs #682.

Measured impact

DeepFilterNet3 model, 480-sample frames, deterministic input, run under V8 (Node), 0.21.12 build vs this 0.23 build:

build avg ms/frame p95
tract 0.21.12 16.7 ms 16.9 ms
tract 0.23 0.8 ms 1.3 ms

~20× faster per frame. Output is unchanged: 106.9 dB SNR agreement between the two builds over 300 frames (max abs sample diff 7.7e-9).

API migration required by 0.23

  • Tensor: to_array_view / into_arrayto_plain_array_view / into_plain_array
  • Graph: with_output_nameswith_outputs_by_name; field symbol_tablesymbols
  • TValue scalar access via try_as_plain()
  • SimpleState<F, O> directly (the TypedSimpleState alias was dropped)
  • ndarray 0.15 → 0.17, wasm-bindgen 0.2.100, js-sys 0.3.77
  • getrandom 0.4 with the wasm_js backend for wasm32-unknown-unknown

Building the wasm feature

RUSTFLAGS='-C target-feature=+simd128 --cfg getrandom_backend="wasm_js"' \
  wasm-pack build --target web --release -- --features wasm --no-default-features

Verified

Compiles for the wasm, capi and default feature sets.

tract 0.23 ships hand-written WASM SIMD matmul/GEMV/sigmoid/tanh kernels;
0.21 fell back to generic scalar code on wasm32. Those kernels dominate the
enc/erb_dec/df_dec inference cost, so this is a large real-time win in the
browser. Measured on a DeepFilterNet3 model under V8, 480-sample frames:
16.7 ms -> 0.8 ms average per frame (~20x), output unchanged (106.9 dB SNR
agreement vs the 0.21 build, max abs diff 7.7e-9). Compiles for the wasm,
capi and default feature sets.

API migration required by 0.23:
- Tensor: to_array_view/into_array -> to_plain_array_view/into_plain_array
- Graph: with_output_names -> with_outputs_by_name
- TValue scalar access via try_as_plain()
- SimpleState<F, O> (the TypedSimpleState alias was dropped); Graph field
  symbol_table -> symbols
- ndarray 0.15 -> 0.17, wasm-bindgen 0.2.100, js-sys 0.3.77
- getrandom 0.4 with the wasm_js backend for wasm32-unknown-unknown

Build the wasm feature with:
  RUSTFLAGS='-C target-feature=+simd128 --cfg getrandom_backend="wasm_js"' \
    wasm-pack build --target web --release -- --features wasm --no-default-features

Refs Rikorose#682.
@chsotelo chsotelo closed this Jul 16, 2026
@chsotelo chsotelo reopened this Jul 16, 2026
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