Count Parameters and Attention Work
Under a fixed total head width, changing head count does not multiply every parameter and compute cost by the number of heads. Count projections, score entries, arithmetic terms, and stored tensors under explicit assumptions.
The phrase “more heads” does not by itself determine parameter count or computation. We must also know the per-head widths, total projected widths, bias convention, sequence length, and which tensors are materialized.
General Bias-Free Parameter Count
With equal widths across heads, the projection matrices contain
The total is
Separate per-head matrices and combined matrices have the same number of entries when they represent the same widths. Combining is an implementation arrangement, not parameter sharing among heads.
Fixed Total Width Makes the Standard Count Independent of Head Count
Under the common convention
the count becomes
Changing while reducing each head width to keep the total widths fixed does not change this projection count. For , one head of width 512 and eight heads of width 64 both use bias-free projection parameters.
They do not compute the same function: the one-head version has one softmax distribution, while the eight-head version has eight.
If an implementation uses projection biases, add their exact lengths. Under one common convention, Q, K, V, and output biases add entries. Some models omit selected biases, so the convention must be stated rather than assumed.
Dense Scores Depend on Head Count and Sequence Length
Each head forms scores per batch item. Across items and heads, the score tensor contains
entries. The approximate multiply-add work for scores and weighted values is
When and remain fixed, these expressions are approximately independent of how the total width is split among heads. The number of separate score matrices still grows with , which can affect kernels, memory layout, and overhead even when the leading arithmetic count is similar.
Compare Counts Under Explicit Conventions
Let , , , with no biases.
| Total Q/K/V/O parameters | Score entries | ||
|---|---|---|---|
| 1 | 12 | 576 | 20,000 |
| 3 | 4 | 576 | 60,000 |
The score entry count triples because there are three separate attention maps. Each map's score dot products are only one third as wide, so the leading score arithmetic remains comparable under this fixed-total-width setup. Entry count, arithmetic, memory, and wall-clock time are related but not interchangeable. The first row uses projection parameters and score entries. Replacing one head with three gives score entries while leaving the projection count fixed.
Q1. Count standard projection parameters
A bias-free layer uses , , and . How many entries are in all Q, K, V, and output projection matrices?
Compute it first, then check your number.
Hint
Solution
Never Compare Head Counts Without Widths
“Eight heads cost eight times as much as one” is false under the common fixed total width. “Eight heads are free” is also false: eight dense maps are stored, and implementation overhead changes. A useful comparison states parameter widths, tensor entries, arithmetic, and measured runtime separately.