Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions doc/en/lmcacheV1-deployment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Mooncake Store x LMCache for vLLM V1

The vLLM v1 version has been released with support for PD separation. The detailed design document can be found here: https://docs.google.com/document/d/1uPGdbEXksKXeN4Q9nUm9hzotqEjQhYmnpAhidLuAsjk. LMCache immediately implemented the corresponding connector to support storage, transmission, and loading of KVCache, enabling collaborative operation with PD nodes. Mooncake, as LMCache's backend storage engine, has undergone extensive optimizations in usability, performance, and stability. This document explains how to deploy a complete vLLM V1 PD separation instance using LMCache + Mooncake.

## Deployment

1. First, you need to prepare two GPU-equipped machines, which we will refer to as Machine A and Machine B. Install vLLM, LMCache, and Mooncake on both Machine A and Machine B. For specific installation instructions, please refer to the official documentation of each repository.

2. Start the Mooncake Master node on Machine A using the following command:
`cd Mooncake/build && ./mooncake-store/src/mooncake_master -v=1 -port=50052 -max_threads 64 -metrics_port 9004`
Copy link

@zhenwei-intel zhenwei-intel May 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @XucSh,

Thanks for sharing this doc, I tried it, but encountered an error Failed to initialize/re-establish remote connection: Please install mooncake by following the instructions
I installed mooncake by pip3 install mooncake-transfer-engine

INFO 05-21 02:31:20 [factory.py:73] Creating v1 connector with name: LMCacheConnectorV1
WARNING 05-21 02:31:20 [base.py:61] Initializing KVConnectorBase_V1. This API is experimental and subject to change in the future as we iterate
 the design.
[2025-05-21 02:31:20,115] LMCache INFO: Loading LMCache config file /datadisk/zhenwei/pd_disagg/mooncake/prefill.yaml (utils.py:56:lmcache.inte
gration.vllm.utils)
[2025-05-21 02:31:20,115] LMCache INFO: LMCache Configuration: {'chunk_size': 256, 'local_cpu': False, 'max_local_cpu_size': '10 GB', 'local_di
sk': None, 'max_local_disk_size': '5 GB', 'remote_url': 'mooncakestore://localhost:50001/', 'remote_serde': 'naive', 'save_decode_cache': False
, 'enable_blending': False, 'blend_recompute_ratio': 0.15, 'blend_min_tokens': 256, 'enable_p2p': False, 'lookup_url': None, 'distributed_url':
 None, 'error_handling': False, 'enable_controller': False, 'lmcache_instance_id': 'lmcache_default_instance', 'enable_nixl': False, 'nixl_role
': None, 'nixl_receiver_host': None, 'nixl_receiver_port': None, 'nixl_buffer_size': None, 'nixl_buffer_device': None, 'nixl_enable_gc': False}
 (config.py:518:lmcache.experimental.config)
[2025-05-21 02:31:20,116] LMCache INFO: Creating LMCacheEngine instance vllm-instance (cache_engine.py:748:lmcache.experimental.cache_engine)
[2025-05-21 02:31:24,017] LMCache INFO: Creating LMCacheEngine with config: LMCacheEngineConfig(chunk_size=256, local_cpu=False, max_local_cpu_
size=10, local_disk=None, max_local_disk_size=5, remote_url='mooncakestore://localhost:50001/', remote_serde='naive', save_decode_cache=False,
enable_blending=False, blend_recompute_ratio=0.15, blend_min_tokens=256, blend_special_str=' # # ', enable_p2p=False, lookup_url=None, distribu
ted_url=None, error_handling=False, enable_controller=False, lmcache_instance_id='lmcache_default_instance', controller_url=None, lmcache_worke
r_port=None, enable_nixl=False, nixl_role=None, nixl_receiver_host=None, nixl_receiver_port=None, nixl_buffer_size=None, nixl_buffer_device=Non
e, nixl_enable_gc=False, audit_actual_remote_url=None) (cache_engine.py:74:lmcache.experimental.cache_engine)
[2025-05-21 02:31:24,036] LMCache WARNING: Failed to initialize/re-establish remote connection: Please install mooncake by following the instru
ctions at https://github.com/kvcache-ai/Mooncake/blob/main/doc/en/build.md to run vLLM with MooncakeConnector. (remote_backend.py:106:lmcache.e
xperimental.storage_backend.remote_backend)
[2025-05-21 02:31:24,037] LMCache INFO: Connected to remote storage at mooncakestore://localhost:50001/ (remote_backend.py:76:lmcache.experimen
tal.storage_backend.remote_backend)
[2025-05-21 02:31:24,037] LMCache INFO: Initializing usage context. (usage_context.py:249:lmcache.usage_context)
WARNING 05-21 02:31:35 [topk_topp_sampler.py:58] FlashInfer is not available. Falling back to the PyTorch-native implementation of top-p & top-
k sampling. For the best performance, please install FlashInfer.
INFO 05-21 02:31:35 [gpu_model_runner.py:1503] Starting to load model Qwen/Qwen3-0.6B...
INFO 05-21 02:31:35 [cuda.py:216] Using Flash Attention backend on V1 engine.
INFO 05-21 02:31:37 [weight_utils.py:291] Using model weights format ['*.safetensors']
INFO 05-21 02:31:38 [weight_utils.py:341] No model.safetensors.index.json found in remote.
Loading safetensors checkpoint shards:   0% Completed | 0/1 [00:00<?, ?it/s]



