At what sequence lengths does attention compute begin to dominate feed-forward compute?

Last updated 22 November 2026

  • Attention's quadratic term (about 4nd FLOPs per token) overtakes FFN (about 16d²) around n ≈ 4d to 12d, depending on causal masking and whether projections are counted. That is roughly 16K to 50K tokens for d=4096.

  • At typical 2K to 8K training contexts, FFN and projections dominate FLOPs. Long-context (100K+) training is where FlashAttention or sparse methods matter most.

  • Wall-clock can diverge from FLOPs: naive attention and KV-cache reads are memory-bandwidth bound, so they dominate runtime earlier (GQA/MQA reduce this).

  • https://jax-ml.github.io/scaling-book/transformers/
  • https://mbrenndoerfer.com/writing/transformer-feed-forward-networks/computational-cost
  • https://medium.com/@VectorWorksAcademy/understanding-flops-in-transformers-a-deep-dive-f05c957f26bc
All Transformers interview questions