XC-LLM: A Specially Optimized LLM Inference Engine for ModelHub XC
Overview
The project is optimized based on the popular LLM inference project vLLM. The current version supports Ascend NPU (910B3 & 910B4).
One of the key features of this project is efficient memory coordination, enabling multiple vLLM instances share and dynamically hold Ascend NPU's physical memory. When an instance is idle, model parameters are offloaded to host memory. Upon a new inference request, the model parameters are quickly restored to the NPU’s memory (if not exist), without the need to initialize the engine and load the model from scratch. As a result, from the application’s perspective, multiple LLM inference engines can run on the NPU even when their total memory requirements exceed the physical memory limit. This technique is referred to as InfiniVRAM.
Installation
Build from Dockerfile
Clone this repository:
docker build -t vllm-ascend-multi-llm:latest -f ./Dockerfile .
Usage
Note
Some platforms may not allow multiple containers to share the same Ascend NPU. You may try to use privilegd container to bypass this restriction and mount all NPUs, and set the env ASCEND_RT_VISIBLE_DEVICES to specify the target device to use.
- To share NPU, processes coordinate via shm, so you need to set all containers with
ipc=host. - Start a daemon process in a standalone container, by running
vllm_vnpu_daemoninstalled inside the image. - Start LLM services with this image, following the official usage instructions.
- Due to the limited stream resource of Ascend NPU, you may need to restrict graph capture sizes or disable ACLgraph by setting
--enforce-eager, especially when launching multiple LLMs. Refer to the link.
Limitations
- This project only support share a single NPU currently. This is also limited by the fact that HCCL cannot be shared.
- The prefix cache will be reset when the LLM is restored, since we just simply discard the KV cache when the LLM is offloaded.