Text Generation
Transformers
Safetensors
PyTorch
nemotron_labs_diffusion
feature-extraction
nvidia
conversational
custom_code
Instructions to use nvidia/Nemotron-Labs-Diffusion-8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/Nemotron-Labs-Diffusion-8B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nvidia/Nemotron-Labs-Diffusion-8B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("nvidia/Nemotron-Labs-Diffusion-8B", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use nvidia/Nemotron-Labs-Diffusion-8B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nvidia/Nemotron-Labs-Diffusion-8B" # 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/Nemotron-Labs-Diffusion-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nvidia/Nemotron-Labs-Diffusion-8B
- SGLang
How to use nvidia/Nemotron-Labs-Diffusion-8B 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/Nemotron-Labs-Diffusion-8B" \ --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/Nemotron-Labs-Diffusion-8B", "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/Nemotron-Labs-Diffusion-8B" \ --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/Nemotron-Labs-Diffusion-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nvidia/Nemotron-Labs-Diffusion-8B with Docker Model Runner:
docker model run hf.co/nvidia/Nemotron-Labs-Diffusion-8B
Patch modeling_ministral.py: filter create_causal_mask kwargs by signature (handles input_embeds rename + cache_position removal in 5.9.0)
Browse files- modeling_ministral.py +16 -16
modeling_ministral.py
CHANGED
|
@@ -420,23 +420,23 @@ class Ministral3Model(Ministral3PreTrainedModel):
|
|
| 420 |
|
| 421 |
if kwargs.get("use_causal_mask", False):
|
| 422 |
mask_function = create_causal_mask if self.config.sliding_window is None else create_sliding_window_causal_mask
|
| 423 |
-
#
|
| 424 |
-
#
|
|
|
|
|
|
|
| 425 |
import inspect
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
)
|
| 439 |
-
|
| 440 |
else:
|
| 441 |
causal_mask = None
|
| 442 |
|
|
|
|
| 420 |
|
| 421 |
if kwargs.get("use_causal_mask", False):
|
| 422 |
mask_function = create_causal_mask if self.config.sliding_window is None else create_sliding_window_causal_mask
|
| 423 |
+
# Build candidate kwargs and filter against the function's signature
|
| 424 |
+
# for cross-transformers-version compatibility:
|
| 425 |
+
# - `input_embeds` (<= 4.x) was renamed to `inputs_embeds` (>= 5.0)
|
| 426 |
+
# - `cache_position` was removed from the signature in 5.9.0
|
| 427 |
import inspect
|
| 428 |
+
sig_params = inspect.signature(mask_function).parameters
|
| 429 |
+
embeds_kw = "inputs_embeds" if "inputs_embeds" in sig_params else "input_embeds"
|
| 430 |
+
candidate = {
|
| 431 |
+
"config": self.config,
|
| 432 |
+
"attention_mask": attention_mask,
|
| 433 |
+
"cache_position": cache_position,
|
| 434 |
+
"past_key_values": past_key_values,
|
| 435 |
+
"position_ids": position_ids,
|
| 436 |
+
embeds_kw: inputs_embeds,
|
| 437 |
+
}
|
| 438 |
+
causal_mask = mask_function(**{k: v for k, v in candidate.items() if k in sig_params})
|
| 439 |
+
|
|
|
|
|
|
|
| 440 |
else:
|
| 441 |
causal_mask = None
|
| 442 |
|