A research release from Luoke Labs: an experiment in pushing a 9B hybrid architecture to its limits on the Apple Neural Engine (ANE) across M6 and M4, not a model used in our products. Code: luokelabs/qwen3.5-9b-ane. ANE weights: Hugging Face.
Conclusions
- M6 (32 GB), quality-matched and speculative on both sides: Long-context code decode at 8K–16K reaches 137–148 tok/s, about 2.2× GPU + DFlash (1.9–2.5× across runs), at 0.136–0.156 J/token whole-machine energy (72%–80% less energy). Short code and JSON prompts are 1.41–1.55× faster; Chinese chat is level in speed (40.7 vs 38.3 tok/s) at 57% less energy; cold prefill (~1,157 tok/s) is level to slightly faster at ~8–9% less energy. English prose is the one clear loss (37.3 vs 46.3 tok/s, −19%).
- Quality is matched only after fixing layers 8–15: Plain 4-bit (LUT4) quantization silently loses 5.1 points on 335-question CMMLU (76.4% vs 81.5%) and loses 10:20 in blind Chinese long-form writing against GPU 4-bit. Restoring precision only in layers 8–15 (per-channel INT8 on M6) recovers the full 81.5% score—matching bf16 and GPU 4-bit—with no significant blind-writing gap (12:16, 2 ties, p = 0.57).
- M4 (24 GB, H16) needs graph rewrites and LUT6: The M4 ANE compiler rejects parts of the M6 graph, and 8-bit weights hit a 3.5× slowdown cliff on H16. Rewriting DeltaNet to 4D channel-major layout, per-channel scales to depthwise convolutions, block Hadamards to a shared matmul, and layers 8–15 plus the layer-0 mixer to LUT6 recovers CMMLU-335 to 80.3% and beats M4 GPU + DFlash on 8K/16K decode (68.2 / 67.0 tok/s, 1.54–2.06×) and cold prefill (419 / 416 tok/s, 1.88–1.99×) at roughly a quarter to a fifth of the net energy per token—though short Chinese chat and English prose remain slower than the GPU.
Data
Without a drafter, a 9B model on the M6 ANE does not beat the GPU. Per-chunk timing shows plain decode is 100% bound by weight-read bandwidth (~4.1 GB per step at ~112 GB/s effective on ANE vs ~139 GB/s on GPU; host and dispatch overhead are under 1%), leaving plain ANE (27–28 tok/s) slightly behind MLX GPU 4-bit (28–30 tok/s).
What flips the comparison is a structural asymmetry in speculative decoding: on the ANE, verifying 8 rows costs almost the same as computing 1 row (~37 ms), and widening to 16 rows adds only ~8% (~40 ms). On the GPU, 4-bit matmul latency climbs sharply past 4–5 rows, capping optimal block size around 5. The ANE can therefore verify up to 16 tokens per ~40 ms weight read while keeping whole-machine power steady at ~19–20 W, multiplying throughput and cutting energy per token together.
M6 Mac mini (32 GB): aligned speed and energy
All columns were measured on an idle machine through the same OpenAI-compatible API and benchmark client (greedy decoding, thinking off, 256 new tokens; energy is whole-machine mactop at 1 s, with net-of-idle at ~1.9 W in parentheses).
| Case | ANE old LUT4 | ANE default (INT8 L8–15) | GPU + DFlash (b5) | GPU plain | ANE default vs GPU + DFlash |
|---|---|---|---|---|---|
| Chinese, 40 hold-out prompts (tok/s) | 45.3 | 40.7 | 38.3 | 30.8 | 1.06× |
| Chinese, 40 prompts: J/token (net) | 0.434 (0.381) | 0.468 (0.420) | 1.100 (1.043) | 0.775 | −57% |
| Short prompts: code / prose / JSON / Chinese (tok/s) | 139 / 41.5 / 166 / 39.8 | 135 / 37.3 / 160 / 36.4 | 95.5 / 46.3 / 103 / 36.1 | ~32 | 1.41× / 0.81× / 1.55× / 1.01× |
| 8K long-context decode (input 7,673): tok/s, J/tok | 146.6, 0.136 | 142.8–147.7, 0.136–0.146 | 64.8–76.3, 0.551–0.647 | 29.5, 0.794 | 1.9–2.3× (median 2.2×), −75% to −79% |
| 16K long-context decode (input 15,865): tok/s, J/tok | 139.3, 0.141 | 136.7–141.3, 0.149–0.156 | 56.3–65.9, 0.609–0.727 | 27.9, 0.857 | 2.1–2.5×, −72% to −80% |
| 8K cold prefill (input 7,673): tok/s, J/tok | 1214, 0.021 | 1157, 0.026 | 1130, 0.0285 | 1027, 0.035 | 1.02×, −9% |
| 16K cold prefill (input 15,865): tok/s, J/tok | 1211, 0.032 | 1127, 0.036 | 1050, 0.039 | 996, 0.040 | 1.07×, −8% |
Two details matter when reading this table:
- Energy inversion on Chinese chat: On the 40 Chinese prompts, enabling DFlash on the GPU gains only 24% speed over plain GPU (30.8 → 38.3 tok/s) while nearly doubling whole-machine power (23.3 → 42.7 W), making GPU + DFlash 42% more expensive per token than plain GPU (1.100 vs 0.775 J). The ANE stays at 18–20 W and uses 0.468 J/token.
- Run-to-run spread and drafter fairness: The long-context benchmark injects a random nonce into every prompt, which shifts greedy continuations and speculative acceptance slightly between runs (within a run, 3 repeats agree to ±1%). We therefore report 4-run ranges and quote about 2.2× rather than a single peak ratio. In addition, GPU + DFlash uses the stock, unmodified z-lab DFlash checkpoint (4-bit full vocab, block 5, no MTP), whereas our ANE default adds exact-target distillation, a re-ranked head subset, and native MTP fallback. Even with both sides using the unmodified z-lab DFlash drafter (no distillation, no MTP), the M6 ANE still reaches 158 / 151 tok/s (0.130 / 0.148 J/token) at 8K/16K—maintaining ~2.3× speed and 75%–79% energy savings from hardware structure alone.
Sampling and thinking mode (M6, measured on INT8 default)
The reference GPU + DFlash loop supports greedy decoding only, so sampling and thinking modes are compared against plain GPU 4-bit on the Chinese hold-out prompts. Rejection-sampled verification preserves the target’s exact sampling distribution on the ANE.
| Mode | ANE default (tok/s) | ANE J/tok (net) | GPU plain (tok/s) | GPU J/tok (net) | ANE vs GPU plain |
|---|---|---|---|---|---|
| Sample: temp 0.7, top_p 0.8, top_k 20, presence 1.5 (40 × 256) | 36.4 | 0.507 (0.440) | 30.2 | 0.786 (0.721) | +21%, −35% |
| Thinking on: temp 1.0, top_p 0.95, top_k 20 (20 × 1024) | 49.0 | 0.387 (0.338) | 30.0 | 0.791 (0.703) | +63%, −51% |
Sampling costs about 10% versus greedy. Thinking traces are more predictable than direct answers, so draft acceptance climbs and the ANE advantage widens further.
Quality alignment: isolating and fixing the layers 8–15 loss
Our early 160-question pilot included only 64 CMMLU items—too small to spot a quantization gap. Expanding CMMLU to 335 questions (67 subjects × 5) and running a 30-prompt blind pairwise Chinese writing evaluation exposed a real loss in all-LUT4 weights: 76.4% vs 81.5% on CMMLU (sign test p = 0.006) and 10:20 against GPU 4-bit in writing.
By restoring groups of layers back to bf16 on a GPU copy of the exact ANE weights, we found the loss was tightly localized: restoring layers 0–7, 16–23, 24–31, or lm_head barely moved the score, whereas restoring layers 8–15 (both MLP and mixer) recovered the full 81.5%. Switching layers 8–15 to per-channel INT8 (growing the target from 4.0 GB to 4.8 GB) aligns both Chinese and English quality with bf16 and GPU 4-bit:
| Evaluation | ANE old LUT4 | ANE default (INT8 L8–15) | Reference |
|---|---|---|---|
| CMMLU 335 q (measured on ANE, 67 subjects × 5, seed 1) | 76.4% | 81.5% | GPU 4-bit 81.5%, bf16 81.5% |
| MMLU 285 q (English, GPU sim of ANE weights, seed 1) | 75.1% | 76.1% | bf16 76.5% |
| Chinese long-form writing, blind (30 × 800 tok, vs GPU 4-bit) | 10 : 20 | 12 : 16, 2 ties (p = 0.57) | baseline |
| IFEval / HumanEval / HumanEval+ (160 q) | 82.8 / 81.3 / 75.0 | 84.4 / 81.3 / 71.9 | paired diff 2/4 and 3/2 (noise) |
Porting to M4 Mac mini (24 GB, H16)
Compiling the M6 packages directly on an M4 fails on all 8 layer chunks and silently falls back to the GPU. Operator-level bisection revealed two hardware/compiler differences between M4 (H16) and M6 (H18): first, the H16 compiler rejects 2D [8192, T] DeltaNet reshapes/transposes, post-conv broadcast channel scaling, grouped-conv Hadamards, and FP8 attention; second, 8-bit weights (INT8 and LUT8) run ~3.5× slower than LUT4 on M4 (36.1 ms for chunk L08–11 vs 6.88 ms on M6), so two INT8 chunks consumed half of total model latency.
Probing LUT6 (64-entry lookup table) broke the deadlock: on M4, L08–11 LUT6 runs in 12.26 ms—matching LUT4’s fast hardware path (10.26 ms) with no 8-bit cliff—while recovering CMMLU-335 to 80.3%. Quantizing the layer-0 DeltaNet mixer (bf16 on M6) to LUT6 as well shrinks the M4 target to 4.2 GB and drops whole-model verify latency to ~93–98.5 ms.
| Case (M4 24 GB, idle 6.0–6.7 W) | M4 ANE (LUT6 target, PP=0) |
M4 GPU + DFlash | M4 GPU plain | M4 ANE vs GPU + DFlash | M6 ANE ref |
|---|---|---|---|---|---|
| Chinese, 40 prompts (tok/s) | 18.8 | 23.3 | 21.3 | 0.81× | 40.7 |
| Chinese, 40 prompts: J/tok (net) | 0.761 (0.404) | 1.415 (1.145) | 1.342 (1.068) | net −65% | 0.468 (0.420) |
| Short prompts: code / prose / JSON / Chinese (tok/s) | 72.9 / 17.6 / 78.8 / 18.3 | 62.4 / 27.1 / 64.0 / 21.5 | 21.4–21.7 | 1.17× / 0.65× / 1.23× / 0.85× | 135 / 37.3 / 160 / 36.4 |
| 8K long-context decode: tok/s, J/tok (net) | 68.2, 0.211 (0.119) | 44.2, 0.754 (0.604) | 20.1, 1.520 (1.203) | 1.54×, −72% | 142.8–147.7 |
| 16K long-context decode: tok/s, J/tok (net) | 67.0, 0.213 (0.119) | 32.5, 1.096 (0.891) | 19.2, 1.600 (1.268) | 2.06×, −81% | 136.7–141.3 |
| 8K cold prefill: tok/s, J/tok (net) | 419, 0.036 (0.021) | 223, 0.166 (0.136) | 223, 0.162 (0.133) | 1.88×, −78% | 1157 |
| 16K cold prefill: tok/s, J/tok (net) | 416, 0.039 (0.024) | 209, 0.163 (0.131) | 209, 0.162 (0.132) | 1.99×, −76% | 1127 |
| Chinese sampling (vs GPU plain) | 17.4 tok/s | — | 18.5 | 0.94×, net −56% | 36.4 |
| Chinese thinking mode (vs GPU plain) | 22.8 tok/s | — | 18.4 | 1.24×, net −64% | 49.0 |
This highlights a clear generational split: M5/M6 GPUs gained dedicated matrix accelerators, making M6 GPU prefill fast (~1,050–1,130 tok/s) so M6 benefits from ANE+GPU pipelining (PP=1). On M4, GPU prefill is only ~220 tok/s, so pure ANE prefill (PP=0) runs nearly 2× faster than M4 GPU at roughly a quarter of the energy—pipelining actually slows M4 down by 7–11% at 2.8× the energy.
Draft head vocabulary fix and L08–11 format probes
During Chinese optimization, three rounds of distillation stalled near ~1.8 tok/verify. Inspecting the subset draft heads (98K rows for DFlash, 32K for MTP) exposed the root cause: the old vocabulary ranking—built from small local text plus raw token-ID order—excluded nearly a third of Chinese target tokens, making them impossible to draft. Re-ranking by the ANE teacher’s actual argmax frequency raised Chinese 40-prompt speed by +13% (39.4 → 44.5 tok/s on LUT4) and structured output by +4% with zero retraining:
| Vocabulary ranking | Head size | Chinese OOV | English OOV | Code OOV | Structured OOV |
|---|---|---|---|---|---|
| Old ranking (local freq + raw ID fill) | 32K | 32.4% | 7.2% | 5.0% | 7.4% |
| Old ranking (local freq + raw ID fill) | 98K | 31.5% | 0.32% | 0.04% | 1.4% |
New ranking (ANE teacher argmax freq, _vk) |
32K | 3.3% | 5.4% | 2.3% | 0.85% |
New ranking (ANE teacher argmax freq, _vk) |
98K | 0.75% | 0.52% | 0.21% | 0.04% |
To pick the M4 weight format, we probed four encodings of chunk L08–11 (v8_8k, all using HAD_BMM=shared) on both chips:
| L08–11 weight format (shared Hadamard) | M6 chunk latency (ms) | M4 chunk latency (ms) | CMMLU-335 (sim) |
|---|---|---|---|
| LUT4 | 4.39 | 10.26 | 77.0% |
| LUT6 (adopted on M4) | 5.74 | 12.26 | 80.0% |
| LUT8 (per-row table) | 17.15 | 33.40 | 81.5% |
| INT8 (adopted on M6) | 6.88 | 36.14 | 81.5% |
Method
Architecture and key engineering changes
The stack is built on anemll-forge (MIT, commit 703131e) with six clean patches covering five areas:
- Target quantization and adaptive 8/16-row verify (
GDN_P=16): GPTQ LUT4 (online block-Hadamard basis, calibrated on 64 WikiText-2 + 64 Chinese Wikipedia rows), with layers 8–15 promoted to per-channel INT8 on M6 and LUT6 (plus the layer-0 mixer) on M4. Widening DeltaNet’s lazy-commit pending buffer from 8 to 16 lets every 4-layer chunk export bothv8andv16entries (6 functions per chunk, under the ANE 7-function fast-entry limit). The server switches between 8-row and 16-row verify per cycle via an acceptance EMA. - Hybrid drafting + exact-target soft-label KD: The 6-layer 1.3B z-lab/Qwen3.5-9B-DFlash drafter (with its 32,768-channel
fcsplit into two 16,384-channel convs to compile on ANE) is paired with Qwen3.5-9B’s native 1-layer MTP head (189 MB). When DFlash’s acceptance EMA falls below0.6, the server routes to MTP and probes DFlash every 24 cycles. External KD against a bf16 teacher failed to transfer because bf16 and the ANE target disagreed on 19% of top-1 tokens (KL 0.19); switching to exact ANE target features and top-64 soft labels (15,578 rows including Chinese, English, code, and 3,000 structured-output prompts) lifted JSON by +30% and structured prompts by +27%. - Two-tier prefix caching and ANE+GPU pipelined prefill: During prefill, 33 MB DeltaNet snapshots are saved every 512 tokens so follow-up questions on the same document skip recomputing the shared prefix. When a new request would evict ≥1,024 cached tokens, the active KV rows, key snapshots, and drafter ring are stashed in RAM (3 GB LRU cap), holding multi-document and multi-chat TTFT to 0.2–0.7 s. On M6, cold prefills of ≥1,024 tokens run layers 0–15 on ANE (64-row blocks) overlapped with layers 16–31 on GPU (512-row MLX fp16 batches using exact dequantized ANE weights), handing KV (fp16 K / int8 V) and DeltaNet state back to ANE (final-y cosine 0.99988, KL 0.0002–0.0014).
- Zero-copy prefill views and streaming UTF-8 fix: Even a few milliseconds of host-side row copying between consecutive 64-row ANE prefill calls causes the ANE to drop into a low-power state and double its runtime; switching to zero-copy views eliminated the regression. We also added
RESET_CLEAR_KV=1to clear stale KV rows between requests (preventing attention tile-scale drift) and buffered incomplete trailing multi-byte UTF-8 characters in streaming mode, eliminatingU+FFFDcorruption. - M4 H16 graph rewrites: Keeping DeltaNet
in_proj → conv1d4D(1, C, 1, P+3)(GDN_CM), replacing broadcast per-channel scale multiplies with 1×1 depthwise convs (QCONV_SCALE=dw, avoiding the 4× slowdown of folding scales into per-row LUTs), replacing grouped-conv Hadamards with signs plus one shared 1024×1024 matmul (HAD_BMM=shared), and usings8,s8battention without FP8.
Hardware, software, and evaluation protocol
- Machines: M6 32 GB (macOS 27.0.1, idle ~1.9 W) and M4 24 GB (macOS 27.2.1, idle 6.0–6.7 W), both tested idle (load ~1.5).
- Baselines: MLX 4-bit (group size 64) Qwen3.5-9B; GPU + DFlash runs z-lab’s official MLX loop with GDN state rollback (block 5, 4-bit drafter). All setups are benchmarked through the same OpenAI-compatible API and client scripts.
- Power: Whole-machine power via
mactopat 1,000 ms. On M6 without root, ANE-only power cannot be separated; SMC single-unit rail mapping confirms the GPU rail (PP1b) sits at 0.0 W during ANE decode, with whole-machine decode power at 19.6 W vs 23.9 W on GPU. - Quality: CMMLU-335 (67 subjects × 5, measured on ANE), MMLU-285 (57 subjects × 5, GPU simulation of exact ANE weights), 160-question pilot (IFEval 64 + HumanEval/HumanEval+ 32 + CMMLU 64), and 30 blind pairwise Chinese writing prompts (800 tokens, randomized A/B order).
Reproduce
All code, anemll-forge patches, and prebuilt weights are publicly available and can be run without redoing GPTQ:
- Code: luokelabs/qwen3.5-9b-ane (MIT)
- Prebuilt weights (M6
target_m6/and M4target_m4/): luokelabs/Qwen3.5-9B-CoreAI-ANE
1. Set up the environment (Apple Silicon Mac, macOS 27)
git clone https://github.com/luokelabs/qwen3.5-9b-ane q9 && cd q9
. ./env.sh
git clone https://github.com/Anemll/anemll-forge.git "$FORGE"
git -C "$FORGE" checkout -b q9 703131e
git -C "$FORGE" am "$Q9"/patches/anemll-forge/*.patch
# Follow anemll-forge's README to create the Python 3.11 venv and build the Core AI Swift bridge.
# Install mlx in that venv (or MLX_PY) if you want PP=1 pipelined prefill on M6.
2. Download prebuilt weights and start the server
On M6 (omit M4 weights with --exclude "target_m4/*"; if MLX is absent, the script falls back to PP=0 automatically):
hf download luokelabs/Qwen3.5-9B-CoreAI-ANE \
--exclude "target_m4/*" \
--local-dir "$Q9_MODELS/Qwen3.5-9B-CoreAI-ANE"
HF_DIR="$Q9_MODELS/Qwen3.5-9B-CoreAI-ANE" runtime/serve_q9.sh 16384
On M4 (PP=0 and COREAI_ALLOW_PRE_M5=1 are enabled automatically):
hf download luokelabs/Qwen3.5-9B-CoreAI-ANE \
--exclude "target_m6/*" --exclude "gh_packed/*" \
--local-dir "$Q9_MODELS/Qwen3.5-9B-CoreAI-ANE"
M4=1 HF_DIR="$Q9_MODELS/Qwen3.5-9B-CoreAI-ANE" runtime/serve_q9.sh 16384
The first startup compiles the Core AI packages for your Mac (a few minutes; subsequent loads take seconds from cache) and serves an OpenAI-compatible API on 127.0.0.1:8775 (model name q9).
3. Re-run benchmarks
All evaluation scripts live under eval/:
- 8K / 16K speed, power, and 160-question pilot:
eval/run_q9_serve_full.sh - CMMLU-335, Chinese writing, and greedy / sampling / thinking speed:
eval/bounds_bench.py - GPU + DFlash baseline server:
eval/gpu_df_server.py - Layer-wise quantization sensitivity:
eval/qsens.py
To rebuild everything from the original bf16 checkpoints (GPTQ, INT8/LUT6 patches, Core AI builds, and drafter distillation), follow the Reproduce section of the repository README.
Limitations
- Asymmetric drafter baseline: GPU + DFlash runs z-lab’s research MLX loop (unmodified drafter, greedy-only, no MTP) rather than a production inference engine, while our ANE default adds target-matched distillation, vocabulary re-ranking, and native MTP fallback (the unmodified-drafter comparison is noted in the Data section).
- Workload dependence: Low-acceptance prose shrinks speculative decoding gains—on M6, English prose is 19% slower than GPU + DFlash; on M4 (~93 ms per target call), short Chinese chat (18.8 vs 23.3 tok/s) and English prose (17.6 vs 27.1 tok/s) lag the GPU, so M4 ANE is best reserved for long-context decode, structured/code output, and cold prefill.
- Memory and storage footprint: The M6 default uses 4.8 GB (target) + 0.85 GB (DFlash) + 0.19 GB (MTP); enabling
PP=1keeps an extra ~6.5 GB of fp16 GPU weights resident (1.6 GB packed download, 6.7 GB unpacked on disk), plus up to 3 GB for prefix stashing. Smaller-memory devices (16 GB or less) should runPP=0and consider the lighter MTP-only drafter. - Hardware coverage and measurement scope: Tested on one M6 (32 GB) and one M4 (24 GB) machine; M5 and Pro/Max/Ultra silicon are untested. Wired memory was not measured on M4. Energy figures are whole-machine totals because non-root macOS cannot isolate ANE-only watts. The released
target_m4/LUT6 tables come from an earlier table-fit revision (current scripts reproduce layers 8–15 within 0.4%–0.8% index difference). - Research prototype status: These packages and scripts are research releases rather than a production engine. The distilled DFlash drafter was trained against the earlier all-LUT4 target and has not yet been re-distilled against the INT8 layers 8–15 target.
Changelog
- 2026-12-04: first version, covering M6 (32 GB) and M4 (24 GB) benchmarks and open-source release links.