Qwen3.6-27B decode on an Apple M5 Pro
Technical report for qwen36-metal-research · Navilan Santhanakrishnan · August 2026 · Change ledger, 106 entries
The research half of an effort to make one model decode faster on one machine: Qwen3.6-27B-Q4_K_M on a binned M5 Pro with 16 GPU cores and 24 GiB of unified memory. Context stays at 4096 and the quantization is never changed.
Decode went from 14.567 tok/s to ~29.4 tok/s (2.0×), measured by the frozen interleaved A/B tool as the steady-state mean over the frozen prompt set. The current target is 30 and has not been reached; the change ledger records why, entry by entry, including the failures, and the failures are most of it.
Two things got it there, and both were lines this project had already written off: a collaborator’s kernel stack (Shrey Vishen’s; see prior work) that sat unmerged for the whole effort (+10.4%, LEDGER 096), and a draft-vocabulary trim that had been closed against an N four times too small (+6.93%, p=0.0312, LEDGER 097/101/105).
An earlier target of 40 was shown to reduce to one falsifiable number: it requires a drafter with sustained per-step acceptance ≥ 0.84, against the MTP head’s measured 0.79 → 0.62 → 0.40 (LEDGER 092).
The kernels and llama.cpp changes live in a separate llama.cpp fork (branch sgmv-q4k). This report is the method, the measurement harness, and the evidence. The code is not public at the moment and is available on request.
The result
| before | after | |
|---|---|---|
| decode, MTP speculative (frozen A/B, steady state) | 14.567 tok/s | ~29.4 tok/s |
| width-8 verification | 215.2 ms | 110 ms |
| width-3 verification | 129.5 ms | 107.4 ms |
| Q4_K mat-vec, m=4096 k=14336, n=8 | 510 µs | 229 µs |
Per category the spread is wide and it is entirely acceptance: json-01 reaches 38.1 tok/s and longctx-01 17.9, at a cycle that varies by under 5%. A single absolute number from this rig carries about ±2.4%, so paired A/B deltas are quoted as deltas and never as levels; LEDGER 063 and LEDGER 089 are both corrections of exactly that mistake.
Decode at one token per forward pass is capped at 16.40 tok/s: 16.5 GB of weights over 270.8 GB/s of measured bandwidth. Everything above that line comes from accepting more than one token per pass, which is why every speculative figure is reported with its acceptance rate beside it.
What is published
- The change ledger: every change tried, with its measured effect and verdict. It is the primary artifact, append-only, and rejections are kept with the reason. Also as raw Markdown.
- This page: the method, the harness rules, and the result.
The ledger refers to working documents that are not reproduced here: GOAL (the target and the rules the work runs under), HARDWARE (measured bandwidth, FLOP/s and thermal reference), MODEL (tensor census by quant type), BASELINE, NOISE (the null test, the positive control and the 3.0% MDE) and LEADS (ranked hypotheses).
The harness
The numbers in the ledger are only worth reading because of how they were taken. The rules, and the scripts that enforce them:
bench/env.sh: a gate that refuses to benchmark on battery, in Low Power Mode, while Spotlight is indexing, above a load average of 3.0, or with any process over 50% CPU. Apple Silicon drops GPU clocks on battery, so a number taken there is not comparable to one that is not.bench/lock.sh: an exclusive measurement lock. There is one GPU and a model that occupies 16 of 24 GiB. Two benchmarks at once do not produce obviously bad numbers; they produce plausible ones.bench/ab.sh,bench/specab.sh: interleaved ABBA A/B with an exact sign-flip permutation test. Both arms are the same binary, selected by an environment variable, so a rebuild cannot be mistaken for an effect. Six pairs is the minimum that can reach p < 0.05 (p = 2/2n).bench/decode.sh: discards any run over 25000 swap pages or 5% relative standard deviation, and checks prefill health so a regression cannot hide.bench/quality.sh,quality-run.sh: greedy token-exactness, perplexity, KL-divergence, andtest-backend-ops. Run throughquality-run.sh:llama-perplexitydefaults to a batch that allocates 2 GB of logits and runs out of memory.bench/spec.sh: speculative decoding, always reporting acceptance and mean accepted tokens per forward pass. A speculative tok/s without acceptance beside it cannot be told apart from a drafting change.bench/sgmv.m,sgmv.metal: a standalone Metal probe for the kernel work. Iterating here takes seconds; a llama.cpp rebuild plus an A/B takes half an hour. Most of the kernel design was found in this file.bench/bwprobe/,bench/gpuinfo/,bench/sgmap.m: the machine-truth probes for attained bandwidth, GPU clock and throttle, and the empirical recovery of the simdgroup matrix lane-to-element layout.probe/mmapeak.m: peak arithmetic throughput of each matrix path with zero memory traffic. This is the probe that overturned the effort’s inherited roofline:simdgroup_float8x8runs at 6.1 TFLOP/s, the same as scalar fp32 fma, not the 17.6 assumed since LEDGER 035.probe/scmv.m: a column-exact scalar multi-column Q4_K mat-vec, built to test whether verify could do only the columns it needs. Correct at every shape and 3.4× off the simdgroup kernel; the negative is the result (LEDGER 084).
The minimum detectable effect is 3.0%, established by a null test (two identical arms, which must report no difference) and a positive control (a deliberate 20 ms/token slowdown, which must be detected; it was, at p=0.0078).
Replicating needs a GGUF of Qwen3.6-27B-Q4_K_M, an Apple Silicon machine, and the code. Nothing here assumes an M5 Pro except the recorded constants, which is the point: any constant tuned for a different core count has to be re-derived, not inherited.
Reading the ledger
Entries are numbered and append-only. A verdict of KEEP means an A/B cleared the 3.0% MDE with p ≤ 0.05; REJECT means it was measured and lost; NO DIFFERENCE means the test could not distinguish it from noise. Rejections are the majority and are kept deliberately: several of this effort’s best ideas are in there, refuted.
A few entries worth reading on their own:
- 036, 037:
simdgroup_matrix::thread_elements()is writable, and the empirical recovery of its implementation-defined lane-to-element layout. This is what made the kernel possible. - 038: the kernel’s progression from 68 to 170 GB/s, and the measured loads-only ceiling of 213 GB/s that bounds it.
- 041, 052: the speculative cost model, solved from measurements, and what it says the target actually requires.
- 074:
simdgroup_float8x8measured at 6.1 TFLOP/s against a scalar-fma control. LEDGER 035 had assumed 17.6 and every roofline since inherited it; this retroactively explains four consecutive failed kernel experiments. - 080: tree drafting, the mechanism this effort had named as the missing piece since LEDGER 052, falsified in half an hour from a per-position acceptance counter the server was already keeping.
- 084: a column-exact scalar verify kernel, built and measured, refuting the plan proposed two entries earlier in the same session.
- 090: why
bench/quality.shis blind to a kernel that only runs under speculation, and what the honest check is instead. - 054: a correction: width-scaling is matmul, not the gated-delta-net recurrence it had been attributed to.
- 057, 058: a frequency-ranked draft vocabulary that works mechanically (the cycle drops 160 → 112 ms) and loses anyway, on acceptance.
Prior work
The multi-column K-quant mat-vec direction, the dequantize_q4_K scale bug, and the test-backend-ops coverage gap come from Shrey Vishen’s llama.cpp-qwen3.6-metal (shreyvishen/llama.cpp-qwen3.6-metal), an M4 Max effort on the same model. His tile constants do not transfer to 16 GPU cores and were re-derived or rejected here; the scale fix and the coverage transfer unchanged and are merged.