Text Generation
Transformers
Safetensors
PyTorch
nemotron_labs_diffusion
feature-extraction
nvidia
conversational
custom_code
Instructions to use nvidia/Nemotron-Labs-Diffusion-8B-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/Nemotron-Labs-Diffusion-8B-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nvidia/Nemotron-Labs-Diffusion-8B-Base", 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-Base", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use nvidia/Nemotron-Labs-Diffusion-8B-Base 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-Base" # 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-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nvidia/Nemotron-Labs-Diffusion-8B-Base
- SGLang
How to use nvidia/Nemotron-Labs-Diffusion-8B-Base 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-Base" \ --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-Base", "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-Base" \ --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-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nvidia/Nemotron-Labs-Diffusion-8B-Base with Docker Model Runner:
docker model run hf.co/nvidia/Nemotron-Labs-Diffusion-8B-Base
Made some potential fixes for DSA, need to test if they work
Browse files- chat_utils.py +3 -2
- modeling_ministral.py +1 -2
chat_utils.py
CHANGED
|
@@ -133,7 +133,7 @@ def generate_with_prefix_cache_block_diff(
|
|
| 133 |
layer.self_attn.diffusion_lm=False
|
| 134 |
|
| 135 |
# Compute KV cache for the prompt initially
|
| 136 |
-
output = model(prompt, use_cache=True)
|
| 137 |
past_key_values = output.past_key_values
|
| 138 |
|
| 139 |
if causal_context:
|
|
@@ -230,7 +230,8 @@ def generate_with_prefix_cache_block_diff(
|
|
| 230 |
output = model(
|
| 231 |
x_accum[:, block_slice],
|
| 232 |
past_key_values=past_key_values,
|
| 233 |
-
use_cache=True
|
|
|
|
| 234 |
)
|
| 235 |
past_key_values = output.past_key_values
|
| 236 |
|
|
|
|
| 133 |
layer.self_attn.diffusion_lm=False
|
| 134 |
|
| 135 |
# Compute KV cache for the prompt initially
|
| 136 |
+
output = model(prompt, use_cache=True, use_causal_mask=causal_context)
|
| 137 |
past_key_values = output.past_key_values
|
| 138 |
|
| 139 |
if causal_context:
|
|
|
|
| 230 |
output = model(
|
| 231 |
x_accum[:, block_slice],
|
| 232 |
past_key_values=past_key_values,
|
| 233 |
+
use_cache=True,
|
| 234 |
+
use_causal_mask=causal_context
|
| 235 |
)
|
| 236 |
past_key_values = output.past_key_values
|
| 237 |
|
modeling_ministral.py
CHANGED
|
@@ -419,8 +419,7 @@ class Ministral3Model(Ministral3PreTrainedModel):
|
|
| 419 |
|
| 420 |
if self.training:
|
| 421 |
causal_mask = None
|
| 422 |
-
|
| 423 |
-
else:
|
| 424 |
mask_function = create_causal_mask if self.config.sliding_window is None else create_sliding_window_causal_mask
|
| 425 |
causal_mask = mask_function(
|
| 426 |
config=self.config,
|
|
|
|
| 419 |
|
| 420 |
if self.training:
|
| 421 |
causal_mask = None
|
| 422 |
+
elif kwargs.get("use_causal_mask", False):
|
|
|
|
| 423 |
mask_function = create_causal_mask if self.config.sliding_window is None else create_sliding_window_causal_mask
|
| 424 |
causal_mask = mask_function(
|
| 425 |
config=self.config,
|