Log inStart free
LESSON 27.01 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Compute-bound vs memory-bound

Watch one layer wait for memory, then become compute-bound as the batch grows.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 27.01 · GPU BAY16 TOKENS · 537 MFLOPS
01
Stage 1 of 6 · Count the FLOPs
The layer multiplies 16 tokens by a 4096 × 4096 weight matrix W. Each weight costs 2 FLOPs per token.
Explain it simply

Each square in the grid stands for a block of weights. For every token, each weight is multiplied once and added once. That's two FLOPs, two floating-point operations. So 16 tokens cost about 537 million FLOPs.

The weight grid W between 16 tokens and the outputs y: 537 MFLOPs.

tokens x, HBM loadsweights W, GPU ratesoutputs y, computewaiting
x · 16 tokensW · 4096 × 4096y2 · 16 · 4096² = 537 MFLOPs1 multiply + 1 add per weight per tokenthe layerx · 16 tokensW · 4096 × 4096y2 · 16 · 4096² = 537 MFLOPs1 multiply + 1 add per weight per tokenthe layer
Toy: one 4096 × 4096 BF16 layer on a GPU with H100 SXM peak rates and no cache
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
F=2 M D2\sy{F}{out}{F} = 2\,\sy{M}{data}{M}\,\sy{D}{param}{D}^2
F=2⋅16⋅40962=536,870,912≈537 MFLOPsF = 2\cdot 16\cdot 4096^2 = 536{,}870{,}912 \approx 537\text{ MFLOPs}

Each weight does one multiply and one add for each of the M tokens.

Common mix-ups

MYTHFaster compute makes every layer faster.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01On Tensor Cores, with W read once, is the layer with 512 tokens memory-bound or compute-bound?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.