[2025-05-21 02:34:13,201] LMCache WARNING: Failed to initialize/re-establish remote connection: Please install mooncake by following the instru
ctions at https://github.com/kvcache-ai/Mooncake/blob/main/doc/en/build.md to run vLLM with MooncakeConnector. (remote_backend.py:106:lmcache.e
xperimental.storage_backend.remote_backend)
[2025-05-21 02:34:13,201] LMCache WARNING: Connection is None in contains, returning False (remote_backend.py:125:lmcache.experimental.storage_
backend.remote_backend)
[2025-05-21 02:34:13,201] LMCache INFO: Storing KV cache for 4 out of 4 tokens for request cmpl-a9817d5fa90244f9aa26d335c623d24e-0 (vllm_v1_ada
pter.py:638:lmcache.integration.vllm.vllm_v1_adapter)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,zhenwei,the error indicates that mooncake is not installed correctly, you can install it by hand.

git clone https://github.com/kvcache-ai/Mooncake.git && cd Mooncake && sh dependencies.sh && mkdir build && cd build && cmake .. -DUSE_ETCD=1 -DUSE_ETCD_LEGACY=1 && make install

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your reply, I will try.

BTW, does LMCache with mooncake backend not rely on the CUDA env and can it also run on other AI accelerators?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Now LMCache V1 only works with CUDA.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@XucSh hello, wanna check if DUSE_ETCD_LEGACY=1 is necessary, it's hard to compile when enable this on my env.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cicirori hi,this is not necessary. Regardless of how it's done, the key is to get the etcd service running. :)


3. Start etcd on Machine A with the command:
`etcd --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://localhost:2379`

4. Launch D endpoint on machine A
- Modify the vllm/examples/lmcache/disagg_prefill_lmcache_v1/disagg_vllm_launcher.sh file.
```diff
diff --git a/examples/lmcache/disagg_prefill_lmcache_v1/disagg_vllm_launcher.sh b/examples/lmcache/disagg_prefill_lmcache_v1/disagg_vllm_launcher.sh
index 831ef0bb5..a2ff0744c 100644
--- a/examples/lmcache/disagg_prefill_lmcache_v1/disagg_vllm_launcher.sh
+++ b/examples/lmcache/disagg_prefill_lmcache_v1/disagg_vllm_launcher.sh
@@ -24,6 +24,8 @@ if [[ $1 == "prefiller" ]]; then
LMCACHE_CONFIG_FILE=$prefill_config_file \
LMCACHE_USE_EXPERIMENTAL=True \
VLLM_ENABLE_V1_MULTIPROCESSING=1 \
+ VLLM_USE_MODELSCOPE=True \
+ MOONCAKE_CONFIG_PATH=./mooncake.json \
VLLM_WORKER_MULTIPROC_METHOD=spawn \
CUDA_VISIBLE_DEVICES=0 \
vllm serve $MODEL \
@@ -36,11 +38,13 @@ if [[ $1 == "prefiller" ]]; then

elif [[ $1 == "decoder" ]]; then
# Decoder listens on port 8200
- decode_config_file=$SCRIPT_DIR/configs/lmcache-decoder-config.yaml
+ decode_config_file=$SCRIPT_DIR/decode.yaml

UCX_TLS=cuda_ipc,cuda_copy,tcp \
LMCACHE_CONFIG_FILE=$decode_config_file \
LMCACHE_USE_EXPERIMENTAL=True \
+ VLLM_USE_MODELSCOPE=True \
+ MOONCAKE_CONFIG_PATH=./mooncake.json \
VLLM_ENABLE_V1_MULTIPROCESSING=1 \
VLLM_WORKER_MULTIPROC_METHOD=spawn \
CUDA_VISIBLE_DEVICES=1 \
```
- Add `decode.yaml` and 'mooncake.json' file
```yaml
chunk_size: 256
local_device: "cpu"
remote_url: "mooncakestore://{IP of Machine A}:50052/"
remote_serde: "naive"
pipelined_backend: False
local_cpu: False
max_local_cpu_size: 100
```
```json
{
"local_hostname": "{IP of Machine A}",
"metadata_server": "etcd://{IP of Machine A}:2379",
"protocol": "rdma",
"device_name": "erdma_0, erdma_1",
"global_segment_size": 3355443200,
"local_buffer_size": 1073741824,
"master_server_address": "{IP of Machine A}:50052"
}
```
- Launch D endpoint using command `bash disagg_vllm_launcher.sh decoder Qwen/Qwen2.5-7B-Instruct-GPTQ-Int4`

