What GPU memory hierarchy bottleneck makes standard self-attention memory-bandwidth bound?
Last updated
GPUs pair large but slow off-chip HBM (about 2 TB/s) with tiny but fast on-chip SRAM (about 19 TB/s), and compute has outgrown bandwidth.
Naive attention writes the N×N score and probability matrices to HBM and reads them back for cheap softmax, mask and dropout ops (low FLOPs per byte), so memory traffic dominates runtime.
Decoding is worse because each token re-reads the whole KV cache. Fixes are kernel fusion with SRAM tiling (FlashAttention) or shrinking the KV cache (GQA/MQA, quantization).