Views
No views yet

spatial_merge_size=2.nvidia/Nemotron-Labs-Diffusion-8B (34 layers, 4096 hidden, 14336 intermediate); the model card structure and inference modes inherit from the LM line.1transformers>=5.0.0
2pillow
3requests
4opencv-python1import sys
2import torch
3from huggingface_hub import snapshot_download
4from transformers import AutoModel, AutoTokenizer
5
6repo_name = "nvidia/Nemotron-Labs-Diffusion-VLM-8B"
7sys.path.insert(0, snapshot_download(repo_name))
8from image_processing import process_messages
9
10tokenizer = AutoTokenizer.from_pretrained(repo_name, trust_remote_code=True)
11model = AutoModel.from_pretrained(repo_name, trust_remote_code=True).cuda().to(torch.bfloat16)
12
13image_path = "path/to/your/image.jpg" # local file or http(s):// URL
14messages = [{
15 "role": "user",
16 "content": [
17 {"type": "image_url", "image_url": {"url": image_path}},
18 {"type": "text", "text": "Describe this image."},
19 ],
20}]
21
22batch = process_messages(tokenizer, messages, add_generation_prompt=True)
23prompt_ids = batch["input_ids"].to("cuda")
24pixel_values = batch["pixel_values"].to("cuda", dtype=torch.bfloat16)
25
26out_ids, nfe = model.generate(
27 prompt_ids,
28 pixel_values=pixel_values,
29 image_sizes=batch["image_sizes"],
30 max_new_tokens=512, steps=512, block_length=32,
31 shift_logits=False, threshold=0.9,
32 eos_token_id=tokenizer.eos_token_id,
33)
34
35tokenized_out = tokenizer.batch_decode(out_ids[:, prompt_ids.shape[1]:], skip_special_tokens=True)
36print(f"Model: {tokenized_out[0]}")
37print(f"[Num Function Eval (NFE)={nfe}]")1@techreport{fu2026nemotronlabsdiffusion,
2 title = {Nemotron-Labs-Diffusion: A Tri-Mode Language Model Unifying Autoregressive, Diffusion, and Self-Speculation Decoding},
3 author = {Yonggan Fu and Lexington Whalen and Abhinav Garg and Chengyue Wu and Maksim Khadkevich and Nicolai Oswald and Enze Xie and Daniel Egert and Sharath Turuvekere Sreenivas and Shizhe Diao and Chenhan Yu and Ye Yu and Weijia Chen and Sajad Norouzi and Jingyu Liu and Shiyi Lan and Ligeng Zhu and Jin Wang and Jindong Jiang and Morteza Mardani and Mehran Maghoumi and Song Han and Ante Jukic and Nima Tajbakhsh and Jan Kautz and Pavlo Molchanov},
4 institution = {NVIDIA},
5 year = {2026},
6 note = {Technical report}
7}