TL;DR
ContiguousKV is a novel offloading system designed to accelerate the "Re-Prefill" phase of Large Language Model (LLM) inference when dealing with long, shared prompts. By aligning the system's physical I/O granularity with the algorithm's semantic pruning chunk size and introducing a two-level asynchronous prefetching engine, it eliminates data transfer waste and resource idle bubbles. The result is a 3.85x speedup over state-of-the-art offloading systems while maintaining high model accuracy.
What Problem Does This Paper Address?
Modern LLM applications like Retrieval-Augmented Generation (RAG) and multi-turn conversational agents frequently process requests that share a massive, identical context (e.g., a long document or chat history). To avoid recomputing this shared context for every query, systems save the pre-computed Key-Value (KV) cache of the prefix. When a new request arrives, the system enters the Re-Prefill Phase: it loads this shared prefix KV cache from a slower storage tier (like CPU memory or an SSD) and computes the attention matrix alongside the new query tokens to generate the first token.
However, existing offloading systems hit a severe I/O bottleneck due to two major inefficiencies:
- Granularity Mismatch (Read Amplification): Algorithmic pruning methods (like H2O) drop unimportant tokens to save memory, selecting critical data at a fine, token-level granularity. Conversely, storage systems manage data in coarse, fixed-size blocks (e.g., 64-token chunks) to maximize disk throughput. This forces systems to load multi-megabyte blocks just to access a few kilobytes of relevant data, causing massive read amplification.
- Sequential Dependency (Idle Bubbles): LLM computation is strictly serialized layer by layer. A system must load a layer's prefix keys before it can identify critical tokens and compute attention, creating massive idle "bubbles" where either the GPU stalls waiting for I/O, or the I/O subsystem sits idle waiting for the next compute step.
Methods
The authors introduce ContiguousKV, an inference system built on three core co-designs:
- ContiguousChunk: Instead of managing I/O in massive, arbitrary blocks, ContiguousKV introduces a unified data management unit called a
ContiguousChunk(typically set to 16 tokens). Importance scoring, storage layout, disk transfer, and caching are all performed at this exact granularity. This perfectly aligns the system's physical transfer size with the algorithm's semantic selection, completely eliminating read amplification. - Two-Level Asynchronous Prefetching: The authors observed that the specific tokens an LLM deems "important" are highly similar across adjacent Transformer layers. They exploit this by grouping layers into Periods.
- Intra-Period Prefetching: Once the first layer of a period identifies critical chunks, the system immediately fires off asynchronous I/O requests to prefetch those exact chunks for all subsequent layers in that period, pipelining I/O with current layer computations.
- Inter-Period Prefetching: Before a new period even begins, the system speculatively prefetches KV caches based on the previous period's selections, warming up period boundaries and hiding initial loading latencies.
- Attention-Guided Cache Management: Rather than relying on generic cache eviction policies like LRU or LFU, ContiguousKV tracks an attention-aware cache score ($S_j = I_j \times F_j$) combining cumulative attention importance ($I_j$) and access frequency ($F_j$). It uses GPU and CPU min-heaps to dynamically keep the most semantically vital chunks in faster memory.
Datasets
The system was evaluated using the Qwen2.5 model series (at 7B, 14B, and 32B scales) across four representative natural language understanding benchmarks configured as few-shot, prompt-based generation tasks:
- SST-2 (Sentiment analysis)
- SubJ (Subjectivity classification)
- TREC (Question classification)
- RTE (Textual entailment)
Key Insights and Ideas
- System-Algorithm Co-Design is Essential: Traditional systems treat the storage layer as a black box blind to model semantics. Aligning physical block sizes to match natural language processing chunks prevents loading wasted data.
- Cross-Layer Semantic Predictability: The fact that token importance maps remain stable across adjacent layers allows the system to accurately predict future data needs, effectively breaking the strict sequential execution barrier of deep networks.
- Chunking Benefits Accuracy: Interestingly, pruning KV caches in small contiguous chunks (like 16 tokens) rather than individual isolated tokens actually helps preserve local semantic context, resulting in better model accuracy under tight memory budgets.
Key Results
- End-to-End Speedup: ContiguousKV achieves a 3.85x speedup in the Re-Prefill phase over IMPRESS (the previous state-of-the-art offloading system) and up to 6.16x over standard AttentionStore (AS+LRU) baselines.
- Massive I/O Reduction: The system reduces the total number of tokens loaded from SSDs by an average of 16.33x compared to IMPRESS due to the elimination of read amplification.
- Tail Latency Mitigation: ContiguousKV significantly flattens latency spikes, reducing P95 tail latency by 0.42s to 1.17s across different model sizes.
Limitations and Future Work
- Probing Key Bottleneck: While ContiguousKV dramatically accelerates the loading of critical KV pairs, it does not optimize the initial step of loading "probing keys" used to calculate token importance. As a result, probing key collection becomes a larger relative bottleneck in the accelerated pipeline.
- Accumulated Loss in Large Periods: Sharing token importance indices across layers is an approximation. If the "Period" size is configured too large (e.g., >16 layers), the approximation error compounds, leading to minor accuracy degradation. Future work could explore dynamically sizing these periods based on layer-wise attention variance.
Summary updated