Skip to content

mlx-exact 0.9.0

Choose a tag to compare

@audenvenn audenvenn released this 20 Nov 11:18

mxfp4 (MX-format) layers are now exact, e.g. the experts of gpt-oss.

  • How: mlx-exact runs MLX v0.32.4's own mxfp4 accelerator implementation (vendored, unmodified arithmetic) with a 16-row tile for any row count, plus an expert-indexed variant for MoE layers.
  • Checks: both are bit-identical to stock MLX's long-prefill kernel and sorted expert kernel (gpt-oss-20b shapes, bf16 and fp16).
  • gpt-oss-20b (mlx-community/gpt-oss-20b-MXFP4-Q8: mxfp4 experts, attention sinks, 128-token sliding windows), 200-token prompt, single sequence:
    • decode and prefill in chunks of 7 match one full prefill at 200 / 200 positions (stock MLX: 0 / 200);
    • decode runs at 0.77× of stock.
  • Tests: new tests/test_mxfp4.py, including a tiny random gpt-oss with mxfp4 experts; 239 tests.
  • Still not exact: nvfp4 and mxfp8 fall back to stock MLX with a warning, and batched generation with sliding windows is not covered.

Install: pip install "mlx-exact[lm] @ git+https://github.com/audenvenn/mlx-exact@v0.9.0". Validated on Apple M6 with MLX 0.32.4 and mlx-lm 0.32.2.

Developed with AI assistance (Anthropic's Claude).