5. Launch P endpoint on machine B
- Modify the vllm/examples/lmcache/disagg_prefill_lmcache_v1/disagg_vllm_launcher.sh file.
```diff
diff --git a/examples/lmcache/disagg_prefill_lmcache_v1/disagg_vllm_launcher.sh b/examples/lmcache/disagg_prefill_lmcache_v1/disagg_vllm_launcher.sh
index 831ef0bb5..9e5a3f044 100644
--- a/examples/lmcache/disagg_prefill_lmcache_v1/disagg_vllm_launcher.sh
+++ b/examples/lmcache/disagg_prefill_lmcache_v1/disagg_vllm_launcher.sh
@@ -18,12 +18,14 @@ fi

if [[ $1 == "prefiller" ]]; then
# Prefiller listens on port 8100
- prefill_config_file=$SCRIPT_DIR/configs/lmcache-prefiller-config.yaml
+ prefill_config_file=$SCRIPT_DIR/prefill.yaml

UCX_TLS=cuda_ipc,cuda_copy,tcp \
LMCACHE_CONFIG_FILE=$prefill_config_file \
LMCACHE_USE_EXPERIMENTAL=True \
VLLM_ENABLE_V1_MULTIPROCESSING=1 \
+ VLLM_USE_MODELSCOPE=True \
+ MOONCAKE_CONFIG_PATH=./mooncake.json \
VLLM_WORKER_MULTIPROC_METHOD=spawn \
CUDA_VISIBLE_DEVICES=0 \
vllm serve $MODEL \
@@ -42,6 +44,8 @@ elif [[ $1 == "decoder" ]]; then
LMCACHE_CONFIG_FILE=$decode_config_file \
LMCACHE_USE_EXPERIMENTAL=True \
VLLM_ENABLE_V1_MULTIPROCESSING=1 \
+ VLLM_USE_MODELSCOPE=True \
+ MOONCAKE_CONFIG_PATH=./mooncake.json \
VLLM_WORKER_MULTIPROC_METHOD=spawn \
CUDA_VISIBLE_DEVICES=1 \
vllm serve $MODEL \
```

- Add `prefill.yaml` and `mooncake.json` file
```yaml
chunk_size: 256
local_device: "cpu"
remote_url: "mooncakestore://{IP of Machine A}:50052/"
remote_serde: "naive"
pipelined_backend: False
local_cpu: False
max_local_cpu_size: 100
```

```json
{
"local_hostname": "{IP of Machine B}",
"metadata_server": "etcd://{IP of Machine A}:2379",
"protocol": "rdma",
"device_name": "erdma_0, erdma_1",
"global_segment_size": 3355443200,
"local_buffer_size": 1073741824,
"master_server_address": "{IP of Machine A}:50052"
}
```

- Launch P endpoint using command `bash disagg_vllm_launcher.sh prefiller Qwen/Qwen2.5-7B-Instruct-GPTQ-Int4`

6. Launch the LoadBalance endpoint using command
```bash
python3 disagg_proxy_server.py --host localhost --port 9000 --prefiller-host IP_of_Machine_B --prefiller-port 8100 --decoder-host IP_of_Machine_B --decoder-port 8200
```

7. Now we can send the requests to LoadBalance to test PD separation.
Loading