KV-cache size
Every generated token must keep its keys and values so later tokens can attend to them. The cache grows linearly with sequence length and batch size, and at long contexts it, not the weights, is what fills the GPU.
- The number of layers.
- The number of key/value heads.
- The dimension of each head.
- The sequence length so far.
- The batch size.
- Bytes per value — two for fp16.