cs.CCMar 11, 2026

On the Computational Hardness of Transformers

Authors: Barna Saha, Yinzhan Xu, Christopher Ye, Hantao Yu

Organizations: University of California San Diego · Columbia University

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^{ω+ 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.

Explore similar work

CardsList
  1. The Head Complexity of Boolean Functions in Single-Layer Attention

    Sep 3, 2026Rajmohan Rajaraman, Ravi Sundaram, Amanuel TesfayeSelf-AttentionAttention Mechanisms

  2. Formally Verified Autoresearch for Analyzing the Expressivity of Multi-Head Attention

    Oct 18, 2026Karthik Viswanathan, Plamen Dimitrov, Stefano Rocca +1Transformer ExpressivityMulti-Head Attention

  3. Expressivity of Transformers: A Tropical Geometry Perspective

    Apr 16, 2026Ye Su, Yong LiuTransformer ExpressivityTransformer