LMCache-Ascend 部署指南#
概述#
LMCache-Ascend 是一个社区维护的插件,用于在昇腾 NPU 上运行 LMCache。
本文提供一份简明的部署指南。关于部署的更多详细信息,请参阅 LMCache-Ascend 文档。
快速开始#
克隆 LMCache-Ascend 仓库#
我们的仓库包含一个 kvcache 算子子模块以便于维护,因此我们建议克隆包含子模块的仓库。
cd /workspace
git clone --recurse-submodules https://github.com/LMCache/LMCache-Ascend.git
Docker#
cd /workspace/LMCache-Ascend
docker build -f docker/Dockerfile.a2.openEuler -t lmcache-ascend:v0.3.12-vllm-ascend-v0.11.0-openeuler .
构建完成后,使用以下命令运行
DEVICE_LIST="0,1,2,3,4,5,6,7"
docker run -it \
--privileged \
--cap-add=SYS_RESOURCE \
--cap-add=IPC_LOCK \
-p 8000:8000 \
-p 8001:8001 \
--name lmcache-ascend-dev \
-e ASCEND_VISIBLE_DEVICES=${DEVICE_LIST} \
-e ASCEND_RT_VISIBLE_DEVICES=${DEVICE_LIST} \
-e ASCEND_TOTAL_MEMORY_GB=32 \
-e VLLM_TARGET_DEVICE=npu \
-v /usr/local/Ascend/driver:/usr/local/Ascend/driver \
-v /etc/localtime:/etc/localtime \
-v /var/log/npu:/var/log/npu \
-v /dev/davinci_manager:/dev/davinci_manager \
-v /dev/devmm_svm:/dev/devmm_svm \
-v /etc/ascend_install.info:/etc/ascend_install.info \
-v /etc/hccn.conf:/etc/hccn.conf \
lmcache-ascend:v0.3.12-vllm-ascend-v0.11.0-openeuler \
/bin/bash
手动安装#
假设您的工作目录是 /workspace 且 vllm/vllm-ascend 已安装。
安装 LMCache 仓库
NO_CUDA_EXT=1 pip install lmcache==0.3.12
安装 LMCache-Ascend 仓库
cd /workspace/LMCache-Ascend python3 -m pip install -v --no-build-isolation -e .
使用方法#
我们通过 LMCacheAscendConnectorV1Dynamic 引入了一个动态 KVConnector,因此 LMCache-Ascend 连接器可以通过以下两种场景下的 kv 传输配置来使用。
在线服务#
python \
-m vllm.entrypoints.openai.api_server \
--port 8100 \
--model /data/models/Qwen/Qwen3-32B \
--trust-remote-code \
--disable-log-requests \
--block-size 128 \
--kv-transfer-config '{"kv_connector":"LMCacheAscendConnector","kv_role":"kv_both"}'
离线#
ktc = KVTransferConfig(
kv_connector="LMCacheAscendConnector",
kv_role="kv_both"
)