llm-d Integration#
llm-d is an open-source, Kubernetes-native stack for distributed LLM inference. Its router selects a vLLM pod for each request. LMCache adds a KV cache layer behind those pods. Each vLLM pod stores KV cache in the LMCache server on its node. For a repeated prefix, the pod reads the KV cache from that server.
No change to llm-d is necessary. The integration uses the released llm-d router chart, router image and P/D sidecar.
Architecture#
The llm-d Router (the Endpoint Picker, EPP) gives a score to each model-server pod for each request and selects one pod. In standalone mode, an Envoy sidecar in the EPP pod receives the requests. A Gateway API provider is not necessary.
The InferencePool selects the model-server pods by label. It also gives the port that the router sends requests to.
The model servers are vLLM Deployments. LMCache connects here. Each pod uses the
lmcache/vllm-openaiimage. Each pod gives the LMCache connector config to vLLM with--kv-transfer-config.One LMCache server runs on each GPU node. All vLLM pods on that node use it.
client -> Envoy (8081) -> EPP selects a pod -> vLLM pod (8000)
|
| LMCacheMPConnector (CUDA IPC)
v
LMCache server on the same node
Tested versions#
The tests for this page used one GPU node and these versions:
Component |
Version |
|---|---|
llm-d router chart |
|
llm-d P/D sidecar |
|
Gateway API Inference Extension (InferencePool CRD) |
|
LMCache server and vLLM image |
|
Prerequisites#
A Kubernetes cluster with one GPU node or more, and the NVIDIA GPU Operator. Two GPUs on one node are necessary for P/D disaggregation. The test with two decode pods uses two GPUs. Only its last step needs the two pods on one node.
kubectland Helm 3.8 or later.A Hugging Face token, if the model is gated.
Qwen/Qwen3-0.6Bis not gated. Create the namespace shows how to give the token to the pods.
Prefix KV reuse#
Create the namespace#
The LMCache server, the router and the model servers use one namespace. A pod can read a ConfigMap only from its own namespace.
kubectl create namespace llm-d
For a gated model, put the Hugging Face token into a Secret in this namespace.
The command reads the token from the HF_TOKEN variable of your shell:
kubectl -n llm-d create secret generic llm-d-hf-token \
--from-literal=HF_TOKEN="$HF_TOKEN"
decode.yaml and pd_pods.yaml have an HF_TOKEN entry in comment
marks for each vLLM container. Remove the comment marks before you apply the
file. The tokenizer sidecar of the router chart reads the same Secret by
default. tokenizer_router_values.yaml sets env: [] to stop this. For a
gated model, remove that line.
Deploy the LMCache server#
lmcache_engine.yaml has three objects:
A DaemonSet that runs
lmcache serverwith--isolated-ipcon each GPU node.The
lmcache-engineService withinternalTrafficPolicy: Local. Each vLLM pod connects to the server on its own node, because CUDA IPC operates only on one node.The
lmcache-engine-connectionConfigMap. Itskv-transfer-config.jsonkey contains theLMCacheMPConnectorsettings. The two other keys are for P/D disaggregation.
# LMCache server for llm-d model servers, without the LMCache Operator.
# The operator creates the same three objects for an LMCacheEngine with
# isolated IPC: a DaemonSet, a node-local Service and the connection ConfigMap.
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: lmcache-engine
namespace: llm-d
labels:
app.kubernetes.io/name: lmcache
app.kubernetes.io/instance: lmcache-engine
spec:
selector:
matchLabels:
app.kubernetes.io/name: lmcache
app.kubernetes.io/instance: lmcache-engine
template:
metadata:
labels:
app.kubernetes.io/name: lmcache
app.kubernetes.io/instance: lmcache-engine
spec:
# The `nvidia` RuntimeClass gives this pod access to the GPUs of the node.
# A GPU Operator with CDI and NRI can have no `nvidia` RuntimeClass. On
# such a cluster, remove this line and request the management CDI device
# with a pod annotation. The key of the annotation contains the container
# name, here `lmcache`. Refer to "GPU Operator NRI/CDI" in
# docs/source/mp/deployment.rst:
# https://docs.lmcache.ai/mp/deployment.html#gpu-operator-nri-cdi
runtimeClassName: nvidia
nodeSelector:
nvidia.com/gpu.present: "true" # GPU nodes only
containers:
- name: lmcache
image: lmcache/vllm-openai:v0.5.6 # the same tag as the vLLM pods
command: ["/opt/venv/bin/lmcache", "server"]
args:
- --host=0.0.0.0
- --port=5555
- --http-port=8080
- --l1-size-gb=20
- --chunk-size=256
- --max-workers=1
- --hash-algorithm=blake3
- --isolated-ipc # KV over driver-level CUDA IPC; no hostIPC
- --eviction-policy=LRU
- --eviction-trigger-watermark=0.80
- --eviction-ratio=0.20
- --prometheus-port=9090
env:
# The server sees every GPU of the node and requests none.
- name: NVIDIA_VISIBLE_DEVICES
value: "all"
- name: NVIDIA_DRIVER_CAPABILITIES
value: "all"
ports:
- name: server
containerPort: 5555
- name: http
containerPort: 8080
# Remove the comment marks if `nvidia-smi -L` fails in this pod.
# securityContext:
# privileged: true
startupProbe:
tcpSocket:
port: 5555
periodSeconds: 10
failureThreshold: 30
resources:
requests:
cpu: "2"
memory: 25Gi # L1 size + 5 Gi
limits:
memory: 38Gi
---
apiVersion: v1
kind: Service
metadata:
name: lmcache-engine
namespace: llm-d
spec:
selector:
app.kubernetes.io/name: lmcache
app.kubernetes.io/instance: lmcache-engine
internalTrafficPolicy: Local # each vLLM pod connects to the server on its own node
ports:
- name: server
port: 5555
- name: http
port: 8080
---
apiVersion: v1
kind: ConfigMap
metadata:
name: lmcache-engine-connection
namespace: llm-d
data:
kv-transfer-config.json: |
{"kv_connector":"LMCacheMPConnector","kv_connector_module_path":"lmcache.integration.vllm.lmcache_mp_connector","kv_role":"kv_both","kv_connector_extra_config":{"lmcache.mp.host":"lmcache-engine.llm-d.svc.cluster.local","lmcache.mp.port":"5555","lmcache.mp.isolated_ipc":true}}
# The two keys below are for P/D disaggregation only.
kv-transfer-config-prefiller.json: |
{"kv_connector":"MultiConnector","kv_role":"kv_producer","kv_connector_extra_config":{"connectors":[{"kv_connector":"NixlConnector","kv_role":"kv_producer","kv_load_failure_policy":"fail"},{"kv_connector":"LMCacheMPConnector","kv_connector_module_path":"lmcache.integration.vllm.lmcache_mp_connector","kv_role":"kv_both","kv_connector_extra_config":{"lmcache.mp.host":"lmcache-engine.llm-d.svc.cluster.local","lmcache.mp.port":"5555","lmcache.mp.isolated_ipc":true}}]}}
kv-transfer-config-decoder.json: |
{"kv_connector":"MultiConnector","kv_role":"kv_consumer","kv_connector_extra_config":{"connectors":[{"kv_connector":"NixlConnector","kv_role":"kv_consumer","kv_load_failure_policy":"fail"},{"kv_connector":"LMCacheMPConnector","kv_connector_module_path":"lmcache.integration.vllm.lmcache_mp_connector","kv_role":"kv_both","kv_connector_extra_config":{"lmcache.mp.host":"lmcache-engine.llm-d.svc.cluster.local","lmcache.mp.port":"5555","lmcache.mp.isolated_ipc":true}}]}}
Apply the manifest from the root of the LMCache repository. Then wait for the server:
kubectl apply -f examples/llm_d_integration/kubernetes/lmcache_engine.yaml
kubectl -n llm-d rollout status ds/lmcache-engine
kubectl -n llm-d logs ds/lmcache-engine | grep "cache server is running"
# LMCache zmq cache server is running on 0.0.0.0:5555
Make sure that each server pod sees the GPUs of its node. The server opens the KV cache of vLLM through CUDA IPC. Thus it must see every GPU. It requests no GPU:
for p in $(kubectl -n llm-d get pod \
-l app.kubernetes.io/instance=lmcache-engine -o name); do
kubectl -n llm-d exec "$p" -- nvidia-smi -L | wc -l
done
Each pod prints the GPU count of its node. If a pod prints an NVML error,
remove the comment marks from securityContext.privileged in the manifest.
Then apply the manifest again.
备注
The lmcache.mp.isolated_ipc value in the ConfigMap must agree with the
--isolated-ipc flag of the server. Refer to the Isolated IPC section
of the 部署指南 guide. For a cluster without the nvidia
RuntimeClass, refer to GPU Operator NRI/CDI in the same guide.
Install the InferencePool CRD#
The llm-d Router creates an InferencePool. The CRD is in the Gateway API
Inference Extension release that llm-d v1.0.0 uses:
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api-inference-extension/releases/download/v1.6.2/v1-manifests.yaml
kubectl wait --for=condition=Established \
crd/inferencepools.inference.networking.k8s.io --timeout=60s
Install the llm-d Router#
The router selects the model-server pods by label. It sends requests to the vLLM port:
# Values for the llm-d-router-standalone chart (v1.0.0).
router:
modelServers:
matchLabels:
llm-d.ai/guide: lmcache # the label of the decode pods in decode.yaml
targetPorts:
- number: 8000 # the vLLM port
epp:
replicas: 1
helm install llm-d oci://ghcr.io/llm-d/charts/llm-d-router-standalone \
--version v1.0.0 --namespace llm-d \
-f examples/llm_d_integration/kubernetes/router_values.yaml --wait
These values use the default plugins of the chart. The prefix-cache-scorer
is one of them (refer to Prefix-aware routing with two or more pods).
The chart gives the release name to its objects. llm-d-epp is the router
Deployment and Service. llm-d is the InferencePool. Port 8081 of the
Service is the Envoy listener for clients.
备注
The chart requests 8 CPUs for the EPP container and 4 CPUs for the Envoy
container. It requests 8 Gi of memory for each container. For a small
cluster, set router.epp.resources and router.proxy.resources to
lower values.
With router.inferencePool.create: false, the chart creates no
InferencePool. The EPP then selects the pods by label, and the CRD is not
necessary.
Deploy the decode model server#
The llm-d guides deploy their model servers from kustomize overlays.
decode.yaml has the same structure as their decode base. It adds the
LMCache settings:
# vLLM decode model server for the llm-d Router. It connects to the LMCache
# server of lmcache_engine.yaml. The structure is the same as the llm-d
# `decode` base: container `modelserver`, port 8000, the `llm-d.ai/role` label.
apiVersion: apps/v1
kind: Deployment
metadata:
name: decode
namespace: llm-d
labels:
llm-d.ai/role: decode
llm-d.ai/guide: lmcache
spec:
replicas: 1
selector:
matchLabels:
llm-d.ai/role: decode
llm-d.ai/guide: lmcache
template:
metadata:
labels:
llm-d.ai/role: decode
llm-d.ai/guide: lmcache # the router selects this label
spec:
terminationGracePeriodSeconds: 120 # vLLM unregisters its KV cache before it stops
containers:
- name: modelserver
image: lmcache/vllm-openai:v0.5.6
command: ["vllm", "serve"]
args:
- Qwen/Qwen3-0.6B
- --port=8000
- --no-enable-prefix-caching # a repeated prompt goes to LMCache; remove in production
- --kv-transfer-config
- $(LMCACHE_KV_CONFIG)
env:
- name: PYTHONHASHSEED
value: "0"
- name: LMCACHE_KV_CONFIG
valueFrom:
configMapKeyRef:
name: lmcache-engine-connection
key: kv-transfer-config.json
# For a gated model, create the Secret `llm-d-hf-token` with the key
# `HF_TOKEN`. Then remove the comment marks from the five lines below.
# - name: HF_TOKEN
# valueFrom:
# secretKeyRef:
# name: llm-d-hf-token
# key: HF_TOKEN
ports:
- name: modelserver
containerPort: 8000
readinessProbe:
httpGet:
path: /health
port: modelserver
initialDelaySeconds: 60
periodSeconds: 15
failureThreshold: 60
resources:
requests:
cpu: "4"
memory: 16Gi
nvidia.com/gpu: "1"
limits:
memory: 32Gi
nvidia.com/gpu: "1"
volumeMounts:
- name: shm
mountPath: /dev/shm
volumes:
- name: shm
emptyDir:
medium: Memory
sizeLimit: 8Gi
kubectl apply -f examples/llm_d_integration/kubernetes/decode.yaml
kubectl -n llm-d rollout status deploy/decode --timeout=15m
Setting |
Reason |
|---|---|
|
The llm-d overlays use |
|
The token hashes must be the same in all processes. |
|
Kubernetes reads the connector JSON from the ConfigMap when the pod starts. It puts the JSON into the vLLM arguments. |
|
|
|
With the prefix cache of vLLM on, vLLM serves a repeated prompt from its own cache. The request then does not go to LMCache. Keep the flag for the test. Remove it in production to use the two cache layers. |
Memory-backed |
The 64 Mi default of the container is too small for the vLLM workers. |
Do a test#
Send requests to the router, not to the model pod:
kubectl -n llm-d port-forward svc/llm-d-epp 8081:8081 &
Send one long prompt two times. The prompt must be longer than one LMCache chunk (256 tokens by default):
PROMPT="$(printf 'Tell me a long story about a brave knight who lived in a faraway kingdom. %.0s' $(seq 1 90))"
for i in 1 2; do
curl -s localhost:8081/v1/completions -H 'Content-Type: application/json' \
-d "{\"model\":\"Qwen/Qwen3-0.6B\",\"prompt\":\"$PROMPT\",\"max_tokens\":16}" \
| jq -r '.choices[0].text'
done
The LMCache server log shows the store operation of the first request. It also shows the retrieve operation of the second request:
kubectl -n llm-d logs -l app.kubernetes.io/instance=lmcache-engine --tail=200 \
| grep -E "Stored|Retrieved"
# Stored 1280 tokens in 0.003 seconds
# Retrieved 1280 tokens in 0.002 seconds
A Registered KV cache for GPU ID line in the same log shows that the
CUDA IPC handshake with vLLM is complete.
Prefix-aware routing with two or more pods#
The default plugins of the chart include the prefix-cache-scorer. This
scorer compares blocks of tokens. It gives a high score to the pod that got
the same prefix before. The EPP makes two default producers for the scorer: a
token-producer and the approx-prefix-cache-producer. Without a
tokenizer, the token-producer estimates the tokens from the bytes of the
request. Thus router_values.yaml gives prefix-aware routing. A change to
the router is not necessary for a second decode pod:
kubectl -n llm-d scale deploy/decode --replicas=2
kubectl -n llm-d rollout status deploy/decode --timeout=15m
Each decode pod requests one GPU.
Send the prompt of Do a test 8 more times through the router. The port-forward of that test must be in operation. Then read the request counter of each decode pod:
PROMPT="$(printf 'Tell me a long story about a brave knight who lived in a faraway kingdom. %.0s' $(seq 1 90))"
for i in $(seq 1 8); do
curl -s -o /dev/null localhost:8081/v1/completions -H 'Content-Type: application/json' \
-d "{\"model\":\"Qwen/Qwen3-0.6B\",\"prompt\":\"$PROMPT\",\"max_tokens\":16}"
done
OTHER=""
for p in $(kubectl -n llm-d get pod -l llm-d.ai/guide=lmcache \
-o jsonpath='{.items[*].metadata.name}'); do
n=$(kubectl get --raw /api/v1/namespaces/llm-d/pods/$p:8000/proxy/metrics \
| awk '/^vllm:request_success_total/ {s+=$2} END {print s+0}')
echo "$p: $n requests"
if [ "$n" = "0" ]; then OTHER=$p; fi
done
# decode-7b58cc687c-5f96g: 10 requests (2 from "Do a test" and 8 new requests)
# decode-7b58cc687c-z227l: 0 requests
The first pod got this prompt before. Thus the scorer gives it the high score, and the router sends all 8 requests to it. The new pod gets no request.
The scorer is approximate. It records the pod that received each prefix. It
has no data about the KV cache in the LMCache server. But two decode pods on
one node use one LMCache server. Thus the new pod can read the prefix that the
first pod stored. To see this, send the same prompt directly to the new pod.
This step needs the two pods on one node, and kubectl scale does not make
sure of that. The NODE column of this command shows the node of each pod:
kubectl -n llm-d get pod -l llm-d.ai/guide=lmcache -o wide
Start a port-forward to the new pod:
kubectl -n llm-d port-forward pod/$OTHER 8001:8000 &
Send the prompt to the new pod. Then read the source of its prompt tokens:
curl -s -o /dev/null localhost:8001/v1/completions -H 'Content-Type: application/json' \
-d "{\"model\":\"Qwen/Qwen3-0.6B\",\"prompt\":\"$PROMPT\",\"max_tokens\":16}"
# The source of the prompt tokens of the new pod (vLLM counters).
kubectl get --raw /api/v1/namespaces/llm-d/pods/$OTHER:8000/proxy/metrics \
| grep '^vllm:prompt_tokens_by_source_total'
# vllm:prompt_tokens_by_source_total{...,source="local_compute"} 251.0
# vllm:prompt_tokens_by_source_total{...,source="local_cache_hit"} 0.0
# vllm:prompt_tokens_by_source_total{...,source="external_kv_transfer"} 1280.0
The new pod read 1280 prompt tokens from the LMCache server
(external_kv_transfer). It computed only the last 251 tokens. The server
log shows one more Retrieved 1280 tokens line.
Real token IDs (optional)#
The estimate is not the tokenization of the model. It is sufficient for the
default approx-prefix-cache-producer, which compares a request only with
the requests that the router sent before. The tokenizer sidecar adds one
container to the router pod (1 CPU and 2 Gi of memory in the example values)
and one render call for each request. Use it when a plugin must have the
tokens of the model. One example is the precise-prefix-cache-producer,
which compares the tokens of a request with the KV cache events of vLLM. A
second example is a plugin with a threshold in tokens, such as the
prefix-based-pd-decider. With the estimate, such a plugin gets an
approximate token count.
To give real token IDs to the scorer, add the tokenizer sidecar of the chart
and connect the token-producer plugin to it.
tokenizer_router_values.yaml has only these two additions. Give it to Helm
after router_values.yaml. It uses the model name of the decode pods:
# Additions to router_values.yaml for the tokenizer sidecar of the
# llm-d-router-standalone chart (v1.0.0). These values are optional. Give this
# file to Helm after router_values.yaml:
# -f router_values.yaml -f tokenizer_router_values.yaml
# Helm rejects this file when it is the only values file, because the chart
# needs the `modelServers` values of router_values.yaml.
# With router_values.yaml only, the EPP estimates the tokens from the bytes of
# the request. With these additions, the `token-producer` plugin gets real
# token IDs from the tokenizer sidecar.
router:
tokenizer:
enabled: true
flavor: python
modelName: Qwen/Qwen3-0.6B # the model of the decode pods
port: 8000 # loopback port in the EPP pod
# `env: []` gives the sidecar no token. For a gated model, remove the line
# below. The chart then reads HF_TOKEN from the Secret `llm-d-hf-token`.
env: []
resources:
requests: { cpu: "1", memory: 2Gi }
limits: { memory: 4Gi }
epp:
pluginsConfigFile: lmcache-plugins.yaml
pluginsConfig: # the default plugins of the chart and the token-producer
apiVersion: llm-d.ai/v1
kind: EndpointPickerConfig
plugins:
- type: token-producer
parameters:
modelName: Qwen/Qwen3-0.6B
vllm: { url: http://localhost:8000, timeout: 10s }
- type: queue-scorer
- type: kv-cache-utilization-scorer
- type: prefix-cache-scorer
- type: metrics-data-source
parameters: { scheme: http, path: /metrics, insecureSkipVerify: true }
- type: core-metrics-extractor
schedulingProfiles:
- name: default
plugins:
- { pluginRef: queue-scorer, weight: 2 }
- { pluginRef: kv-cache-utilization-scorer, weight: 2 }
- { pluginRef: prefix-cache-scorer, weight: 3 }
helm upgrade --install llm-d oci://ghcr.io/llm-d/charts/llm-d-router-standalone \
--version v1.0.0 --namespace llm-d \
-f examples/llm_d_integration/kubernetes/router_values.yaml \
-f examples/llm_d_integration/kubernetes/tokenizer_router_values.yaml --wait
The upgrade makes a new router pod. This stops the port-forward of Do a test. Start that port-forward again. Then send the 8 requests and read the counters again. One pod gets all 8 requests, as before.
P/D disaggregation#
The llm-d Router can send the prefill and the decode of each request to different pods. One LMCache server is the KV cache layer of the two pods:
The router selects a decode pod and a prefill pod for each request. It selects them by the
llm-d.ai/rolelabel.A routing sidecar in the decode pod sends the prompt to the prefill pod with
max_tokens=1.The prefill pod stores the prefix in LMCache. For a repeated prompt, it reads the prefix from LMCache.
The sidecar sends the request to the vLLM of the decode pod. That vLLM gets the KV cache from the prefill pod through NIXL. Then it generates the output.
Refer to 分离式预填充 for the connector design. This section uses the namespace and the LMCache server of Prefix KV reuse. Each vLLM pod requests one GPU.
Remove the first router and its decode pod#
Each release of the router chart makes a ConfigMap with the name envoy.
Thus one namespace can contain only one release. The decode pods of the
procedures before this one also use GPUs. If you did those procedures, remove
their router and their decode pods. Keep the LMCache server:
helm -n llm-d uninstall llm-d
kubectl -n llm-d delete -f examples/llm_d_integration/kubernetes/decode.yaml
Install the router with the P/D plugins#
These values agree with the llm-d v1.0.0 pd-disaggregation guide. This
release creates no InferencePool. Its EPP selects the pods by label.
# Values for the llm-d-router-standalone chart (v1.0.0), P/D disaggregation.
# The plugins agree with the llm-d v1.0.0 `pd-disaggregation` guide. The
# router disaggregates every request. The `prefill` and `decode` profiles
# select pods by the `llm-d.ai/role` label.
router:
inferencePool:
create: false # the EPP selects the pods by the label below
modelServers:
matchLabels:
llm-d.ai/guide: lmcache-pd
targetPorts:
- number: 8000 # the prefill vLLM, and the routing sidecar of the decode pod
epp:
replicas: 1
pluginsConfigFile: pd-plugins.yaml
pluginsConfig:
apiVersion: llm-d.ai/v1
kind: EndpointPickerConfig
plugins:
- type: always-disagg-pd-decider
- type: disagg-profile-handler
parameters:
deciders:
prefill: always-disagg-pd-decider
- type: prefill-filter
- type: decode-filter
- type: queue-scorer
- type: max-score-picker
- type: metrics-data-source
parameters:
scheme: http
path: /metrics
insecureSkipVerify: true
- type: core-metrics-extractor
schedulingProfiles:
- name: prefill
plugins:
- pluginRef: prefill-filter
- pluginRef: queue-scorer
- pluginRef: max-score-picker
- name: decode
plugins:
- pluginRef: decode-filter
- pluginRef: queue-scorer
- pluginRef: max-score-picker
helm upgrade --install llm-d-pd oci://ghcr.io/llm-d/charts/llm-d-router-standalone \
--version v1.0.0 --namespace llm-d \
-f examples/llm_d_integration/kubernetes/pd_router_values.yaml --wait
Deploy the prefill and decode pods#
Each pod reads the config of its role from the connection ConfigMap. Each
config is a MultiConnector with NixlConnector first and
LMCacheMPConnector second. The decode pod also runs the llm-d routing
sidecar. The sidecar listens on port 8000 and sends requests to vLLM on port
8200.
# Prefill and decode model servers for llm-d P/D disaggregation. Each pod
# reads the connector config of its role from the ConfigMap of
# lmcache_engine.yaml.
apiVersion: apps/v1
kind: Deployment
metadata:
name: prefill
namespace: llm-d
labels:
llm-d.ai/role: prefill
llm-d.ai/guide: lmcache-pd
spec:
replicas: 1
selector:
matchLabels:
llm-d.ai/role: prefill
llm-d.ai/guide: lmcache-pd
template:
metadata:
labels:
llm-d.ai/role: prefill
llm-d.ai/guide: lmcache-pd
spec:
terminationGracePeriodSeconds: 120
containers:
- name: modelserver
image: lmcache/vllm-openai:v0.5.6
command: ["vllm", "serve"]
args:
- Qwen/Qwen3-0.6B
- --port=8000
- --no-enable-prefix-caching # a repeated prompt goes to LMCache
- --disable-hybrid-kv-cache-manager
- --kv-transfer-config
- $(LMCACHE_KV_CONFIG)
env:
- name: PYTHONHASHSEED
value: "0"
- name: LMCACHE_KV_CONFIG
valueFrom:
configMapKeyRef:
name: lmcache-engine-connection
key: kv-transfer-config-prefiller.json
- name: VLLM_NIXL_SIDE_CHANNEL_HOST
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: VLLM_HTTP_TIMEOUT_KEEP_ALIVE
value: "120"
# For a gated model, create the Secret `llm-d-hf-token` with the key
# `HF_TOKEN`. Then remove the comment marks from the five lines below.
# - name: HF_TOKEN
# valueFrom:
# secretKeyRef:
# name: llm-d-hf-token
# key: HF_TOKEN
ports:
- name: modelserver
containerPort: 8000
- name: nixl
containerPort: 5600
readinessProbe:
httpGet:
path: /health
port: 8000
initialDelaySeconds: 60
periodSeconds: 15
failureThreshold: 60
resources:
requests:
cpu: "4"
memory: 16Gi
nvidia.com/gpu: "1"
limits:
memory: 32Gi
nvidia.com/gpu: "1"
volumeMounts:
- name: shm
mountPath: /dev/shm
volumes:
- name: shm
emptyDir:
medium: Memory
sizeLimit: 8Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: decode-pd
namespace: llm-d
labels:
llm-d.ai/role: decode
llm-d.ai/guide: lmcache-pd
spec:
replicas: 1
selector:
matchLabels:
llm-d.ai/role: decode
llm-d.ai/guide: lmcache-pd
template:
metadata:
labels:
llm-d.ai/role: decode
llm-d.ai/guide: lmcache-pd
spec:
terminationGracePeriodSeconds: 120
initContainers:
- name: routing-proxy # native sidecar: runs for the life of the pod
image: ghcr.io/llm-d/llm-d-router-disagg-sidecar:v1.0.0
restartPolicy: Always
args:
- --port=8000
- --model-server-port=8200
- --kv-connector=nixlv2
- --secure-serving=false
ports:
- name: sidecar
containerPort: 8000
containers:
- name: modelserver
image: lmcache/vllm-openai:v0.5.6
command: ["vllm", "serve"]
args:
- Qwen/Qwen3-0.6B
- --port=8200
- --enable-prompt-tokens-details # the response shows cached_tokens
- --disable-hybrid-kv-cache-manager
- --kv-transfer-config
- $(LMCACHE_KV_CONFIG)
env:
- name: PYTHONHASHSEED
value: "0"
- name: LMCACHE_KV_CONFIG
valueFrom:
configMapKeyRef:
name: lmcache-engine-connection
key: kv-transfer-config-decoder.json
- name: VLLM_NIXL_SIDE_CHANNEL_HOST
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: VLLM_HTTP_TIMEOUT_KEEP_ALIVE
value: "120"
# For a gated model, create the Secret `llm-d-hf-token` with the key
# `HF_TOKEN`. Then remove the comment marks from the five lines below.
# - name: HF_TOKEN
# valueFrom:
# secretKeyRef:
# name: llm-d-hf-token
# key: HF_TOKEN
ports:
- name: vllm
containerPort: 8200
- name: nixl
containerPort: 5600
readinessProbe:
httpGet:
path: /health
port: 8200
initialDelaySeconds: 60
periodSeconds: 15
failureThreshold: 60
resources:
requests:
cpu: "4"
memory: 16Gi
nvidia.com/gpu: "1"
limits:
memory: 32Gi
nvidia.com/gpu: "1"
volumeMounts:
- name: shm
mountPath: /dev/shm
volumes:
- name: shm
emptyDir:
medium: Memory
sizeLimit: 8Gi
kubectl apply -f examples/llm_d_integration/kubernetes/pd_pods.yaml
kubectl -n llm-d rollout status deploy/prefill --timeout=20m
kubectl -n llm-d rollout status deploy/decode-pd --timeout=20m
Setting |
Reason |
|---|---|
|
It is necessary for |
|
The NIXL side channel must listen on the pod IP, not on localhost. |
|
A repeated prompt goes to LMCache. Thus the server log shows the retrieve operation. Remove the flag in production to use the two cache layers. |
|
The sidecar keeps idle connections for 90 s. A shorter keep-alive time of vLLM causes connection resets. |
|
The response then shows |
|
The operator gives this role to the two pods. In this procedure, the
prefill pod stores the prompt, and the decode pod gets its KV cache
through NIXL. The connector stores only the chunks that are not in the
server. Thus the decode pod stores no chunk. With the
|
Do a P/D test#
Send one long prompt two times through the P/D router:
kubectl -n llm-d port-forward svc/llm-d-pd-epp 8082:8081 &
PROMPT="$(printf 'Tell me a long story about a brave knight who lived in a faraway kingdom. %.0s' $(seq 1 90))"
for i in 1 2; do
curl -s localhost:8082/v1/completions -H 'Content-Type: application/json' \
-d "{\"model\":\"Qwen/Qwen3-0.6B\",\"prompt\":\"$PROMPT\",\"max_tokens\":16}" \
| jq '.usage.prompt_tokens_details.cached_tokens'
done
# 0 first request
# 1280 second request (the number changes with the prompt length)
Then examine each part of the path:
# The decode pod got the KV cache through NIXL.
kubectl -n llm-d logs deploy/decode-pd -c modelserver \
| grep "NIXL compatibility check passed"
# The prefill pod stored the prefix. Then it read the prefix for the second request.
kubectl -n llm-d logs -l app.kubernetes.io/instance=lmcache-engine --tail=200 \
| grep -E "Stored|Retrieved"
# Stored 1280 tokens in 0.004 seconds
# Retrieved 1280 tokens in 0.001 seconds
# Each pod served the two requests (vLLM request counters).
for r in prefill:8000 decode:8200; do
p=$(kubectl -n llm-d get pod \
-l llm-d.ai/guide=lmcache-pd,llm-d.ai/role=${r%%:*} \
-o jsonpath='{.items[0].metadata.name}')
echo "${r%%:*}: $(kubectl get --raw \
/api/v1/namespaces/llm-d/pods/$p:${r##*:}/proxy/metrics \
| awk '/^vllm:request_success_total/ {s+=$2} END {print s}') requests"
done
# prefill: 2 requests
# decode: 2 requests
Use the LMCache Operator#
警告
The LMCache Kubernetes operator (operator/) is deprecated and no
longer maintained. It is expected to be removed from this repository in
2027Q1. Existing release artifacts (e.g. operator-v* install.yaml)
will not receive fixes or updates.
Prefer the manual manifests above for new deployments.
The LMCache Operator creates the same DaemonSet, Service
and ConfigMap from an LMCacheEngine resource. The ConfigMap name is
<engine-name>-connection. With spec.pd, the ConfigMap also has the
prefiller and decoder keys. Use that ConfigMap name in decode.yaml and
pd_pods.yaml.
The injection webhook of the operator does not change a container that sets
command. The llm-d model-server overlays set
command: ["vllm", "serve"]. Thus this page sets the connector config in
the Deployment. The tests of Prefix KV reuse and P/D disaggregation used
an LMCache server as in lmcache_engine.yaml.
Troubleshooting#
Symptom |
Cause |
Fix |
|---|---|---|
|
No model-server pod is Ready. |
Wait until the decode Deployment is Ready. |
503 continues, and the EPP log shows no endpoints. |
|
Use the same |
|
The InferencePool CRD is not installed. |
Install the CRD, or set |
|
A different release of the router chart is in the namespace. |
Uninstall that release (refer to Remove the first router and its decode pod). |
vLLM stops at |
The LMCache server pod does not see the GPUs of the node. |
Set |
The LMCache server log shows no |
The prompt is shorter than one chunk, or the log is from the server of a different node. |
Use a longer prompt. Read the log of the server on the node of the vLLM pod. |
Cleanup#
Delete the model servers and the router release that are in the namespace. Then delete the LMCache server and the namespace:
kubectl -n llm-d delete --ignore-not-found \
-f examples/llm_d_integration/kubernetes/pd_pods.yaml \
-f examples/llm_d_integration/kubernetes/decode.yaml
for r in llm-d-pd llm-d; do
if helm -n llm-d status "$r" >/dev/null 2>&1; then
helm -n llm-d uninstall "$r"
fi
done
kubectl delete -f examples/llm_d_integration/kubernetes/lmcache_engine.yaml
kubectl delete namespace llm-d