Serving stack#
One request#
Start the server#
uv venv --python 3.12 --seedclean Python 3.12 environment
source .venv/bin/activateuse it in this shell
uv pip install vllm==0.31.0 --torch-backend=autopinned install
vllm serve Qwen/Qwen3-0.6B --reasoning-parser qwen3 2>&1 | tee server.logstart and keep a log
curl http://localhost:8000/v1/modelsrun in a second terminal
Tasks#
| Task | Code |
|---|
| Install vLLM 0.31.0 | uv pip install vllm==0.31.0 --torch-backend=auto |
|---|
| Start a server with the reasoning parser | vllm serve Qwen/Qwen3-0.6B --reasoning-parser qwen3 |
|---|
| Check the health route | curl -i http://localhost:8000/health |
|---|
| List the model name | curl http://localhost:8000/v1/models |
|---|
| Turn the thinking off for one request | "chat_template_kwargs": {"enable_thinking": false} |
|---|
Commands#
| Command | What it does |
|---|
vllm --version | Prints the installed version. It must read 0.31.0. |
|---|
docker logs | Reads the log of the container that runs the server. |
|---|
nvidia-smi --query-gpu=name,memory.total,driver_version --format=csv | Prints the GPU name, memory and driver. |
|---|
Defaults#
| Setting | Default | Note |
|---|
--host | every network interface | Set 127.0.0.1 for a local test |
|---|
--port | 8000 | HTTP port of the server |
|---|
--gpu-memory-utilization | 0.92 | Share of total GPU memory for one instance |
|---|
--max-num-batched-tokens | 2048 | Under 70 GiB of GPU memory. 8192 from 70 GiB |
|---|
--max-num-seqs | 256 | Under 70 GiB of GPU memory. 1024 from 70 GiB |
|---|
--block-size | 16 | Tokens in one KV block |
|---|
--kv-cache-dtype | auto | Model data type. fp8 halves the bytes per token |
|---|
-O0 to -O3 | -O2 | Compile and CUDA graph level |
|---|
Key terms#
- Prefix hash
- a hash of a block and the block before it, so one hash names a whole prefix.
- Preemption
- vLLM stops a request to free its blocks and computes it again later.
Glossary#
- API server
- the process that serves HTTP, tokenizes and streams the answer.
- Engine core
- the process that runs the scheduler and the KV cache manager.
- Block
- a fixed group of 16 tokens in the KV cache.
- Preemption
- stopping a running request to free its blocks, then computing it again.
Tips#
- Keep the log with
tee server.log, and read the startup lines at every start. - On the pip path, install the CUDA toolkit before the first start.
- Use the health route for liveness, and one real request for readiness.
- Read the symptom section before you change a flag.