Abstract
Retrieval-Augmented Generation (RAG) significantly enhances Large Language Model (LLM) accuracy but introduces substantial computational overhead during the prefill phase. MatKV (Materialized KVs) addresses this by precomputing Key-Value (KV) caches for documents and storing them on inexpensive flash SSDs. By shifting the bottleneck from GPU computation to storage I/O, MatKV reduces inference latency and energy consumption by up to 50% while maintaining competitive accuracy.
Introduction
The cost of LLM inference is increasingly dominated by the prefill phase, particularly in RAG systems where massive amounts of external data must be processed. Recomputing KV caches for frequently retrieved documents wastes expensive GPU cycles and electricity. While DRAM-based caching offers a solution, its high cost and limited capacity make it unscalable for large-scale document databases.
System Architecture and Methods
MatKV proposes a storage-centric approach to LLM inference through three primary mechanisms:
- Materialization: Documents are pre-processed once on a GPU to generate KV caches, which are then stored on commodity flash SSDs.
- Efficient Retrieval: During inference, the system bypasses redundant GPU computation by loading precomputed KV tensors directly from the SSD into the GPU's High Bandwidth Memory (HBM).
- I/O Overlapping: To minimize latency, MatKV decouples prefill and decoding. The system prefetches KV caches for subsequent queries while the GPU is occupied with current text generation.
A critical component of this strategy is the "Ten-Day Rule," an economic break-even analysis derived by the authors. They determined that if a document is accessed at least once every ten days, the cost of SSD storage is lower than the cost of recomputing its KV cache on a high-end H100 GPU.
Key Insights: The Shift to Storage-Centric AI
The motivation for MatKV stems from diverging hardware trends. While GPU performance has improved significantly over the last decade, SSD bandwidth and cost-efficiency have grown at an even faster rate.
Furthermore, MatKV leverages the observation that in RAG, self-attention between different retrieved documents is often less critical than the attention between the query and each individual document. This allows for independent document precomputation, simplifying the architecture without sacrificing significant accuracy. This approach also democratizes high-end inference; a consumer-grade RTX 4090 using MatKV can achieve performance levels comparable to a top-tier H100 running standard inference.
Evaluation and Results
MatKV was evaluated using benchmarks including TurboRAG, LongBench, and Deep1B. Key findings include:
- Performance: Up to a 2x speedup in batched inference scenarios.
- Efficiency: A 50% reduction in total system power consumption.
- Accuracy: Negligible loss on LongBench QA tasks compared to vanilla inference.
- Scalability: The benefits of MatKV scale positively with model size, as compute costs grow faster than KV cache storage requirements.
Limitations and Future Work
Current limitations include the "cold start" requirement for the initial materialization and the storage capacity needed for billions of documents. Future research will focus on selective materialization of "hot" documents, KV compression techniques, and extending the framework to agentic AI and long-context tasks.
Summary updated