Top 3 Memory-Intensive Operations in LLM Inference
The most memory-intensive operations during LLM inference are consistently identified as loading large model weights, accessing the Key-Value (KV) cache for self-attention, and performing embedding lookups.
The top 3
- Model Weights Loading: The Core Memory Bottleneck: Loading billions of model parameters (weights) from slower main memory (DRAM/HBM) to faster on-chip memory (SRAM/caches) for each computation is a primary memory bandwidth bottleneck in LLM inference, especially for large models in FP16 or BF16 precision.
- KV Cache Management: Growing Memory Footprint: The Key-Value (KV) cache, which stores intermediate attention states to avoid recomputation, dynamically expands with sequence length and batch size, consuming significant memory and leading to memory-bound operations, particularly during the decode phase of token generation.
- Small Matrix Multiplications: Low Arithmetic Intensity Challenge: During single-token decoding, many matrix multiplication operations have small dimensions, resulting in low 'arithmetic intensity'. This means the processor spends more time waiting for data to be transferred from memory than performing actual calculations, making these operations memory-bandwidth bound.
Sources
Open the full topic