English

On the Computational Hardness of Transformers

Computational Complexity 2026-03-13 v1 Machine Learning

Abstract

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^{\omega + o(1)} arithmetic operations (plus exponents), where ω\omega is the matrix multiplication exponent. We establish that this is optimal, by showing that LHNωo(1)LHN^{\omega - o(1)} arithmetic operations are necessary when ω>2\omega > 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.

Keywords

Cite

@article{arxiv.2603.11332,
  title  = {On the Computational Hardness of Transformers},
  author = {Barna Saha and Yinzhan Xu and Christopher Ye and Hantao Yu},
  journal= {arXiv preprint arXiv:2603.11332},
  year   = {2026}
}

Comments

46 pages, 2 figures. Abstract shortened to meet arXiv requirements

R2 v1 2026-07-01T11:15:36.634Z