LLM Architectures: Memory Bandwidth Efficiency Kings

Specific architectural choices significantly impact memory efficiency for local LLM inference. Mistral 7B's Sliding Window Attention (SWA) effectively minimizes Key-Value (KV) cache memory usage, keeping VRAM requirements low even with extended context lengths. Gemma 2B utilizes Multi-Query Attention (MQA) to reduce memory bandwidth demands, making it particularly advantageous for efficient inference on memory-constrained devices.

The top 3

  1. GQA: New King of LLM Memory Efficiency: Grouped-Query Attention (GQA) balances Multi-Head Attention's quality with Multi-Query Attention's speed, reducing KV cache size by up to 90% and boosting inference by 30-40% compared to MHA, adopted by Llama 2/3 and Mistral 7B.
  2. MQA: Pioneering Memory Savings in LLMs: Multi-Query Attention (MQA) significantly reduces memory bandwidth and KV cache storage by sharing a single key and value head across all attention heads, potentially offering 10-100x smaller KV cache and 12x faster decoder inference, though sometimes at the cost of accuracy.
  3. Sparse Attention: Unlocking Million-Token Contexts: Sparse attention mechanisms, like sliding windows or landmark tokens, overcome the quadratic memory scaling of traditional attention by having queries attend to only a subset of keys, enabling LLMs to handle context lengths up to 100 million tokens.

Sources

Open the full topic