Beyond Bit-Depth: LLM VRAM's Hidden Influencers
While bit-depth reduction is crucial for VRAM savings, other factors significantly impact total VRAM for LLM inference, including the Key-Value (KV) cache (especially for longer context windows), activation memory, batch size, and overhead from the chosen inference framework. These elements can add an extra 10-20% to the model's base memory footprint.
The top 3
- KV Cache: Context Window's Hidden VRAM Tax: The Key-Value (KV) cache is a primary VRAM bottleneck, growing linearly with batch size and quadratically with context length, with a Llama 3.1 70B model needing approximately 40 GB for a single 128K context request.
- Attention Architectures: GQA's VRAM Efficiency Edge: Grouped-Query Attention (GQA), an architectural feature used in models like Llama 3.1 and Mistral, can reduce KV cache memory by up to 8x compared to standard Multi-Head Attention, making large 70B models more feasible on single GPUs.
- PagedAttention: Revolutionizing LLM VRAM Management: vLLM's PagedAttention, inspired by operating system virtual memory, eliminates KV cache fragmentation to achieve near-optimal memory usage (under 4% waste) and significantly boosts LLM inference throughput.
Sources
Open the full topic