21/26
Part 4 of 4 · Prefill, decode and memoryWatch
Watch · 3 min
The memory formula worked on a 30B-parameter model, where a batch of 128 at 1,024 tokens needs a 180 GB cache, three times the weights. The video writes the formula with the model width, heads times head size. That's right for multi-head attention. With fewer key/value heads, use the key/value heads times the head size instead.
The KV Cache: Memory Usage in Transformers · Efficient NLP · Jul 2023YouTube