Repository navigation
perf(qwen3-asr,qwen3-tts): fuse decode plans, Metal kernels, and audio/codec paths - #445
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Summary
Optimizes Qwen3-ASR and Qwen3-TTS end-to-end across three axes with zero silent quantization and full precision parity:
rfftlog-mel frontend (zero-copyas_strided), single-FFI C++ decode plans for ASR, Talker, and 15-step CodePredictor, single-copyto_float32_vec, removed redundant streaming sync barriers,PrefixCachesingle-sync, deferred batched load evals with validated-range page-cache prewarming, and a 66× faster NEONf64polyphase resampler (resample_mono_cow).snake_beta,add_bias_layernorm,causal_im2col,causal_transpose_overlap_add,sample_logits_full,swiglu_stacked), zero-copyslice+ in-placemlx_kv_store_rowsin fused decode/predictor loops, compiledbias_gelu_exact, stacked RVQ decode, andK == stridesingle-GEMM transpose conv.bias_gelu_exact, greedy/top-k/top-p sampling, stacked QKV/SwiGLU, and maskless causal prefill; F32 registers only where exactness requires it (LayerNorm,SnakeBetatrig, pre-projected 1.7B tables rounded before bias); dropped ~2.1 GB duplicate ASR and ~1.9 GB duplicate TTS eager weights when fused plans are active; bounded 512-row KV reservation for fused ASR & TTS Talkers; compacted prepared-voice KV caches (20.4 → 4.4 MiB).flowchart LR subgraph ASR["Qwen3-ASR"] A1["NEON f64 Resampler<br/>(66x faster)"] --> A2["GPU rfft Log-Mel<br/>(25-28x faster)"] A2 --> A3["AudioTower<br/>Stacked QKV + Batched SDPA<br/>bias_gelu_exact + add_bias_layernorm"] A3 --> A4["Fused C++ TextDecoder<br/>(BF16/MXFP4, 512-row KV reserve)"] end subgraph TTS["Qwen3-TTS"] T1["Fused C++ Talker<br/>(512-row KV reserve)"] --> T2["1-Dispatch Metal Sampler<br/>(mask + 64-tok rep penalty + radix top_k/top_p)"] T2 --> T3["1-FFI C++ 15-Step CodePredictor<br/>(in-place 16-row KvStoreRows,<br/>pre-projected 1.7B tables)"] T3 --> T4["Fused Metal CodecDecoder<br/>(2D/3D SnakeBeta, im2col, overlap_add,<br/>stacked RVQ, compact voice KV)"] endBenchmarks (Apple M5 Max, 128 GB, Full Precision)
main)8546d359e)44.1 → 16 kHz, 2s)12.68 ms0.192 ms917.1 ms(feat6.49 ms,121.9 tok/s)891.1 ms(feat0.23 ms,124.3 tok/s, RTF0.0297)53.9 ms(prefill19.9 ms, feat0.77 ms)48.6 ms(prefill11.5 ms, feat0.10 ms, RTF0.0145)381.8 ms(prefill52.6 ms, feat6.49 ms)378.3 ms(prefill46.4 ms, feat0.26 ms, RTF0.0126)324.8 ms252.7 ms3207.8 ms(79.8 fps, RTF0.1566, TTFA110.1 ms)2729.9 ms(93.8 fps, RTF0.1333, warm TTFA23.7 ms)topP=0.9(2f)1207.8 ms(72.0 fps, RTF0.1735)982.1 ms(88.6 fps, RTF0.1411)3518.2 ms(91.8 fps, RTF0.1362)3408.5 ms(94.8 fps, RTF0.1319)61.8 fps(RTF0.2022)69.5 fps(RTF0.1800)topP=0.9(2f)57.1 fps(RTF0.2190)65.3 fps(RTF0.1915)Metal command trace (
MLX_METAL_COMMAND_TRACE=2):0Split,0Concatenate,0Broadcast,0AsTypein steady decode; ASR MXFP4 dispatches/tok536 → 286; Codec 8-frame chunk15.5 → 3.76 ms.Verification
cargo fmt --check&cargo clippy -p mlx-core -p mlx-audio --lib --tests -- -D warnings: pass (0 warnings)vp run build: 2/2 pass (release native addon + metallib smoke checks on MLX84be893fe)cargo test -p mlx-audio: 20/20 passedcargo test -p mlx-core --lib(ASR, TTS, kernels, KV cache, sampling,as_strided): 187/187 passedvp test(ASR/TTS/CLI/server suite): 203/203 passedqwen3-asr-1.7b-mlx-mxfp4): 2/2 passed0.6b&1.7bCustomVoice): 5/5 passedgpt-6.2-sol) addressed prior to opening PR.