htdemucs (Demucs v4), ONNX, mixed float16 for WebGPU
htdemucs_fp16.onnx is Demucs v4's
htdemucs model (Hybrid Transformer Demucs, 4 stems) converted to mixed
float16 for ONNX Runtime Web
on WebGPU. It is 92 MB instead of 180 MB, and about twice as fast, with the
same separation quality.
Source
The float32 graph is htdemucs_embedded.onnx from
timcsy/demucs-web-onnx.
Inputs, outputs and pre- and post-processing are the same as that model's;
only the internal precision changed.
Conversion
Converted with onnxconverter-common's convert_float_to_float16
(keep_io_types=True, so inputs and outputs stay float32). These parts are
kept in float32:
- the normalizations (
InstanceNormalization,LayerNormalization,ReduceMean,Sqrt,Erf), whose sums of squares overflow in half; - the input's own normalization (mean and spread over the whole segment), with every node before it;
ConvTranspose: in half the decoder's output loses quality.
Measurements
On one 7.8 s segment of a test song (voice mixed into music), with onnxruntime-web 1.31 on WebGPU (Intel Iris Xe):
| float32 | this model | |
|---|---|---|
| size | 180 MB | 92 MB |
| time per segment | 5–6 s | 2.4–2.8 s |
| vocals vs the true voice | 14.8 dB | 14.8 dB |
| vocals vs float32's vocals (SNR) | — | 48.2 dB |
Requirements
A WebGPU adapter with the shader-f16 feature. Without it, use the
float32 model.
License
MIT, as Demucs. See LICENSE.
Demucs: Alexandre Défossez, Simon Rouard, Meta AI. Rouard, Massa and Défossez, Hybrid Transformers for Music Source Separation, ICASSP 2023.