AI Hardware & Software Stack

LLM inference splits into a stage that processes the input prompt together (prefill) and a stage that generates output one token at a time (decode). With small batches, what mainly limits each stage?

  1. APrefill by memory bandwidth, decode by compute
  2. BPrefill is limited by compute, decode by memory bandwidth
  3. CBoth by storage speed
Show answer and explanation

Answer: B. Prefill is limited by compute, decode by memory bandwidth

In prefill, hundreds or thousands of input tokens are computed together, so weights are reused across many tokens, the work becomes matrix-matrix products and it is compute-bound. In decode, every new token requires reading all the weights for just one token's worth of computation, so intensity is low and it is memory-bound. Decode speed is therefore roughly memory bandwidth divided by model size.

  • A. It is the other way around.
  • B. Correct. Decode reads all weights for every token.
  • C. Weights sit in memory during inference.
Practice this topic Back to topic

More AI Hardware & Software Stack questions

  1. What is the role of the KV cache in LLM inference?
  2. When LLM inference handles long contexts or large batches, what tends to become a problem?
  3. 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?
  4. How does the computation of Transformer self-attention grow with input sequence length n?
  5. What is the main idea behind fast attention implementations such as FlashAttention?