The MLX-Vulkan backend was not broken: decode 5.78 to 28.43 tokens/s
On one M2 Ultra, MLX on Vulkan measured 5.78 tokens/s of decode where llama.cpp on the same Vulkan driver measured 44.65, which looked like a broken backend. It decomposed into three measured factors: weights and adapter 4.118×, protocol 1.194×, our own patch set 1.267×. Most of the gap was our GGUF path, which runs f32 activations and spends 43 % of decode GPU time on type casts. Prefill is the real remaining weakness, still 3.5× off llama.cpp.
A 4-billion-parameter model, one Apple M2 Ultra, one Vulkan driver. MLX measured 131.1 tokens/s of prefill and 5.78 tokens/s of decode. llama.cpp, through the same Honeykrisp driver, measured 523.845 and 44.647. Decode was 7.7 times slower. That looked absurd enough to call the backend broken.
It was not the backend. Decomposed on the same boot, the same frozen prompt and the same model class, the gap was weights and adapter 4.118×, protocol 1.194× and our patch set 1.267×. Together they close it: 5.781 → 28.428 tokens/s, with no driver change, no new Mesa, and no upstream fork.
The reversal is uncomfortable and worth stating plainly. The number was real. The explanation we first reached for — a young Vulkan backend on alien hardware — was wrong. The dominant term sat in the loader we wrote.
Prefill is the pass that reads the prompt; decode generates one token at a time afterwards. MLX is Apple's array framework, and omarchy-mlx is a patch set that runs it on Vulkan under Linux. Honeykrisp is Mesa's Vulkan driver for Apple GPUs.
The two numbers that did not fit
Both rows below come from the same machine and the same Qwen3-4B file: our GGUF, mapped zero-copy into MLX by an adapter we wrote.
| path, 952-token prompt | prefill tok/s | decode tok/s |
|---|---|---|
| omarchy-mlx, our GGUF adapter (N=5) | 131.126 | 5.785 |
| llama.cpp-Vulkan, same silicon and driver | 523.845 | 44.647 |
Sources: row 1 of docs/benchmarks/evidence/agx-metal-parity-20261023/MLX-RECEIPTS.md for the MLX baseline and docs/benchmarks/evidence/mlx-vulkan-20261022/README.md:144 for the engine table. Both are conditional measurements, not clock-asserted performance data, for the reason in the last section.
The receipt defines its own fields, and they matter when comparing across engines. Decode is 32 / decode_seconds over the 32 decode intervals only, with time to first token excluded; prefill is 952 / ttft_seconds. Neither is end-to-end throughput, and llama.cpp's rows use its own prompt-eval and eval timers. The baseline is also a speed measurement on a deterministic prefix: its generated ids first diverge from the llama.cpp reference at index 28, so no coherence claim rides on any number here.
The first hypothesis was the patch-set. We had four patches written against omarchy-mlx and had never measured them on hardware. If the backend were leaving that much on the table, maybe the patches would move it.
They did, and not nearly enough. Four patches, each measured in five independent processes behind the registered token-id gate:
| arm | patches | prefill tok/s | decode tok/s |
|---|---|---|---|
| control | none | 131.098 | 5.781 |
| constants | 0001 | 131.676 | 7.380 |
| batch | 0002 | 133.201 | 6.821 |
| wide tile | 0003 | 135.585 | 5.787 |
| combined | 0001+0002+0003 | 137.661 | 7.299 |
Source: row 2 of docs/benchmarks/evidence/agx-metal-parity-20261023/MLX-RECEIPTS.md (per-arm medians; detail in .../wide-run/d1-mlx/c27a/REPORT.md). That is +5.00 % prefill and +26.3 % decode, ranges disjoint against the same-wheel control. Real, worth keeping, and nowhere near 7.7×.
A fifth patch, bringing the whole decode step into one submission, changed the combined arm by +0.34 % prefill and +0.34 % decode — inert, as its own header predicted. Source: row 3 of the same index (.../d1-mlx/c40a/REPORT.md).
So the patch path was not the explanation either. The remaining suspects were the model path and the harness, and both were ours.
Where the 4.1× actually is
The banked kernel census explains it. One profiled 952+13 request produced 36,134 dispatches in 6,664 submissions (docs/benchmarks/evidence/mlx-vulkan-20261022/census/analysis.txt:3), with the GPU busy 87.99 % of the span. In decode alone, a decoded token is 1,386 dispatches and 219 submissions, and 508 of those dispatches are one operation: AsType, a type cast.
| per decoded token | measured |
|---|---|
| dispatches | 1,386 |
AsType casts | 508 |
| cast time | 60.33 ms (43 % of decode GPU) |
| GPU busy | 140.1 ms of a 173.0 ms token wall (81 %) |
| host submission | 61.2 ms (35 %, overlapping) |
| single largest dispatch | one 40.4 ms CopyGeneralF16 |
Sources: rows 6 and 8 of docs/benchmarks/evidence/agx-metal-parity-20261023/MLX-RECEIPTS.md for the per-token figures, which re-cut the banked census in docs/benchmarks/evidence/mlx-vulkan-20261022/census/analysis.txt (row 8 is the phase cut: decode_steps_profiled: 24, AsType 508 at 60.325 ms, GPU busy 140.13 ms, host submit 61.23 ms). The census build is a diagnostics build; it is not a timing run.
Two conclusions follow directly. Decode was GPU-bound, not submission-bound: the GPU was busy four-fifths of the token, and collapsing submissions without changing the graph could recover at most the idle fifth. Patch 0004 measured that ceiling and found 0.34 %. And the GPU was busy with the wrong work — casts and copies were 49 % of its budget, while the actual matrix-vector product was 42.6 ms.
The adapter is why. It maps GGUF Q4_0 weights and runs the graph with f32 activations. MLX promotes the f16 affine parameters to f32 on every quantized matmul, so every layer casts. The replacement path was already installed on the same machine: an MLX-native 4-bit checkpoint of the same model, group size 64, bf16 activations.
Holding the serial protocol fixed and changing only the weights and adapter:
| weights and adapter | protocol | decode tok/s | prefill tok/s |
|---|---|---|---|
| GGUF Q4_0, group 32, f32 activations | serial-step | 5.781 | 131.098 |
| MLX 4-bit, group 64, bf16 | serial-step | 23.805 | 148.481 |
| MLX 4-bit, group 64, bf16 | generate_step, prompt cache | 28.428 | 150.697 |
Source: rows 9 and 10 of docs/benchmarks/evidence/agx-metal-parity-20261023/MLX-RECEIPTS.md — row 10 is the per-arm receipt (tg_median, pp_median_tok_s, ids_identical: true), row 9 the chain and its premise corrections. The native rows are nine trials across three preflight-accepted processes, tokens identical across all of them. The last two rows are not the registered protocol and are labelled that way in the receipt.
The decomposition is therefore three measured ratios, each with one variable held:
| factor | measurement | effect |
|---|---|---|
| weights and adapter | 5.781 → 23.805, protocol identical | ×4.118 |
| protocol | 23.805 → 28.428, weights identical | ×1.194 |
| our patch set | 5.781 → 7.325, frozen protocol | ×1.267 |
The product is 4.916×, or 28.43 tokens/s. Inside the 4.1×, the split between group-32 versus group-64 quantization, activation dtype, and the adapter's per-token host bookkeeping is not separated by these measurements. The cast census points at activation dtype; that is an inference, not an isolated cause. The one-line experiment that would test it — forcing the adapter to build an f16 graph — has not been run.
One defect appeared while measuring and is retained: with the f32 GGUF graph, the default prefill path in mlx-lm 0.31.3 raises RuntimeError: NYI at mlx_lm/generate.py:442, evaluating the prompt-cache state. Pinning the prefill chunk to the exact prompt length runs it. The same default chunk runs cleanly on the bf16 MLX-native checkpoint, so this is an adapter-graph interaction, not a version-wide bug. Which chunk sizes fail was not bisected.
Against upstream's own numbers
omarchy-mlx publishes a Linux-versus-macOS table on one M1 Max, same models, same mlx-lm 0.32.0. Its own hardware table lists M2 Ultra as untested — the machine used here. The rows whose driver build is recorded ran on main at e57cb301 with a private Honeykrisp ICD at Mesa git 6543eeb7df7; for the remaining rows the driver build was not recorded. Their methodology is a median of 10 greedy generations of 64 tokens for decode and a median of 5 runs of a 512-token prompt for prefill.
Their published Qwen3-4B-Instruct-2507 row is 21.98 tokens/s decode and 185.35 prefill on a 13-inch M1. Our serial loop on identical-class native weights measures 23.805 on the M2 Ultra, and 28.428 with native batching.
That comparison should not be read as a win. Different silicon, different driver builds, different prompt length and a different decode window. It says one thing only: once the weights are MLX-native, this stack is in the same range as their published row, and the 7× deficit was not a property of the backend.
What is still slow: prefill
Prefill never left the 130–150 tokens/s band. On llama.cpp-Vulkan, 952 prompt tokens at 523.845 tokens/s is 1.82 ms per token. Here it is about 7.5 ms per token.
The census names the cost. QmmTileF32, the quantized-matmul tile kernel that dominates prefill, accounts for 67.7 % of profiled GPU time at a mean 23.99 ms per dispatch (docs/benchmarks/evidence/mlx-vulkan-20261022/census/analysis.txt:11; per-token prefill cost from row 6 of the receipt index). The dispatch carries too little work: at 952 rows the kernel's tile row groups are small, so weight staging and dequantization are repeated per launch.
This is the same lesson our own AGX replay engine proved on the same day. Widening the prefill batch from 32 rows to Metal's 512 took that engine from 832.69 to 1,820.43 tokens/s with the same kernels (wide prefill). Patch 0003 applies the same idea inside omarchy's scalar tile and buys 3.42 % — a narrow tile, not a wide batch. The backend's dispatch geometry, not its arithmetic, is the lever still unexploited.
The decision: pin the platform, change our code
Two operator decisions are now recorded in the campaign's patch handoff: row 13 of docs/benchmarks/evidence/agx-metal-parity-20261023/MLX-RECEIPTS.md, source benchmarks/mlx-vulkan-parity/README.md.
First, omarchy-mlx is the primary path, and the other MLX-on-Vulkan patch set stays a measured comparator. The upstream contribution targets omarchy, after testing.
Second, and more constraining: the stack stays pinned. Mesa 26.1.8 and Honeykrisp, no driver upgrade, no second parallel install. Every gain has to come from adapting code to that platform. Row 12 records the verified identity: Honeykrisp, Mesa 26.1.8, Apple M2 Ultra (G14D B1).
That pin has a known cost. mlx-omarchy warns at every import that Mesa older than 26.2.4 can return wrong results from int8 and other shift-heavy kernels. The warning is retained verbatim in every receipt, and driver behavior remains an unquantified variable. It cannot explain the whole gap: the same pinned driver serves llama.cpp at 523.845 and 44.647.
What goes upstream, and what does not
Four patches exist. Three are candidates for upstream; one stays home:
| patch | what it changes | measured here |
|---|---|---|
| 0001 constant caching | adapter only: caches f32 scale/bias copies, freezes an inference-only quantized-linear class | +27.7 % decode alone; not proposed upstream |
| 0002 batched forward graphs | suppresses discretionary node splits inside a forward graph | +1.60 % prefill |
| 0003 wide f32 qmm tile | 64×16 outputs per threadgroup for large-row f32 affine qmm | +3.42 % prefill |
| 0004 one submission per step | defers opportunistic commits to the step boundary, keeps every mandatory split | +0.34 % / +0.34 % on the frozen path |
Sources: rows 14 through 18 of the receipt index, and benchmarks/mlx-vulkan-parity/upstream/PR-series.md with PR-0001.md through PR-0004.md. Every patch is default-off, and each keeps the correctness boundaries that force a submission: byte pressure, host-visible reads, event waits, fence signals. Patch 0004's own claim — one submission per uninterrupted GPU step — is not contradicted by its 0.34 %; the serial adapter's per-token host reads force splits, so the collapse it targets never materialises in this benchmark.
The plan is three to five patches, submitted only after same-boot A/B testing with per-patch numbers. The three upstream drafts are above, and patch 0001 stays a harness change. Two more are designed and not yet written or measured: a fix for the buffer-copy residency behind the single 40.4 ms CopyGeneralF16 per token, and a rows-per-dispatch fix for QmmTileF32, whose 23.99 ms mean per dispatch is the measured prefill target.
No number in those drafts is a result yet. The gate is a fresh control on the same boot, five independent processes per arm, admission prefixes and the first-logits hash on every child.
What this does not say
- Clocks cannot be asserted on this platform. GPU frequency scaling runs in firmware with no Linux interface to read or pin it, so every receipt carries
clock_assertion=UNASSERTABLE reason=firmware_dvfs_no_devfreq. These are conditional measurements, internally consistent and gated, not certified performance data. - The windows differ between engines, and between our own arms. MLX prefill here is prompt tokens over time to first token; llama.cpp reports its own prompt-eval timer. Decode for MLX is a host-window measure over 32 intervals; our AGX figures elsewhere use a GPU device interval. No ratio in this post crosses those windows without saying so.
- This is one model, one prompt, one machine. 952 prompt tokens, 33 generated, Qwen3-4B, one M2 Ultra. The 28.43 figure is not the registered protocol and is labelled non-frozen in its receipt.
- Full-reference coherence is not claimed. The baseline's generated ids diverge from the llama.cpp reference at index 28. Speed numbers describe a deterministic admitted prefix, not a coherence result.
- The driver is an open variable. The pinned Mesa predates the private ICD the upstream numbers used, and the int8 warning is unresolved. No driver-side improvement is claimed or attempted.
Where the numbers live
Paths are relative to the campaign repository. The primary index is docs/benchmarks/evidence/agx-metal-parity-20261023/MLX-RECEIPTS.md (commit caf5352be), an append-only table of every MLX receipt from 2026-10-23 with a sha256 per row, the field definitions and the clock clause. Rows used here: 1 baseline, 2 per-patch arms, 3 the 0004 rebuild, 6 and 8 the per-token census cut, 9 and 10 the weights/protocol chain, 12 platform identity, 13 the decisions, 14–18 the upstream drafts.
- First survey and engine table:
docs/benchmarks/evidence/mlx-vulkan-20261022/README.md - Kernel census and host accounting:
docs/benchmarks/evidence/mlx-vulkan-20261022/census/analysis.txt - Frozen baseline execution log:
docs/benchmarks/evidence/agx-metal-parity-20261023/wide-run/EXEC-LOG.md:28-35 - Per-patch reports:
.../wide-run/d1-mlx/c27a/REPORT.mdand .../d1-mlx/c40a/REPORT.md - Per-token breakdown:
.../wide-run/d7-reality-check/README.mdand receipts/task1-breakdown.json - Weights and protocol decomposition:
.../wide-run/d8-omarchy-gap/README.mdand receipts/run/combined-summary.json - Decisions, pin, patch drafts:
benchmarks/mlx-vulkan-parity/README.md, pins.json, upstream/PR-series.md - Upstream claims quoted above: the omarchy-mlx
README.mdhardware and "How close to macOS" sections, plus its docs/BENCHMARKS.mdfor the Qwen3 row and methodology.
Reproduction of the frozen arm: 952 prompt ids, 33 generated, 32 decode intervals, fresh caches, greedy, EOS retained, setup excluded, one warmup and one measured trial per process, one child at a time under exclusive GPU occupancy.
