Repository navigation
mlx-exact 0.8.0
Exact attention for head dims 64/96/128 (bf16/fp16) now calls MLX's own fused attention kernel directly, with per-sequence key offsets: no query padding, no key copies, and the KV cache is read in place.
- Batched exact decode is 2× faster: Qwen3-0.6B-4bit, 8 sequences, 1,125 generated tok/s vs 566 in 0.7.1 (stock 1,260; now 0.89× of stock). Single-sequence decode: 0.95× of stock.
- Results are unchanged: bit-identical to 0.7.x in 552 kernel checks, and a GSM8K replay (120 problems × 3 schedules) is token-identical.
- Fixes, found in an independent pre-release review and confirmed with regression tests (
tests/test_attention_review.py):- NaN in left-padded batches in exact mode for head dims 192/256 with one KV head (e.g. Gemma 3 1B), since 0.7.0;
- backward passes through every exact attention route (missing on the fixed-order, re-alignment and quantized-KV routes);
- unrestricted attention (
mask=Nonewith several queries) was made causal on the padded fallback path; more queries than keys; masks broadcast along the key axis with rotating caches.
Install: pip install "mlx-exact[lm] @ git+https://github.com/audenvenn/mlx-exact@v0.8.0". Validated on Apple M6 with MLX 0.32.4 and mlx-lm 0.32.2. Full changelog, results and limitations: README.
Developed with AI assistance (Anthropic's Claude). This release also had an independent pre-release code review by another AI model (OpenAI's Codex).