-
Notifications
You must be signed in to change notification settings - Fork 864
Voxtral Realtime: enable CUDA backend with int4 quantization #17798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,8 +88,43 @@ python export_voxtral_rt.py \ | |
| |---------|---------|-----------|--------------| | ||
| | `xnnpack` | ✓ | ✓ | `4w`, `8w`, `8da4w`, `8da8w` | | ||
| | `metal` | ✓ | ✓ | none (fp32) or `fpa4w` (Metal-specific 4-bit) | | ||
| | `cuda` | ✓ | ✓ | `4w`, `8w`, `8da4w`, `8da8w` | | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does Cuda support 8da4w/8da8w? Related, I'm pretty sure xnnpack does not support 4w/8w.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Good catch, will fix.
xnnpack supports per-channel 4w and 8w. For example, we use 8w for token embeddings.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ET's embedding CPU op supports weight only schemes, but I don't think xnnpack supports weight-only quantization for linear layers. With that said, 4w/8da4w and 8w/8da8w quantize weight data the same. The only difference is the 8da variants add fake activation quantization in front.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @manuelcandales is there any plan for metal aoti to use int4/int8 for a more uniform experience. The kernel should support it because I'm using int4/int8 with MLX. |
||
|
|
||
| Metal backend provides Apple GPU acceleration. | ||
| Metal backend provides Apple GPU acceleration. CUDA backend provides NVIDIA GPU | ||
| acceleration via AOTInductor. | ||
|
|
||
| #### CUDA export examples | ||
|
|
||
| Offline with int4 quantization: | ||
|
|
||
| ```bash | ||
| python export_voxtral_rt.py \ | ||
| --model-path ~/models/Voxtral-Mini-4B-Realtime-2602 \ | ||
| --backend cuda \ | ||
| --dtype bf16 \ | ||
| --output-dir ./voxtral_rt_exports \ | ||
| --qlinear-encoder 4w \ | ||
| --qlinear-encoder-packing-format tile_packed_to_4d \ | ||
| --qlinear 4w \ | ||
| --qlinear-packing-format tile_packed_to_4d \ | ||
| --qembedding 8w | ||
| ``` | ||
|
|
||
| Streaming with int4 quantization: | ||
|
|
||
| ```bash | ||
| python export_voxtral_rt.py \ | ||
| --model-path ~/models/Voxtral-Mini-4B-Realtime-2602 \ | ||
| --backend cuda \ | ||
| --dtype bf16 \ | ||
| --streaming \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if this is supported, then why not test it in CI? |
||
| --output-dir ./voxtral_rt_exports \ | ||
| --qlinear-encoder 4w \ | ||
| --qlinear-encoder-packing-format tile_packed_to_4d \ | ||
| --qlinear 4w \ | ||
| --qlinear-packing-format tile_packed_to_4d \ | ||
| --qembedding 8w | ||
| ``` | ||
|
|
||
| #### Metal export examples | ||
|
|
||
|
|
@@ -133,14 +168,17 @@ EXECUTORCH_BUILD_KERNELS_TORCHAO=1 TORCHAO_BUILD_EXPERIMENTAL_MPS=1 ./install_ex | |
| | Flag | Default | Description | | ||
| |------|---------|-------------| | ||
| | `--model-path` | (required) | Directory with `params.json` + `consolidated.safetensors` | | ||
| | `--backend` | `xnnpack` | `xnnpack`, `metal`, or `portable` | | ||
| | `--backend` | `xnnpack` | `xnnpack`, `metal`, `cuda`, or `portable` | | ||
| | `--dtype` | `fp32` | Model dtype: `fp32` or `bf16` | | ||
| | `--output-dir` | `./voxtral_rt_exports` | Output directory | | ||
| | `--max-seq-len` | `4096` | KV cache length | | ||
| | `--delay-tokens` | `6` | Transcription delay in tokens (6 = 480ms) | | ||
| | `--qlinear` | (none) | Decoder linear layer quantization (`4w`, `8w`, `8da4w`, `8da8w`, `fpa4w`) | | ||
| | `--qlinear-group-size` | `32` | Group size for decoder linear quantization | | ||
| | `--qlinear-packing-format` | (none) | Packing format for decoder 4w quantization (`tile_packed_to_4d` for CUDA) | | ||
| | `--qlinear-encoder` | (none) | Encoder linear layer quantization (`4w`, `8w`, `8da4w`, `8da8w`, `fpa4w`) | | ||
| | `--qlinear-encoder-group-size` | `32` | Group size for encoder linear quantization | | ||
| | `--qlinear-encoder-packing-format` | (none) | Packing format for encoder 4w quantization (`tile_packed_to_4d` for CUDA) | | ||
| | `--qembedding` | (none) | Embedding layer quantization (`8w`) | | ||
| | `--streaming` | off | Export streaming encoder with KV cache | | ||
| | `--max-enc-len` | `750` | Encoder sliding window size (streaming only) | | ||
|
|
@@ -164,6 +202,15 @@ make voxtral_realtime-cpu | |
| This builds ExecuTorch core libraries with XNNPACK, then the runner binary | ||
| at `cmake-out/examples/models/voxtral_realtime/voxtral_realtime_runner`. | ||
|
|
||
| ### CUDA (NVIDIA GPU) | ||
|
|
||
| ```bash | ||
| make voxtral_realtime-cuda | ||
| ``` | ||
|
|
||
| This builds ExecuTorch with CUDA backend support. The runner binary is at | ||
| the same path as above. Requires NVIDIA GPU with CUDA toolkit installed. | ||
|
|
||
| ### Metal (Apple GPU) | ||
|
|
||
| ```bash | ||
|
|
@@ -180,10 +227,22 @@ The runner requires: | |
| - `tekken.json` — tokenizer from the model weights directory | ||
| - `preprocessor.pte` — mel spectrogram preprocessor (see [Preprocessor](#preprocessor)) | ||
| - A 16kHz mono WAV audio file (or live audio via `--mic`) | ||
| - For CUDA: `aoti_cuda_blob.ptd` — delegate data file (pass via `--data_path`) | ||
|
|
||
| ```bash | ||
| cmake-out/examples/models/voxtral_realtime/voxtral_realtime_runner \ | ||
| --model_path voxtral_rt_exports/model.pte \ | ||
| --tokenizer_path ~/models/Voxtral-Mini-4B-Realtime-2602/tekken.json \ | ||
| --preprocessor_path voxtral_rt_exports/preprocessor.pte \ | ||
| --audio_path input.wav | ||
| ``` | ||
|
|
||
| For CUDA, include the `.ptd` data file: | ||
|
|
||
| ```bash | ||
| cmake-out/examples/models/voxtral_realtime/voxtral_realtime_runner \ | ||
| --model_path voxtral_rt_exports/model.pte \ | ||
| --data_path voxtral_rt_exports/aoti_cuda_blob.ptd \ | ||
| --tokenizer_path ~/models/Voxtral-Mini-4B-Realtime-2602/tekken.json \ | ||
| --preprocessor_path voxtral_rt_exports/preprocessor.pte \ | ||
| --audio_path input.wav | ||
|
|
@@ -218,9 +277,13 @@ ffmpeg -f avfoundation -i ":0" -ar 16000 -ac 1 -f f32le -nostats -loglevel error | |
|
|
||
| Ctrl+C stops recording and flushes remaining text. | ||
|
|
||
| **CUDA:** Add `--data_path voxtral_rt_exports/aoti_cuda_blob.ptd` to all | ||
| run commands above when using the CUDA backend. | ||
|
|
||
| | Flag | Default | Description | | ||
| |------|---------|-------------| | ||
| | `--model_path` | `model.pte` | Path to exported model | | ||
| | `--data_path` | (none) | Path to delegate data file (`.ptd`, required for CUDA) | | ||
| | `--tokenizer_path` | `tekken.json` | Path to Tekken tokenizer | | ||
| | `--preprocessor_path` | (none) | Path to mel preprocessor `.pte` | | ||
| | `--audio_path` | (none) | Path to 16kHz mono WAV file | | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not streaming?