Concept

Per-Token Time Complexity Across Layers in Self-Attention

During autoregressive generation, calculating self-attention for a single new token over a context sequence of length len has a linear time complexity of O(L×len)O(L \times len) across LL transformer layers. This cost arises because at each layer, the two primary matrix-vector operations—the dot products between the query and previous key vectors, and the weighted summation of previous value vectors—both scale linearly with len.

0

1

Updated 2026-06-17

Contributors are:

Who are from:

Tags

Ch.5 Inference - Foundations of Large Language Models

Foundations of Large Language Models

Computing Sciences

Foundations of Large Language Models Course