arXiv:2609.09208cs.ARSep 2026

Manuscript Offprint

arXiv:2609.09208

Shift-Accumulate Attention: Multiplier-Free Query--Key Products for Transformer Decoding

Khubaib Ahmed, Amna Noor, Ahsan Ul haq

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Khubaib Ahmed

University of Wolverhampton

Wolverhampton, UK

Amna Noor

Edge Hill University

Ormskirk, UK

Ahsan Ul Haq

University of Technology

and Applied Sciences

Oman

Abstract—Power-of-two quantisation turns a multiplication into a bit shift, but it has so far been applied only to the post-softmax attention-value product. We reformulate the earlier and larger product, S=QK⊤S = QK^\top, by quantising the key cache to a signed power-of-two fixed-point code, so that every scalar multiplication in the score computation becomes a sign flip, a shift and an integer accumulation. A fixed-point head-room F≥emax⁡F \geq e_{\max} makes every shift a non-negative left shift, which renders the accumulation exact with respect to the quantised operands. We extend the code with a mantissa field that trades additional shift-adds for accuracy, and pair it with a shift-exact online softmax whose running maximum lives in an integer log⁡2\log_2 domain. Fused CUDA kernels for a 1.1 B-parameter Llama decoder on an RTX 4090 reach 4.60×4.60 \times the throughput of FP16 scaled dot-product attention at T=32kT = 32k with a 2.5×2.5 \times smaller KV cache, and 7.881→7.8967.881 \rightarrow 7.896 WikiText perplexity at 8 stored bits. A first-order cost model calibrated on the measured kernels shows that the remaining bottleneck is not memory but instruction issue: because current GPUs expose a 4-way integer multiply-accumulate but no shift equivalent, the shift datapath spends 1011 integer ALU operations where a MAC kernel spends 409. We show by disassembly that PTX's scalar shift-accumulate (vsh1 .add) is emulated on sm_89 at 4.1×4.1 \times the cost of an ordinary C shift-add, and that the genuinely missing primitive is a packed shift-dot-accumulate, DS4A, the shift analogue of __dp4a. Given DS4A at the same throughput, the identical kernel would reach 6.51×6.51 \times over FP16 — 1.52×1.52 \times beyond what we measure today, and beyond what an optimised INT8 MAC kernel achieves on this hardware, because the power-of-two format moves 101 bytes per key against 133.

Index Terms—Transformer inference, attention, power-of-two quantisation, fixed-point arithmetic, KV cache, CUDA kernels, hardware–software co-design.

I. INTRODUCTION

Scaled dot-product attention [1] contains two dense matrix products,

S=QK⊤,O=AV,A=softmax⁡(S/d),(1)\mathbf{S}=\mathbf{Q}\mathbf{K}^{\top},\qquad\mathbf{O}=\mathbf{A}\mathbf{V},\quad\mathbf{A}=\operatorname{s o f t m a x}(\mathbf{S}/\sqrt{d}), \tag{1}

both conventionally evaluated on multiply–accumulate (MAC) hardware. If an operand is constrained to a signed power of two, σ2−e\sigma 2^{-e} with σ∈{−1,+1}\sigma \in \{-1, +1\}, the multiplication collapses to a shift, an optional negation and an addition — replacing a multiplier array with a barrel shifter and an adder, which is the central efficiency argument of the multiplication-free network literature [2], [3].

FQ-ViT [4] applies this to the post-softmax matrix, logarithmically quantising A and evaluating AV with bit shifts. I-ViT [5] performs integer-only inference with dyadic arithmetic, ShiftAddViT [6] reparameterises attention with binary and additive kernels, and P 2^{2}-ViT [7] develops power-of-two post-training quantisation with hardware co-design. What no prior work does is represent one operand of QK ⊤^{\top} itself as a signed power-of-two fixed-point code, so that the score computation becomes shift-and-accumulate in ordinary scaled dot-product attention. This is the larger of the two opportunities in a decoder: the key cache is read in full for every generated token, so both its arithmetic and its bit-width bound the decode rate.