Supercharge Your LLM with the Fastest KV Cache Layer

Supercharge Your LLM with the Fastest KV Cache Layer

技术背景

在大语言模型(LLM)的服务过程中,降低首次标记响应时间(TTFT)并提高吞吐量是关键挑战,特别是在长上下文场景下。LMCache 作为一种 LLM 服务引擎扩展,旨在解决这些问题。它通过在不同位置(如 GPU、CPU DRAM、本地磁盘)存储可重复使用文本的 KV 缓存,实现了对任意可重复使用文本(不一定是前缀)的 KV 缓存重用,从而节省了宝贵的 GPU 周期并减少了用户响应延迟。

实现步骤

安装和快速开始

请参考 LMCache V1 和 LMCache V0 的详细文档。对于大规模部署,请参考 vLLM 生产堆栈。

结合 vLLM 使用

可以使用预构建的 vllm Docker 镜像来尝试 LMCache。通过将 LMCache 与 vLLM 结合,在许多 LLM 使用场景(如多轮问答和检索增强生成(RAG))中,LMCache 可实现 3 - 10 倍的延迟节省和 GPU 周期减少。

核心代码

文档中未明确给出核心代码示例,但可通过以下方式安装和集成 LMCache:

1
pip install LMCache

然后将其集成到最新的 vLLM 中。

最佳实践

利用高性能特性

LMCache V1 与 vLLM 集成后,具有高性能 CPU KV 缓存卸载、分布式预填充、P2P KV 缓存共享等特性。在实际使用中,可以充分利用这些特性来提高系统性能。

参考文档和博客

参考 LMCache 的最新博客文章和文档页面,获取更多使用技巧和最佳实践。

常见问题

如何参与贡献

欢迎并重视任何贡献和合作。请查看 CONTRIBUTING.md 了解如何参与。

如何引用

如果在研究中使用 LMCache,请引用以下论文:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
@inproceedings{liu2024cachegen,
title={Cachegen: Kv cache compression and streaming for fast large language model serving},
author={Liu, Yuhan and Li, Hanchen and Cheng, Yihua and Ray, Siddhant and Huang, Yuyang and Zhang, Qizheng and Du, Kuntai and Yao, Jiayi and Lu, Shan and Ananthanarayanan, Ganesh and others},
booktitle={Proceedings of the ACM SIGCOMM 2024 Conference},
pages={38--56},
year={2024}
}

@article{cheng2024large,
title={Do Large Language Models Need a Content Delivery Network?},
author={Cheng, Yihua and Du, Kuntai and Yao, Jiayi and Jiang, Junchen},
journal={arXiv preprint arXiv:2409.13761},
year={2024}
}

@inproceedings{10.1145/3689031.3696098,
author = {Yao, Jiayi and Li, Hanchen and Liu, Yuhan and Ray, Siddhant and Cheng, Yihua and Zhang, Qizheng and Du, Kuntai and Lu, Shan and Jiang, Junchen},
title = {CacheBlend: Fast Large Language Model Serving for RAG with Cached Knowledge Fusion},
year = {2025},
url = {https://doi.org/10.1145/3689031.3696098},
doi = {10.1145/3689031.3696098},
booktitle = {Proceedings of the Twentieth European Conference on Computer Systems},
pages = {94–109},
}

社区会议

LMCache 的社区会议每周举行。会议详情如下:

  • 太平洋时间周二上午 9:00
  • 太平洋时间周二下午 6:30
    会议时间每周在这两个时间之间交替。欢迎所有人参加。

Supercharge Your LLM with the Fastest KV Cache Layer
https://119291.xyz/posts/supercharge-your-llm-with-the-fastest-kv-cache-layer/
作者
ww
发布于
2025年7月27日
许可协议