← all posts
September 13, 2026·Ronald Adonyo· 9 min read

Mapping Honeykrisp decode: +27%, and where the other half lives

An M2 Ultra decodes a 4B model at half the rate of a machine with a third of its bandwidth. Two environment variables recover 27%, and six further experiments rule out the conventional explanations. The remaining 2x lies below the kernel source and the compiler schedule.

38.5 → 48.9 t/sdecode, Qwen3-4B Q4_0
+21.3%DMMV_WG=1 alone
34 µs + bytes/290 GB/sthe fixed-cost fit
−17.5%Metal algebra on winning geometry
+14.4%ALU-ablation ceiling
75.6 W / 88.9 W peakdecode power
vulkanasahi-linuxapple-siliconllama-cppbenchmarking
A hand-drawn map of a mountain, a lake and several paths unrolled on a rock above a misty valley, most of the paths crossed through; a gorilla sits holding one corner flat and a crested crane at the right looks down at the map, among giant lobelia and tree ferns.

An ⁠M2 ​Ultra ​decodes ‌a ​4B ‌quantized ‌model ​at ‌38.5 ‌tokens ‌per ‌second ​through ​Vulkan. ‌A ​Strix ‌Halo, ‌with ​a ‌third ‌of ​the ​memory ‌bandwidth ‌on ‌paper, ‌decodes ‌the ​same ‌file ​at ​78. ​Each ​candidate ‌explanation ‌for ​the ‌gap ​was ‌tested ​by ⁠one ⁠experiment. ​Two ​environment ‌variables ​recover ‌+27%, ‌and ​the ‌measurements ‌place ‌the ‌rest ​of ​the ‌gap ​outside ‌the ‌kernel ​source, ‌the ‌arithmetic ​and ​the ‌compiler's ‌instruction ‌schedule. ‌This ‌post ​lists ‌every ​experiment ​with ​its ​numbers.

Transcript

An M2 Ultra decodes a 4B model at 38.5 tokens per second through Vulkan. A Strix Halo, with a third of the memory bandwidth on paper, decodes the same file at 78.

Two environment variables take the M2 Ultra from 38.5 to 48.9 tokens per second. That's plus 27 percent.

llama.cpp tunes its matrix-vector kernels per GPU vendor. Honeykrisp, Mesa's Vulkan driver for Apple silicon, matches no vendor, so it gets 32-thread workgroups. With 128-thread workgroups, 4 subgroups share each row: plus 21.3 percent on its own.

Where does the rest go? Every dispatch pays about 34 microseconds before its first byte streams. At 250 dispatches per token, that's about 8.5 of a 20.6 millisecond token: 41 percent of every token is overhead, not work.

The usual suspects were measured and closed. Apple's own Metal arithmetic, ported: minus 17.5 percent. Deleting the math entirely, and keeping the loads: only plus 14.4.

Apple's compiler builds the same scalar kernel, so the remaining 2x lies below the kernel source and the compiler schedule. For now, two variables recover 27 percent. The full write-up is at boracode.ai.

The post in under two minutes: the two variables worth 27%, the fixed cost of every dispatch, and the suspects that were closed. Narrated in Ronald's cloned voice.

Test bench

host     Apple Mac Studio, M2 Ultra (G14D B1)
         24 cores, 190.0 GiB unified memory (measured)
         integrated AGX GPU, 60 cores, ~800 GB/s LPDDR5

OS       Fedora Asahi Remix 44
         kernel 7.1.13-usb4gpu (locally built)

Vulkan   Mesa 26.1.5-1.fc44, driver Honeykrisp (release build)

runtime  llama.cpp f5919bf + env-knob layer
         (the pristine control build is never modified)

model    Qwen3-4B Q4_0, 2.21 GiB, md5 verified every run
         loaded with -lm dio (weights bypass the page cache, for reasons covered in a separate post)

reference AMD Strix Halo, Radeon 8060S, RADV, ~256 GB/s
         same file, same flags, same day

