Bump tract 0.21.4 → 0.23 (WASM SIMD kernels)#695
Open
chsotelo wants to merge 1 commit into
Open
Conversation
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.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Bumps
tractfrom 0.21.4 to 0.23 and migrateslibDFto 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 theenc/erb_dec/df_decinference 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:
~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_array→to_plain_array_view/into_plain_arrayGraph:with_output_names→with_outputs_by_name; fieldsymbol_table→symbolsTValuescalar access viatry_as_plain()SimpleState<F, O>directly (theTypedSimpleStatealias was dropped)ndarray0.15 → 0.17,wasm-bindgen0.2.100,js-sys0.3.77getrandom0.4 with thewasm_jsbackend forwasm32-unknown-unknownBuilding the wasm feature
Verified
Compiles for the
wasm,capiand default feature sets.