Pie: Pooling CPU Memory for LLM Inference

Yi Xu, Ziming Mao, Xiangxi Mo, Shu Liu, Ion StoicaarXiv 2024 · DOI

Introduction

The rapid advancement of Large Language Models (LLMs) has encountered a significant bottleneck: the "memory wall." While GPU compute capabilities have scaled dramatically, onboard High Bandwidth Memory (HBM) capacity has not kept pace with the growing size of models and their associated Key-Value (KV) caches. Standard approaches to mitigate this involve "swapping"—moving data to CPU RAM—but this typically introduces severe performance penalties due to interconnect latency, causing the GPU to stall while waiting for data.

Pie is a novel inference framework designed to make CPU memory a "performance-transparent" extension of the GPU. By exploiting the predictable access patterns of LLM inference and leveraging high-bandwidth interconnects, Pie breaks the memory wall without sacrificing throughput or latency.

Performance-Transparent Swapping

The core of Pie's efficiency lies in its ability to overlap data movement with computation. Because LLM inference proceeds layer-by-layer, the sequence of required memory blocks is entirely predictable. Pie implements a background prefetching mechanism that treats the LLM layers as a sequence.

Pie's layer-by-layer prefetching and swapping mechanism.

As shown in the architecture above, Pie uses a background FIFO queue to prefetch upcoming KV cache layers from CPU memory to the GPU while the GPU is actively computing the current layer ($Layer\ k$). On high-bandwidth systems like the NVIDIA GH200 Grace Hopper Superchip, which features NVLink C2C (900GB/s), these transfers often complete before the GPU requires the data, effectively hiding the swapping latency from the execution pipeline.

Adaptive Memory Expansion

Determining the optimal amount of data to offload to CPU memory is a dynamic challenge. Excessive swapping can saturate the interconnect and lead to GPU stalls, while insufficient swapping fails to utilize available resources. Pie addresses this through an "Adaptive Expansion" algorithm.

The adaptive expansion process, showing how Pie converges to an optimal swapping configuration.

The system starts with zero swapping and incrementally expands the KV cache into CPU memory. It continuously monitors three key metrics: interconnect saturation, the relationship between swapping and computation latency, and overall throughput. If the monitoring logic detects a performance dip or interconnect bottleneck, it automatically scales back the expansion. This online approach allows Pie to adapt to varying workloads and model requirements without the need for expensive offline profiling, typically converging within a brief warm-up phase.

Evaluation and Results

The researchers evaluated Pie using the OPT (13B, 30B) and Llama-13B models on real-world datasets, including ShareGPT and Alpaca. The hardware testbed featured the NVIDIA GH200 Grace Hopper Superchip.

Pie demonstrated substantial improvements over existing state-of-the-art frameworks:

  • Throughput and Latency: Compared to vLLM, Pie achieved up to 1.9× higher throughput and a 2× reduction in latency. The latency improvement is largely attributed to reduced queuing time; by fitting more requests into the expanded "effective memory," tokens are scheduled more quickly.
  • Comparison with FlexGen: Pie outperformed FlexGen by 9.4× in throughput. Unlike FlexGen's static offline profiling, Pie’s dynamic adaptation is better suited for real-time serving environments.
  • Memory Efficiency: Pie can reduce physical GPU memory requirements by 1.67× while maintaining the same performance level as a GPU-only configuration.

Conclusion

Pie demonstrates that with the right architectural approach and high-bandwidth interconnects, CPU memory can be seamlessly pooled with GPU memory for LLM inference. By transforming swapping from a "last resort" into a primary architectural choice, Pie provides a scalable solution to the GPU memory wall. Future work will explore extending these pooling techniques to multi-node clusters and optimizing performance on standard PCIe-based systems where the "transparent" window is narrower.

Summary updated

BibTeX
@misc{xu2024pie,
  author = {Yi Xu and Ziming Mao and Xiangxi Mo and Shu Liu and Ion Stoica},
  title = {{Pie: Pooling CPU Memory for LLM Inference}},
  year = {2024},
  eprint = {2411.09317},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.09317},
}
Figure