Improve vLLM usage guidance
#4
by oliverholworthy - opened
README.md
CHANGED
|
@@ -55,7 +55,7 @@ pipeline_tag: sentence-similarity
|
|
| 55 |
# Model Overview
|
| 56 |
|
| 57 |
### Description
|
| 58 |
-
**Nemotron-3-Embed-1B-NVFP4** is the quantized version of the [Nemotron-3-Embed-1B-BF16](https://huggingface.co/nvidia/Nemotron-3-Embed-1B-BF16) model, which is developed for text question-answering retrieval. For more information, please check [here](https://huggingface.co/nvidia/Nemotron-3-Embed-1B-BF16). The **Nemotron-3-Embed-1B-NVFP4** model is quantized with [NVIDIA Model Optimizer](https://github.com/NVIDIA/Model-Optimizer), using nvidia-modelopt v0.45.0.
|
| 59 |
This model was evaluated on 34 languages: English, Arabic, Assamese, Bengali, Bulgarian, Chinese, Danish, Dutch, Finnish, French, German, Hindi, Hinglish, Indonesian, Italian, Japanese, Korean, Malay, Marathi, Nepali, Norwegian, Persian, Portuguese, Romanian, Russian, Spanish, Swahili, Swedish, Tamil, Telugu, Thai, Ukrainian, Urdu, Vietnamese. Read more details in our [Blog Post](https://huggingface.co/blog/nvidia/nemotron-3-embed-wins-rteb).
|
| 60 |
|
| 61 |
This model is ready for commercial use.
|
|
@@ -145,7 +145,10 @@ pip install --upgrade "vllm==0.25.0" openai requests numpy
|
|
| 145 |
|
| 146 |
### vLLM Offline Python
|
| 147 |
|
| 148 |
-
Use the offline Python API for local vLLM inference without an HTTP server.
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
<details>
|
| 151 |
<summary>vLLM Offline Python Example</summary>
|
|
@@ -156,7 +159,6 @@ from vllm import LLM
|
|
| 156 |
|
| 157 |
MODEL_ID = "nvidia/Nemotron-3-Embed-1B-NVFP4"
|
| 158 |
MAX_MODEL_LEN = 4096
|
| 159 |
-
MAX_BATCHED_TOKENS = 4096
|
| 160 |
|
| 161 |
QUERIES = [
|
| 162 |
"Write a Python function that counts the frequency of each element in a list of lists.",
|
|
@@ -176,8 +178,6 @@ def main():
|
|
| 176 |
llm = LLM(
|
| 177 |
model=MODEL_ID,
|
| 178 |
max_model_len=MAX_MODEL_LEN,
|
| 179 |
-
max_num_batched_tokens=MAX_BATCHED_TOKENS,
|
| 180 |
-
max_cudagraph_capture_size=MAX_BATCHED_TOKENS,
|
| 181 |
)
|
| 182 |
texts = ["query: " + query for query in QUERIES] + [
|
| 183 |
"passage: " + doc for doc in DOCUMENTS
|
|
@@ -222,58 +222,37 @@ q[3] -0.0222 0.0265 0.1261 0.7677
|
|
| 222 |
|
| 223 |
### vLLM Online Serving
|
| 224 |
|
| 225 |
-
|
| 226 |
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
MAX_MODEL_LEN=4096
|
| 230 |
-
MAX_BATCHED_TOKENS=4096
|
| 231 |
-
|
| 232 |
-
vllm serve "$MODEL_ID" \
|
| 233 |
-
--max-model-len "$MAX_MODEL_LEN" \
|
| 234 |
-
--max-num-batched-tokens "$MAX_BATCHED_TOKENS" \
|
| 235 |
-
--max-cudagraph-capture-size "$MAX_BATCHED_TOKENS"
|
| 236 |
-
```
|
| 237 |
-
|
| 238 |
-
#### CUDA Graph Sizing
|
| 239 |
-
|
| 240 |
-
The checkpoint supports sequences up to 32,768 tokens. The examples use 4,096 as a conservative starting point.
|
| 241 |
-
|
| 242 |
-
Use the following guidance to tune CUDA graph capture:
|
| 243 |
-
|
| 244 |
-
- Set `--max-model-len` to the longest request you intend to serve. Tune `--max-num-batched-tokens` for the workload, concurrency, and available GPU memory. When chunked prefill is disabled, the batched-token budget must be at least the model-length limit.
|
| 245 |
-
- For default capture buckets up to 8,192, set `--max-cudagraph-capture-size` equal to `--max-num-batched-tokens`. This setting makes batches up to the scheduler budget eligible for CUDA graph execution. Batches outside the captured range use a slower uncaptured path.
|
| 246 |
-
- Larger capture ranges increase startup time and graph memory. Benchmark representative traffic on the target hardware. Do not capture beyond the batched-token budget.
|
| 247 |
-
|
| 248 |
-
Use a maximum capture size of 4,096 as the conservative default for services that restart or autoscale regularly. A maximum capture size of 8,192 can be reasonable when a longer cold start is acceptable. For maximum capture sizes above 8,192, pass a smaller, workload-aligned set with `--cudagraph-capture-sizes` to keep startup time under control.
|
| 249 |
-
|
| 250 |
-
<details>
|
| 251 |
-
<summary>Example Sparse Capture Sizes for Inputs up to 32,768 Tokens</summary>
|
| 252 |
-
|
| 253 |
-
The following command uses a sparse capture-size list:
|
| 254 |
|
| 255 |
```bash
|
| 256 |
-
|
| 257 |
-
|
| 258 |
|
| 259 |
-
vllm serve
|
| 260 |
-
--max-num-batched-tokens "$MAX_BATCHED_TOKENS" \
|
| 261 |
--cudagraph-capture-sizes \
|
| 262 |
-
1 2 4 8 16
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
24576 32768
|
| 266 |
```
|
| 267 |
|
| 268 |
-
|
|
|
|
|
|
|
|
|
|
| 269 |
|
| 270 |
-
|
|
|
|
| 271 |
|
| 272 |
-
|
|
|
|
|
|
|
| 273 |
|
| 274 |
Add `--host` or `--port` to the serving command if you need non-default network settings.
|
| 275 |
|
| 276 |
-
To serve a local checkpoint, replace
|
| 277 |
|
| 278 |
#### Recommended Retrieval Endpoint
|
| 279 |
|
|
|
|
| 55 |
# Model Overview
|
| 56 |
|
| 57 |
### Description
|
| 58 |
+
**Nemotron-3-Embed-1B-NVFP4** is the quantized version of the [Nemotron-3-Embed-1B-BF16](https://huggingface.co/nvidia/Nemotron-3-Embed-1B-BF16) model, which is developed for text question-answering retrieval. For more information, please check [here](https://huggingface.co/nvidia/Nemotron-3-Embed-1B-BF16). The **Nemotron-3-Embed-1B-NVFP4** model is quantized with [NVIDIA Model Optimizer](https://github.com/NVIDIA/Model-Optimizer), using nvidia-modelopt v0.45.0.
|
| 59 |
This model was evaluated on 34 languages: English, Arabic, Assamese, Bengali, Bulgarian, Chinese, Danish, Dutch, Finnish, French, German, Hindi, Hinglish, Indonesian, Italian, Japanese, Korean, Malay, Marathi, Nepali, Norwegian, Persian, Portuguese, Romanian, Russian, Spanish, Swahili, Swedish, Tamil, Telugu, Thai, Ukrainian, Urdu, Vietnamese. Read more details in our [Blog Post](https://huggingface.co/blog/nvidia/nemotron-3-embed-wins-rteb).
|
| 60 |
|
| 61 |
This model is ready for commercial use.
|
|
|
|
| 145 |
|
| 146 |
### vLLM Offline Python
|
| 147 |
|
| 148 |
+
Use the offline Python API for local vLLM inference without an HTTP server.
|
| 149 |
+
`LLM.embed` accepts formatted strings.
|
| 150 |
+
Add the `query: ` and `passage: ` prefixes manually.
|
| 151 |
+
The example limits input sequences to 4,096 tokens and leaves batch and CUDA graph sizing at the vLLM defaults.
|
| 152 |
|
| 153 |
<details>
|
| 154 |
<summary>vLLM Offline Python Example</summary>
|
|
|
|
| 159 |
|
| 160 |
MODEL_ID = "nvidia/Nemotron-3-Embed-1B-NVFP4"
|
| 161 |
MAX_MODEL_LEN = 4096
|
|
|
|
| 162 |
|
| 163 |
QUERIES = [
|
| 164 |
"Write a Python function that counts the frequency of each element in a list of lists.",
|
|
|
|
| 178 |
llm = LLM(
|
| 179 |
model=MODEL_ID,
|
| 180 |
max_model_len=MAX_MODEL_LEN,
|
|
|
|
|
|
|
| 181 |
)
|
| 182 |
texts = ["query: " + query for query in QUERIES] + [
|
| 183 |
"passage: " + doc for doc in DOCUMENTS
|
|
|
|
| 222 |
|
| 223 |
### vLLM Online Serving
|
| 224 |
|
| 225 |
+
vLLM reads the checkpoint's NVFP4 and pooling metadata, so you do not need to set quantization or runner flags.
|
| 226 |
|
| 227 |
+
Use the following Bash or Zsh command as a starting point on NVIDIA Blackwell GPUs.
|
| 228 |
+
Set `VLLM_CACHE_ROOT` to a writable directory that persists across restarts so vLLM can reuse compatible compilation and FP4 GEMM autotuning artifacts:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
|
| 230 |
```bash
|
| 231 |
+
export VLLM_CACHE_ROOT=/mnt/vllm-cache
|
| 232 |
+
mkdir -p "$VLLM_CACHE_ROOT"
|
| 233 |
|
| 234 |
+
vllm serve nvidia/Nemotron-3-Embed-1B-NVFP4 \
|
|
|
|
| 235 |
--cudagraph-capture-sizes \
|
| 236 |
+
1 2 4 {8..248..8} {256..4096..16} \
|
| 237 |
+
{4224..8192..128} {8448..16384..256} \
|
| 238 |
+
{16896..32768..512}
|
|
|
|
| 239 |
```
|
| 240 |
|
| 241 |
+
The example uses `/mnt/vllm-cache`, but you can use any writable directory that persists across restarts.
|
| 242 |
+
For container deployments, mount persistent storage at the directory you choose.
|
| 243 |
+
Bash and Zsh expand the capture-size ranges before vLLM starts.
|
| 244 |
+
For other launchers, pass the expanded integer list to `--cudagraph-capture-sizes`.
|
| 245 |
|
| 246 |
+
The sparse CUDA graph profile is a practical starting point. Benchmark representative traffic before changing it or increasing `--api-server-count`.
|
| 247 |
+
For other cache or tuning configurations, refer to the vLLM [`VLLM_CACHE_ROOT` reference](https://docs.vllm.ai/en/v0.25.0/usage/security/?h=vllm_cache_root#cache-directory-configuration), [`--cudagraph-capture-sizes` reference](https://docs.vllm.ai/en/v0.25.0/configuration/engine_args/#-cudagraph-capture-sizes), and [Parallel Processing guide](https://docs.vllm.ai/en/v0.25.0/configuration/optimization/#parallel-processing).
|
| 248 |
|
| 249 |
+
Expect the first startup to take several minutes while vLLM tunes FP4 GEMMs and captures CUDA graphs.
|
| 250 |
+
vLLM recaptures CUDA graphs on every launch.
|
| 251 |
+
Startup time varies by hardware and deployment configuration.
|
| 252 |
|
| 253 |
Add `--host` or `--port` to the serving command if you need non-default network settings.
|
| 254 |
|
| 255 |
+
To serve a local checkpoint, replace the model ID with its path. Add `--served-model-name nvidia/Nemotron-3-Embed-1B-NVFP4` if clients should continue using the Hugging Face model ID.
|
| 256 |
|
| 257 |
#### Recommended Retrieval Endpoint
|
| 258 |
|