AI Hardware & Software Stack

When LLM inference handles long contexts or large batches, what tends to become a problem?

  1. AThe number of weights grows with context length
  2. BKV cache memory grows with context length and batch size and can even exceed the weights
  3. CMore tokens always make the model's answers shorter
Show answer and explanation

Answer: B. KV cache memory grows with context length and batch size and can even exceed the weights

KV cache size is the number of layers × key and value dimensions × number of tokens × batch size × bytes per element. With contexts of tens of thousands of tokens or many simultaneous requests, it reaches tens of GB and can exceed weight memory. Techniques include storing the KV cache in lower precision, sharing keys and values across attention heads and managing memory in small blocks.

  • A. The number of weights is fixed.
  • B. Correct. Techniques such as KV cache compression and quantization are used.
  • C. It has nothing to do with answer length.
Practice this topic Back to topic

More AI Hardware & Software Stack questions

  1. A model with about 14 GB of FP16 weights decodes at batch size 1 on a GPU with 2 TB/s memory bandwidth. What is closest to the lower bound on time per generated token?
  2. How does the computation of Transformer self-attention grow with input sequence length n?
  3. What is the main idea behind fast attention implementations such as FlashAttention?
  4. What is the main purpose of operator fusion in AI computation?
  5. A matrix product followed by a bias add and a ReLU is fused from three separate kernels into one. What mainly decreases?