38/42
Part 6 of 6 · Follow-upsLearn
A narrower head keeps its full T × T grid
That's why more heads cost memory but not compute.
| C = 768, T = 1,024 | 12 heads | 24 heads |
|---|---|---|
| head size d | 64 | 32 |
| parameters | 2,362,368 | 2,362,368 |
| matmul FLOPs | same | same |
| score grids, each T × T | 12 | 24 |
| score memory, fp32 | 48 MiB | 96 MiB |
A head does FLOPs for its two matmuls and stores scores. Narrow the head and its compute shrinks, but its score grid doesn't: 1,048,576 scores, 4 MiB in fp32 at , whether is 64 or 32.
So going from 12 heads to 24 at the same keeps the parameters and the FLOPs, and doubles the score memory.