Skip to content

Commit 5b6aa93

Browse files
committed
[Docs] Update Llama3/4 and GPT-OSS recipe for NVIDIA GPUs
Signed-off-by: Po-Han Huang <[email protected]>
1 parent 2b294fe commit 5b6aa93

File tree

3 files changed

+349
-96
lines changed

3 files changed

+349
-96
lines changed

Llama/Llama3.3-70B.md

Lines changed: 55 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ This quick start recipe provides step-by-step instructions for running the Llama
66

77
The recipe is intended for developers and practitioners seeking high-throughput or low-latency inference using NVIDIA’s accelerated stack—building a docker image with vLLM for model serving, FlashInfer for optimized CUDA kernels, and ModelOpt to enable FP8 and NVFP4 quantized execution.
88

9-
109
## Access & Licensing
1110

1211
### License
@@ -34,31 +33,19 @@ For Hopper, FP8 offers the best performance for most workloads. For Blackwell, N
3433

3534
## Deployment Steps
3635

37-
### Build Docker Image
36+
### Pull Docker Image
3837

39-
Build a docker image with vLLM using the official vLLM Dockerfile at a specific commit (`dc5e4a653c859573dfcca99f1b0141c2db9f94cc`) on the main branch. This commit contains more performance optimizations compared to the latest official vLLM docker image (`vllm/vllm-openai:latest`).
38+
Pull the vLLM release docker image for a specific commit (`de533ab2a14192e461900a4950e2b426d99a6862`) on the main branch and tag it as `vllm/vllm-openai:deploy`. This commit contains more performance optimizations compared to the latest official vLLM docker image (`vllm/vllm-openai:latest`).
4039

41-
`build_image.sh`
42-
```
43-
# Clone the vLLM GitHub repo and checkout the spcific commit.
44-
git clone -b main --single-branch https://github.com/vllm-project/vllm.git
45-
cd vllm
46-
git checkout dc5e4a653c859573dfcca99f1b0141c2db9f94cc
47-
48-
# Build the docker image using official vLLM Dockerfile.
49-
DOCKER_BUILDKIT=1 docker build . \
50-
--file docker/Dockerfile \
51-
--target vllm-openai \
52-
--build-arg CUDA_VERSION=12.8.1 \
53-
--build-arg max_jobs=32 \
54-
--build-arg nvcc_threads=2 \
55-
--build-arg RUN_WHEEL_CHECK=false \
56-
--build-arg torch_cuda_arch_list="9.0+PTX 10.0+PTX" \
57-
--build-arg vllm_fa_cmake_gpu_arches="90-real;100-real" \
58-
-t vllm/vllm-openai:deploy
40+
`pull_image.sh`
5941
```
42+
# On x86_64 systems:
43+
docker pull --platform linux/x86_64 public.ecr.aws/q9t5s3a7/vllm-release-repo:de533ab2a14192e461900a4950e2b426d99a6862
44+
# On aarch64 systems:
45+
# docker pull --platform linux/aarch64 public.ecr.aws/q9t5s3a7/vllm-release-repo:de533ab2a14192e461900a4950e2b426d99a6862
6046
61-
Note: building the docker image may use lots of CPU threads and CPU memory. If you build the docker image on machines with fewer CPU cores or less CPU memory, please reduce the value of `max_jobs`.
47+
docker tag public.ecr.aws/q9t5s3a7/vllm-ci-postmerge-repo:de533ab2a14192e461900a4950e2b426d99a6862 vllm/vllm-openai:deploy
48+
```
6249

6350
### Run Docker Container
6451

@@ -73,6 +60,29 @@ Note: You can mount additional directories and paths using the `-v <local_path>:
7360

