Skip to main content

LWS

还没翻译译自英文(docs.vllm.ai)本页 19 段都还没译

LWS

LeaderWorkerSet (LWS) is a Kubernetes API that aims to address common deployment patterns of AI/ML inference workloads. A major use case is for multi-host/multi-node distributed inference.

vLLM can be deployed with LWS on Kubernetes for distributed model serving.

Prerequisites

  • At least two Kubernetes nodes, each with 8 GPUs, are required.
  • Install LWS by following the instructions found here.

Deploy and Serve

Deploy the following yaml file lws.yaml (we have examples that use multiprocessing or Ray):

lws.yaml

kubectl apply -f lws.yaml

Verify the status of the pods:

kubectl get pods

Should get an output similar to this:

NAME       READY   STATUS    RESTARTS   AGE
vllm-0     1/1     Running   0          2s
vllm-0-1   1/1     Running   0          2s

Verify that the distributed tensor-parallel inference works:

Multiprocessing (default)Ray

kubectl logs vllm-0 | grep -i "Model loading"
kubectl logs vllm-0-1 | grep -i "Model loading"

Should get something similar to this:

POD 0 (PP Rank 0)

(Worker_PP0_TP0 pid=601) INFO 04-28 08:16:58 [gpu_model_runner.py:4820] Model loading took 3.82 GiB memory and 157.996399 seconds

POD 1 (PP Rank 1)

(Worker_PP1_TP0 pid=396) INFO 04-28 08:17:09 [gpu_model_runner.py:4820] Model loading took 3.82 GiB memory and 168.878781 seconds

Access ClusterIP service

# Listen on port 8080 locally, forwarding to the targetPort of the service's port 8080 in a pod selected by the service
kubectl port-forward svc/vllm-leader 8080:8080

The output should be similar to the following:

Forwarding from 127.0.0.1:8080 -> 8080
Forwarding from [::1]:8080 -> 8080

Serve the model

Open another terminal and send a request

curl http://localhost:8080/v1/completions \
-H "Content-Type: application/json" \
-d '{
    "model": "meta-llama/Meta-Llama-3.1-405B-Instruct",
    "prompt": "San Francisco is a",
    "max_tokens": 7,
    "temperature": 0
}'

The output should be similar to the following

Output