FIER: Fine-Grained and Efficient KV Cache Retrieval for Long-context LLM Inference

Dongwei Wang, Zijie Liu, Song Wang, Yuxin Ren, Jianing Deng, Jingtong Hu, Tianlong Chen, Huanrui Yang

TL;DR

This paper introduces FIER, a novel method for efficiently retrieving key-value (KV) cache entries in large language models (LLMs) handling long contexts. By using 1-bit quantized keys for fine-grained token-level importance estimation, FIER significantly reduces memory usage and speeds up inference without sacrificing accuracy, matching full KV cache performance with only 11% of the budget.

What Problem Does This Paper Address?

Large Language Models (LLMs) are increasingly being used for tasks requiring long-context understanding, but their inference efficiency is hampered by the growing size of the KV cache. As the context length increases, the time and memory required to access the KV cache become a significant bottleneck, often accounting for over half of the total inference time. Previous solutions like KV eviction (keeping fixed tokens) or page-level KV retrieval (processing tokens in fixed-size blocks) struggle with the dynamic nature of token importance and the sparse distribution of relevant information within long contexts, leading to either performance degradation or inefficient retrieval.

Methods

FIER tackles this problem with a two-pronged approach:

  • Fine-Grained Token-Level Retrieval: Unlike page-level methods that treat entire blocks of tokens, FIER focuses on identifying and retrieving individual important tokens. This is crucial because relevant information is often scattered, and page-level retrieval can include many irrelevant tokens while missing critical ones.
  • 1-Bit Quantization for Efficient Importance Estimation: To make fine-grained retrieval computationally feasible, FIER quantizes the key cache to 1-bit. The paper demonstrates that this extreme quantization has a minimal impact on the accuracy of identifying the most important tokens (Top-k selection). This is achieved by using a relaxed "hinge objective" that prioritizes preserving the relative ranking of important tokens over exact score reconstruction. This allows for efficient computation of approximate attention scores using quantized keys, followed by a full-precision attention computation on the selected subset of tokens.

The workflow involves:

  1. Quantizing the key cache (K) to 1-bit.
  2. Computing approximate attention scores using the quantized keys and the query (q).
  3. Selecting the Top-k most important tokens based on these scores.
  4. Performing full-precision self-attention only on the selected tokens.

Datasets

The paper evaluates FIER on several benchmarks:

  • PG19: For language modeling evaluation.
  • LongBench: A benchmark for long-context QA, comprising six datasets: NarrativeQA, Qasper, MultiFieldQA, HotpotQA, GovReport, and TriviaQA.
  • Passkey Retrieval Benchmark: To assess the model's ability to handle long-range dependencies.

Key Insights and Ideas

  • Sparse Importance, Coarse Granularity Mismatch: The core insight is that important tokens in long contexts are sparsely distributed, making coarse-grained page-level retrieval inherently inaccurate. This sparsity necessitates a fine-grained, token-level approach.
  • 1-Bit Quantization is Sufficient for Ranking: Surprisingly, quantizing KV cache keys to just 1-bit does not significantly degrade the ability to identify the most important tokens. This is because the goal is ranking (Top-k selection), not precise score reconstruction, and the hinge loss objective is more robust to outliers and quantization errors for this purpose.
  • Efficiency vs. Accuracy Trade-off is Manageable: By combining fine-grained retrieval with efficient 1-bit quantization, FIER achieves a better balance between accuracy and efficiency than existing methods, which often sacrifice one for the other.

Key Results

  • Performance: FIER matches full KV cache performance while using only 11% of the KV budget across various long-context tasks.
  • Speedup: FIER reduces decoding latency by 1.2x to 1.5x on a single RTX 4090 GPU, with speedup increasing at longer context lengths.
  • Accuracy: FIER consistently outperforms existing KV eviction and retrieval baselines on PG19, LongBench, and the passkey retrieval benchmark. For instance, on LongBench, it achieves comparable performance to full KV with just 1k tokens (11% of the full cache budget).
  • Recall: FIER demonstrates a significantly higher recall rate (91%) compared to Quest (44% with page size 16) in identifying important tokens.

Limitations and Future Work

  • Model Scale: Experiments were limited to models up to 8B parameters. Evaluating FIER on larger models (13B, 70B) is suggested to explore its scalability.
  • System Optimization: The current implementation uses Triton for operators. Custom CUDA kernels could potentially offer further optimization for inference speedup.
  • Grouped-Query Attention (GQA) Compatibility: FIER is not yet integrated with GQA. Exploring the compatibility between token pruning (FIER's approach) and GQA (reducing KV heads) is identified as a future research direction.

Summary updated

BibTeX
@inproceedings{wang2025fier,
  author = {Dongwei Wang and Zijie Liu and Song Wang and Yuxin Ren and Jianing Deng and Jingtong Hu and Tianlong Chen and Huanrui Yang},
  title = {{FIER: Fine-Grained and Efficient KV Cache Retrieval for Long-context LLM Inference}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2025},
}
Figure