Text Generation
Transformers
Safetensors
PyTorch
nemotron_h
nvidia
conversational
custom_code
Eval Results
Instructions to use nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16", trust_remote_code=True, device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16
- SGLang
How to use nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16 with Docker Model Runner:
docker model run hf.co/nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16
Add vLLM example w/ 1M context length (#38)
Browse files- Add vLLM example w/ 1M context length (a7827f58c69fb9db6b791916cae7cc86bef763bf)
README.md
CHANGED
|
@@ -315,11 +315,12 @@ Download the custom parser from the Hugging Face repository.
|
|
| 315 |
wget https://huggingface.co/nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16/resolve/main/nano_v3_reasoning_parser.py
|
| 316 |
```
|
| 317 |
|
| 318 |
-
Launch a vLLM server using the custom parser.
|
| 319 |
|
| 320 |
```
|
| 321 |
vllm serve nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16 \
|
| 322 |
-
|
|
|
|
| 323 |
--tensor-parallel-size 1 \
|
| 324 |
--max-model-len 262144 \
|
| 325 |
--port 8000 \
|
|
@@ -330,6 +331,24 @@ vllm serve nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16 \
|
|
| 330 |
--reasoning-parser nano_v3
|
| 331 |
```
|
| 332 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
Here is an example client code for vLLM. By default, the endpoint has reasoning enabled. We recommend setting a high value (e.g., 10,000) for `max_tokens`.
|
| 334 |
|
| 335 |
```shell
|
|
|
|
| 315 |
wget https://huggingface.co/nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16/resolve/main/nano_v3_reasoning_parser.py
|
| 316 |
```
|
| 317 |
|
| 318 |
+
Launch a vLLM server using the custom parser.
|
| 319 |
|
| 320 |
```
|
| 321 |
vllm serve nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16 \
|
| 322 |
+
--served-model-name model \
|
| 323 |
+
--max-num-seqs 8 \
|
| 324 |
--tensor-parallel-size 1 \
|
| 325 |
--max-model-len 262144 \
|
| 326 |
--port 8000 \
|
|
|
|
| 331 |
--reasoning-parser nano_v3
|
| 332 |
```
|
| 333 |
|
| 334 |
+
In the example above, we use a context length of 256k. You can increase the context size up to 1M to support longer contexts.
|
| 335 |
+
To enable this, set the `VLLM_ALLOW_LONG_MAX_MODEL_LEN=1` environment variable as shown below:
|
| 336 |
+
|
| 337 |
+
```
|
| 338 |
+
VLLM_ALLOW_LONG_MAX_MODEL_LEN=1 \
|
| 339 |
+
vllm serve nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16 \
|
| 340 |
+
--served-model-name model \
|
| 341 |
+
--max-num-seqs 8 \
|
| 342 |
+
--tensor-parallel-size 1 \
|
| 343 |
+
--max-model-len 1M \
|
| 344 |
+
--port 8000 \
|
| 345 |
+
--trust-remote-code \
|
| 346 |
+
--enable-auto-tool-choice \
|
| 347 |
+
--tool-call-parser qwen3_coder \
|
| 348 |
+
--reasoning-parser-plugin nano_v3_reasoning_parser.py \
|
| 349 |
+
--reasoning-parser nano_v3
|
| 350 |
+
```
|
| 351 |
+
|
| 352 |
Here is an example client code for vLLM. By default, the endpoint has reasoning enabled. We recommend setting a high value (e.g., 10,000) for `max_tokens`.
|
| 353 |
|
| 354 |
```shell
|