Abstract
As Large Language Models (LLMs) scale to massive context windows, the infrastructure supporting them faces significant bottlenecks, particularly in Time to First Token (TTFT). LayerKV introduces a layer-wise Key-Value (KV) cache management system that offloads specific layers to CPU memory and utilizes an SLO-aware scheduler. This approach reduces queuing delays and improves TTFT by up to 69x without compromising generation throughput.
Introduction
The demand for long-context LLMs—capable of processing up to a million tokens—has exposed limitations in current serving architectures. While long contexts enable sophisticated document analysis, they often lead to excessive TTFT, degrading user experience. The primary bottleneck is not just the computational cost of the initial prompt processing (prefill latency), but the queuing delay caused by GPU memory constraints.
As shown in Figure 1, TTFT increases exponentially with context length, while Time Per Output Token (TPOT) remains relatively stable. This disparity highlights the inefficiency of current memory allocation strategies.
The Queuing Bottleneck
Current state-of-the-art systems like vLLM allocate KV cache blocks in GPU memory at the request level. For long-context prompts, the required memory is substantial. When a new request arrives and GPU memory is saturated, it must wait in a queue until active requests complete.
Empirical analysis (Figure 2) reveals that for context lengths exceeding 1024 tokens, queuing delay becomes the dominant component of TTFT. Addressing this delay is critical for maintaining responsiveness in high-load scenarios.
LayerKV Methodology
LayerKV proposes a granular approach to memory management by operating at the layer level rather than the request level.
1. SLO-aware Scheduler
The scheduler predicts the remaining execution time for active requests and identifies "slack" periods before Service Level Objectives (SLOs) are violated. It then schedules new prefill requests into these gaps, maximizing GPU utilization.
2. Layer-wise Allocation and Offloading
Instead of requiring the entire KV cache to reside on the GPU, LayerKV offloads specific layers to host (CPU) memory. This frees up GPU blocks, allowing new requests to enter the prefill stage earlier.
3. Asynchronous Communication
To mitigate the latency of PCIe transfers between the CPU and GPU, LayerKV overlaps computation with communication. The system offloads the KV cache of layer $N-1$ while the GPU processes layer $N$.
Evaluation and Results
The researchers evaluated LayerKV using LLaMA-2-7B, Yi-34B-200K, and LLaMA-3.1-70B models on synthetic and real-world (ShareGPT) datasets.
Key findings include:
- TTFT Reduction: LayerKV achieved up to a 69x reduction in mean TTFT for long-context requests.
- SLO Compliance: The system reduced SLO violation rates by 28.7%.
- Tail Latency: P99 TTFT saw a 45x reduction under heavy load.
- Throughput Preservation: Overall throughput remained within 3% of vLLM, indicating that the latency improvements come with minimal overhead.
Conclusion
LayerKV demonstrates that layer-wise KV cache management is a highly effective strategy for scaling LLM serving to long contexts. By prioritizing the reduction of queuing delays through intelligent offloading and scheduling, LayerKV significantly enhances the responsiveness of LLM-based services. Future work will explore the integration of KV cache quantization and disaggregated prefill-decoding architectures.
Summary updated