Mar 31, 2026 O(n²) complexity self-attention computational costThe O(n²) Problem: Why Doubling Your Context Window Quadruples the CostSelf-attention computes all pairwise interactions between tokens. For n tokens, that's n² computations. Here's the full mathematical derivation.