At what sequence lengths does attention compute begin to dominate feed-forward compute?
Last updated
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).