vTensor: Flexible Virtual Tensor Management for Efficient LLM Serving

Jiale Xu, Rui Zhang, Cong Guo, Weiming Hu, Zihan Liu, Feiyang Wu, Yu Feng, Shixuan Sun, Changxu Shao, Yuhong Guo, Junping Zhao, Ke Zhang, Minyi Guo, Jingwen LengarXiv 2024 · DOI

Introduction

Large Language Model (LLM) serving is fundamentally constrained by memory bandwidth and capacity. To optimize inference, modern systems employ a Key-Value (KV) cache to store intermediate computations. However, serving concurrent requests with varying sequence lengths introduces significant memory fragmentation. While state-of-the-art solutions like vLLM's PagedAttention mitigate fragmentation, they do so by "coupling" memory management logic directly into the GPU computation kernels. This coupling necessitates complex page table lookups within the kernel, precluding the use of highly optimized libraries such as FlashAttention or cuBLAS and limiting the system's ability to reach peak hardware performance.

The vTensor Framework

To resolve this tension between memory efficiency and computational throughput, we present vTensor. vTensor is a novel management framework that leverages low-level GPU Virtual Memory Management (VMM) APIs (e.g., cuMemMap and cuMemAddressReserve) to decouple memory defragmentation from computation.

Decoupled Memory Management

Unlike previous paged approaches, vTensor provides a contiguous virtual address space backed by non-contiguous physical memory chunks. This abstraction allows the GPU kernels to operate on standard, contiguous tensor pointers, enabling the use of "vanilla" optimized kernels that were never designed for paged memory. The complexity of memory mapping is offloaded to the CPU, which manages the logical allocation and scheduling asynchronously.

Comparison of KV cache management: (a) Native, (b) Paged (vLLM), and (c) vTensor (Ours). vTensor decouples management from the kernel, allowing for dynamic extension and optimized GEMM.

Dynamic Extension and Prefix Caching

vTensor supports Dynamic Extension, allowing a tensor to grow in memory as new tokens are generated without requiring data migration or reallocation. Furthermore, the framework implements a Radix Tree (rTree) for prefix caching. This structure stores and reuses KV caches for common prompt prefixes in multi-turn conversations, significantly reducing redundant computation and memory overhead.

Evaluation and Key Results

The vTensor framework, implemented within the FlexInfer serving system, was evaluated using long-context benchmarks (LV-Eval) and synthetic multi-turn datasets across Yi and LLaMA model architectures.

Throughput and Kernel Efficiency

vTensor achieved an average throughput speedup of 1.86×, with gains reaching up to 2.42× in multi-turn scenarios compared to vLLM. In direct kernel benchmarks, vTensor's kernels outperformed the paged kernels of vLLM and SGLang by 2.12× to 3.15×.

Roofline Performance

A critical advantage of vTensor is its ability to utilize Tensor Cores effectively. As shown in the roofline analysis, for models with high arithmetic intensity like Multi-Query Attention (MQA), vTensor reached 27.3 TFLOP/s. This is nearly an 8x improvement over the 3.6 TFLOP/s constraint imposed by the paged mechanism in vLLM.

Roofline performance analysis comparing FlexInfer (vTensor) against vLLM across various arithmetic intensities.

Memory Utilization

By utilizing VMM to eliminate internal fragmentation, vTensor reduced memory waste by up to 80%. On an NVIDIA A100 (80GB), the system freed approximately 57GB of memory compared to static allocation, facilitating significantly larger batch sizes and improved hardware utilization.

Conclusion and Future Work

vTensor demonstrates that hardware-level virtual memory management is a powerful tool for LLM serving. By decoupling memory logic from the execution path, it allows for the simultaneous achievement of high memory efficiency and peak computational performance. Future work will explore extending this virtualized approach to multi-GPU and distributed environments to address cross-node fragmentation.

Summary updated

BibTeX
@misc{xu2024vtensor,
  author = {Jiale Xu and Rui Zhang and Cong Guo and Weiming Hu and Zihan Liu and Feiyang Wu and Yu Feng and Shixuan Sun and Changxu Shao and Yuhong Guo and Junping Zhao and Ke Zhang and Minyi Guo and Jingwen Leng},
  title = {{vTensor: Flexible Virtual Tensor Management for Efficient LLM Serving}},
  year = {2024},
  eprint = {2407.15309},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.15309},
}
Figure