Skip to content

inferd 0.4.5

Latest

Choose a tag to compare

@johntdavies johntdavies released this 21 Nov 18:14
· 3 commits to main since this release

inferd 0.4.5 is a maintenance release. It fixes wrong output from Qwen3.6-35B-A3B on Macs whose GPUs have no
neural accelerators (M1, M2, M3 and M4 families)
. It is 0.4.4 plus this fix only.

Who is affected

  • Affected: Qwen3.6-35B-A3B on an M1–M4 GPU, with any prompt or turn longer than one chunk (the sorted-MoE path
    takes steps of 16 or more tokens), and its speculative verify steps. Every release from 0.3.0 to 0.4.4 has the
    bug, the 0.4.1 macOS 26 build included.
  • Not affected: Qwen3.8-27B and Qwen3.5-9B on any Mac, and every model on M5 and M6 GPUs. On those, 0.4.5 gives the
    same logits as 0.4.4, byte for byte (checked on an M4 Pro for the 27B and 9B, and on M5 Pro for the 27B and 35B).

What was wrong

On GPUs without neural accelerators, two of the 35B-A3B's routes still ran MLX's neural-accelerator (NAX) kernels,
and those kernels compute garbage there:

  1. Sorted-MoE prefill. Steps with 128 or more routed rows (16+ tokens at 8 experts per token) ran MLX's NAX gathered
    quantized matmul. On an M4 Pro its outputs have a relative RMS error of 1.40 against an fp64 reference (99.5% of
    outputs wrong).
  2. 2–8-row attention. These are speculative verify blocks and the last step of a prompt that ends 2–8 tokens past a
    chunk boundary. On the 35B they went to attn_paged_nax, which is also NAX code.

Measured on an M4 Pro against mlx_lm, 12 × 512 positions at 256-token chunks: KL 3.16 and 53% of top-1 tokens
flipped
. The model produced fluent-looking but wrong text.

The fix

  • On M1–M4 the sorted-MoE gathers run MLX's simdgroup affine_gather_qmm_rhs with MLX's own tiles for these GPUs.
    That is the kernel mlx_lm itself runs there (mlx_gqmm_sg_b4/b8, src/ops/gather.h).
  • On M1–M4, 2–8-row attention runs take the multi-row attn_gqa kernel.
  • Backstop: on a GPU without neural accelerators the engine now refuses to load any MLX NAX kernel. It stops with
    an error that names the kernel instead of returning wrong output (NAX_ON_NONAX=1 overrides, for experiments).
    As a result, a few routes that 0.4.4 still sent to NAX code on M1–M4 now stop with that error instead of returning
    wrong output. These are linears with unquantized (bf16) weights, as in bf16 checkpoints, and they may include
    Qwen3.8-Flash-Next's bf16 router during prefill. None of these affects the 4- and 8-bit Qwen3.8-27B, Qwen3.5-9B or
    Qwen3.6-35B-A3B checkpoints.
  • Regression test: build/gqmm_test checks the sorted-MoE chain and the gathered kernel this GPU routes to
    against fp64. It is in the release gate.
  • On GPUs with neural accelerators (M5, M6) the kernels and dispatches are the same as in 0.4.4.

Before and after (M4 Pro, Qwen3.6-35B-A3B 4-bit)

0.4.4 0.4.5
KL vs mlx_lm, 256-token chunks (12 × 512 positions) 3.16 0.0108 (mlx_lm's own chunking band: 0.0098–0.0105)
top-1 flips vs mlx_lm 53% bf16 noise (within the reference's own band)
release-gate logits vs mlx_lm, 4 × 2,048 tokens: sequences with the right top-1 at chunks 1 / 24 / 256 / 1536 4 / 0 / 1 / 1 of 4 (KL up to 11.1) 4 / 4 / 4 / 4 of 4, KL ≤ 0.03

The sorted path is now correct and 1.5–2.2× faster at prefill than the workaround of turning it off
(MOE_SORT_MIN=100000000): 509 vs 235 tok/s at 4k, 212 vs 142 at 16k. If you set MOE_SORT_MIN to work around the
bug, remove it.

The per-position rows (KL, top-1 flips) were measured with the same fix on the development branch, against the
same broken kernels; the release-gate row and the byte-identity checks were run on the 0.4.4 and 0.4.5 release builds.

Upgrade

Download inferd-0.4.5-macos27-arm64.tar.gz and its .sha256 from this release, then:

cd ~/Downloads && shasum -a 256 -c inferd-0.4.5-macos27-arm64.tar.gz.sha256   # prints OK
tar xzf inferd-0.4.5-macos27-arm64.tar.gz && cd inferd-0.4.5
./install.sh && ./run.sh start --model 27b        # or your usual model and flags

Stop the running server first (./run.sh stop in the old directory). Your models and settings carry over. To build from
source, use git checkout v0.4.5. On macOS 26 there is no 0.4.5 prebuilt, so build from source. If you run the
35B-A3B on an M1–M4 Mac, upgrading is strongly recommended. On M5/M6, or with only the 27B or 9B, there is no change
in output, and upgrading is optional.

sha256 (inferd-0.4.5-macos27-arm64.tar.gz): 852066c8e381cd4baf66c2d67d631abb603169b204b927f117ed1daeb1d6ac7a