Module 3 of 6
What is limiting my GPU?
Before optimizing anything, find the bottleneck. A GPU is usually held back by one of four things.
Compute-bound
The cores are busy doing maths.
Memory-bound
The model or data doesn't fit in VRAM.
Memory-bandwidth-bound
Data can't reach the cores fast enough.
Communication-bound
GPUs wait on data from each other.
A GPU has two kinds of memory
The GPU chip
Compute cores
Do the maths
SRAM
Tiny, very fast, on the chip
slow trip
⇄
⇄
HBM (VRAM)
Huge, but much slower to reach
On an H100, on-chip SRAM is measured in tens of megabytes, while HBM holds 80 GB and moves about 3.35 TB per second. Every trip to HBM costs time.
Attention builds a big table
Easy maths, huge data: arithmetic intensity
An H100 can do about 300 FLOPs in the time it moves one byte from HBM. Operations with far fewer FLOPs per byte, like softmax over the attention table, leave the cores waiting. That is memory-bandwidth-bound.
FlashAttention: move less data
FlashAttention computes exact attention in small tiles that fit in SRAM. The full table never travels to HBM. Same maths, far less data movement.
