Transformer Inference FLOPs Calculator

Interactive estimate for dense transformer inference. It separates linear-layer work from the quadratic full-attention term and shows prefill versus one-token decode.

Prefill results

Per-layer prefill FLOPs
Whole-model prefill FLOPs
Dense fraction
Attention fraction

Per-layer prefill breakdown

OperationFormulaFLOPs
Q/K/V projections6Nd²
QKᵀ2N²d
Attention × V2N²d
Output projection2Nd²
MLP
Total / layer

Decode results — one newly generated token

Per-layer decode FLOPs
Whole-model FLOPs / generated token
Attention FLOPs / layer
Dense FLOPs / layer

Scaling experiments

If hidden size doubles
Prefill FLOPs ratio
If sequence length doubles
Prefill FLOPs ratio
Attention-only N doubling
Because N² → (2N)²

Useful mental model

Dense work ~ N d² Attention ~ N² d Prefill: many tokens at once → large GEMMs → usually compute-friendly Decode: 1 token × huge weights + growing KV cache → often bandwidth / latency sensitive