passdrill
AI & LLM Engineering · How LLMs Work: Transformers & Training · Card 022/024 hard

Shazeer (2019), "Fast Transformer Decoding: One Write-Head is All You Need," introduces multi-query attention as a modification to standard multi-head attention aimed at speeding up autoregressive decoding. What does multi-query attention change relative to standard multi-head attention, and why does this help?

  1. It reduces the number of query heads down to a single shared query head, while each head keeps its own separate key and value projections, cutting the number of query computations performed at each step
  2. It removes the key and value projections entirely, having every attention head operate directly on the raw token embeddings instead of projected keys and values
  3. It increases the number of key and value heads beyond the number of query heads, giving each query head access to several redundant copies of the same key and value vectors
  4. It keeps multiple separate query heads but has all of them share a single set of key and value projections, shrinking the size of the cached keys and values that must be stored and read back at every decoding step, which reduces the memory-bandwidth cost that dominates incremental decoding
Next card → Shuffle