Skip to main content
QUICK REVIEW

[Paper Review] On The Computational Complexity of Self-Attention

Feyza Duman Keles, Pruthuvi Mahesakya Wijewardena|arXiv (Cornell University)|Sep 11, 2022
Neural Networks and Reservoir ComputingComputer Science29 citations
TL;DR

The paper proves conditional quadratic lower bounds on the time complexity of self-attention under SETH for various self-attention formulations, and shows linear-time approximation via finite Taylor series with exponential cost in polynomial order.

ABSTRACT

Transformer architectures have led to remarkable progress in many state-of-art applications. However, despite their successes, modern transformers rely on the self-attention mechanism, whose time- and space-complexity is quadratic in the length of the input. Several approaches have been proposed to speed up self-attention mechanisms to achieve sub-quadratic running time; however, the large majority of these works are not accompanied by rigorous error guarantees. In this work, we establish lower bounds on the computational complexity of self-attention in a number of scenarios. We prove that the time complexity of self-attention is necessarily quadratic in the input length, unless the Strong Exponential Time Hypothesis (SETH) is false. This argument holds even if the attention computation is performed only approximately, and for a variety of attention mechanisms. As a complement to our lower bounds, we show that it is indeed possible to approximate dot-product self-attention using finite Taylor series in linear-time, at the cost of having an exponential dependence on the polynomial order.

Motivation & Objective

  • Motivate the study of fundamental time/accuracy tradeoffs in self-attention within transformers.
  • Establish conditional lower bounds showing quadratic time is necessary in many settings under SETH.
  • Explore upper bounds and practical linear-time approximations via Taylor series for self-attention.
  • Provide a unified framework for hardness results across multiple self-attention variants.

Proposed method

  • Use reductions from the Orthogonal Vectors Problem (OVP) and related problems (TVPP, BHCP, BHFP) to prove SETH-based lower bounds.
  • Construct vector gadgets to translate OVP instances into self-attention inputs.
  • Analyze dot-product and softmax dot-product self-attention, including exact and approximate (multiplicative/additive) scenarios.
  • Extend to sliding window and l2 (RBF) self-attention to show rectangular/quadratic hardness.
  • Propose polynomial (Taylor) approximations to achieve linear-time computation with exponential dependence on polynomial order.
  • Provide conditions under which linear-time computation is achievable (finite Taylor series).

Experimental results

Research questions

  • RQ1Can self-attention computation be sub-quadratic in input length under standard complexity assumptions?
  • RQ2Do approximate self-attention methods admit provable error guarantees while beating quadratic time?
  • RQ3How do different self-attention variants (dot-product, softmax, windowed, l2) fare under SETH-based hardness reductions?
  • RQ4What are viable linear-time approximations for self-attention, and what trade-offs do they entail?
  • RQ5How do polynomial approximations influence the time/accuracy frontier for self-attention?

Key findings

  • Exact and approximate self-attention computations are conditionally quadratic-time under SETH for several variants.
  • Sliding window self-attention and l2 (RBF) self-attention inherit quadratic lower bounds under appropriate conditions.
  • A finite Taylor series approximation of softmax self-attention yields linear-time computation, with time exponential in the polynomial order.
  • Hardness proofs rely on reductions from OVP via TVPP and BHCP/BHFP, with vector gadgets enabling the constructions.
  • The work underscores a potential no-free-lunch phenomenon: sub-quadratic and near-accurate self-attention may be unlikely across all inputs.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.