Instructions to use google/diffusiongemma-26B-A4B-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/diffusiongemma-26B-A4B-it with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="google/diffusiongemma-26B-A4B-it") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("google/diffusiongemma-26B-A4B-it") model = AutoModelForMultimodalLM.from_pretrained("google/diffusiongemma-26B-A4B-it") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use google/diffusiongemma-26B-A4B-it with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "google/diffusiongemma-26B-A4B-it" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "google/diffusiongemma-26B-A4B-it", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/google/diffusiongemma-26B-A4B-it
- SGLang
How to use google/diffusiongemma-26B-A4B-it 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 "google/diffusiongemma-26B-A4B-it" \ --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": "google/diffusiongemma-26B-A4B-it", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "google/diffusiongemma-26B-A4B-it" \ --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": "google/diffusiongemma-26B-A4B-it", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use google/diffusiongemma-26B-A4B-it with Docker Model Runner:
docker model run hf.co/google/diffusiongemma-26B-A4B-it
Custom chat template: empty content in multi-turn conversations (with fix)
Custom chat template for DiffusionGemma: empty content in multi-turn conversations (with fix)
The Problem
DiffusionGemma's tokenizer_config.json has no built-in chat_template, so anyone serving via vLLM needs to supply one via --chat-template. When writing a custom Jinja2 template using the Gemma4 <|turn>/<turn|> format, multi-turn conversations with prior assistant messages return completely empty content and reasoning with finish_reason: stop. Single-turn works fine.
Root Cause
Two template mistakes that compound in multi-turn:
Double
<|turn>modelgeneration prompt: If each user turn appends<|turn>model\n<eos>ANDadd_generation_prompt=Truealso adds it, the model receives two consecutive<|turn>modelopenings — causing empty output.Unbounded assistant turns: If assistant messages lack
<|turn>model/<turn|>markers, the assistant's response is floating text. The next<|turn>userconcatenates directly to it without a<turn|>closure, breaking the conversation structure.
Buggy pattern ❌
User turn: <|turn>user\n{content}<turn|><|turn>model\n<eos> ← adds model marker
Assistant turn: {content} ← no markers at all
Generation: <|turn>model\n<eos> ← SECOND model marker
Correct pattern ✅
User turn: <|turn>user\n{content}<turn|> ← close user only
Assistant turn: <|turn>model\n{content}<turn|> ← proper markers
Generation: <|turn>model\n<eos> ← only at the end
Reference template
{%- for message in messages -%}
{%- if message['role'] == 'user' -%}
<|turn>user
{{ message['content'] }}<turn|>
{%- elif message['role'] == 'assistant' -%}
<|turn>model
{{ message['content'] }}<turn|>
{%- endif -%}
{%- endfor -%}
{%- if add_generation_prompt -%}
<|turn>model
<eos>
{%- endif -%}
Verified on
- Model:
nvidia/diffusiongemma-26B-A4B-it-NVFP4(NVFP4 quantization) - vLLM:
vllm/vllm-openai:gemmaDocker image - Flags:
--chat-template template.jinja --enable-auto-tool-choice --tool-call-parser gemma4 --reasoning-parser gemma4 - Hardware: NVIDIA DGX Spark (4x Grace Hopper, 128GB unified memory)
- Tests passed: single-turn, multi-turn (2+ turns), coding mode detection, custom system prompt override
Suggestion
It would be helpful if a reference chat template were included in the model repo (e.g., as a chat_template.jinja file or in tokenizer_config.json). This would prevent other users from hitting the same issue and provide a starting point for customization.
Hi @buzman 👋
I'm not sure if I follow this issue, this repo contain a chat_template.jinja file here. The chat template in nvidia/diffusiongemma-26B-A4B-it-NVFP4 is a clone.
vLLM recommends using a custom chat template, though, see their cookbook. In other words, you may be observing a vLLM-specific issue :)