7461
The `-e HF_TOKEN="$HF_TOKEN" -e HF_HOME="$HF_HOME"` flags are added so that the models are downloaded using your HuggingFace token and the downloaded models can be cached in $HF_HOME. Refer to [HuggingFace documentation](https://huggingface.co/docs/huggingface_hub/en/package_reference/environment_variables#hfhome) for more information about these environment variables and refer to [HuggingFace Quickstart guide](https://huggingface.co/docs/huggingface_hub/en/quick-start#authentication) about steps to generate your HuggingFace access token.
7562

63+
### Install Latest NCCL
64+
65+
The default NCCL version in the docker container may lead to long NCCL initialization time on Blackwell architecture. Therefore, install `nvidia-nccl-cu12==2.26.2.post1` to fix it. Refer to [this GitHub issue](https://github.com/vllm-project/vllm/issues/20862) for more information.
66+
67+
`install_nccl.sh`
68+
```
69+
pip uninstall -y nvidia-nccl-cu12
70+
pip install nvidia-nccl-cu12==2.26.2.post1
71+
```
72+
73+
### Install Latest FlashInfer
74+
75+
The default FlashInfer version (v0.2.4.post1) in the docker container has some functional issues.. Therefore, reinstall FlashInfer at commit `9720182476ede910698f8d783c29b2ec91cec023` to fix it.
76+
77+
`install_flashinfer.sh`
78+
```
79+
pip uninstall -y flashinfer-python
80+
git clone --recursive https://github.com/flashinfer-ai/flashinfer.git
81+
git checkout 9720182476ede910698f8d783c29b2ec91cec023
82+
cd flashinfer
83+
pip install .
84+
```
85+
7686
### Launch the vLLM Server
7787

7888
Below is an example command to launch the vLLM server with Llama-3.3-70B-Instruct-FP4/FP8 model. The explanation of each flag is shown in the "Configs and Parameters" section.
@@ -83,15 +93,14 @@ Below is an example command to launch the vLLM server with Llama-3.3-70B-Instruc
8393
# They will be removed when the performance optimizations have been verified and enabled by default.
8494
COMPUTE_CAPABILITY=$(nvidia-smi -i 0 --query-gpu=compute_cap --format=csv,noheader)
8595
if [ "$COMPUTE_CAPABILITY" = "10.0" ]; then
86-
# Use FlashInfer backend for attentions
87-
export VLLM_ATTENTION_BACKEND=FLASHINFER
88-
# Use FlashInfer trtllm-gen attention kernels
89-
export VLLM_USE_TRTLLM_ATTENTION=1
96+
# Set AR+Norm fusion thresholds
97+
export VLLM_FLASHINFER_ALLREDUCE_FUSION_THRESHOLDS_MB='{"2":32,"4":32,"8":8}'
9098
# Enable async scheduling
9199
ASYNC_SCHEDULING_FLAG="--async-scheduling"
92-
# Enable FlashInfer fusions
93-
FUSION_FLAG='{"pass_config":{"enable_fi_allreduce_fusion":true,"enable_noop":true},"custom_ops":["+quant_fp8","+rms_norm"],"full_cuda_graph":true}'
100+
# Enable vLLM fusions and cuda graphs
101+
FUSION_FLAG='{"pass_config":{"enable_fi_allreduce_fusion":true,"enable_attn_fusion":true,"enable_noop":true},"custom_ops":["+quant_fp8","+rms_norm"],"cudagraph_mode":"FULL_DECODE_ONLY","splitting_ops":[]}'
94102
# Use FP4 for Blackwell architecture
103+
# Change this to FP8 to run FP8 on Blackwell architecture
95104
DTYPE="FP4"
96105
else
97106
# Disable async scheduling on Hopper architecture due to vLLM limitations
@@ -102,24 +111,25 @@ else
102111
DTYPE="FP8"
103112
fi
104113
114+
# Disable prefix caching when running with synthetic dataset for consistent performance measurement.
115+
NO_PREFIX_CACHING_FLAG="--no-enable-prefix-caching"
116+
105117
# Launch the vLLM server
106118
vllm serve nvidia/Llama-3.3-70B-Instruct-$DTYPE \
107119
--host 0.0.0.0 \
108-
--port 8080 \
109-
--tokenizer nvidia/Llama-3.3-70B-Instruct-$DTYPE \
120+
--port 8000 \
110121
--kv-cache-dtype fp8 \
111122
--trust-remote-code \
112123
--gpu-memory-utilization 0.9 \
113-
--compilation-config $FUSION_FLAG \
114-
$ASYNC_SCHEDULING_FLAG \
124+
--compilation-config ${FUSION_FLAG} \
125+
${ASYNC_SCHEDULING_FLAG} \
115126
--enable-chunked-prefill \
116-
--no-enable-prefix-caching \
127+
${NO_PREFIX_CACHING_FLAG} \
117128
--pipeline-parallel-size 1 \
118129
--tensor-parallel-size 1 \
119130
--max-num-seqs 512 \
120131
--max-num-batched-tokens 8192 \
121132
--max-model-len 9216 &
122-
123133
```
124134

125135
After the server is set up, the client can now send prompt requests to the server and receive results.
@@ -133,15 +143,12 @@ You can specify the IP address and the port that you would like to run the serve
133143

134144
Below are the config flags that we do not recommend changing or tuning with:
135145

136-
- `--tokenizer`: Specify the path to the model file.
137-
- `--quantization`: Must be `modelopt` for FP8 model and `modelopt_fp4` for FP4 model.
138146
- `--kv-cache-dtype`: Kv-cache data type. We recommend setting it to `fp8` for best performance.
139147
- `--trust-remote-code`: Trust the model code.
140148
- `--gpu-memory-utilization`: The fraction of GPU memory to be used for the model executor. We recommend setting it to `0.9` to use up to 90% of the GPU memory.
141-
- `--compilation-config`: Configuration for vLLM compilation stage. We recommend setting it to `'{"pass_config":{"enable_fi_allreduce_fusion":true,"enable_noop":true},"custom_ops":["+quant_fp8","+rms_norm"],"full_cuda_graph":true}'` to enable all the necessary fusions for the best performance on Blackwell architecture. However, this feature is not supported on Hopper architecture yet.
142-
- We are trying to enable these fusions by default so that this flag is no longer needed in the future.
143-
- `--enable-chunked-prefill`: Enable chunked prefill stage. We recommend always adding this flag for best performance.
149+
- `--compilation-config`: Configuration for vLLM compilation stage. We recommend setting it to `'{"pass_config":{"enable_fi_allreduce_fusion":true,"enable_attn_fusion":true,"enable_noop":true},"custom_ops":["+quant_fp8","+rms_norm"],"cudagraph_mode":"FULL_DECODE_ONLY","splitting_ops":[]}'` to enable all the necessary fusions for the best performance on Blackwell architecture. However, this feature is not supported on Hopper architecture yet.
144150
- `--async-scheduling`: Enable asynchronous scheduling to reduce the host overheads between decoding steps. We recommend always adding this flag for best performance on Blackwell architecture. However, this feature is not supported on Hopper architecture yet.
151+
- `--enable-chunked-prefill`: Enable chunked prefill stage. We recommend always adding this flag for best performance.
145152
- `--no-enable-prefix-caching` Disable prefix caching. We recommend always adding this flag if running with synthetic dataset for consistent performance measurement.
146153
- `--pipeline-parallel-size`: Pipeline parallelism size. We recommend setting it to `1` for best performance.
147154

@@ -163,11 +170,11 @@ Refer to the "Balancing between Throughput and Latencies" about how to adjust th
163170

164171
### Basic Test
165172

166-
After the vLLM server is set up and shows `Application startup complete`, you can send requests to the server
173+
After the vLLM server is set up and shows `Application startup complete`, you can send requests to the server
167174

168175
`run_basic_test.sh`
169176
```
170-
curl http://0.0.0.0:8080/v1/completions -H "Content-Type: application/json" -d '{ "model": "nvidia/Llama-3.3-70B-Instruct-FP4", "prompt": "San Francisco is a", "max_tokens": 20, "temperature": 0 }'
177+
curl http://0.0.0.0:8000/v1/completions -H "Content-Type: application/json" -d '{ "model": "nvidia/Llama-3.3-70B-Instruct-FP4", "prompt": "San Francisco is a", "max_tokens": 20, "temperature": 0 }'
171178
```
172179

173180
Here is an example response, showing that the vLLM server returns "*city that is known for its vibrant culture, stunning architecture, and breathtaking natural beauty. From the iconic...*", completing the input sequence with up to 20 tokens.
@@ -190,7 +197,7 @@ lm_eval \
190197
--model local-completions \
191198
--tasks gsm8k \
192199
--model_args \
193-
base_url=http://0.0.0.0:8080/v1/completions,\
200+
base_url=http://0.0.0.0:8000/v1/completions,\
194201
model=nvidia/Llama-3.3-70B-Instruct-FP4,\
195202
tokenized_requests=False,tokenizer_backend=None,\
196203
num_concurrent=128,timeout=120,max_retries=5
@@ -199,7 +206,7 @@ num_concurrent=128,timeout=120,max_retries=5
199206
Here is an example accuracy result with the nvidia/Llama-3.3-70B-Instruct-FP4 model on one B200 GPU:
200207

201208
```
202-
local-completions (base_url=http://0.0.0.0:8080/v1/completions,model=nvidia/Llama-3.3-70B-Instruct-FP4,tokenized_requests=False,tokenizer_backend=None,num_concurrent=128,timeout=120,max_retries=5), gen_kwa
209+
local-completions (base_url=http://0.0.0.0:8000/v1/completions,model=nvidia/Llama-3.3-70B-Instruct-FP4,tokenized_requests=False,tokenizer_backend=None,num_concurrent=128,timeout=120,max_retries=5), gen_kwa
203210
rgs: (None), limit: None, num_fewshot: None, batch_size: 1
204211
|Tasks|Version| Filter |n-shot| Metric | |Value | |Stderr|
205212
|-----|------:|----------------|-----:|-----------|---|-----:|---|-----:|
@@ -215,7 +222,7 @@ To benchmark the performance, you can use the `vllm bench serve` command.
215222
```
216223
vllm bench serve \
217224
--host 0.0.0.0 \
218-
--port 8080 \
225+
--port 8000 \
219226
--model nvidia/Llama-3.3-70B-Instruct-FP4 \
220227
--trust-remote-code \
221228
--dataset-name random \
@@ -237,9 +244,9 @@ Explanations for the flags:
237244
- `--num-prompts`: Total number of prompts used for performance benchmarking. We recommend setting it to at least five times of the `--max-concurrency` to measure the steady state performance.
238245
- `--save-result --result-filename`: Output location for the performance benchmarking result.
239246

240-
### Interpreting `benchmark_serving.py` Output
247+
### Interpreting Performance Benchmarking Output
241248

242-
Sample output by the `benchmark_serving.py` script:
249+
Sample output by the `vllm bench serve` command:
243250

244251
```
245252
============ Serving Benchmark Result ============
@@ -272,11 +279,11 @@ P99 E2EL (ms): xxx.xx
272279
Explanations for key metrics:
273280

274281
- `Median Time to First Token (TTFT)`: The typical time elapsed from when a request is sent until the first output token is generated.
275-
- `Median Time Per Output Token (TPOT)`: The typical time required to generate each token after the first one.
282+
- `Median Time Per Output Token (TPOT)`: The typical time required to generate each token after the first one.
276283
- `Median Inter-Token Latency (ITL)`: The typical time delay between the completion of one token and the completion of the next.
277284
- `Median End-to-End Latency (E2EL)`: The typical total time from when a request is submitted until the final token of the response is received.
278285
- `Output token throughput`: The rate at which the system generates the output (generated) tokens.
279-
- `Total Token Throughput`: The combined rate at which the system processes both input (prompt) tokens and output (generated) tokens.
286+
- `Total Token Throughput`: The combined rate at which the system processes both input (prompt) tokens and output (generated) tokens.
280287

281288
### Balancing between Throughput and Latencies
282289

0 commit comments

Comments
 (0)