Skip to main content

Profiling vLLM

Run vLLM with the Zymtrace GPU profiler injected, on NVIDIA or AMD GPUs. The examples serve zai-org/GLM-4-9B-0414 (~19 GB of BF16 weights) with CUDA or HIP graphs enabled, which is vLLM's default. Check the prerequisites first.

Install the Zymtrace profiler first

Install the Zymtrace profiler on your cluster with Helm and enable the CUDA profiler (--set profiler.cudaProfiler.enabled=true). It extracts the CUDA profiler library to /var/lib/zymtrace/profiler on every GPU node. See Install with Helm.

The manifest mounts /var/lib/zymtrace/profiler from the node and sets CUDA_INJECTION64_PATH, as described in Kubernetes GPU configuration. These are the fields that enable profiling:

spec:
template:
spec:
hostIPC: true
containers:
- name: vllm
image: vllm/vllm-openai:v0.32.0
args: ["--model", "zai-org/GLM-4-9B-0414", "--host", "0.0.0.0", "--port", "8000"]
env:
- name: CUDA_INJECTION64_PATH
value: /opt/zymtrace/profiler/libzymtracecudaprofiler.so
resources:
limits:
nvidia.com/gpu: 1
volumeMounts:
- name: zymtrace-profiler
mountPath: /opt/zymtrace/profiler
readOnly: true
volumes:
- name: zymtrace-profiler
hostPath:
path: /var/lib/zymtrace/profiler
type: Directory

Apply the full manifest:

kubectl apply -f https://gist.githubusercontent.com/iogbole/0060415b87d6d8ecff8cdc4b5a3143e4/raw/vllm.yaml

# Reach the OpenAI-compatible API on localhost:8000
kubectl -n vllm port-forward svc/vllm 8000:8000

Send requests​

vLLM exposes an OpenAI-compatible API:

curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "zai-org/GLM-4-9B-0414", "messages": [{"role": "user", "content": "How does machine learning work?"}], "max_tokens": 256}'

Metrics​

vLLM exposes its Prometheus metrics by default, and Zymtrace collects them alongside the profiles. See Inference Server Metrics.

For PC sampling (NVIDIA) and verification, see the overview.