Context The local kernel work ran on the four-phone Inkling 2 Mini cluster; the study page has the testbed and the full request results. Inkling 2 Mini study.

“Fuse the operations” is good advice with a hidden assumption. It assumes the boundary between two operations is more expensive than the work inside them. That is often true, but not always. A fused kernel that spills an intermediate to memory, changes the numerical path, or blocks a faster backend can lose to two simpler kernels.

On local hardware, the boundary has several costs: kernel launch, command buffer submission, synchronization, a layout change, a quantization step, or a copy between memory spaces. Fusion pays when it removes one of those costs without adding a larger one.

Three local examples

The four-bit IQ4_NL work on the phone cluster produced three useful cases. Each was measured at the kernel or block level first. None was treated as a full-model speedup without a separate request test.

1. A subgroup reduction

The packed-dot control reduced 64 lanes through shared memory. A variant replaced that with a single-subgroup reduction while preserving the workgroup layout and the lookup-table initialization. All routes passed the 0.5% parity gate.

Across three routes, the candidate means were 4.71–4.77 ms per block, against 5.01–5.13 ms for the bracketing control. That is a 0.24–0.39 ms saving per block. The separate GPU timestamp runs showed 2.76 ms for gate/up and 1.64 ms for down, versus 2.92 ms and 1.80 ms for the original.

2. Exact activation-sum reuse

The second variant started from the original packed-dot reduction. While packing, it stored the exact signed 32-value activation sum in the second metadata halfword. The first halfword kept the ordinary half-precision scale. An integer 128 × sum replaced the repeated bias-correction dots in the projection.

The activation block stayed the same size. Static packed-dot instructions fell from 128 to 64 in the matched device shader program (SPIR-V), and all routes passed the parity gate. The candidate means were 4.05–4.07 ms per block, against 4.99–5.03 ms for the control: a 0.93–0.96 ms saving per block. The tagged GPU intervals were 2.36 ms for gate/up and 1.42 ms for down.

3. A precision-matching conversion

The Hexagon Matrix Extensions (HMX) prefill path is the cautionary case. Matching ARM's eight-bit Q8_0 activation rounding reduced worst output error from 1.13% to 0.406% relative to production ARM, passing the 0.5% gate. That is a real numerical improvement. But at 64 positions, rounded HMX was still 3.4–9.5 ms behind six-thread ARM in the two full-bank orders. The request speed gate did not pass, so the longer live HMX prefill request was held.

The conversion work was measurable: about 0.97–0.99 ms for the two conversions, 0.20 ms for the intermediate read, 0.14 ms writing inputs, and 0.05 ms for the final read. Fusing the arithmetic did not remove the staging cost around it.

What a macro-kernel has to own

A macro-kernel is not just a longer kernel. It is a contract for a region of the graph: which tensors stay resident, which layout is canonical, where quantization happens, and who synchronizes. If the contract is incomplete, the boundary reappears inside the macro-kernel as a spill, a copy, or a wait.

  • Residency: the intermediate should stay in the fastest memory that can hold it for the whole region.
  • Layout: the producer and consumer should agree on the layout, or the fusion should include the transform.
  • Numerics: the fused path must match the reference within a stated tolerance, at every position tested.
  • Scheduling: the macro-kernel must expose enough independent work to overlap memory and compute, without hiding a dependency.
  • Exit cost: the final write and the next consumer's read are part of the region's cost.

Why kernel wins disappear

A block-level saving can vanish for ordinary reasons. The full model may spend more time in a different operator family. A thermal cap may lower the clock during the longer kernel. A layout change may add a copy that the microbenchmark excluded. Or the fused path may be correct but not faster enough to justify a new deployment.

The Qualcomm Adreno GPU variants were intentionally kept independent and were not installed in a full-model deployment. That is the right status for a kernel-level result until a matched request test exists. The HMX case shows why: the numerical gate passed, and the speed gate still failed.

The useful question

Before fusing, ask what boundary is being removed and what new boundary is being created. If the answer is “the intermediate never leaves the workgroup, and the next consumer reads the same layout,” fusion is promising. If the answer is “the intermediate is written to global memory and read back with a different scale,” the win may be smaller than the diagram suggests.

The local results support a modest claim: boundary removal can save sub-millisecond to millisecond time per block on this hardware. Turning that into a request-level gain requires the same discipline as any other optimization — matched arms, exact outputs, thermal control, and a clear statement of what was not measured.

Sources & notes

  1. Dao et al., FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness (2022)
  2. llama.cpp repository and GGML backend documentation
  3. ARM KleidiAI micro-kernel library