cs.CCNov 26, 2026

The Scratchpad Complexity of Autoregressive Multiplication with Hard Attention

Authors: Kundan Baliga, Ryan Kim

Organizations: University of Illinois Urbana-Champaign, Urbana, IL, USA.

Abstract

How many auxiliary tokens does a causal hard-attention transformer need to multiply two NN-bit integers? First, we resolve the true-prefix parity conjecture of Amiri Bavandpour et al. on independent uniform NN-bit operands. The correlation bound permits any bounded test of each operand and every earlier product-bit parity. Second, we give a task-independent transfer from low-degree correlation bounds to causal hard-attention lower bounds. Position-union approximation verifies which keys win, and marked replay counts possible scratch traces using their positions. Third, at fixed depth, head count, and number of selected keys, the probability of generating the product with a sufficiently small linear scratch and edit budget is exponentially small even with a growing vocabulary. A one-head, one-layer packed FFT attains linear scratch with linear vocabulary and constant hidden dimension.

Figures & tables

Appendix figures & tables4 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

Mar 11, 2026

On the Computational Hardness of Transformers

The transformer has revolutionized modern AI across language, vision, and beyond. It consists of LL layers, each running HH attention heads in parallel and feeding the combined output to the subsequent layer. In attention, the input consists of NN tokens, each a vector of dimension mm. The attention mechanism involves multiplying three N×mN \times m matrices, applying softmax to an intermediate product. Several recent works have advanced our understanding of the complexity of attention. Known algorithms for transformers compute each attention head independently. This raises a fundamental question that has recurred throughout TCS under the guise of ``direct sum'' problems: can multiple instances of the same problem be solved more efficiently than solving each instance separately? Many answers to this question, both positive and negative, have arisen in fields spanning communication complexity and algorithm design. Thus, we ask whether transformers can be computed more efficiently than LHLH independent evaluations of attention. In this paper, we resolve this question in the negative, and give the first non-trivial computational lower bounds for multi-head multi-layer transformers. In the small embedding regime (m=No(1)m = N^{o(1)}), computing LHLH attention heads separately takes LHN2+o(1)LHN^{2 + o(1)} time. We establish that this is essentially optimal under SETH. In the large embedding regime (m=Nm = N), one can compute LHLH attention heads separately using LHNω+o(1)LHN^{ω+ o(1)} arithmetic operations (plus exponents), where ωω is the matrix multiplication exponent. We establish that this is optimal, by showing that LHNω−o(1)LHN^{ω- o(1)} arithmetic operations are necessary when ω>2ω> 2. Our lower bound in the large embedding regime relies on a novel application of the Baur-Strassen theorem, a powerful algorithmic tool underpinning the famous backpropagation algorithm.
Sep 3, 2026

The Head Complexity of Boolean Functions in Single-Layer Attention

What can a single layer of self-attention compute? We study head complexity: the minimum number of attention heads required to compute a function in a one-layer attention-only model. We establish an exact hierarchy under this measure: kk heads compute kk-bit parity but cannot compute (k+1)(k+1)-bit parity. The lower bound is unconditional in the two resources a transformer might otherwise exploit; it holds at unbounded embedding dimension and unbounded numerical precision. The proof rests on an alternating-sum obstruction: after clearing the softmax denominators, every monomial in the resulting decision polynomial omits at least one of the k+1k+1 input bits, forcing its correlation with parity to vanish. The same obstruction yields lower bounds for related tasks, including the well-studied multi-hop induction-head task. We also establish compactness bounds for embedding dimension and numerical precision. Specifically, a compactness theorem shows that any function computable at all can be computed with embedding dimension and precision bounded by the discrete data of the task, namely, head count, alphabet size, and length. Thus, potentially unbounded dimension or precision provably cannot substitute for heads. Finally, we derive nearly matching universal bounds for general binary functions: 2n2^n heads suffice to compute every nn-bit binary function, with one head per monomial in its multilinear expansion, while a counting argument shows almost all such functions require Ω(2n/n2)Ω(2^n/n^2) heads. This lower bound matches the upper bound to within a poly⁡(n)\operatorname{poly}(n) factor, even when dimension and precision are unbounded. Together, these results characterize head requirements for Boolean computation in this model.
Nov 4, 2026

Softmax Attention with Any Temperature in Fixed Dimension: Matching the Best Known Maximum-Inner-Product Bounds

Attention is central to modern AI models for language, vision, and scientific modeling. However, direct evaluation compares every query with every key, requiring quadratic time in the context length, which limits its scalability to long contexts. Consequently, characterizing the complexity bounds of attention is of fundamental importance. For every fixed dimension dd, we give an algorithm for mm queries, nn key-value pairs, and additive error ε\varepsilon, with expected time O~((mn)k/(k+1)+m+n),k=⌊d/2⌋.\widetilde{\mathrm{O}}\bigl((mn)^{k/(k+1)}+m+n\bigr),\qquad k=\lfloor d/2\rfloor. For fixed dimension and a fixed number of value channels, soft-O hides factors of the form poly⁡d(b,log⁡(m+n),log⁡B,log⁡(1/ε)),\operatorname{poly}_d\bigl(b,\log(m+n),\log B,\log(1/\varepsilon)\bigr), where bb bounds input encoding lengths and BB bounds coordinate and value magnitudes. In particular, the dependence on BB and 1/ε1/\varepsilon is polylogarithmic, which allows arbitrary positive temperature. When m=nm=n and d≥2d\ge2, the bound is O~(n2−2/(⌊d/2⌋+1))\widetilde{\mathrm{O}}(n^{2-2/(\lfloor d/2\rfloor+1)}): near-linear in dimensions two and three, with exponent 4/34/3 in dimensions four and five and 3/23/2 in dimensions six and seven. It improves the previous O~(n2−1/d)\widetilde{\mathrm{O}}(n^{2-1/d}) upper bound and matches the best known batch maximum-inner-product bound in each fixed dimension. Additionally, we reduce integer batch maximum inner product computation to one attention call with the same dimension and input sizes m,nm,n.