Upstream defaults leave half the decode rate

The ‌kernel ‌dispatch ​code ‌in ​ggml-vulkan.cpp ‌tunes ​two ⁠values ⁠per ​driver: ​rows ‌per ​workgroup ‌(AMD ‌GCN ​and ‌Intel ‌get ‌raised ‌values) ​and ​a ‌shader_core_count ​that ‌several ‌memory ​heuristics ‌consume. ‌Mesa's ​Honeykrisp ​reports ‌VK_VENDOR_ID_MESA, ‌which ‌matches ‌neither ‌vendor ​branch. ‌It ​therefore ​receives ​32-thread ​workgroups ‌and ‌a ​core ‌count ​of ‌zero, ​and ⁠every ⁠heuristic ​downstream ​of ‌those ​two ‌values ‌runs ​at ‌its ‌floor.

GGML_VK_DMMV_WG=1 GGML_VK_SHADER_CORE_COUNT=60 \
  llama-bench -m model.gguf -ngl 99 -lm dio

control (upstream defaults)      38.17-38.47 t/s floor
DMMV_WG=1  (128-thread groups)  46.29   +21.3%
+ SHADER_CORE_COUNT=60          48.38   +25.8%

The ‌two ‌knobs ​compose ​multiplicatively: ‌1.213 ​× ‌1.038 ‌= ​1.259, ‌measured ‌1.258. ​Throughput ​rises ‌monotonically ‌with ‌parallelism ‌per ‌row. ​Raising ‌rows ​per ​workgroup ​loses ​7–34% ‌because ‌there ​are ‌fewer ​groups, ‌doubling ​the ⁠groups ⁠gains ​7%, ​and ‌the ​four-subgroup ‌cooperative ‌form ​is ‌best. ‌Strix ‌Halo's ‌driver ​makes ​the ‌equivalent ​choice ‌for ‌its ​hardware, ‌and ‌Honeykrisp ​has ​no ‌such ‌branch.

Per-shape bandwidth

With ‌the ‌two ‌knobs ​set, ‌a ​perf-logger ​decomposition ​of ​one ‌decode ‌token ​shows ‌the ​whole ‌token ​inside ⁠matrix-vector ⁠kernels. ​Per-shape ​effective ‌bandwidth ​accounts ‌for ‌the ​rest ‌of ‌the ‌gap:

shapeper dispatcheffective
gate+up 9728×256081.9 µs171 GB/s · 4864 workgroups
down 2560×972884.6 µs165 GB/s
q-proj 4096×256055.0 µs107 GB/s
kv 1024×256038.7 µs38 GB/s · 512 workgroups
output head q6_K1582 µs202 GB/s
— machine peak800 GB/s

Useful ‌FLOPs ​run ​at ‌0.5–2.1% ​of ‌the ‌27 ​TFLOPS ‌peak. ‌Issued ​instructions, ​counting ‌the ‌full ‌dequantization ‌overhead ‌of ​~12.8 ‌scalar ​operations ​per ​weight, ​reach ‌~13% ‌of ​issue ‌capacity. ​An ‌ALU-ablation ​run ⁠(same ⁠loads, ​checksum ​instead ‌of ​the ‌arithmetic) ‌gains ​exactly ‌+14.4%, ‌which ‌matches ‌that ​ceiling. ​Neither ‌pipe ​is ‌saturated, ‌so ​the ‌kernel ‌is ​latency-bound.

Every dispatch pays 34 µs before the first byte streamsper-dispatch time vs weight bytes — M2 Ultra, warm, one harness02550751004 MB8 MB12 MB16 MBµs / dispatchkv · 39 µs · 38 GB/sq · 55 µs · 107 GB/so · 62 µs · 96 GB/sgate/up · 82 µs · 171 GB/sdown · 85 µs · 165 GB/s34 µs fixed
The fit t ≈ 34 µs + bytes/290 GB/s predicts every shape within ~15%. The kv projection is 89% fixed cost — the smallest shape pays the full toll to move 1.47 MB. 250 such dispatches make the fixed term 41% of every decode token.

