Files
2026-07-13 10:14:34 +00:00

160 lines
10 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!-- WEHUB_ZH_README -->
> [!NOTE]
> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
> [English](./README.en.md) · [原始项目](https://github.com/LMCache/LMCache) · [上游 README](https://github.com/LMCache/LMCache/blob/HEAD/README.md)
> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
<div align="center">
<p align="center">
<img src="asset/logo.png" alt="lmcache logo" width="45%">
</p>
<h3 align="center">
面向可扩展 LLM 推理的 KV Cache 管理层
</h3>
<hr width="78%">
<h3 align="center">
<a href="https://blog.lmcache.ai/">博客</a> |
<a href="https://docs.lmcache.ai/">文档</a> |
<a href="https://join.slack.com/t/lmcacheworkspace/shared_invite/zt-3zxjao8h0-lRfBfnLqbALOtLsWn2ITxA">加入 Slack</a> |
<a href="https://docs.lmcache.ai/community/meetings.html">社区会议</a> |
<a href="https://github.com/LMCache/LMCache/issues/2923">路线图</a>
</h3>
[![GitHub Repo stars](https://img.shields.io/github/stars/LMCache/LMCache?style=flat&logo=github)](https://github.com/LMCache/LMCache/stargazers)
[![PyPI](https://img.shields.io/pypi/v/lmcache)](https://pypi.org/project/lmcache/)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/lmcache)](https://pypi.org/project/lmcache/)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/w/LMCache/LMCache)](https://github.com/LMCache/LMCache/graphs/commit-activity)
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/LMCache/LMCache/)
**如果 LMCache 能帮助你更快、更便宜地部署 LLM 服务,请[为我们点个星](https://github.com/LMCache/LMCache) — 这能帮助更多团队发现该项目。**
</div>
## 更新
- [2026/05] 🔥 基于 AMD MI300X 的 Agentic 工作负载基准测试([博客](https://blog.lmcache.ai/en/2026/05/12/benchmarking-lmcache-for-multi-turn-agentic-workloads-on-amd-mi300x/)).
- [2026/04] 🔥 LMCache 全新多进程(MP)架构发布([博客](https://blog.lmcache.ai/en/2026/04/03/lmcaches-new-architecture-boosts-moe-inference-performance-by-10x/)).
- [2026/03] LMCache 亮相 GTC 2026[文章](https://www.linkedin.com/posts/lmcache-lab_llm-opensource-nvidiagtc-activity-7442721875664826369-pMAu?utm_source=share&utm_medium=member_desktop&rcm=ACoAADkIIvQBTyG53kXXX70OZdE5rhpllYQqmIA)).
- [2026/01] LMCache 多节点 P2P CPU 内存共享,从实验特性走向生产([博客](https://blog.lmcache.ai/en/2026/01/21/p2p-1/)).
<details>
<summary>更多</summary>
- [2025/11] LMCache x CoreWeave 为 Cohere 加速高效 LLM 推理([博客](https://blog.lmcache.ai/en/2025/10/29/breaking-the-memory-barrier-how-lmcache-and-coreweave-power-efficient-llm-inference-for-cohere/)).
- [2025/10] LMCache 加入 PyTorch FoundationTensormesh 正式发布([博客](https://blog.lmcache.ai/en/2025/10/31/tensormesh-unveiled-and-lmcache-joins-the-pytorch-foundation/), [PyTorch](https://pytorch.org/blog/lmcache-joins-pytorch-ecosystem/)).
- [2025/09] NVIDIA Dynamo 集成 LMCache,加速 LLM 推理([博客](https://blog.lmcache.ai/en/2025/09/18/nvidia-dynamo-integrates-lmcache-accelerating-llm-inference/)).
- [2025/08] 🎉 LMCache GitHub Star 数突破 5,000+[博客](https://blog.lmcache.ai/en/2025/08/28/%f0%9f%8e%89-lmcache-hits-5000-github-stars-thank-you-community/)).
- [2025/08] LMCache 首日即支持 gpt-oss20B/120B)([博客](https://blog.lmcache.ai/en/2025/08/05/lmcache-supports-gpt-oss-20b-120b-on-day-1/)).
- [2025/07] 借助 LMCache 与 Redis 实现更快的 LLM 推理与更低成本的响应([Redis 博客](https://redis.io/blog/get-faster-llm-inference-and-cheaper-responses-with-lmcache-and-redis/)).
- [2025/07] LMCache 在 vLLM V1 中将加速能力扩展至多模态模型([博客](https://blog.lmcache.ai/en/2025/07/03/lmcache-extends-its-turbo-boost-to-multimodal-models-in-vllm-v1/)).
- [2025/06] LLM Production Stack 实现跨硬件支持:AMD、Arm 与 Ascend[博客](https://blog.lmcache.ai/en/2025/06/20/llm-production-stack-goes-cross-hardware-ascend-arm-and-amd-support-incoming/)).
</details>
## 关于
LMCache 是面向 LLM 推理的 **KV cache 管理层**。它将 KV cache 从临时状态转化为可复用的 *AI 原生知识(AI-native knowledge*,可被持久 *存储*、在多个 serving engine 间 *复用*、通过可观测性技术栈进行 *监控*,并 *转换* 以提升生成质量。因此,LMCache 能够 **降低 TTFT**time-to-first-token,首 token 时间)并 **提升吞吐量**,尤其适用于长上下文 agentic、多轮对话以及知识增强类工作负载(例如 RAG)。
LMCache 具备 **厂商中立(vendor-neutral** 特性。它可作为 KV cache 层,用于多种主流开源 serving engine、推理框架、硬件厂商、存储系统与基础设施提供商。厂商中立性使用户能够在不同 serving engine 与存储供应商之间自由切换,同时复用已存储的 KV cache。
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="asset/deployment_modes_dark.png">
<source media="(prefers-color-scheme: light)" srcset="asset/deployment_modes_light.png">
<img alt="LMCache Deployment Modes" src="asset/deployment_modes_light.png">
</picture>
</p>
### 核心特性
- **与推理引擎解耦的部署**:LMCache 作为独立守护进程,与推理引擎进程分离管理 KV cache,因此即使推理引擎崩溃,KV cache 也不会丢失(即不与引擎命运共享)。
- **持久化、分层的 KV cache 卸载与复用**:将 KV cache 从 GPU 内存迁移至跨越 CPU 内存、本地存储与远程后端的分层存储体系,实现跨请求、会话与引擎实例的复用,减少重复的 prefill 计算并改善 TTFT。
- **生产级 KV cache 可观测性**LMCache 提供丰富的 KV cache 可观测性指标,包括典型 Kubernetes 指标(健康监控、性能诊断)、KV cache 专属指标(请求级与 token 级前缀缓存命中、生命周期、请求级 KV cache 性能)、管理指标(用户级用量)等。
- **可插拔的存储与传输后端**:通过统一接口轻松集成远程存储与 KV 传输后端,实现跨存储提供商的 KV cache 卸载与共享。借助该接口,LMCache 支持 CPU RAM、本地磁盘(SSD)、Redis/Valkey、Mooncake、InfiniStore、S3 兼容对象存储、NIXL 与 GDS 等存储后端。
- **非前缀 KV 复用**:借助 CacheBlend 在提示词任意位置复用已缓存的 KV 块,将 KV 复用扩展至前缀缓存之外,并有选择地重算 token 以恢复质量。
- **PD 解耦与 KV 传输**:通过 NIXL 等传输层,支持经 NVLink、RDMA 或 TCP 将 KV cache 从 prefill worker 传输至 decode worker。
- **可插拔 KV 转换**:为研究人员提供简洁接口,通过灵活的 SERDE 接口实现压缩、token 丢弃与自定义序列化。
LMCache 正成为 LLM 推理 *生态* 中的关键层,并与 serving engine、推理框架、硬件厂商、存储系统及基础设施提供商开展由 *社区* 驱动的集成:
<p align="center">
<img src="asset/ecosystem.png" alt="LMCache ecosystem">
</p>
## 快速开始
要使用 LMCache,只需通过包管理器安装 `lmcache`,例如 pip
```bash
pip install lmcache
```
更多安装选项与示例,请参阅:
- [安装](https://docs.lmcache.ai/getting_started/installation.html)
- [快速入门](https://docs.lmcache.ai/getting_started/quickstart.html)
- [LMCache Recipes](https://docs.lmcache.ai/recipes/index.html)
- [CLI 参考](https://docs.lmcache.ai/cli/index.html)
- [基准测试指南](https://docs.lmcache.ai/getting_started/benchmarking.html)
- [生产部署](https://docs.lmcache.ai/mp/deployment.html)
## 贡献
我们欢迎并重视各类贡献与合作。欢迎加入我们一起改进 LMCache。请查阅[贡献指南](https://docs.lmcache.ai/developer_guide/contributing.html),或加入我们的 [Slack 社区](https://join.slack.com/t/lmcacheworkspace/shared_invite/zt-3zxjao8h0-lRfBfnLqbALOtLsWn2ITxA) 以开始参与。
## 采用与合作伙伴
LMCache 拥有一个不断壮大的开发者、研究人员、行业采用方和合作伙伴社区,共同构建下一代高效 LLM 推理系统。
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="asset/partner_dark.png">
<source media="(prefers-color-scheme: light)" srcset="asset/partner_light.png">
<img alt="LMCache 采用与合作伙伴" src="asset/partner_light.png">
</picture>
</p>
作为一个独立的开源项目,LMCache 正在成为 LLM 推理中 KV Cache 管理的事实标准。其持续开发和社区工作部分由 [Tensormesh](https://www.tensormesh.ai/). 支持。
## 引用
LMCache 建立在 KV cache 管理相关研究之上,包括缓存复用、卸载、压缩和服务优化。如果您在研究中使用 LMCache,请引用 LMCache 论文及相关工作。
~~~bibtex
@article{cheng2025lmcache,
title={LMCache: An Efficient KV Cache Layer for Enterprise-Scale LLM Inference},
author={Cheng, Yihua and Liu, Yuhan and Yao, Jiayi and An, Yuwei and Chen, Xiaokun and Feng, Shaoting and Huang, Yuyang and Shen, Samuel and Du, Kuntai and Jiang, Junchen},
journal={arXiv preprint arXiv:2510.09665},
year={2025}
}
~~~
<details>
<summary>相关论文</summary>
~~~bibtex
@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}
}
@inproceedings{yao2025cacheblend,
title={Cacheblend: Fast large language model serving for rag with cached knowledge fusion},
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},
booktitle={Proceedings of the twentieth European conference on computer systems},
pages={94--109},
year={2025}
}
~~~
</details>
## 许可证
LMCache 代码库采用 Apache License 2.0 许可证。详情请参阅 [LICENSE](LICENSE) 文件。