Context
A custom flash attention Metal kernel with online softmax was added in mlx-rs-core/src/metal_kernels.rs (flash_attention()). It avoids materializing the full attention matrix, supports GQA and causal masking.
Benchmarking showed it's slower than MLX SDPA for Q=1 decode (TTS), but should excel on long-prefill encoder paths (ASR encoder, FLUX spatial attention) where Q >> 1 and MLX falls back to regular operations.
TODO
Measured dimensions where gains are expected
| Model |
Seq tokens |
Heads |
SDPA ms (24L) |
Manual ms (24L) |
| Step-Audio-2 |
1500 |
20 |
59ms |
119ms |
| Qwen3-VL |
1024 |
16 |
28ms |
54ms |
Context
A custom flash attention Metal kernel with online softmax was added in
mlx-rs-core/src/metal_kernels.rs(flash_attention()). It avoids materializing the full attention matrix, supports GQA and causal masking.Benchmarking showed it's slower than MLX SDPA for Q=1 decode (TTS), but should excel on long-prefill encoder paths (ASR encoder, FLUX spatial attention) where Q >> 1 and MLX falls back to regular operations.
TODO
step-audio2-mlx/src/encoder.rsbehind a feature flagMeasured dimensions where gains are expected