Fitting ​the ‌six ‌shapes ‌gives ‌t ‌≈ ​34 ‌µs ​+ ​bytes/290 ​GB/s. ​Every ‌dispatch ‌pays ​a ‌fixed ​cost ‌before ​the ⁠first ⁠byte ​streams. ​At ‌250 ​matvec ‌dispatches ‌per ​token, ‌that ‌fixed ‌cost ‌is ​~8.5 ​ms ‌of ​a ‌20.6 ‌ms ​token, ‌so ‌41% ​of ​every ‌token ‌is ‌dispatch ‌overhead ‌and ​not ‌work.

Closed by measurement

Eight levers, each measuredgreen shipped · grey closed by measurement · orange openwide workgroups + core count+27% — shippedMetal kernel geometry−10% · closedMetal kernel arithmetic−17.5% · closedALU reduction (all of it)+14% ceiling · closedper-shape workgroup countflat on kv · closedsubmit batchingflat above default · closedgate/up fusion+1.1% measured · shippedfinal lowering + driverthe remaining ~2×
Every closed row is a measurement, not an argument — the two Metal ports were correctness-gated (991/991) before timing, and the ALU ceiling comes from an ablation run that keeps the loads and deletes the math.

Each ​row ​of ​the ​ladder ‌is ‌an ​experiment. ‌Two ​need ‌detail.

Metal ​ports. ⁠Porting ⁠Apple's ​own ​Metal ‌kernel ​for ‌this ‌operation, ​first ‌its ‌geometry ‌and ‌then ​separately ​its ‌arithmetic, ​loses ‌on ‌Honeykrisp: ​−10% ‌and ‌−17.5% ​respectively, ​991/991 ‌correct ‌both ‌times. ‌The ‌generic ​kernel's ‌structure ​already ​suits ​this ​machine, ‌and ‌Apple's ​source ‌suits ​Apple's ‌compiler.

Gate/up ​pair ⁠fusion. ⁠The ​host ​patch ‌fuses ​all ‌36 ‌layers. ​The ‌perf ‌logger ‌shows ‌MUL_MAT_PAIR_GATE_UP ​at ​36 ‌dispatches ​replacing ‌72, ‌and ​the ‌pair ‌itself ​runs ​19% ‌faster. ‌End ‌to ‌end, ‌however, ​the ‌gain ​is ​only ​+1.1% ​where ‌the ‌fixed-cost ​model ‌predicted ​+6%. ‌The ​fixed ⁠cost ⁠partly ​overlaps ​other ‌work, ​and ‌removing ‌dispatches ​converts ‌to ‌wall-clock ‌time ‌at ​only ​~18% ‌of ​the ‌naive ‌rate. ​Dispatch-count ‌estimates ‌should ​be ​priced ‌at ‌that ‌measured ‌conversion ‌and ​not ‌at ​the ​nominal ​saving.

Apple compiles the same scalar kernel

ggml's ​Metal ‌kernel ‌compiles ​on ‌a ​Mac ‌with ​xcrun -sdk macosx metal -S -O3. ⁠The ⁠optimized ​IR ​of ‌the ​reference ‌q4_0 ‌matvec ​is ‌scalar ‌throughout: ‌2-byte ‌nibble ​loads, ​element-by-element ‌activation ​reads, ‌one ‌simd_sum, ​no ‌vector ‌loads ​and ​no ‌exotic ‌intrinsics. ‌The ‌Vulkan ‌shader ​here ‌has ​the ​same ​structure.

The ​Mesa ‌compiler ‌flags ​point ‌the ​same ‌way. ​Disabling ⁠the ⁠backend ​optimizer ​entirely ‌(AGX_MESA_DEBUG=noopt) ​or ‌the ‌scheduler ​(nosched) ‌moves ‌decode ‌by ‌less ​than ​half ‌a ​percent. ‌The ‌gap ​to ‌Apple's ‌~2x ​on ​the ‌same ‌silicon ‌is ‌therefore ‌not ​in ‌the ​kernel ​source ​or ​the ‌instruction ‌schedule.

