Quadratic Scaling: The Hidden Cost Multiplier

AI model attention mechanisms scale quadratically with context window length, meaning doubling the input tokens can quadruple computational costs for re-reads, making large contexts exponentially expensive.

The top 3

  1. Quadratic Scaling: The Self-Attention Cost Multiplier: Quadratic scaling means computational and memory costs grow by the square of the input length (O(n²)), primarily due to the self-attention mechanism in transformer models where every token compares itself to every other token.
  2. Context Window Expansion Quadruples LLM Costs: Doubling an LLM's context window length, from 4k to 8k tokens for example, does not double its cost but quadruples it, a direct consequence of quadratic scaling.
  3. Agent Loops: Quadratic Cost Dominates Cache Reads: In long-running AI agent conversations, cache reads, which are part of processing the growing context, can dominate costs quadratically; for example, they can account for 87% of total conversation costs by 27,500 tokens.

Sources

Open the full topic