Results
Three mometal modes and five peers
All benchmarks ran sequentially on one Apple M4 Max (48 GiB unified RAM) serving netprojects/Qwen3.8-27B-pi-adapted-MLX-4bit — harness-hub/Qwen3.8-27B-pi-adapted (an RL LoRA fine-tune for the pi coding agent) merged into Qwen/Qwen3.8-27B and quantized to MLX 4-bit affine group-64 (g64, 4.5 bpw) with Qwen's bundled 228 MiB multi-token prediction (MTP) head.1
Comparing our GPU-only exact g64 mode directly against peers isolates what actually drives each number. Across n=3 interleaved AC-power restarts on identical g64 weights (matching TensorFold and pmetal's greedy SHA-256 on 1 of 4 tasks, C++ refactor 3d678dbd2c6c), GPU-only mometal hits 91.6 tok/s greedy 4-task mean (range 91.1–91.8; +35% over mlx-serve at 68.1 tok/s, 3.4× over mlx-lm) and 271.5 tok/s cold 3.7k prefill inside 16.41 GiB. That shows the decode lead is independent of ANE and hf4, coming from our Metal decode and speculative tree path rather than weight sharing.
Turning on 1-copy ANE-Share (hf4) keeps active memory at 16.24 GiB (0 B swapped) and lifts cold 3.7k prefill 2.3× to 621.9 tok/s (n=3 AC median, range 620.2–623.7; 629.1 tok/s without --cache-dir; 684.7 tok/s at 4,077 tokens), while reaching 93.8 tok/s greedy mean (range 93.8–94.0) on 4.0 bpw per-channel hf4 MLPs.2 Notice that 2-copy ANE + g64 reaches 95.2 tok/s on the exact same greedy token stream as GPU-only g64 (91.6 tok/s) across all three interleaved trials, likely because offloading the 3.7k and 284-token prefills to ANE avoided 13.7 s of full-power GPU heating immediately before decode. Because hf4 weights produce a different greedy token stream from g64, we report exact g64 alongside hf4 and measure the full quality delta in Section 3.
v1.2 release step-up: Keeping the original n=3 interleaved v1.1 rows below as the controlled three-mode baseline, v1.2 pushes 1-copy hf4 significantly further across every regime—lifting 4-task greedy decode from 93.8 to 98.2 tok/s (py_lru 118.9, cpp_refactor 113.4, cpp_spsc 86.6, prose 73.8 tok/s; sampled T=0.7 py_lru 121.4 tok/s), cold 3.7k prefill to 646 tok/s (5.75 s; exact 4,096 tokens: 707.2 tok/s), warm model load down to 550–629 ms (2.7× faster than v1.1's 1.5–1.8 s; server ready in 1.04 s), and FULL M=8 verify down to 38.89 ms while cutting phys_footprint by another −1.5 GiB (6.22 GiB post-decode / 14.08 GiB wired; 5.05 GiB with --mtp off, −2.32 GiB).
Throughput and exact physical memory across Apple Silicon runtimes
Unique-salted prompt guaranteeing a cache miss on AC power. mometal v1.2 (1-copy hf4) reaches 646 tok/s cold 3.7k (5.75 s TTFT) and 707.2 tok/s on exact 4,096 tokens (644.9 tok/s at 512, +80.9% vs v1.1). The three v1.1 rows preserve the balanced interleaved n=3 fresh-restart AC medians (1-copy range: 620.2–623.7 tok/s; 2-copy: 450–497 with --cache-dir under 25.2 GiB pressure).
| Engine | MLPs / KV | Cold 3.7k PF | Warm | Greedy | Py T=0.7 | Total GiB |
|---|---|---|---|---|---|---|
| mometal v1.2 (1-copy)Release · AC · 14.08 GiB wired · 0 swap | hf4 / KV8 | 646 tok/s | 255 ms | 98.2 tok/s | 121.4 tok/s | 14.21 GiB |
| mometal v1.1 (1-copy)ANE-Share · n=3 AC · 15.05 GiB wired | hf4 / KV8 | 622 tok/s | 205 ms | 93.8 tok/s | 102.5 tok/s | 16.24 GiB |
| mometal (GPU-only)Exact g64 control · n=3 AC · 15.21 GiB wired | g64 / KV8 | 272 tok/s | 198 ms | 91.6 tok/s | 116.7 tok/s | 16.41 GiB |
| mometal (2-copy ANE)n=3 AC · 23.95 GiB wired · 1.13 GiB swap | hf4+g64 / KV8 | 465 tok/s | 267 ms | 95.2 tok/s | 117.9 tok/s | 25.20 GiB |
| mlx-serve v26.11.3Zig/MLX 0.32.5 · MTP + warmup-full | g64 / KV8 | 263 tok/s | 173 ms | 68.1 tok/s | 70.1 tok/s | 16.48 GiB |
| oMLX v0.8.3Python/MLX 0.32.4 · MTP · prefix cache | g64 / BF16 | 260 tok/s | 314 ms | 64.0 tok/s | 68.4 tok/s | 18.44 GiB |
| TensorFold v1.3.4Zig/Metal · repacked MTP-6 · 32k alloc | g64 / BF16 | 233 tok/s | 69 ms | 57.7 tok/s | 59.9 tok/s | 21.88 GiB |
| pmetal v0.7.1Rust/Metal+MLX · autoregressive | g64 / BF16 | 254 tok/s | 14,809 ms | 28.5 tok/s | 28.1 tok/s | 19.69 GiB |
| mlx-lm v0.31.3Apple reference MLX 0.32.1 · AR | g64 / BF16 | 256 tok/s | 187 ms | 27.3 tok/s | 27.6 tok/s | 17.35 GiB |
Quality evaluation
Measuring Wave 3 NF4, hf4 and Quest tradeoffs
Apple's Neural Engine achieves full W4A8 prefill throughput on M4/M5 using per-channel asymmetric INT4 weights (hf4, 4.0 bpw with SmoothQuant and MSE clipping) rather than Metal's group-64 affine format (g64, 4.5 bpw). Because single-copy sharing reuses those compiled model.hwx MLPs during decode, we measured the exact quality delta directly against g64 on both language modeling and executed code.7
On eight evenly spaced WikiText-2 test passages (256-token prefill followed by 256 scored decode steps each; 2,048 scored tokens total), KV8 is nearly lossless (+0.003–0.007 PPL), while moving the 64 MLPs from 4.5 bpw g64 to v1.1 4.0 bpw hf4 increases perplexity by +0.23 (+2.98%, mean KL 0.0623, median KL 0.0299, 88.92% top-1, 99.56% top-5 preservation). On the full 164-problem HumanEval coding suite (greedy T=0.0, unit tests executed in isolated Python subprocesses), pass@1 moves from 92.07% (151/164) to 88.41% (145/164), with 93.9% exact per-problem outcome agreement (143 both pass, 11 both fail, 8 only g64, 2 only hf4).
Wave 3 NF4 quality breakthrough: Probing M4 ANE's compiler exposed a decisive hardware fact: blockwise g=128 affine quantization falls back to CPU (no .hwx), but non-uniform NormalFloat-4 palettization (--format nf4, constexpr_lut_to_dense) executes 100% on the Neural Engine at exact 0.5029 B/wt across M1–M5, embedding the 16-entry FP16 NF4 table directly in chunk header bytes [0..31]. On the identical 2,048-token WikiText-2 benchmark, nf4 cuts mean KL divergence vs exact g64 BF16 by −44.3% (0.0623 → 0.0347; median KL −49.3% to 0.0152) and lifts top-1 argmax agreement by +3.90 pp (88.92% → 92.82%, with 99.85% top-5 preservation). Paired with our 1 KB byte-pair threadgroup LUT (s_lut2[256], 0 B extra SRAM, 2.12× faster than simd_shuffle), nf4 hits 41.64 ms FULL M=8 decode (337.6 / 331.0 GB/s) and 429.6 tok/s 4k prefill on M4 Max. Note that MSE-clipped tail sharpness leaves raw NLL slightly above v1.1 hf4 (8.070 vs 8.016 PPL) even as full-vocabulary KL and argmax fidelity jump sharply; HumanEval pass@1 has not yet been re-run on nf4.
| Configuration | 64L build | WT-2 PPL | Mean KL | Med KL | Top-1 | Top-5 / HE |
|---|---|---|---|---|---|---|
| Exact g64 (BF16 KV, reference)4.5 bpw MLPs · GPU-only (272 tok/s PF) | — | 7.7873 | 0.0000 | 0.0000 | 100.00% | 92.07% HE151/164 |
| 1-Copy Wave 3 NF4 (KV8)0.503 B/wt M1–M5 · 41.6 ms M=8 · 430 tok/s 4k PF | 7.23 s | 8.0703 | 0.0347−44.3% KL | 0.0152−49.3% | 92.82%+3.90 pp | 99.85% top-5HE unmeasured |
| 1-Copy v1.2 hf4 (KV8, fixed SQ/zp)0.503 B/wt M4/M5 · 38.9 ms M=8 · 688–707 tok/s 4k | 8.39 s | 8.2485 | 0.0550−11.7% KL | 0.0253 | 89.75%+0.83 pp | 99.80% top-5argmax∈ref5 |
| 1-Copy v1.1 hf4 (KV8, on-disk)4.0 bpw MLPs + KV8 · v1.1 baseline & HumanEval | 16.9 s* | 8.0164 | 0.0623 | 0.0299 | 88.92% | 88.41% HE145/164 · 99.56% t5 |
*v1.1 originally converted MLPs in 4.0 min via Python; v1.2's initial C++ builder took 16.9 s and its ARM64 NEON L1 row-streaming builder cuts 64-layer conversion to 8.39 s (hf4, 2.0×) and 7.23 s (nf4, 2.3×). BF16 KV controls match within 0.0004 KL (nf4 BF16: PPL 8.0733, mean KL 0.0343, top-1 92.87%, ref-top1∈top5 99.85%, argmax∈ref-top5 99.90%; full matrix in JSON dataset).
This tradeoff is selectable at launch via --format auto|hf4|lut4|nf4 or --ane-models off. If a workflow demands exact g64 weights (92.1% HumanEval) and can tolerate 272 tok/s GPU prefill, disabling ANE still delivers 91.6 tok/s greedy decode in 16.41 GiB. For maximum prefill speed on M4/M5 (707 tok/s @ 4k, 98.2 tok/s decode), pick hf4; for the closest distributional fidelity to exact g64 (or native 4-bit single-copy on M1–M3), pick --format nf4.
We also measured opt-in Quest query-aware block-sparse decode against exact dense KV8 at 16k, 32k, and 64k WikiText-2 prefixes (257 scored continuation tokens each; because 257 tokens makes raw ΔPPL noisy, we focus on full-vocabulary KL divergence, Top-1 agreement, and Top-5 preservation). Up to 32k, Quest 8192 stays tight (mean KL 0.0027 at 16k and 0.0169 at 32k, both 100.0% Top-5). At 64k (12.5% coverage), however, Quest 8192 rises to mean KL 0.0916 (worse than 16k Quest 4096 at 0.0811) and drops Top-5 to 99.2%—so we mark Quest 8192 at 64k+ as not recommended. Raising the budget to 12288 halves 64k KL to 0.0492, restores 100.0% Top-5, recalls 3/3 passkeys planted simultaneously at 15%, 50%, and 85% depth (68.8 tok/s), and still runs 61.2 tok/s at 64k and 56.6 tok/s at 128k. We did not measure KL/PPL at 128k, so dense exact KV8 remains the default.
| Prefix & budget | KV cov. | PPL* | Mean KL | Top-1 | Top-5 | Multi-needle |
|---|---|---|---|---|---|---|
| 16k · Dense Exact KV8 | 100% | 7.17 | — | 100.0% | 100.0% | — |
| 16k · Quest 4096Not recommended | 25.0% | 7.73 | 0.0811 | 93.0% | 99.6% | — |
| 16k · Quest 8192Recommended ≤32k | 50.0% | 7.15 | 0.0027 | 98.1% | 100.0% | — |
| 16k · Quest 12288 | 75.0% | 7.17 | 0.0005 | 99.6% | 100.0% | — |
| 32k · Dense Exact KV8 | 100% | 6.77 | — | 100.0% | 100.0% | — |
| 32k · Quest 8192Recommended ≤32k | 25.0% | 6.80 | 0.0169 | 96.9% | 100.0% | 2/2 (top+50%) |
| 32k · Quest 12288 | 37.5% | 6.75 | 0.0028 | 99.2% | 100.0% | — |
| 64k · Dense Exact KV8 | 100% | 6.97 | — | 100.0% | 100.0% | — |
| 64k · Quest 8192Not recommended · KL > 0.08 | 12.5% | 6.62 | 0.0916 | 94.9% | 99.2% | 3/3 (72.8) |
| 64k · Quest 12288Recommended 64k+ budget | 18.8% | 6.72 | 0.0492 | 95.7% | 100.0% | 3/3 (68.8) |
*n = 257 continuation tokens per prefix; single-passage PPL swings (e.g., 6.97 → 6.62 at 64k) are small-sample noise, so KL divergence and Top-1/Top-5 agreement are the reliable fidelity indicators. Multi-needle 64k tested 3 simultaneous passkeys at 15%, 50%, and 85% depth. 128k KL/PPL was not measured.
Kernels, portability and ceilings
Metal kernels, M1–M5 portability and hardware ceilings
Reading Apple's compiled model.hwx directly from Metal is not free: the ANE compiler stripes output channels across 16 interleaved chunks rather than contiguous g64 rows. Our first kernel (matching ANE prefill logits to 10⁻⁶ relative error) ran 3.7 ms/rnd slower than 2-copy g64 (42.06 ms/rnd) on an internal 512→256 benchmark. Seven iterations—including two reverted regressions—closed the gap on M=8 verify to within 0.9 ms/rnd (reaching 360.2 GB/s across the 64 mmap'd model.hwx files, plus a dedicated M=1 ane_hf4 QMV that cut autoregressive step latency from 39.03 → 33.10 ms / 29.2 tok/s). We also empirically confirmed M4 Max's 4-bit compute ridge point at M=16 (26.64 ms / 13.7 TFLOPs), validating M=8 as the speculative verification optimum.
BF16 simdgroup_matrix, TN=1, U=4, KS=1
First correct kernel matching ANE prefill logits to 10⁻⁶ relative error; slowed by half-to-bf16 casts and low register reuse.
Cross-chunk TN=2/4, KS=1 (reverted)
Striding ~700 KB across separate chunks regressed round latency by +2.33 ms/rnd.
K-split 8/4 + selective sub-buffer mmap
Coalesced K-split reads while unmapping all 64 duplicate .safetensors MLPs (−8.90 GiB wired RAM).
Adjacent-slot TN=2/4 in same chunk, KS=8
Pairing consecutive slots inside one chunk (20.5 KB / 8.7 KB apart) cut activation reads 2–4× and dropped latency by 1.57 ms/rnd.
Lane-split + simd_shuffle (reverted)
Adding inner-loop simd_shuffle reductions regressed round latency by +11.24 ms/rnd.
Interleaved load/MMA + slot-major swiglu + dedicated M=1 QMV
Interleaving FP16 simdgroup_matrix accumulation with native 16-bit ushort2 nibble unpacks and slot-major grid mapping hit 360.2 GB/s on mmap'd model.hwx (43.0 ms/rnd; M=1 AR 39.03 → 33.10 ms).
v1.2: PSO function constants, coalesced uint2, KS=4 down_sk4 & 1 KB s_lut2[256]
Compile-time shape specialization (pipeline_u32_constants), coalesced uint2 + simd_shuffle loads, zero-tail-waste 128-thr KS=4 down_sk4, and 0 B-overhead aliased s_lut2[256] push 64× hf4 MLP to 379 / 362 GB/s (FULL M=8: 38.89 ms, M=4: 22.75 ms, M=1: 32.78 ms) and nf4 to 41.64 ms (2.12× faster).
Six first-principles engineering pillars lift v1.2 to 98.2 tok/s greedy decode, 707 tok/s exact 4k prefill, 0.00 GiB swap at 128k, and universal M1–M5 single-copy support:
BitScreen, full-ctx MTP KV4 & shared-base T7
BitScreen packs 98,304 lm_head rows into 1-bit sign(W) (60.0 MiB) in stride-2048 order and scores 3-bitplane activations via popcount + register top-2 into a 32 KiB L2 table (0.16–0.17 ms). tri_probe expands 3 branches inside CB #1 alongside lazy fused GDN replay (−65.9 MB). In v1.2, keeping full-context 1-layer MTP KV4 (only ~128 MB at 128k, avoiding 4k-window acceptance drops) and replacing independent M=4/M=8 EMAs with a shared non-attention base EMA prevented cold-page 128k bandit inversion (64k: 53.4 tok/s, 128k: 37.5 tok/s).
Lean-SRAM FA-2, 4-barrier gqa6 & MTP dead-compute skip
encode_mtp_kv_prime skips dead prefill q_proj, 17th O(L²) attention, o_proj, and 267M MLP (32.31 → 4.86 ms at M=512, −26.0 s at 128k). v1.2 upgrades prefill FA-2 to 4 barriers/tile with disjoint sP[64][36] (22.1 KiB SRAM, 185.1 ms at pos=3072) and adds half2 KV8/KV4 scales + half split-K partials + 4-SG vsplit2 (+21% to +38% at 32k; −11% to −18% at 128k).
Zero-Python C++ build-ane & MTLHeap aliasing
mometal build-ane eliminates Python/coremltools completely: ARM64 NEON L1 row-streaming (20 KB per worker, zero 1.07 GB FP32 matrices) plus branchless 4-level FP16 vqtbl + vfmlalq builds all 64 layers in 7.23 s (nf4, 2.3×) / 8.39 s (hf4, 2.0×). At runtime, MTLHeapTypePlacement aliases 13 disjoint scratch buffers (225.75 → 83.25 MiB, −142.5 MiB), lazy QwenVisionTower + bundled MTP dedup + stepwise KV allocation cut phys_footprint by −1.5–1.7 GiB (CpuMmapQ4Weight cuts −682 MiB more on --mtp off to 5.05 GiB), and 4-deep async warmup trims warm load to 550–629 ms.
Cross-chip M1–M5 single-copy & byte-pair TG LUT
All four shaders compile under Metal 3.0 (auto-enabling Metal 3.1 simdgroup_bfloat8x8 Vision on Apple9+). Because ANECompiler silently promotes linear hf4 to 8-bit on M1–M3 (h13g–h15g), --format auto selects universal 4-bit lut4 on M1–M3 and hf4 on M4/M5+, while opt-in --format nf4 delivers 0.503 B/wt across all five generations. On GPU, aliasing a 1 KB half2 s_lut2[256] table into existing reduction SRAM decodes 2 nibbles in one 32-bit TG load (2.12× faster, 338/331 GB/s).
Hardware ceilings proved on silicon
Direct hardware probes settled three architectural limits. First, rows=256 is the true ANE sweet spot (715–722 tok/s MLP, kts=16 single-copy): rows=128 hits the ANE weight-bandwidth floor (4.44 ms/L, 451 tok/s, −37%), while rows=384/512 hit the ANE SRAM cliff, shattering 16 linears into 144 sub-tiled __KERN tensors (−15% to −23% slower at 553–612 tok/s and breaking single-copy). Second, lean-SRAM occupancy beats wider tiles on Apple GPUs: GQA-2× FA-2 (28.25 KiB) spilled registers (32k: 498 → 452 tok/s) and uint4+float4 KV8 inside 192-thr M=8 gqa6 spilled (128k: 37 → 69 ms). Third, N=256 qs={1,0} with mA=192[ANE] + mB=64[AMX M=8] (414.8 tok/s) proved Pareto optimal over mB ∈ {16..128}.
Async ANE pipelining & shared Quest cache
v1.2 replaces the worker thread/mutex/CV with per-slot persistent dispatch_group_t lock-free async ANE pipelining and absorbs 1–64-token tails onto Half B only (keeping Half A at exact 256/512 rows so 524-token prompts jump +80.9% to 644.9 tok/s and 4,112-token prompts hit 684 tok/s). Stripping decode-only Quest tags from PrefixCache hashes still lets Dense and Quest share exact .micache snapshots on SSD.
| Format flag | ANE target | B / wt | GPU decode kernel | M4 Max 4k PF | M4 Max M=8 | Recommended use |
|---|---|---|---|---|---|---|
--format hf4Default on M4 / M5+ (h16g, h17g) | W4A8 INT4 | 0.503 | ane_hf4_* (379/362 GB/s) | 707.2 tok/s | 38.89 ms | Peak prefill & decode on M4/M5 |
--format nf4Universal M1–M5 (h13g–h17g) | W4A8 NF4 LUT | 0.503 | ane_lut4_* + s_lut2[256] | 429.6 tok/s | 41.64 ms | −44.3% KL quality / universal M1–M5 |
--format lut4Default on M1–M3 (h13g–h15g) | W4 palettized | 0.503 | ane_hf4_* (2's-comp LUT) | probe local* | same as hf4 | Avoids M1–M3 8-bit promotion |
--ane-models offStrict GPU-only fallback | None (g64) | 0.563 | mma_qmm8_q4_g64_* | 271.5 tok/s | 91.6 tok/s | Exact g64 (92.1% HumanEval) |
*lut4 / nf4 binary layouts were verified bit-exact across h13g (M1) through h17g (M5) via ANECompiler.framework; live throughput was measured on M4 Max. Users on M1–M3 or M5 Macs can run the 30-second local compatibility & throughput check via python3 scripts/probe_m_chip.py.
Method and disclosures
Controls, caveats, references and dataset
| Parameter | Measured configuration |
|---|---|
| Hardware, power & idle load | Apple M4 Max, 48 GiB unified memory (546 GB/s), macOS 27.0 (26A428). All three mometal modes (n=3 balanced interleaved restarts), matched controls, 66k paging check, and 4k–128k sweeps ran on AC power (100% charged, zero pmset -g therm warnings; idle baseline 2.78 GiB wired, 1.67 GiB compressor, 18.70 GiB free with desktop apps + Docker Desktop VM ~0.88 GB running; exact process list saved in starmo-mometal-ac-proof-2026.json). |
| Checkpoint | netprojects/Qwen3.8-27B-pi-adapted-MLX-4bit (harness-hub/Qwen3.8-27B-pi-adapted RL LoRA merged into Qwen/Qwen3.8-27B; 64 transformer layers = 48 GDN + 16 full-attn GQA, plus 1 full-attn MTP layer = 17 full-attn layers total, 16 executed during prefill; 15.40 GiB .safetensors). |
| Runtime & native builder | Zero-Python C++20 / Objective-C++ / Metal for both inference and 4-bit ANE MLP conversion (mometal build-ane / auto-build on --ane-share: 8.39 s for 64L hf4, 7.23 s for 64L nf4 via ARM64 NEON L1 row-streaming, replacing v1.1's 4.0 min Python conversion; scripts/probe_m_chip.py checks M1–M5 compatibility in 30 s). |
| Trial counts & peer memory sampling | All three mometal modes ran n=3 balanced interleaved fresh restarts on AC power (1-copy PF 620.2–623.7, greedy 93.8–94.0; GPU-only PF 271.1–271.7, greedy 91.1–91.8; 2-copy PF 450.0–497.2, greedy 95.1–95.3; T=0.7 sampled rows are n=6 means with ±12–13% spread). Five peer speed rows ran n=1 sequentially on AC power (T=0.7 is 2-run mean); peer byte-exact footprint rows ran n=1 on battery power, sampled 0.5 s after 3.7k cold + 3.7k warm + 64-token greedy decode (where pmetal retained MLX prefill scratch buffers at 19.69 GiB vs 15.0 GiB rounded after 8 long decodes). “Cold” denotes a fresh process and cache-miss prompt with warm OS page cache. |
| Versions & repository | mometal (MIT license; AC benchmarked on pre-rename binary SHA-256 8941b000, renamed binary 203489f1; probe script benchmarks/verify_ac_3mode.py and raw footprint/vm_stat dumps in benchmarks/raw_ac_proof/), mlx-serve 26.11.3 (mlx 0.32.5), oMLX 0.8.3 (mlx 0.32.4), TensorFold 1.3.4, pmetal 0.7.1, mlx-lm 0.31.3 (mlx 0.32.1). |
| Disabled extras | mometal --suffix-dir (workspace repo suffix cache) turned OFF for all benchmark numbers. |
In-session suffix cache isolation
Repeating prompts or sweeping multiple context lengths inside one mometal process allows its built-in session suffix cache to draft earlier turns. Every interleaved AC trial and every point of the 4k–128k sweep restarted a fresh server process to eliminate cross-turn carryover.
KV cache parity & prefix restore
mometal and mlx-serve ran KV8; TensorFold enforces BF16 KV on Metal (pre-allocating 32k slots up front, accounting for 21.88 GiB), while oMLX, pmetal, and mlx-lm default to dynamic BF16 KV. Our matched-KV AC control confirms BF16 KV vs KV8 shifts short-context greedy speed by <1% (93.0 vs 93.8 tok/s) and WikiText-2 by +0.0033 PPL, while warm SSD prefix restore (MICACHE2) slows from 205 ms to 355 ms on BF16 KV (vs oMLX at 314 ms).
Excluded engines & peer setup
MTPLX v2.13.1 and vllm-mlx v0.2.5 emitted corrupted tokens on this pi-adapted Qwen3_5 checkpoint even with KV quantization off. TensorFold required repacking MTP keys into language_model.mtp. to activate native --mtp-drafts 6. lithos-metal v0.1.2 requires NVFP4, and llama.cpp requires GGUF.
References
- Dao, T. (2023). FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning. arXiv:2307.08691.
- Xiao, G., Lin, J., Seznec, M., Wu, H., Demouth, J., & Han, S. (2023). SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Models. ICML 2023.
- Miao, X., et al. (2023). SpecInfer: Accelerating Generative Large Language Model Serving with Tree-based Speculative Inference and Verification. ASPLOS 2024.
- Li, Y., Wei, F., Zhang, C., & Zhang, H. (2024). EAGLE-2: Faster Inference of Language Models with Dynamic Draft Trees. EMNLP 2024.
- Dettmers, T., Pagnoni, A., Holtzman, A., & Zettlemoyer, L. (2023). QLoRA: Efficient Finetuning of Quantized LLMs. NeurIPS 2023 (NormalFloat-4 / NF4).
- Tang, J., Zhao, Y., Zhu, K., Xiao, G., Kasikci, B., & Han, S. (2024). Quest: Query-Aware Sparsity for Efficient Long-Context LLM Inference. ICML 2024.
Serving command, source code and open dataset
Zero-Python launch flags for 1-copy 128k local serving on Apple Silicon (--ane-share automatically builds 64L 4-bit MLPs natively in C++ in 7–8 s; source code is open under MIT at github.com/tinjakr/mometal; the benchmark JSON, v1.2 sweep JSON, CSV summary, and raw AC-power proof JSON are published under CC BY 4.0):
# Zero-Python 1-copy 128k serving (auto-selects lut4 on M1-M3, hf4 on M4/M5+; # add --ane-tag nf4 for universal M1-M5 NF4 quality: -44.3% KL, 92.8% top-1): ./build/mometal serve \ --model ~/models/qwen38-pi-adapted-mlx4 \ --ane-share \ --max-seq 131072 --kv-bits 8 \ --cache-dir ~/.cache/mometal-pi \ --host 127.0.0.1 --port 8092 # Optional explicit pre-build (8.39 s hf4 / 7.23 s nf4): # ./build/mometal build-ane --model ~/models/qwen38-pi-adapted-mlx4 --format nf4 # Optional block-sparse decode (recommended 64k+ budget: 61.2 tok/s @ 64k [0.049 KL, 100% top-5]): # --sparse-kv-budget 12288
Cite as: Tinjak, R. (2026). Single-copy ANE weight sharing for local 27B inference on Apple M4 Max. starmo.ai. https://starmo.ai/reports/mometal-ane-share
Questions
What this report answers
How do we verify single-copy ANE sharing actually saves ~8.9 GiB in system RAM?
Using footprint -f bytes --wired --swapped alongside vm_stat, lsof, and /usr/libexec/aned RSS on AC power. Immediately after 3.7k prefill and 64-token decode in our v1.1 n=3 AC proof, 2-copy ANE reports 16.51 GiB phys_footprint plus 8.69 GiB in 192 unmapped neural regions (25.20 GiB total, 23.95 GiB process wired, +23.98 GiB system vm_stat wired delta, 1.13 GiB swapped). In 1-copy ANE-Share mode, unmapped neural drops to 128 I/O regions (0.71 GiB), the exact 8,579,448,832 B (7.99 GiB) of model.hwx weights move into shared wired mapped file, and wired RAM drops −8.90 GiB (15.05 GiB process wired, +15.08 GiB vm_stat wired delta, 0 B swapped, aned RSS 6.6 MiB). v1.2 trims phys_footprint an additional −1.5 to −1.7 GiB across 256→128k (6.05 GiB FP / 14.62 GiB wired at 256–1k; 5.05 GiB with --mtp off; 0.00 GiB swap at 128k).
Does ANE sharing cause the +35% to +44% decode speedup over mlx-serve?
No. With ANE completely disabled on identical group-64 (g64) weights, mometal still reaches 91.6 tok/s greedy decode (n=3 AC median, range 91.1–91.8, vs 68.1 tok/s for mlx-serve) in 16.41 GiB. The decode lead is independent of ANE and hf4, coming from our Metal decode and speculative tree path (0.16 ms BitScreen draft head, tri_probe trees, fused GDN replay, and in v1.2 specialized PSOs + lean-SRAM gqa6 pushing 1-copy greedy decode to 98.2 tok/s and 38.89 ms FULL M=8 verify). The trade of single-copy ANE-Share is 2.3× faster prefill (646 tok/s cold 3.7k; 707.2 tok/s exact 4k) with −8.90 GiB wired RAM vs 2-copy ANE.
What actually happens to 2-copy ANE at long context on a 48 GiB Mac on AC power?
On AC power with 18.70 GiB free at idle, 2-copy ANE at 66k (69,632-slot KV tier) totals 27.40 GiB (26.13 GiB wired, 1.16 GiB swapped). Live vm_stat instrumentation shows XNU's memory compressor thrashing 22.5M compressions (343.5 GiB) and 22.0M decompressions (336.1 GiB) during prefill as GPU weights are evicted to fit ANE, dropping prefill from 389.7 to 311.9 tok/s (−20%). When decode starts, XNU faults 593,657 decompressions (9.06 GiB) and 11,012 pageins back into wired RAM, cutting decode from 45.9 to 37.0 tok/s (−19%). Single-copy stays at 0 compressions and in v1.2 scales all the way to 128k (128,078 tokens) with 0.00 GiB swap, 10.39 GiB phys_footprint, 8.31 GiB ANE resident, and 37.5 tok/s dense decode (53.4 tok/s at 64k).
How does Wave 3 NF4 improve quality and enable M1–M5 single-copy sharing?
On M1–M3 (h13g–h15g), ANECompiler silently promotes linear int4 (hf4) to 8-bit (2× RAM), and on M4 it rejects g=128 blockwise quant to CPU. Encoding weights with 4-bit palettized lookup tables (--format lut4 or non-uniform --format nf4) executes 100% on the Neural Engine at exact 0.5029 B/wt across M1–M5 (h13g–h17g), embedding the 16-entry FP16 LUT directly in __KERN chunk bytes [0..31]. On WikiText-2 (2,048 tokens vs exact g64 BF16), NF4 cuts mean KL by −44.3% (0.0623 → 0.0347) and lifts top-1 agreement by +3.90 pp (88.92% → 92.82%, 99.85% top-5), while our 1 KB byte-pair threadgroup LUT (s_lut2[256], 0 B extra SRAM) runs GPU decode 2.12× faster at 41.64 ms M=8 (338/331 GB/s) and 429.6 tok/s 4k prefill on M4 Max.
Why does prefill slow down from 707 tok/s at 4k to 279 tok/s at 128k?
Prefill latency follows an O(L) linear term from projections, GatedDeltaNet, and ANE MLPs (~1.38 ms/tok) plus an O(L²) quadratic term from the 16 full-attention transformer layers (0.0180 ms/tok per 1k tokens; encode_mtp_kv_prime eliminates the 17th O(L²) MTP attention layer during prefill). The crossover sits near 76.4k tokens; at 128k quadratic attention dominates (~62% of prefill time). In v1.2, 4-barrier single-head FA-2 and single-half tail absorption push 512 prefill +80.9% (356.5 → 644.9 tok/s), exact 4k to 707.2 tok/s, and cut 128k TTFT by another −16.0 s (475.1 → 459.2 s).
Which Quest block-sparse budget should be used at 32k vs 64k+?
Against exact dense KV8 over 257 WikiText-2 continuation tokens, Quest 8192 is well-behaved up to 32k: mean KL 0.0027 (98.1% Top-1, 100% Top-5) at 16k and KL 0.0169 (96.9% Top-1, 100% Top-5) at 32k. At 64k (12.5% coverage), Quest 8192 crosses our quality bar with KL 0.0916 (worse than 16k Quest 4096 at 0.0811) and is not recommended; use Quest 12288 at 64k+ instead (KL 0.0492, 100.0% Top-5, 61.2 tok/s at 64k and 56.6 tok/s at 128k). KL/PPL was not measured at 128k, so dense exact KV8 remains the default.
Version 1.2, 25 Nov 2026: preserves the v1.1 AC-power interleaved n=3 3-mode verification and 66k vm_stat proof, and adds verified v1.2 release results (98.2 tok/s 4-task greedy, 707.2 tok/s exact 4k / 644.9 tok/s 512 prefill, 10/10 green 256–128k sweep with 0.00 GiB swap at 128k and 53.4 tok/s at 64k, 550–629 ms warm load, 7.23 / 8.39 s zero-Python C++ build-ane, M1–M5 cross-chip single-copy, and Wave 3 NF4 with −44.3% KL and 2.12× byte-pair TG LUT decode).