Remaining work

Two ​layers ‌sit ​below ‌everything ​eliminated ⁠so ⁠far. ​The ​first ‌is ​Apple's ‌final ‌AIR-to-AGX ​lowering, ‌which ‌is ‌invisible ‌from ​Linux. ​It ‌could ​be ‌captured ‌by ​running ‌macOS ‌as ​a ​guest ‌under ‌the ‌m1n1 ‌hypervisor, ‌tracing ​what ‌the ​driver ​uploads, ​and ​decoding ‌it ‌with ​Asahi's ‌own ​disassembler. ‌The ​second ⁠is ⁠the ​kernel-driver ​submission ‌pipeline, ​where ‌the ‌34 ​µs ‌fixed ‌cost ‌lives. ‌It ​is ​open ‌source ​on ‌this ‌machine ​and ‌can ‌be ​profiled. ​A ‌debug ‌Mesa ‌build ‌(26.1.5, ‌same ​commit ‌as ​the ​release ​driver) ​supplies ‌the ‌other ​side ‌of ​the ‌comparison: ​this ⁠machine's ⁠own ​compiled ​machine ‌code ​for ‌the ‌same ​kernel, ‌dumpable ‌with ‌AGX_MESA_DEBUG=shaders. ‌The ​plan ​is ‌to ​disassemble ‌both, ‌diff ​the ‌structure, ‌and ​patch ​what ‌the ‌diff ‌identifies.

Reproducing the +27%

# integrity first: the model must read identically through the page cache
# and O_DIRECT on this host (a separate finding)
md5sum model.gguf
dd if=model.gguf bs=8M iflag=direct | md5sum

GGML_VK_DMMV_WG=1 GGML_VK_SHADER_CORE_COUNT=60 \
  llama-bench -m model.gguf -ngl 99 -p 512,2048 -n 128 -r 5 -lm dio

Power ‌and ‌thermals ​were ‌monitored ​throughout ​(system ​draw, ​SoC ‌rail, ‌fans, ​every ‌temperature ​channel ‌the ​SMC ⁠exposes). ⁠Full ​decode ​drew ‌75.6 ​W ‌mean ‌and ​88.9 ‌W ‌peak ‌against ‌a ​~370 ​W ‌envelope, ​with ‌the ‌fans ​unmoved. ‌Nothing ‌here ​is ​power- ‌or ‌thermally-limited, ‌and ‌the ‌ceiling ​is ‌structural.


Update, ​2026-09-14: ​the ​follow-up ​campaign ‌ran, ‌starting ​with ‌the ​graph ‌chain ​and ⁠then ⁠the ​quant. ​Decode ‌reached ​7.7 ‌t/s ‌on ​this ‌machine. ‌An ‌imported ‌"optimization ​table" ​turned ‌out ​to ‌be ‌wrong ​in ‌a ‌lane ​that ​only ‌the ‌get-rows ‌gate ‌reads, ‌and ​a ‌control ​arm ​was ​measuring ​a ‌CPU ‌fallback ​and ‌not ​the ‌best ​existing ⁠path. ⁠The ​full ​account, ‌including ​the ‌attribution ‌matrix ​that ‌cleared ‌the ‌kernels ‌and ​a ​second ‌case ​of ‌the ‌page ​cache ‌returning ‌wrong ​data, ​is ‌in ‌the ‌update ‌to ‌Raising the Honeykrisp memory cap.

boracode.ai · Ronald Adonyo · honeykrisp-decode-map
content hash 2de5b3e86a3a
A wide horizon at dusk: layered hills in muted plum and ochre above a lake that holds the last light, a family of crested cranes at the water's edge, an acacia in silhouette and a single bright star above the ridge.