目录
Feng Liu

[KV Cache][Feature] Support Layerwise KV Pooling (#10077)

Limitations of the Previous Layerwise Design

1. Per-Layer Key Management

  • Each KV cache block in every layer was assigned a unique key.
  • The number of keys increased proportionally with the number of layers and blocks, resulting in significant metadata management overhead.

2. High Metadata Lookup Latency

  • Both put and get operations required querying the Meta Server to resolve the memory address associated with a key.
  • Frequent metadata lookups introduced additional latency on the critical access path.

3. Inefficient HBM Address Computation

  • HBM addresses were computed using Python lists.
  • This approach incurred noticeable CPU overhead when processing large numbers of blocks.

Optimizations

1. Unified Key Management

  • Keys are now managed at the request ID level.
  • KV cache blocks belonging to different layers but the same request share a single key.
  • This significantly reduces the number of keys and metadata management overhead.

2. One-Time Address Resolution

  • Key-to-address mapping is performed only once during initialization.
  • Subsequent accesses locate layer-specific blocks using a base address plus a layer offset.
  • This eliminates repeated Meta Server lookups during runtime.

3. New Address-Based Memcache Interface

  • Introduced a new batch_copy API in Memcache.
  • Memory can be accessed directly through physical addresses without key resolution.
  • This reduces access latency and improves batch transfer efficiency.

4. Accelerated HBM Address Computation

  • Replaced Python list-based address computation with NumPy vectorized operations.
  • This reduces CPU overhead and improves address generation efficiency.

5. CPU Affinity Optimization

  • Applied CPU affinity binding to Memcache worker threads.
  • This minimizes thread migration, reduces cache misses, and improves scheduling efficiency.

6. Controlled Overlap Between Data Transfer and Attention

Computation

  • Limited the degree of concurrency between KV cache transfers and Attention computation.
  • This reduces resource contention and minimizes interference with the inference execution path.

Results

The optimized design delivers the following benefits:

  • Reduced metadata lookup overhead.
  • Lower access latency through address-based memory operations.
  • Improved HBM address computation efficiency.
  • Reduced CPU overhead through vectorized computation and CPU affinity optimization.
  • Lower runtime contention between KV cache transfers and model execution.
  • Improved overall Layerwise KV Cache Pool performance and scalability.

DeepSeek V3.2 TP16 hit rate 90%

| kv cache pool | Input tokens | Output tokens | Concurrency | Average TTFT | |—-|—-|—-|—-|—-| | no-layerwise | 64k | 1 | 36.9 | 312519.2 ms | | layerwise | 64k | 1 | 36.9 | 191323.1 ms | | no-layerwise | 32k | 1 | 37.1 | 149498.4 ms | | layerwise | 32k | 1 | 36.8 | 64203.3 ms | | HBM hit | 32k | 1 | 37.1 | 64276.3 ms |

What this PR does / why we need it?

Does this PR introduce any user-facing change?

How was this patch tested?


Signed-off-by: F.Liu 1661888967@qq.com Co-authored-by: luokui183 luokui@huawei.com Co-authored-by: 520xie 1023005685@qq.com Co-authored-by: wangxiaochao6 wangxiaochao6@hisilicon.com Co-authored-by: zhangsicheng5 zhangsicheng5@huawei.com Co-authored-by: tyy0829 1455207791@qq.com Co-authored-by: Pz1116 zpbzpb123123@gmail.com Co-authored-by: DreamerLeader 2270923832@qq.com

1个月前3703次提交

vllm-ascend

vLLM Ascend Plugin

| 关于昇腾 | 官方文档 | #sig-ascend | 用户论坛 | 社区例会 |

English | 中文


最新消息 🔥

  • [2026/05] 我们发布了新的正式版本 v0.18.0! 请按照官方指南开始在Ascend上部署vLLM Ascend Plugin。
  • [2026/02] 我们发布了新的正式版本 v0.13.0! 请按照官方指南开始在Ascend上部署vLLM Ascend Plugin。
更多内容

总览

vLLM 昇腾插件 (vllm-ascend) 是一个由社区维护的让vLLM在Ascend NPU无缝运行的后端插件。

此插件是 vLLM 社区中支持昇腾后端的推荐方式。它遵循[RFC]: Hardware pluggable所述原则:通过解耦的方式提供了vLLM对Ascend NPU的支持。

使用 vLLM 昇腾插件,可以让类Transformer、混合专家(MOE)、嵌入、多模态等流行的大语言模型在 Ascend NPU 上无缝运行。

支持的模型详细信息,请参考模型支持列表

准备

  • 硬件:Atlas 800I A2 Inference系列、Atlas A2 Training系列、Atlas 800I A3 Inference系列、Atlas A3 Training系列、Atlas 300I Duo(实验性支持)
  • 操作系统:Linux
  • 软件:
    • Python >= 3.10, < 3.12
    • CANN == 9.0.0 (Ascend HDK 版本详见 版本说明)
    • PyTorch == 2.10.0, torch-npu == 2.10.0
    • vLLM (与vllm-ascend版本一致)

开始使用

推荐您使用以下版本快速开始使用:

Version Release type Doc
v0.21.0rc1 最新RC版本 请查看快速开始安装指南了解更多
v0.18.0 最新正式/稳定版本 请查看快速开始安装指南了解更多

分支策略

vllm-ascend有主干分支和开发分支。

  • main: 主干分支,与vLLM的主干分支对应,并通过昇腾CI持续进行质量看护。
  • releases/vX.Y.Z: 开发分支,随vLLM部分新版本发布而创建,比如releases/v0.13.0是vllm-ascend针对vLLM v0.13.0 版本的开发分支。

下面是维护中的分支:

分支 状态 备注
main Maintained 基于vLLM main分支和vLLM最新版本(v0.22.1)CI看护
v0.7.1-dev Unmaintained 不再维护
v0.7.3-dev Unmaintained 只允许Bug修复,不会再发布新版本
v0.9.1-dev Unmaintained 只允许Bug修复,不会再发布新版本
v0.11.0-dev Unmaintained 只允许Bug修复,不会再发布新版本
releases/v0.13.0 Maintained 基于vLLM v0.13.0版本CI看护
releases/v0.18.0 Maintained 基于vLLM v0.18.0版本CI看护
releases/v0.20.2rc Maintained 基于vLLM v0.20.2版本CI看护
rfc/feature-name Maintained 为协作创建的特性分支

请参阅版本策略了解更多详细信息。

贡献

请参考CONTRIBUTING文档了解更多关于开发环境搭建、功能测试以及 PR 提交规范的信息。

我们欢迎并重视任何形式的贡献与合作:

  • 请通过Issue来告知我们您遇到的任何Bug。
  • 请通过用户论坛来交流使用问题和寻求帮助。

社区例会

许可证

Apache 许可证 2.0,如 LICENSE 文件中所示。

邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802047560号