[Paper Review] H$_2$O: Heavy-Hitter Oracle for Efficient Generative Inference of Large Language Models
H2O introduces a heavy-hitter based KV-cache eviction policy that dramatically reduces memory footprint and increases throughput for LLM inference without sacrificing accuracy, validated across OPT, LLaMA, and GPT-NeoX.
Hyde-IKV is a dynamic management system for the Key-Value (KV) cache in Small Language Models (SLMs). It tackles the memory bottleneck of long-context inference by intelligently prioritizing and compressing the stored context. Instead of abruptly deleting tokens, Hyde-IKV uses a hybrid strategy of positional decay (gradually reducing the influence of older tokens) and importance-based modulation (preserving tokens with high attention scores or large key vector magnitudes). This non-invasive approach, implemented via hooks into the transformer architecture, significantly reduces GPU memory usage and speeds up inference for long sequences while largely preserving the quality of the generated text.
Motivation & Objective
- Motivate reducing KV-cache memory in long-content generation without large accuracy loss.
- Identify that a small set of tokens (heavy-hitters) drive most attention scores.
- Develop a low-cost eviction policy leveraging heavy-hitters to balance recency and relevance.
- Provide theoretical guarantees for a dynamic submodular eviction framework.
- Demonstrate practical improvements in throughput and latency on multiple model families.
Proposed method
- Observe sparsity in attention (over 95%) to justify smaller KV-cache needs.
- Characterize heavy-hitters (H2) as tokens with concentrated attention scores and high co-occurrence with frequent words.
- Formulate KV-cache eviction as a dynamic submodular problem and propose H2O eviction (greedy) based on F_score scores.
- Implement a low-cost, dynamic greedy algorithm that uses local attention statistics per decoding step.
- Prove a near-optimality guarantee under mild submodularity assumptions for the greedy policy.
- Integrate H2O into FlexGen to evaluate across OPT, LLaMA, and GPT-NeoX with 20% KV-cache budget.
Experimental results
Research questions
- RQ1Can KV-cache memory be reduced significantly without harming generation quality?
- RQ2Do heavy-hitter tokens (H2) capture most of the attention signal and can they guide eviction decisions?
- RQ3Can a greedy, low-cost eviction policy achieve near-optimal performance under a submodular attention assumption?
- RQ4How does H2O perform across model families (OPT, LLaMA, GPT-NeoX) and tasks varying in sequence length?
- RQ5What throughput and latency gains are achievable in real systems when using H2O?
Key findings
- Reducing KV-cache to about 20% yields comparable or better generation quality on many tasks, with substantial memory savings.
- H2O achieves up to 29× throughput improvements over DeepSpeed Zero-Inference and Hugging Face Accelerate, and up to 3× over FlexGen on OPT-6.7B and OPT-30B.
- H2O reduces latency by up to 1.9× at the same batch size compared with a baseline system.
- Combining H2 with existing sparsification methods maintains performance where other methods fail at low budgets.
- The approach exhibits robustness across model sizes (6.7B–175B) and tasks from HELM and lm-eval-harness, including long-sequence generation.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.