[Doc] Host model recipes in recipes/ (#61302)

Signed-off-by: esmeetu <jasonailu87@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Roy Wang
2026-10-17 09:14:36 +00:00
committed by GitHub
co-authored by Claude Opus 5.5
parent f98ae6a9fd
commit b515648641
193 changed files with 44859 additions and 6 deletions
@@ -0,0 +1,358 @@
meta:
title: "DiffusionGemma 26B-A4B IT"
slug: "diffusiongemma-26b-a4b-it"
provider: "Google"
description: "Google's DiffusionGemma — a block-diffusion language model built on Gemma 4's MoE backbone (26B total / 4B active). Generates tokens via iterative denoising over a fixed-length canvas rather than left-to-right autoregressive decoding, enabling higher throughput with parallel block generation."
date_added: 2026-06-11
date_updated: 2026-09-23
tasks:
- multimodal
- text
performance_headline: "Block-diffusion MoE — 26B total / 4B active, canvas-based parallel generation with ~1.9x throughput vs autoregressive baseline"
related_recipes:
- google/gemma-4-26B-A4B-it
- google/gemma-4-31B-it
hardware:
h100: verified
h200: verified
dgx_spark_gb10: verified
xeon6: verified
arc_pro_b60: verified
arc_pro_b70: verified
model:
model_id: "google/diffusiongemma-26B-A4B-it"
min_vllm_version: "0.24.0"
docker_image: "vllm/vllm-openai:gemma"
architecture: moe
parameter_count: "26B"
active_parameters: "4B"
context_length: 262144
base_args:
- "--max-num-seqs"
- "4"
base_env: {}
dependencies: []
features:
tool_calling:
description: "Enable automatic tool choice with Gemma 4 parser and chat template"
args:
- "--enable-auto-tool-choice"
- "--tool-call-parser"
- "gemma4"
- "--chat-template"
- "examples/tool_chat_template_gemma4.jinja"
reasoning:
description: "Enable structured thinking/reasoning output"
args:
- "--reasoning-parser"
- "gemma4"
opt_in_features: []
variants:
default:
precision: bf16
vram_minimum_gb: 64
description: "Full BF16 — single 80 GB NVIDIA GPU (H100/H200). Requires --max-num-seqs 4 to avoid OOM from diffusion state buffers."
supported_hardware: [h100, h200, dgx_spark_gb10, xeon6]
fp8:
model_id: "RedHatAI/diffusiongemma-26B-A4B-it-FP8-dynamic"
precision: fp8
vram_minimum_gb: 32
description: "FP8 (E4M3) weights with dynamic per-token activation quantization"
supported_hardware: [h100, h200, dgx_spark_gb10]
nvfp4:
model_id: "RedHatAI/diffusiongemma-26B-A4B-it-NVFP4"
precision: nvfp4
label: "NVFP4 - RedHatAI"
vram_minimum_gb: 24
description: "NVFP4 (4-bit) quantized weights"
supported_hardware: [dgx_spark_gb10]
nvidia_nvfp4:
model_id: "nvidia/diffusiongemma-26B-A4B-it-NVFP4"
precision: nvfp4
label: "NVFP4 - NVIDIA"
vram_minimum_gb: 24
description: "NVIDIA NVFP4 (4-bit) quantized weights"
supported_hardware: [dgx_spark_gb10]
hardware_overrides:
dgx_spark_gb10:
extra_args:
- "--gpu-memory-utilization"
- "0.8"
- "--max-num-seqs"
- "8"
- "--enable-auto-tool-choice"
- "--tool-call-parser"
- "gemma4"
- "--load-format"
- "fastsafetensors"
- "--attention-backend"
- "TRITON_ATTN"
- "--enable-prefix-caching"
- "--diffusion-config"
- '{"canvas_length":256}'
- "--override-generation-config"
- '{"max_new_tokens": null}'
- "--reasoning-parser"
- "gemma4"
- "--default-chat-template-kwargs"
- '{"enable_thinking": true}'
compatible_strategies:
- single_node_tp
hardware_overrides:
cpu: {}
xpu:
extra_args:
- "--enforce-eager"
- "--attention-backend"
- "TRITON_ATTN"
- "--tensor-parallel-size"
- "4"
strategy_overrides:
single_node_tp:
tp: 1
guide: |
## Overview
[DiffusionGemma 26B-A4B](https://huggingface.co/google/diffusiongemma-26B-A4B-it) is a block-diffusion language model built on Gemma 4's MoE backbone. Instead of generating tokens one at a time (autoregressive), it generates blocks of 256 tokens simultaneously via iterative denoising over a fixed canvas — trading higher time-to-first-token for significantly higher per-request generation throughput.
### Key Architecture Features
- **Block Diffusion**: Generates tokens in 256-token canvas blocks via iterative denoising (up to 48 steps per block).
- **MoE Backbone**: Same Gemma 4 architecture — 128 fine-grained experts with top-8 routing, 26B total / 4B active parameters.
- **Entropy-Bound Sampling**: Uses an entropy-based sampler (`diffusion_sampler: entropy_bound`, `entropy_bound: 0.1`) for the denoising process.
- **Multimodal**: Supports text + images via the Gemma 4 vision encoder.
- **Thinking Mode**: Supports structured reasoning via `<|channel>thought\n...<channel|>` delimiters.
- **Function Calling**: Supports Gemma 4's tool-call protocol (works best in thinking mode).
### Important Deployment Notes
DiffusionGemma requires several specific flags that differ from standard Gemma 4:
| Flag | Why |
|------|-----|
| `--max-num-seqs 4` | The diffusion state buffers (`self_conditioning_probs`) pre-allocate `max_seqs × canvas_length × vocab_size` tensors. With Gemma's 262K vocab and canvas_length=256, higher values cause OOM. |
| `--generation-config vllm` | The checkpoint's `generation_config.json` sets `max_tokens: 256`, which would override per-request limits. This flag ignores it. |
| `--gpu-memory-utilization 0.85` | Leaves headroom for activation memory during denoising. |
| `--hf-overrides '{"diffusion_sampler":"entropy_bound","diffusion_entropy_bound":0.1}'` | Configures the entropy-bound denoising sampler. |
| `--diffusion-config '{"canvas_length": 256}'` | Sets the canvas block size for generation. |
## Prerequisites
DiffusionGemma requires a vLLM build with diffusion model support, available in the
Gemma docker image:
```bash
docker pull vllm/vllm-openai:gemma
```
## Deployment
### Single GPU (H100/H200, BF16)
```bash
docker run -itd --name diffusiongemma \
--ipc=host --network host --gpus all \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai:gemma \
--model google/diffusiongemma-26B-A4B-it \
--max-model-len 262144 \
--max-num-seqs 4 \
--gpu-memory-utilization 0.85 \
--host 0.0.0.0 --port 8000
```
### Intel Xeon 6 (CPU, BF16)
DiffusionGemma runs on Intel Xeon 6 CPUs using vLLM's CPU backend with AMX BF16 acceleration.
The generated example uses TP=1. Adjust `--tensor-parallel-size` based on the
detected NUMA topology and deployment requirements.
```bash
docker run \
--privileged --ipc=host -p 8000:8000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai-cpu:latest-x86_64 google/diffusiongemma-26B-A4B-it \
--max-num-seqs 4 \
--tensor-parallel-size 1 \
--enable-auto-tool-choice \
--tool-call-parser gemma4 \
--chat-template examples/tool_chat_template_gemma4.jinja \
--reasoning-parser gemma4
```
### Intel XPU (B60 / B70, BF16)
Validated on 4x Intel Arc Pro B60 / B70 (B60 24 GB, B70 32 GB per card)
with the official vLLM XPU image `vllm/vllm-openai-xpu:latest`. `--enforce-eager`
and `--attention-backend TRITON_ATTN` are required on this backend. Select Arc Pro
B60/B70 in the hardware picker above for the exact command.
### Full-Featured Server (text + image + thinking + tools)
```bash
docker run -itd --name diffusiongemma \
--ipc=host --network host --gpus all \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai:gemma \
--model google/diffusiongemma-26B-A4B-it \
--max-model-len 262144 \
--max-num-seqs 4 \
--gpu-memory-utilization 0.85 \
--mm-processor-kwargs '{"max_soft_tokens": 1120}' \
--limit-mm-per-prompt '{"image": 7}' \
--enable-auto-tool-choice \
--tool-call-parser gemma4 \
--reasoning-parser gemma4 \
--host 0.0.0.0 --port 8000
```
### Jev-Style Structured Decisions (Nightly)
vLLM's structured-read support for DiffusionGemma can answer yes/no, multiple-choice,
and scored questions with a confidence value. The example server seeds a canvas with
the response template, leaves only the answer slots noisy, and reads a probability
distribution from every slot after one denoising step. It exposes the Jev-compatible
`/v1/systemone` endpoint; this is an example server rather than a standard vLLM endpoint.
Use the pinned nightly image that contains the merged structured-read support:
```bash
docker run -d --name dgemma \
--gpus '"device=0"' \
--ipc=host \
-p 8000:8000 \
-p 8011:8011 \
-v "$HOME/.cache/huggingface:/root/.cache/huggingface" \
vllm/vllm-openai:nightly-e9757321527ca1ecd514c07c1418dd2c53da3d19 \
google/diffusiongemma-26B-A4B-it \
--served-model-name dgemma \
--diffusion-config '{"canvas_length":64}' \
--max-logprobs 32 \
--enable-prefix-caching
```
Wait for the vLLM server to become healthy, then start the example server in the same
container:
```bash
until curl -fsS localhost:8000/health >/dev/null; do sleep 2; done
docker exec -d dgemma \
python /vllm-workspace/examples/features/structured_diffusion/structured_server.py \
--upstream http://127.0.0.1:8000 \
--tokenizer google/diffusiongemma-26B-A4B-it \
--canvas 64
```
After the example server becomes healthy, send a Jev-style decision request:
```bash
until curl -fsS localhost:8011/health >/dev/null; do sleep 2; done
curl -sS localhost:8011/v1/systemone \
-H 'content-type: application/json' \
-d '{
"model": "jev-latest",
"state": {"ticket": "Everything is down, demo at noon."},
"questions": {
"urgent": {
"type": "noul",
"instructions": "Needs a reply within the hour?"
}
}
}'
```
## Client Usage
### Text Generation
```python
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
response = client.chat.completions.create(
model="google/diffusiongemma-26B-A4B-it",
messages=[{"role": "user", "content": "Write a poem about the ocean."}],
max_tokens=512,
temperature=0.7,
)
print(response.choices[0].message.content)
```
### Offline Inference
```python
from vllm import LLM, SamplingParams
from transformers import AutoTokenizer
model_path = "google/diffusiongemma-26B-A4B-it"
tokenizer = AutoTokenizer.from_pretrained(model_path)
llm = LLM(
model=model_path,
max_num_seqs=4,
gpu_memory_utilization=0.85,
hf_overrides={
"diffusion_sampler": "entropy_bound",
"diffusion_entropy_bound": 0.1,
},
diffusion_config={"canvas_length": 256},
)
messages = [{"role": "user", "content": "Explain quantum computing in simple terms."}]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
outputs = llm.generate(prompt, SamplingParams(temperature=0.0, max_tokens=1024))
print(outputs[0].outputs[0].text)
```
### Thinking Mode
Launch the server with `--reasoning-parser gemma4`, then enable per-request:
```python
response = client.chat.completions.create(
model="google/diffusiongemma-26B-A4B-it",
messages=[{"role": "user", "content": "What is the derivative of x^3 * ln(x)?"}],
max_tokens=32768,
extra_body={"chat_template_kwargs": {"enable_thinking": True}},
)
```
## Performance Characteristics
Compared to the autoregressive Gemma 4 26B-A4B baseline (single H100, concurrency=1, SPEED-Bench):
| Metric | Gemma 4 26B-A4B (baseline) | DiffusionGemma 26B-A4B |
|--------|---------------------------|------------------------|
| Output TPS | 199 tok/s | 375 tok/s (**1.9×**) |
| E2E Request Time (mean) | 2.87s | 0.88s (**3.3× faster**) |
| TTFT (mean) | 53ms | 489ms (higher due to canvas denoising setup) |
| Per-request Gen TPS (mean) | 205 tok/s | 1,282 tok/s (**6.2×**) |
The diffusion model trades higher time-to-first-token for significantly higher generation throughput. It generates fewer total tokens per prompt on average (shorter outputs) but completes requests much faster.
## Known Limitations
- **TTFT**: ~10× higher than autoregressive baseline — the model must denoise an entire canvas block before emitting the first token.
- **`--max-num-seqs`**: Must be kept low (≤4) due to the large diffusion state tensors. Higher values cause CUDA OOM.
- **Audio**: Not supported — the diffusion checkpoints do not include an audio encoder.
- **Function Calling**: Works best in thinking mode. Non-thinking mode may answer directly instead of emitting tool calls.
## References
- [Model card](https://huggingface.co/google/diffusiongemma-26B-A4B-it)
- [vLLM structured-read support for DiffusionGemma](https://github.com/vllm-project/vllm/pull/57250)
- [djev-run Cloud Run deployment](https://github.com/taeold/djev-run)
- [Gemma 4 26B-A4B (autoregressive baseline)](https://huggingface.co/google/gemma-4-26B-A4B-it)
- [Gemma docs](https://ai.google.dev/gemma/docs)
+316
View File
@@ -0,0 +1,316 @@
meta:
title: "Gemma 4 12B IT"
slug: "gemma-4-12b-it"
provider: "Google"
description: "Google's encoder-free unified Gemma 4 dense model (12B) with native text, image, and audio, plus thinking mode and tool-use protocol."
date_added: 2026-06-03
date_updated: 2026-09-09
tasks:
- multimodal
- text
performance_headline: "Encoder-free unified multimodal model with audio, structured thinking, and function calling — runs on a single 40 GB+ GPU"
related_recipes:
- google/gemma-4-E4B-it
- google/gemma-4-26B-A4B-it
- google/gemma-4-31B-it
hardware:
h100: verified
arc_pro_b60: verified
arc_pro_b70: verified
model:
model_id: "google/gemma-4-12B-it"
min_vllm_version: "0.23.0"
docker_image: "vllm/vllm-openai:gemma4-unified"
install:
docker: {}
pip: {}
architecture: dense
parameter_count: "12B"
active_parameters: "12B"
context_length: 131072
base_args: []
base_env: {}
dependencies:
- note: "Audio extras — only needed when serving the audio modality"
command: 'uv pip install "vllm[audio]"'
optional: true
features:
tool_calling:
description: "Enable automatic tool choice with Gemma 4 parser and chat template"
args:
- "--enable-auto-tool-choice"
- "--tool-call-parser"
- "gemma4"
- "--chat-template"
- "examples/tool_chat_template_gemma4.jinja"
reasoning:
description: "Enable structured thinking/reasoning output"
args:
- "--reasoning-parser"
- "gemma4"
spec_decoding:
description: "MTP speculative decoding for accelerated inference"
args:
- "--speculative-config"
- '{"model":"google/gemma-4-12B-it-assistant","num_speculative_tokens":4}'
opt_in_features:
- spec_decoding
variants:
default:
precision: bf16
vram_minimum_gb: 29
description: "Full BF16 — single 40 GB+ NVIDIA GPU"
nvfp4:
model_id: "RedHatAI/gemma-4-12B-it-NVFP4"
precision: nvfp4
vram_minimum_gb: 8
description: "RedHatAI compressed-tensors NVFP4 quantization for Blackwell GPUs"
extra_args:
- "--kv-cache-dtype"
- "fp8"
w4a16:
model_id: "google/gemma-4-12B-it-qat-w4a16-ct"
precision: int4
vram_minimum_gb: 9
description: "W4A16 QAT (4-bit weights, 16-bit activations, group_size=32) via compressed-tensors — runs on any GPU"
fp8:
model_id: "RedHatAI/gemma-4-12B-it-FP8-Dynamic"
precision: fp8
vram_minimum_gb: 15
description: "RedHatAI FP8 (E4M3) with dynamic per-token activation quantization"
extra_args:
- "--kv-cache-dtype"
- "fp8"
compatible_strategies:
- single_node_tp
- multi_node_tp
hardware_overrides:
xpu:
extra_args:
- "--enforce-eager"
- "--attention-backend"
- "flash_attn"
- "--trust-remote-code"
- "--gpu-memory-utilization"
- "0.9"
- "--no-enable-prefix-caching"
- "--max-num-batched-tokens"
- "8192"
- "--max-model-len"
- "5120"
- "--tensor-parallel-size"
- "2"
strategy_overrides:
single_node_tp:
tp: 1
guide: |
## Overview
[Gemma 4](https://ai.google.dev/gemma/docs) is Google's most capable open model family, featuring a unified multimodal architecture that natively processes text, images, and audio. The **12B Unified** model is *encoder-free*: instead of dedicated vision/audio encoders, it projects raw image patches and audio waveforms directly into the decoder's embedding space through lightweight linear layers, so every modality flows into a single decoder-only transformer. Gemma 4 models support structured thinking/reasoning, function calling with a custom tool-use protocol, and dynamic vision resolution — all available through vLLM's OpenAI-compatible API.
### Key Features
- **Encoder-free multimodality**: Text, image, and audio inputs handled by a single decoder-only transformer — no separate encoders to load, reducing multimodal latency.
- **Dual Attention**: Alternating sliding-window (local, 1024 tokens) and global attention; the final layer is always global, with unified Keys/Values and Proportional RoPE on global layers for long-context efficiency.
- **Thinking Mode**: Structured reasoning via `<|channel>thought\n...<channel|>` delimiters.
- **Function Calling**: Custom tool-call protocol with dedicated special tokens.
- **Native System Prompt Support**: First-class `system` role.
### Supported Variants
Dense:
- `google/gemma-4-E2B-it` (effective 2B)
- `google/gemma-4-E4B-it` (effective 4B)
- `google/gemma-4-12B-it` (11.95B, encoder-free)
- `google/gemma-4-31B-it` (31B)
MoE:
- `google/gemma-4-26B-A4B-it` (26B total / 4B active)
> **Context length**: this recipe pins `context_length` to the value in `config.json` (`max_position_embeddings = 131072`, i.e. 128K). The Gemma 4 model card markets the 12B at up to 256K — raise `--max-model-len` only if your vLLM build accepts it.
TPU support is provided through [vLLM TPU](https://github.com/vllm-project/tpu-inference) with recipes for [Trillium](https://github.com/AI-Hypercomputer/tpu-recipes/tree/main/inference/trillium/vLLM/Gemma4) and [Ironwood](https://github.com/AI-Hypercomputer/tpu-recipes/blob/main/inference/ironwood/vLLM/Gemma4/).
> **Nightly required**: support for the encoder-free 12B Unified model landed in [vllm-project/vllm#44429](https://github.com/vllm-project/vllm/pull/44429) and has not yet shipped in a stable release. Use the pinned Docker image (recommended) or a nightly pip wheel.
## Prerequisites
### Docker (recommended)
```bash
docker pull vllm/vllm-openai:gemma4-unified # NVIDIA (CUDA 13; append -cu129 for CUDA 12.9 hosts)
docker pull vllm/vllm-openai-xpu:latest # Intel XPU (B60 / B70)
```
TPU images are published separately by [vllm-project/tpu-inference](https://github.com/vllm-project/tpu-inference); see the Trillium / Ironwood tpu-recipes below for the pinned tag.
### pip (nightly, NVIDIA CUDA)
```bash
uv venv
source .venv/bin/activate
uv pip install -U vllm --pre \
--extra-index-url https://wheels.vllm.ai/nightly/cu129 \
--extra-index-url https://download.pytorch.org/whl/cu129 \
--index-strategy unsafe-best-match
```
## Deployment Configurations
### Quick Start (Single GPU, BF16)
The 12B fits comfortably on a single 40 GB+ GPU.
```bash
vllm serve google/gemma-4-12B-it \
--max-model-len 32768 \
--gpu-memory-utilization 0.90
```
### Full-Featured Server Launch
Enables text, image, audio, thinking, and tool calling:
```bash
vllm serve google/gemma-4-12B-it \
--max-model-len 16384 \
--gpu-memory-utilization 0.90 \
--enable-auto-tool-choice \
--reasoning-parser gemma4 \
--tool-call-parser gemma4 \
--chat-template examples/tool_chat_template_gemma4.jinja \
--limit-mm-per-prompt '{"image": 4, "audio": 1}' \
--async-scheduling \
--host 0.0.0.0 \
--port 8000
```
### Docker (NVIDIA)
```bash
docker run -itd --name gemma4 \
--ipc=host --network host --shm-size 16G --gpus all \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai:gemma4-unified \
--model google/gemma-4-12B-it \
--max-model-len 32768 \
--gpu-memory-utilization 0.90 \
--host 0.0.0.0 --port 8000
```
On CUDA 12.9 hosts, use the `vllm/vllm-openai:gemma4-unified-cu129` tag instead.
### Docker (Intel XPU B60 / B70, TP=2, Full-Featured)
Validated on 2× Intel Arc Pro B60 / B70 with the official vLLM XPU image.
```bash
docker run --device /dev/dri \
-v /dev/dri/by-path:/dev/dri/by-path --shm-size=16g \
--privileged --ipc=host -p 8000:8000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai-xpu:latest \
google/gemma-4-12B-it \
--enforce-eager \
--attention-backend flash_attn \
--host 0.0.0.0 \
--port 8000 \
--trust-remote-code \
--enable-auto-tool-choice \
--reasoning-parser gemma4 \
--tool-call-parser gemma4 \
--chat-template examples/tool_chat_template_gemma4.jinja \
--limit-mm-per-prompt '{"image": 4, "audio": 1}' \
--async-scheduling \
--gpu-memory-utilization 0.9 \
--no-enable-prefix-caching \
--max-num-batched-tokens 8192 \
--max-model-len 5120 \
--tensor-parallel-size 2
```
### Docker (Cloud TPU — Trillium / Ironwood)
TPU uses the separate `vllm/vllm-tpu` image (no pip wheel). Pull the tag specified by the upstream [Trillium](https://github.com/AI-Hypercomputer/tpu-recipes/tree/main/inference/trillium/vLLM/Gemma4) or [Ironwood](https://github.com/AI-Hypercomputer/tpu-recipes/blob/main/inference/ironwood/vLLM/Gemma4/) recipe, then run:
```bash
docker run -itd --name gemma4-tpu \
--privileged --network host --shm-size 16G \
-v /dev/shm:/dev/shm -e HF_TOKEN=$HF_TOKEN \
vllm/vllm-tpu:latest \
--model google/gemma-4-12B-it \
--max-model-len 16384 \
--disable_chunked_mm_input \
--host 0.0.0.0 --port 8000
```
## Client Usage
### Text Generation
```python
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
response = client.chat.completions.create(
model="google/gemma-4-12B-it",
messages=[{"role": "user", "content": "Write a poem about the ocean."}],
max_tokens=512, temperature=0.7,
)
print(response.choices[0].message.content)
```
### Image Understanding
```python
response = client.chat.completions.create(
model="google/gemma-4-12B-it",
messages=[{"role": "user", "content": [
{"type": "image_url", "image_url": {"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg"}},
{"type": "text", "text": "Describe this image in detail."},
]}],
max_tokens=1024,
)
```
### Audio
Requires `uv pip install "vllm[audio]"`.
```bash
vllm serve google/gemma-4-12B-it \
--max-model-len 8192 \
--limit-mm-per-prompt '{"image": 4, "audio": 1}'
```
### Thinking Mode
```bash
vllm serve google/gemma-4-12B-it \
--max-model-len 16384 \
--enable-auto-tool-choice \
--reasoning-parser gemma4 \
--tool-call-parser gemma4 \
--chat-template examples/tool_chat_template_gemma4.jinja
```
Enable thinking per-request via `extra_body={"chat_template_kwargs": {"enable_thinking": True}}`, or default-on with `--default-chat-template-kwargs '{"enable_thinking": true}'`.
### Structured Outputs
vLLM guided decoding constrains output to a JSON schema. Include semantic instructions in the system prompt — the model does not see schema descriptions.
## Configuration Tips
- Set `--max-model-len` to match your workload.
- `--gpu-memory-utilization 0.90–0.95` maximizes KV cache.
- Image-only workloads: pass `--limit-mm-per-prompt.audio 0`.
- Text-only workloads: pass `--limit-mm-per-prompt '{"image": 0, "audio": 0}'` to skip MM profiling.
- `--async-scheduling` improves throughput.
- FP8 KV cache (`--kv-cache-dtype fp8`) saves ~50% KV memory.
## Speculative Decoding (MTP)
Enable the **Spec Decoding** feature toggle (above) or add `--speculative-config` manually to use MTP drafting with the [assistant model](https://huggingface.co/google/gemma-4-12B-it-assistant). Recommended `num_speculative_tokens`: 4–8 for this model.
> **Note:** MTP speculative decoding for Gemma 4 requires the nightly build — the pinned `vllm/vllm-openai:gemma4-unified` image or a nightly pip wheel. The standard `:latest` stable tag does not include this feature.
## References
- [Model card](https://huggingface.co/google/gemma-4-12B-it)
- [vLLM support PR (#44429)](https://github.com/vllm-project/vllm/pull/44429)
- [Assistant (MTP draft) model](https://huggingface.co/google/gemma-4-12B-it-assistant)
- [Gemma docs](https://ai.google.dev/gemma/docs)
- [vLLM Gemma 4 tool-call template](https://github.com/vllm-project/vllm/blob/main/examples/tool_chat_template_gemma4.jinja)
- [TPU recipes: Trillium](https://github.com/AI-Hypercomputer/tpu-recipes/tree/main/inference/trillium/vLLM/Gemma4)
- [TPU recipes: Ironwood](https://github.com/AI-Hypercomputer/tpu-recipes/blob/main/inference/ironwood/vLLM/Gemma4/)
@@ -0,0 +1,602 @@
meta:
title: "Gemma 4 26B-A4B IT"
slug: "gemma-4-26b-a4b-it"
provider: "Google"
description: "Google's Gemma 4 MoE multimodal model (26B total / 4B active) with 128 fine-grained experts, top-8 routing, thinking mode, and tool-use protocol."
date_added: 2026-04-02
date_updated: 2026-09-27
tasks:
- multimodal
- text
performance_headline: "MoE multimodal model — 26B total / 4B active, 128 experts with top-8 routing"
related_recipes:
- google/gemma-4-E2B-it
- google/gemma-4-E4B-it
- google/gemma-4-31B-it
platforms:
- id: modal
blurb: "Serverless deploy via the Gemma 4 Modal script bundled with this recipe."
script: https://github.com/vllm-project/recipes/blob/main/Google/gemma4-modal.py
install: |
curl -O https://raw.githubusercontent.com/vllm-project/recipes/main/Google/gemma4-modal.py
pip install modal
modal setup
modal deploy gemma4-modal.py
modal run gemma4-modal.py
hardware:
h100: verified
h200: verified
mi300x: verified
mi325x: verified
mi355x: verified
trillium: verified
ironwood: verified
xeon6: verified
dgx_spark_gb10: verified
dgx_station_gb300: verified
rtx_pro_6000: verified
rtx_5090: verified
arc_pro_b60: verified
arc_pro_b70: verified
model:
model_id: "google/gemma-4-26B-A4B-it"
min_vllm_version: "0.25.0"
architecture: moe
parameter_count: "26B"
active_parameters: "4B"
context_length: 131072
base_args: []
base_env: {}
dependencies: []
features:
tool_calling:
description: "Enable automatic tool choice with Gemma 4 parser and chat template"
args:
- "--enable-auto-tool-choice"
- "--tool-call-parser"
- "gemma4"
- "--chat-template"
- "examples/tool_chat_template_gemma4.jinja"
hardware_overrides:
dgx_spark_gb10:
args:
- "--enable-auto-tool-choice"
- "--tool-call-parser"
- "gemma4"
reasoning:
description: "Enable structured thinking/reasoning output"
args:
- "--reasoning-parser"
- "gemma4"
text_only:
description: "Skip loading the vision encoder for text-only workloads — frees VRAM for KV cache. Mutually exclusive with encoder_parallel."
args:
- "--language-model-only"
spec_decoding:
description: "MTP speculative decoding for accelerated inference"
default_mode: mtp
modes:
mtp:
label: "MTP"
description: "Built-in Multi-Token Prediction, 4 draft tokens."
args:
- "--speculative-config"
- '{"model":"google/gemma-4-26B-A4B-it-assistant","num_speculative_tokens":4}'
# The single-GPU Blackwell desktops run the draft MoE on the Triton
# backend — the fused CUTLASS path the drafter picks by default is not
# built for GB10/GB300/RTX PRO in the validated images.
hardware_overrides:
dgx_spark_gb10: &gemma4_mtp_triton
args:
- "--speculative-config"
- '{"method":"mtp","model":"google/gemma-4-26B-A4B-it-assistant","num_speculative_tokens":4,"moe_backend":"triton"}'
dgx_station_gb300: *gemma4_mtp_triton
rtx_pro_6000: *gemma4_mtp_triton
eagle3:
label: "Eagle3"
description: "Eagle3 speculative decoding with externally trained draft model; the served checkpoint is unchanged."
variants:
- default
args:
- "--speculative-config"
- '{"model": "RedHatAI/gemma-4-26B-A4B-it-speculator.eagle3", "num_speculative_tokens": 3, "method": "eagle3"}'
opt_in_features:
- text_only
- spec_decoding
variants:
default:
precision: bf16
vram_minimum_gb: 64
description: "Full BF16 — single 80 GB NVIDIA GPU or 1x MI300X/MI325X/MI350X/MI355X or 2x Xeon6/Xeon5 NUMA nodes"
supported_hardware: [h100, h200, mi300x, mi325x, mi355x, trillium, ironwood, xeon6, dgx_spark_gb10, dgx_station_gb300, rtx_pro_6000, rtx_5090]
hardware_overrides:
dgx_spark_gb10:
extra_env:
VLLM_USE_V2_MODEL_RUNNER: "1"
dgx_station_gb300:
extra_env:
VLLM_USE_V2_MODEL_RUNNER: "1"
rtx_pro_6000:
extra_env:
VLLM_USE_V2_MODEL_RUNNER: "1"
extra_args:
- "--gpu-memory-utilization"
- "0.9"
fp8:
model_id: "RedHatAI/gemma-4-26B-A4B-it-FP8-dynamic"
precision: fp8
vram_minimum_gb: 32
description: "FP8 (E4M3) weights with dynamic per-token activation quantization — Hopper or Blackwell"
supported_hardware: [h100, h200, dgx_spark_gb10, dgx_station_gb300, rtx_pro_6000, rtx_5090]
extra_args:
- "--kv-cache-dtype"
- "fp8"
hardware_overrides:
dgx_spark_gb10:
extra_env:
VLLM_USE_V2_MODEL_RUNNER: "1"
dgx_station_gb300:
extra_env:
VLLM_USE_V2_MODEL_RUNNER: "1"
rtx_pro_6000:
extra_env:
VLLM_USE_V2_MODEL_RUNNER: "1"
extra_args:
- "--gpu-memory-utilization"
- "0.9"
rtx_5090:
extra_env:
VLLM_USE_V2_MODEL_RUNNER: "1"
extra_args:
- "--gpu-memory-utilization"
- "0.92"
- "--max-model-len"
- "131072"
- "--max-num-seqs"
- "1"
nvfp4:
model_id: "RedHatAI/gemma-4-26B-A4B-it-NVFP4"
precision: nvfp4
label: "NVFP4 - RedHatAI"
vram_minimum_gb: 16
description: "NVFP4 (4-bit) quantized weights — requires Blackwell (B200/B300)"
supported_hardware: [dgx_spark_gb10, dgx_station_gb300, rtx_pro_6000, rtx_5090]
extra_args:
- "--kv-cache-dtype"
- "fp8"
hardware_overrides:
dgx_spark_gb10:
extra_env:
VLLM_USE_V2_MODEL_RUNNER: "1"
dgx_station_gb300:
extra_env:
VLLM_USE_V2_MODEL_RUNNER: "1"
rtx_pro_6000:
extra_env:
VLLM_USE_V2_MODEL_RUNNER: "1"
extra_args:
- "--gpu-memory-utilization"
- "0.9"
rtx_5090:
extra_env:
VLLM_USE_V2_MODEL_RUNNER: "1"
extra_args:
- "--gpu-memory-utilization"
- "0.9"
- "--max-num-batched-tokens"
- "4096"
- "--max-num-seqs"
- "4"
nvidia_nvfp4:
model_id: "nvidia/Gemma-4-26B-A4B-NVFP4"
precision: nvfp4
label: "NVFP4 - NVIDIA"
vram_minimum_gb: 16
description: "NVIDIA ModelOpt NVFP4 (4-bit) quantized weights — validated on the single-GPU Blackwell desktops (DGX Spark GB10, DGX Station GB300, RTX PRO 6000)"
supported_hardware: [dgx_spark_gb10, dgx_station_gb300, rtx_pro_6000]
hardware_overrides:
dgx_spark_gb10:
# vLLM 0.24 and the generic nightly both fail on GB10 with this
# checkpoint; the dated ARM64 community build is the tested runtime, so
# the wheel tab is hidden here rather than offering a command that
# won't start.
docker_image: "eugr/spark-vllm:nightly-20260704"
# This image's entrypoint is nvidia_entrypoint.sh, not `vllm serve`.
docker_serve_command: "vllm serve"
install:
pip: false
extra_env:
VLLM_USE_V2_MODEL_RUNNER: "1"
extra_args:
# GB10 shares its 128 GB with the CPU, so leave headroom for the host.
- "--gpu-memory-utilization"
- "0.8"
- "--max-model-len"
- "262144"
- "--max-num-seqs"
- "8"
- "--max-num-batched-tokens"
- "8192"
- "--enable-prefix-caching"
- "--load-format"
- "fastsafetensors"
dgx_station_gb300:
extra_env:
VLLM_USE_V2_MODEL_RUNNER: "1"
extra_args:
# 252 GB on one GB300 — full context at high utilization and a 64-way
# batch.
- "--gpu-memory-utilization"
- "0.92"
- "--max-model-len"
- "262144"
- "--max-num-seqs"
- "64"
- "--max-num-batched-tokens"
- "8192"
- "--enable-chunked-prefill"
- "--enable-prefix-caching"
- "--load-format"
- "fastsafetensors"
rtx_pro_6000:
extra_env:
VLLM_USE_V2_MODEL_RUNNER: "1"
extra_args:
- "--gpu-memory-utilization"
- "0.92"
- "--max-model-len"
- "262144"
- "--max-num-seqs"
- "8"
- "--max-num-batched-tokens"
- "8192"
- "--enable-prefix-caching"
- "--load-format"
- "fastsafetensors"
rtx_5090:
extra_env:
VLLM_USE_V2_MODEL_RUNNER: "1"
extra_args:
- "--kv-cache-dtype"
- "fp8"
- "--gpu-memory-utilization"
- "0.9"
- "--max-num-batched-tokens"
- "4096"
- "--enable-prefix-caching"
- "--enable-chunked-prefill"
- "--async-scheduling"
- "--max-num-seqs"
- "4"
compatible_strategies:
- single_node_tp
- single_node_tep
- single_node_dep
- multi_node_tp
- multi_node_tep
- multi_node_dep
hardware_overrides:
xpu:
extra_args:
- "--enforce-eager"
- "--attention-backend"
- "flash_attn"
- "--trust-remote-code"
- "--gpu-memory-utilization"
- "0.9"
- "--no-enable-prefix-caching"
- "--max-num-batched-tokens"
- "8192"
- "--max-model-len"
- "5120"
- "--tensor-parallel-size"
- "4"
strategy_overrides:
single_node_tp:
tp: 1
guide: |
## Overview
[Gemma 4 26B-A4B](https://huggingface.co/google/gemma-4-26B-A4B-it) is the Mixture-of-Experts member of Google's Gemma 4 family — 26B total parameters with only 4B active per token via 128 fine-grained experts and top-8 routing. It supports text + images natively, structured thinking, function calling, and dynamic vision resolution.
Intel Xeon 6 CPU support remains verified. Benchmark-specific TP/DP, CPU binding,
sequence limits, and repro-only timeouts remain deployment choices.
### Key Features
- **MoE**: 128 fine-grained experts with top-8 routing and custom GELU-activated FFN.
- **Multimodal**: Text + images natively (video via custom frame-extraction pipeline). Audio is only supported on the smaller E2B/E4B variants.
- **Dual Attention**: Alternating sliding-window (local) and global attention with different head dimensions.
- **Thinking Mode**: Structured reasoning via `<|channel>thought\n...<channel|>` delimiters.
- **Function Calling**: Custom tool-call protocol with dedicated special tokens.
- **Dynamic Vision Resolution**: Per-request configurable vision token budget (70, 140, 280, 560, 1120 tokens).
TPU support is provided through [vLLM TPU](https://github.com/vllm-project/tpu-inference) with recipes for [Trillium](https://github.com/AI-Hypercomputer/tpu-recipes/tree/main/inference/trillium/vLLM/Gemma4) and [Ironwood](https://github.com/AI-Hypercomputer/tpu-recipes/blob/main/inference/ironwood/vLLM/Gemma4/).
## Prerequisites
- Hardware: Intel Xeon 6/Xeon 5 CPUs
- vLLM >= 0.25.0
### pip (NVIDIA CUDA)
```bash
uv venv
source .venv/bin/activate
uv pip install -U vllm --pre \
--extra-index-url https://wheels.vllm.ai/nightly/cu129 \
--extra-index-url https://download.pytorch.org/whl/cu129 \
--index-strategy unsafe-best-match
```
### pip (AMD ROCm: MI300X, MI325X, MI350X, MI355X)
Requires Python 3.12, ROCm 7.2.1, glibc >= 2.35 (Ubuntu 22.04+).
```bash
uv venv --python 3.12
source .venv/bin/activate
uv pip install vllm --pre \
--extra-index-url https://wheels.vllm.ai/rocm/nightly/rocm721 --upgrade
```
### pip (Intel Xeon 6 CPUs)
For Intel and AMD x86 CPUs, follow the [CPU pre-built wheels](https://docs.vllm.ai/en/latest/getting_started/installation/cpu/#pre-built-wheels) installation instructions.
### Docker
```bash
docker pull vllm/vllm-openai:gemma4-0505-cu129 # NVIDIA Hopper (H100/H200, CUDA 12.9)
docker pull vllm/vllm-openai:gemma4-0505-cu130 # NVIDIA Blackwell (B200/B300, CUDA 13.0)
docker pull vllm/vllm-openai-rocm:latest # AMD
docker pull vllm/vllm-openai-cpu:latest-x86_64 # For Intel Xeon 6
docker pull vllm/vllm-openai-xpu:latest # Intel XPU (B60 / B70)
```
TPU images are published separately by [vllm-project/tpu-inference](https://github.com/vllm-project/tpu-inference); see the Trillium / Ironwood tpu-recipes below for the pinned tag.
## Deployment Configurations
### 26B MoE on 1x A100/H100 (BF16)
```bash
vllm serve google/gemma-4-26B-A4B-it \
--max-model-len 32768 \
--gpu-memory-utilization 0.90
```
### Full-Featured Server Launch
Enables text, image, thinking, and tool calling:
```bash
vllm serve google/gemma-4-26B-A4B-it \
--max-model-len 16384 \
--gpu-memory-utilization 0.90 \
--enable-auto-tool-choice \
--reasoning-parser gemma4 \
--tool-call-parser gemma4 \
--chat-template examples/tool_chat_template_gemma4.jinja \
--limit-mm-per-prompt.image 4 \
--async-scheduling \
--host 0.0.0.0 \
--port 8000
```
### Docker (NVIDIA)
```bash
docker run -itd --name gemma4-moe \
--ipc=host --network host --shm-size 16G --gpus all \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai:gemma4-0505-cu129 \
--model google/gemma-4-26B-A4B-it \
--max-model-len 32768 \
--gpu-memory-utilization 0.90 \
--host 0.0.0.0 --port 8000
```
Swap `vllm/vllm-openai:gemma4-0505-cu129` for `vllm/vllm-openai:gemma4-0505-cu130` on Blackwell (B200/B300).
### Docker (AMD MI300X/MI325X/MI350X/MI355X)
```bash
docker run -itd --name gemma4-rocm \
--ipc=host --network=host --privileged \
--cap-add=CAP_SYS_ADMIN --device=/dev/kfd --device=/dev/dri \
--group-add=video --cap-add=SYS_PTRACE \
--security-opt=seccomp=unconfined --shm-size 16G \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai-rocm:latest \
--model google/gemma-4-26B-A4B-it \
--host 0.0.0.0 --port 8000
```
### Docker (Cloud TPU — Trillium / Ironwood)
TPU uses the separate `vllm/vllm-tpu` image (no pip wheel). Pull the tag specified by the upstream [Trillium](https://github.com/AI-Hypercomputer/tpu-recipes/tree/main/inference/trillium/vLLM/Gemma4) or [Ironwood](https://github.com/AI-Hypercomputer/tpu-recipes/blob/main/inference/ironwood/vLLM/Gemma4/) recipe, then run:
```bash
docker run -itd --name gemma4-tpu \
--privileged --network host --shm-size 16G \
-v /dev/shm:/dev/shm -e HF_TOKEN=$HF_TOKEN \
vllm/vllm-tpu:latest \
--model google/gemma-4-26B-A4B-it \
--tensor-parallel-size 8 \
--max-model-len 16384 \
--disable_chunked_mm_input \
--host 0.0.0.0 --port 8000
```
Trillium requires a 4-chip slice minimum; Ironwood runs on a single chip.
### Intel Xeon 6 Deployment via Docker
Launch the x86 CPU vLLM Docker container for `google/gemma-4-26B-A4B-it`:
```bash
docker run \
--privileged --ipc=host -p 8000:8000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai-cpu:latest-x86_64 google/gemma-4-26B-A4B-it \
--tensor-parallel-size 1 \
--enable-auto-tool-choice \
--tool-call-parser gemma4 \
--chat-template examples/tool_chat_template_gemma4.jinja \
--reasoning-parser gemma4
```
For additional Intel Xeon 6 deployment details, see the Intel Software Catalog entries for [Gemma 4 26B-A4B IT](https://aiswcatalog.intel.com/models/google-gemma-4-26b-a4b-it).
The following settings are intentionally not prescribed as portable CPU model
defaults because they depend on the workload, hardware, or runtime environment:
- `--max-num-batched-tokens`: scheduler/throughput tuning.
- `--max-num-seqs`: concurrency and scheduler-capacity tuning.
- `--gpu-memory-utilization`: platform memory-budget tuning.
- `--no-enable-prefix-caching`: workload/benchmark cache-policy tuning.
- `VLLM_ENGINE_ITERATION_TIMEOUT_S`: operational runtime timeout.
These settings may still appear in validated hardware-specific overrides. Tune
them at deployment time based on platform resources, workload shape, and
latency/throughput goals.
### Docker (Intel XPU B60 / B70, TP=4, Full-Featured)
Validated on 4x Intel Arc Pro B60 / B70 with the official vLLM XPU image.
```bash
docker run --device /dev/dri \
-v /dev/dri/by-path:/dev/dri/by-path --shm-size=16g \
--privileged --ipc=host -p 8000:8000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai-xpu:latest \
google/gemma-4-26B-A4B-it \
--enforce-eager \
--attention-backend flash_attn \
--host 0.0.0.0 \
--port 8000 \
--trust-remote-code \
--enable-auto-tool-choice \
--reasoning-parser gemma4 \
--tool-call-parser gemma4 \
--chat-template examples/tool_chat_template_gemma4.jinja \
--limit-mm-per-prompt.image 4 \
--async-scheduling \
--gpu-memory-utilization 0.9 \
--no-enable-prefix-caching \
--max-num-batched-tokens 8192 \
--max-model-len 5120 \
--tensor-parallel-size 4
```
## Client Usage
### Text Generation
```python
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
response = client.chat.completions.create(
model="google/gemma-4-26B-A4B-it",
messages=[{"role": "user", "content": "Write a poem about the ocean."}],
max_tokens=512, temperature=0.7,
)
print(response.choices[0].message.content)
```
### Image Understanding
```python
response = client.chat.completions.create(
model="google/gemma-4-26B-A4B-it",
messages=[{"role": "user", "content": [
{"type": "image_url", "image_url": {"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg"}},
{"type": "text", "text": "Describe this image in detail."},
]}],
max_tokens=1024,
)
```
### Thinking Mode
```bash
vllm serve google/gemma-4-26B-A4B-it \
--max-model-len 16384 \
--reasoning-parser gemma4 \
--tool-call-parser gemma4 \
--enable-auto-tool-choice \
--chat-template examples/tool_chat_template_gemma4.jinja
```
Enable per-request via `extra_body={"chat_template_kwargs": {"enable_thinking": True}}`.
### Dynamic Vision Resolution
Supported values: 70, 140, 280 (default), 560, 1120 tokens/image.
```bash
vllm serve google/gemma-4-26B-A4B-it \
--mm-processor-kwargs '{"max_soft_tokens": 560}'
```
## Configuration Tips
- Set `--max-model-len` to match your workload.
- `--gpu-memory-utilization 0.90-0.95` maximizes KV cache.
- Text-only workloads: `--limit-mm-per-prompt '{"image": 0, "audio": 0}'`.
- `--async-scheduling` improves throughput.
- FP8 KV cache (`--kv-cache-dtype fp8`) saves ~50% KV memory.
- For MoE, TEP (tensor-expert parallelism) and DEP (data-expert parallelism) strategies scale better than pure TP at large node counts.
## Quantized Variants
Three pre-quantized checkpoints are available:
- [`RedHatAI/gemma-4-26B-A4B-it-FP8-dynamic`](https://huggingface.co/RedHatAI/gemma-4-26B-A4B-it-FP8-dynamic) — FP8 (E4M3) weights with dynamic per-token activation quantization; runs on Hopper and Blackwell.
- [`RedHatAI/gemma-4-26B-A4B-it-NVFP4`](https://huggingface.co/RedHatAI/gemma-4-26B-A4B-it-NVFP4) — NVFP4 (4-bit) weights; requires Blackwell (B200/B300).
- [`nvidia/Gemma-4-26B-A4B-NVFP4`](https://huggingface.co/nvidia/Gemma-4-26B-A4B-NVFP4) — NVIDIA ModelOpt NVFP4 (4-bit) weights; this is the checkpoint validated on the single-GPU Blackwell desktops below.
Pick them from the **Variant** dropdown above, or pass the repo id directly to `vllm serve`.
### NVFP4 on the Blackwell desktops
[`nvidia/Gemma-4-26B-A4B-NVFP4`](https://huggingface.co/nvidia/Gemma-4-26B-A4B-NVFP4)
has been run end to end on DGX Spark (GB10), DGX Station (GB300) and RTX PRO
6000, in each case on one GPU at TP1 with MTP drafting against
[`google/gemma-4-26B-A4B-it-assistant`](https://huggingface.co/google/gemma-4-26B-A4B-it-assistant).
Select the **NVIDIA NVFP4** variant, enable **Spec Decoding**, and switch the
hardware pill — memory utilization, batch size, prefill scheduling and the
drafter's MoE backend all differ per box and are encoded per hardware, so the
generated command is the tested one. Highlights:
- **DGX Spark (GB10)** — 128 GB shared with the CPU, so `--gpu-memory-utilization 0.8`
and an 8-way batch. Serve from `eugr/spark-vllm:nightly-20260704`: vLLM 0.24
and the generic nightly both fail on this checkpoint, so the pip tab is
hidden on this hardware.
- **DGX Station (GB300)** — 252 GB on one GPU, so `--gpu-memory-utilization 0.92`
with chunked prefill and a 64-way batch.
- **RTX PRO 6000** — 96 GB, `--gpu-memory-utilization 0.92` and an 8-way batch.
All three run the full 262,144-token context, above the 131,072 in
`config.json`, and pass `"moe_backend":"triton"` in `--speculative-config`
because the drafter's default fused MoE path is not built in these images.
The GB300 and RTX PRO 6000 runs used an internal NVIDIA nightly vLLM build.
As noted under Speculative Decoding below, Gemma 4 MTP has not landed in a
stable release, so the default `vllm/vllm-openai:latest` tag will not serve
these commands with Spec Decoding enabled — use a nightly wheel or a nightly
image on those two boxes.
## Throughput vs Latency
| Goal | TP | `--max-num-seqs` | Notes |
|------|----|------------------|-------|
| Max throughput | 1-2 | 256-512 | Best tok/s per GPU |
| Min latency | 4-8 | 8-16 | Best TTFT/TPOT |
| Balanced | 2 | 128 | Mixed workloads |
## Speculative Decoding (MTP)
Enable the **Spec Decoding** feature toggle (above) or add `--speculative-config` manually to use MTP drafting with the [assistant model](https://huggingface.co/google/gemma-4-26B-A4B-it-assistant). Recommended `num_speculative_tokens`: 4 for this model. See the [Gemma 4 usage guide](../../Google/Gemma4) for details and benchmarks.
> **Note:** MTP speculative decoding for Gemma 4 is only available on the vLLM nightly build — it has not yet landed in a stable release. Install via the nightly wheel (`uv pip install -U vllm --pre --extra-index-url https://wheels.vllm.ai/nightly/cu129 …`) or use the `vllm/vllm-openai:gemma4-0505-cu129` / `vllm/vllm-openai:gemma4-0505-cu130` images above; the standard `:latest` stable tag does not include this feature.
## References
- [Model card](https://huggingface.co/google/gemma-4-26B-A4B-it)
- [FP8 variant](https://huggingface.co/RedHatAI/gemma-4-26B-A4B-it-FP8-dynamic)
- [NVFP4 variant](https://huggingface.co/RedHatAI/gemma-4-26B-A4B-it-NVFP4)
- [NVIDIA ModelOpt NVFP4 variant](https://huggingface.co/nvidia/Gemma-4-26B-A4B-NVFP4)
- [Gemma docs](https://ai.google.dev/gemma/docs)
- [vLLM Gemma 4 tool-call template](https://github.com/vllm-project/vllm/blob/main/examples/tool_chat_template_gemma4.jinja)
- [TPU recipes: Trillium](https://github.com/AI-Hypercomputer/tpu-recipes/tree/main/inference/trillium/vLLM/Gemma4)
- [TPU recipes: Ironwood](https://github.com/AI-Hypercomputer/tpu-recipes/blob/main/inference/ironwood/vLLM/Gemma4/)
- [Xeon 6 recipe: Gemma 4 26B-A4B IT](https://aiswcatalog.intel.com/models/google-gemma-4-26b-a4b-it)
+425
View File
@@ -0,0 +1,425 @@
meta:
title: "Gemma 4 31B IT"
slug: "gemma-4-31b-it"
provider: "Google"
description: "Google's unified multimodal Gemma 4 dense model (31B) with native text, image, and audio, plus thinking mode and tool-use protocol."
date_added: 2026-04-02
date_updated: 2026-09-09
tasks:
- multimodal
- text
performance_headline: "Unified multimodal model with structured thinking, function calling, dynamic vision resolution"
related_recipes: []
hardware:
h100: verified
mi300x: verified
mi325x: verified
mi355x: verified
trillium: verified
ironwood: verified
arc_pro_b60: verified
arc_pro_b70: verified
model:
model_id: "google/gemma-4-31B-it"
min_vllm_version: "0.19.1"
architecture: dense
parameter_count: "31B"
active_parameters: "31B"
context_length: 262144
base_args: []
base_env: {}
dependencies:
- note: "Audio extras — only needed when serving the audio modality"
command: 'uv pip install "vllm[audio]"'
optional: true
features:
tool_calling:
description: "Enable automatic tool choice with Gemma 4 parser and chat template"
args:
- "--enable-auto-tool-choice"
- "--tool-call-parser"
- "gemma4"
- "--chat-template"
- "examples/tool_chat_template_gemma4.jinja"
reasoning:
description: "Enable structured thinking/reasoning output"
args:
- "--reasoning-parser"
- "gemma4"
text_only:
description: "Skip loading the vision encoder for text-only workloads — frees VRAM for KV cache. Mutually exclusive with encoder_parallel."
args:
- "--language-model-only"
spec_decoding:
description: "MTP speculative decoding for accelerated inference"
default_mode: mtp
modes:
mtp:
label: "MTP"
description: "Built-in Multi-Token Prediction, 4 draft tokens."
args:
- "--speculative-config"
- '{"model":"google/gemma-4-31B-it-assistant","num_speculative_tokens":4}'
dflash:
label: "DFlash"
description: "DFlash speculative decoding with an externally trained draft model; the served checkpoint is unchanged."
variants:
- default
args:
- "--speculative-config"
- '{"model": "RedHatAI/gemma-4-31B-it-speculator.dflash", "num_speculative_tokens": 7, "method": "dflash"}'
dspark:
label: "DSpark"
description: "DSpark drafting with an externally trained draft model; the served checkpoint is unchanged."
variants:
- default
args:
- "--speculative-config"
- '{"model": "RedHatAI/gemma-4-31B-it-speculator.dspark", "num_speculative_tokens": 7, "method": "dspark"}'
eagle3:
label: "Eagle3"
description: "Eagle3 speculative decoding with externally trained draft model; the served checkpoint is unchanged."
variants:
- default
args:
- "--speculative-config"
- '{"model": "RedHatAI/gemma-4-31B-it-speculator.eagle3", "num_speculative_tokens": 3, "method": "eagle3"}'
opt_in_features:
- text_only
- spec_decoding
variants:
default:
precision: bf16
vram_minimum_gb: 75
description: "Full BF16 — single 80 GB NVIDIA GPU or 1x MI300X/MI325X/MI350X/MI355X"
fp8:
model_id: "RedHatAI/gemma-4-31B-it-FP8-dynamic"
precision: fp8
vram_minimum_gb: 38
description: "FP8 (E4M3) linear weights with dynamic per-token activation quantization (vision tower stays BF16) — Hopper or Blackwell"
extra_args:
- "--kv-cache-dtype"
- "fp8"
nvfp4:
model_id: "nvidia/gemma-4-31B-it-NVFP4"
precision: nvfp4
vram_minimum_gb: 19
description: "NVIDIA NVFP4 quantized weights for Blackwell GPUs"
extra_args:
- "--kv-cache-dtype"
- "fp8"
redhat_nvfp4:
model_id: "RedHatAI/gemma-4-31B-it-NVFP4"
precision: nvfp4
label: "NVFP4 (RedHat)"
vram_minimum_gb: 19
description: "RedHatAI compressed-tensors NVFP4 quantization for Blackwell GPUs"
extra_args:
- "--kv-cache-dtype"
- "fp8"
w4a16:
model_id: "google/gemma-4-31B-it-qat-w4a16-ct"
precision: int4
vram_minimum_gb: 20
description: "W4A16 QAT (4-bit weights, 16-bit activations, group_size=32) via compressed-tensors — runs on any GPU"
redhat_fp8:
model_id: "RedHatAI/gemma-4-31B-it-FP8-block"
precision: fp8
label: "FP8 Block (RedHat)"
vram_minimum_gb: 38
description: "RedHatAI FP8 block quantization"
extra_args:
- "--kv-cache-dtype"
- "fp8"
compatible_strategies:
- single_node_tp
- multi_node_tp
hardware_overrides:
xpu:
extra_args:
- "--enforce-eager"
- "--attention-backend"
- "flash_attn"
- "--trust-remote-code"
- "--gpu-memory-utilization"
- "0.9"
- "--no-enable-prefix-caching"
- "--max-num-batched-tokens"
- "8192"
- "--max-model-len"
- "5120"
- "--tensor-parallel-size"
- "4"
strategy_overrides:
single_node_tp:
tp: 1
guide: |
## Overview
[Gemma 4](https://ai.google.dev/gemma/docs) is Google's most capable open model family, featuring a unified multimodal architecture that natively processes text, images, and audio. Gemma 4 models support structured thinking/reasoning, function calling with a custom tool-use protocol, and dynamic vision resolution — all available through vLLM's OpenAI-compatible API.
### Key Features
- **Multimodal**: Text + images natively (video via custom frame-extraction pipeline). The smaller E2B and E4B models also support audio.
- **MoE variant**: 128 fine-grained experts with top-8 routing and custom GELU-activated FFN (Gemma 4 26B-A4B).
- **Dual Attention**: Alternating sliding-window (local) and global attention with different head dimensions.
- **Thinking Mode**: Structured reasoning via `<|channel>thought\n...<channel|>` delimiters.
- **Function Calling**: Custom tool-call protocol with dedicated special tokens.
- **Dynamic Vision Resolution**: Per-request configurable vision token budget (70, 140, 280, 560, 1120 tokens).
### Supported Variants
Dense:
- `google/gemma-4-E2B-it` (effective 2B)
- `google/gemma-4-E4B-it` (effective 4B)
- `google/gemma-4-31B-it` (31B)
MoE:
- `google/gemma-4-26B-A4B-it` (26B total / 4B active)
TPU support is provided through [vLLM TPU](https://github.com/vllm-project/tpu-inference) with recipes for [Trillium](https://github.com/AI-Hypercomputer/tpu-recipes/tree/main/inference/trillium/vLLM/Gemma4) and [Ironwood](https://github.com/AI-Hypercomputer/tpu-recipes/blob/main/inference/ironwood/vLLM/Gemma4/).
## Prerequisites
### pip (NVIDIA CUDA)
```bash
uv venv
source .venv/bin/activate
uv pip install -U vllm --pre \
--extra-index-url https://wheels.vllm.ai/nightly/cu129 \
--extra-index-url https://download.pytorch.org/whl/cu129 \
--index-strategy unsafe-best-match
```
### pip (AMD ROCm: MI300X, MI325X, MI350X, MI355X)
Requires Python 3.12, ROCm 7.2.1, glibc >= 2.35 (Ubuntu 22.04+).
```bash
uv venv --python 3.12
source .venv/bin/activate
uv pip install vllm --pre \
--extra-index-url https://wheels.vllm.ai/rocm/nightly/rocm721 --upgrade
```
### Docker
```bash
docker pull vllm/vllm-openai:gemma4-0505-cu129 # NVIDIA Hopper (H100/H200, CUDA 12.9)
docker pull vllm/vllm-openai:gemma4-0505-cu130 # NVIDIA Blackwell (B200/B300, CUDA 13.0)
docker pull vllm/vllm-openai-rocm:latest # AMD
docker pull vllm/vllm-openai-xpu:latest # Intel XPU (B60 / B70)
```
TPU images are published separately by [vllm-project/tpu-inference](https://github.com/vllm-project/tpu-inference); see the Trillium / Ironwood tpu-recipes below for the pinned tag.
## Deployment Configurations
### Quick Start (Single GPU)
```bash
vllm serve google/gemma-4-E4B-it \
--max-model-len <n_of_tokens> # up to 131072
```
### 31B Dense on 2xA100/H100 (TP=2, BF16)
```bash
vllm serve google/gemma-4-31B-it \
--tensor-parallel-size 2 \
--max-model-len 32768 \
--gpu-memory-utilization 0.90
```
### 26B MoE on 1xA100/H100 (BF16)
```bash
vllm serve google/gemma-4-26B-A4B-it \
--max-model-len 32768 \
--gpu-memory-utilization 0.90
```
### Full-Featured Server Launch
Enables text, image, audio, thinking, and tool calling:
```bash
vllm serve google/gemma-4-31B-it \
--tensor-parallel-size 2 \
--max-model-len 16384 \
--gpu-memory-utilization 0.90 \
--enable-auto-tool-choice \
--reasoning-parser gemma4 \
--tool-call-parser gemma4 \
--chat-template examples/tool_chat_template_gemma4.jinja \
--limit-mm-per-prompt '{"image": 4, "audio": 1}' \
--async-scheduling \
--host 0.0.0.0 \
--port 8000
```
### Docker (NVIDIA)
```bash
docker run -itd --name gemma4 \
--ipc=host --network host --shm-size 16G --gpus all \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai:gemma4-0505-cu129 \
--model google/gemma-4-31B-it \
--tensor-parallel-size 2 \
--max-model-len 32768 \
--gpu-memory-utilization 0.90 \
--host 0.0.0.0 --port 8000
```
Swap `vllm/vllm-openai:gemma4-0505-cu129` for `vllm/vllm-openai:gemma4-0505-cu130` on Blackwell (B200/B300).
### Docker (AMD MI300X/MI325X/MI350X/MI355X)
```bash
docker run -itd --name gemma4-rocm \
--ipc=host --network=host --privileged \
--cap-add=CAP_SYS_ADMIN --device=/dev/kfd --device=/dev/dri \
--group-add=video --cap-add=SYS_PTRACE \
--security-opt=seccomp=unconfined --shm-size 16G \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai-rocm:latest \
--model google/gemma-4-31B-it \
--host 0.0.0.0 --port 8000
```
### Docker (Intel XPU B60 / B70, TP=4, Full-Featured)
Validated on 4× Intel Arc Pro B60 / B70 with the official vLLM XPU image.
```bash
docker run --device /dev/dri \
-v /dev/dri/by-path:/dev/dri/by-path --shm-size=16g \
--privileged --ipc=host -p 8000:8000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai-xpu:latest \
google/gemma-4-31B-it \
--enforce-eager \
--attention-backend flash_attn \
--host 0.0.0.0 \
--port 8000 \
--trust-remote-code \
--enable-auto-tool-choice \
--reasoning-parser gemma4 \
--tool-call-parser gemma4 \
--chat-template examples/tool_chat_template_gemma4.jinja \
--limit-mm-per-prompt '{"image": 4, "audio": 1}' \
--async-scheduling \
--gpu-memory-utilization 0.9 \
--no-enable-prefix-caching \
--max-num-batched-tokens 8192 \
--max-model-len 5120 \
--tensor-parallel-size 4
```
### Docker (Cloud TPU — Trillium / Ironwood)
TPU uses the separate `vllm/vllm-tpu` image (no pip wheel). Pull the tag specified by the upstream [Trillium](https://github.com/AI-Hypercomputer/tpu-recipes/tree/main/inference/trillium/vLLM/Gemma4) or [Ironwood](https://github.com/AI-Hypercomputer/tpu-recipes/blob/main/inference/ironwood/vLLM/Gemma4/) recipe, then run:
```bash
docker run -itd --name gemma4-tpu \
--privileged --network host --shm-size 16G \
-v /dev/shm:/dev/shm -e HF_TOKEN=$HF_TOKEN \
vllm/vllm-tpu:latest \
--model google/gemma-4-31B-it \
--tensor-parallel-size 8 \
--max-model-len 16384 \
--disable_chunked_mm_input \
--host 0.0.0.0 --port 8000
```
## Client Usage
### Text Generation
```python
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
response = client.chat.completions.create(
model="google/gemma-4-31B-it",
messages=[{"role": "user", "content": "Write a poem about the ocean."}],
max_tokens=512, temperature=0.7,
)
print(response.choices[0].message.content)
```
### Image Understanding
```python
response = client.chat.completions.create(
model="google/gemma-4-31B-it",
messages=[{"role": "user", "content": [
{"type": "image_url", "image_url": {"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg"}},
{"type": "text", "text": "Describe this image in detail."},
]}],
max_tokens=1024,
)
```
### Dynamic Vision Resolution
Supported values: 70, 140, 280 (default), 560, 1120 tokens/image.
```bash
vllm serve google/gemma-4-31B-it \
--mm-processor-kwargs '{"max_soft_tokens": 560}'
```
### Audio (E2B / E4B)
Requires `uv pip install "vllm[audio]"`.
```bash
vllm serve google/gemma-4-E2B-it \
--max-model-len 8192 \
--limit-mm-per-prompt '{"image": 4, "audio": 1}'
```
### Thinking Mode
```bash
vllm serve google/gemma-4-31B-it \
--max-model-len 16384 \
--enable-auto-tool-choice \
--reasoning-parser gemma4 \
--tool-call-parser gemma4 \
--chat-template examples/tool_chat_template_gemma4.jinja
```
Enable thinking per-request via `extra_body={"chat_template_kwargs": {"enable_thinking": True}}`, or default-on with `--default-chat-template-kwargs '{"enable_thinking": true}'`.
### Structured Outputs
vLLM guided decoding constrains output to a JSON schema. Include semantic instructions in the system prompt — the model does not see schema descriptions.
## Configuration Tips
- Set `--max-model-len` to match your workload.
- `--gpu-memory-utilization 0.90–0.95` maximizes KV cache.
- Image-only workloads: pass `--limit-mm-per-prompt.audio 0`.
- Text-only workloads: pass `--limit-mm-per-prompt '{"image": 0, "audio": 0}'` to skip MM profiling.
- `--async-scheduling` improves throughput.
- FP8 KV cache (`--kv-cache-dtype fp8`) saves ~50% KV memory.
## Quantized Variants
Two pre-quantized checkpoints are available:
- [`RedHatAI/gemma-4-31B-it-FP8-dynamic`](https://huggingface.co/RedHatAI/gemma-4-31B-it-FP8-dynamic) — FP8 (E4M3) linear weights with dynamic per-token activation quantization (vision tower stays BF16); runs on Hopper and Blackwell.
- [`nvidia/gemma-4-31B-it-NVFP4`](https://huggingface.co/nvidia/gemma-4-31B-it-NVFP4) — NVFP4 (4-bit) weights; requires Blackwell (B200/B300).
Pick them from the **Variant** dropdown above, or pass the repo id directly to `vllm serve`.
## Throughput vs Latency
| Goal | TP | `--max-num-seqs` | Notes |
|------|----|------------------|-------|
| Max throughput | 1-2 | 256-512 | Best tok/s per GPU |
| Min latency | 4-8 | 8-16 | Best TTFT/TPOT |
| Balanced | 2 | 128 | Mixed workloads |
## Speculative Decoding (MTP)
Enable the **Spec Decoding** feature toggle (above) or add `--speculative-config` manually to use MTP drafting with the [assistant model](https://huggingface.co/google/gemma-4-31B-it-assistant). Recommended `num_speculative_tokens`: 4–8 for this model. See the [Gemma 4 usage guide](../../Google/Gemma4) for details and benchmarks.
> **Note:** MTP speculative decoding for Gemma 4 is only available on the vLLM nightly build — it has not yet landed in a stable release. Install via the nightly wheel (`uv pip install -U vllm --pre --extra-index-url https://wheels.vllm.ai/nightly/cu129 …`) or use the `vllm/vllm-openai:gemma4-0505-cu129` / `vllm/vllm-openai:gemma4-0505-cu130` images above; the standard `:latest` stable tag does not include this feature.
## References
- [Model card](https://huggingface.co/google/gemma-4-31B-it)
- [FP8 variant](https://huggingface.co/RedHatAI/gemma-4-31B-it-FP8-dynamic)
- [NVFP4 variant](https://huggingface.co/nvidia/gemma-4-31B-it-NVFP4)
- [Gemma docs](https://ai.google.dev/gemma/docs)
- [vLLM Gemma 4 tool-call template](https://github.com/vllm-project/vllm/blob/main/examples/tool_chat_template_gemma4.jinja)
- [TPU recipes: Trillium](https://github.com/AI-Hypercomputer/tpu-recipes/tree/main/inference/trillium/vLLM/Gemma4)
- [TPU recipes: Ironwood](https://github.com/AI-Hypercomputer/tpu-recipes/blob/main/inference/ironwood/vLLM/Gemma4/)
+322
View File
@@ -0,0 +1,322 @@
meta:
title: "Gemma 4 E2B IT"
slug: "gemma-4-e2b-it"
provider: "Google"
description: "Google's compact Gemma 4 multimodal model (effective 2B) with native text, image, and audio, plus thinking mode and tool-use protocol."
date_added: 2026-04-02
date_updated: 2026-09-12
tasks:
- multimodal
- text
performance_headline: "Compact unified multimodal model with audio, thinking, and function calling — runs on a single 24 GB+ GPU"
related_recipes:
- google/gemma-4-E4B-it
- google/gemma-4-31B-it
- google/gemma-4-26B-A4B-it
hardware:
h100: verified
mi300x: verified
mi325x: verified
mi355x: verified
trillium: verified
ironwood: verified
xeon6: verified
model:
model_id: "google/gemma-4-E2B-it"
min_vllm_version: "0.19.1"
architecture: dense
parameter_count: "5B"
active_parameters: "5B"
context_length: 131072
base_args: []
base_env: {}
dependencies:
- note: "Audio extras — needed to serve the audio modality"
command: 'uv pip install "vllm[audio]"'
optional: true
features:
tool_calling:
description: "Enable automatic tool choice with Gemma 4 parser and chat template"
args:
- "--enable-auto-tool-choice"
- "--tool-call-parser"
- "gemma4"
- "--chat-template"
- "examples/tool_chat_template_gemma4.jinja"
reasoning:
description: "Enable structured thinking/reasoning output"
args:
- "--reasoning-parser"
- "gemma4"
text_only:
description: "Skip loading the vision and audio encoders for text-only workloads — frees VRAM for KV cache. Mutually exclusive with encoder_parallel."
args:
- "--language-model-only"
spec_decoding:
description: "MTP speculative decoding with centroids masking for accelerated inference"
args:
- "--speculative-config"
- '{"model":"google/gemma-4-E2B-it-assistant","num_speculative_tokens":2}'
opt_in_features:
- text_only
- spec_decoding
variants:
default:
precision: bf16
vram_minimum_gb: 13
description: "Full BF16 — single 24 GB+ NVIDIA GPU or 1x MI300X/MI325X/MI350X/MI355X or 1x Xeon6/Xeon5 NUMA node"
supported_hardware: [h100, mi300x, mi325x, mi355x, trillium, ironwood, xeon6]
fp8:
model_id: "RedHatAI/gemma-4-E2B-it-FP8-dynamic"
precision: fp8
vram_minimum_gb: 6
description: "FP8 (E4M3) linear weights with dynamic per-token activation quantization (vision/audio encoders stay BF16) — Hopper or Blackwell"
supported_hardware: [h100]
extra_args:
- "--kv-cache-dtype"
- "fp8"
w4a16:
model_id: "google/gemma-4-E2B-it-qat-w4a16-ct"
precision: int4
vram_minimum_gb: 8
description: "W4A16 QAT (4-bit weights, 16-bit activations, group_size=32) via compressed-tensors — runs on any GPU"
supported_hardware: [h100, mi300x, mi325x, mi355x]
mobile:
model_id: "google/gemma-4-E2B-it-qat-mobile-ct"
precision: int2/4/8
vram_minimum_gb: 4
description: "Mobile QAT — mixed int2/4/8 compressed-tensors (int2 embeddings + lm_head + deep MLP, int4 attention + early MLP, int8 vision + gates). 3.6× weight compression vs BF16, up to 1.25× faster decode at low batch"
supported_hardware: [h100, mi300x, mi325x, mi355x]
compatible_strategies:
- single_node_tp
- multi_node_tp
strategy_overrides:
single_node_tp:
tp: 1
guide: |
## Overview
[Gemma 4 E2B](https://huggingface.co/google/gemma-4-E2B-it) is the smallest member of Google's Gemma 4 family — an effective-2B unified multimodal model that natively processes text, images, and audio, with structured thinking/reasoning, function calling, and dynamic vision resolution. It runs comfortably on a single 24 GB+ GPU.
Intel Xeon 6 CPU support remains verified. No additional benchmark-specific CPU
tuning is prescribed for general deployment.
### Key Features
- **Multimodal**: Text + images + audio natively (video via custom frame-extraction pipeline).
- **Dual Attention**: Alternating sliding-window (local) and global attention with different head dimensions.
- **Thinking Mode**: Structured reasoning via `<|channel>thought\n...<channel|>` delimiters.
- **Function Calling**: Custom tool-call protocol with dedicated special tokens.
- **Dynamic Vision Resolution**: Per-request configurable vision token budget (70, 140, 280, 560, 1120 tokens).
TPU support is provided through [vLLM TPU](https://github.com/vllm-project/tpu-inference) with recipes for [Trillium](https://github.com/AI-Hypercomputer/tpu-recipes/tree/main/inference/trillium/vLLM/Gemma4) and [Ironwood](https://github.com/AI-Hypercomputer/tpu-recipes/blob/main/inference/ironwood/vLLM/Gemma4/).
## Prerequisites
- Hardware: Intel Xeon 6/Xeon 5 CPUs
- vLLM >= 0.19.1
### pip (NVIDIA CUDA)
```bash
uv venv
source .venv/bin/activate
uv pip install -U vllm --pre \
--extra-index-url https://wheels.vllm.ai/nightly/cu129 \
--extra-index-url https://download.pytorch.org/whl/cu129 \
--index-strategy unsafe-best-match
```
### pip (AMD ROCm: MI300X, MI325X, MI350X, MI355X)
Requires Python 3.12, ROCm 7.2.1, glibc >= 2.35 (Ubuntu 22.04+).
```bash
uv venv --python 3.12
source .venv/bin/activate
uv pip install vllm --pre \
--extra-index-url https://wheels.vllm.ai/rocm/nightly/rocm721 --upgrade
```
### pip (Intel Xeon 6 CPUs)
For Intel and AMD x86 CPUs, follow the [CPU pre-built wheels](https://docs.vllm.ai/en/latest/getting_started/installation/cpu/#pre-built-wheels) installation instructions.
### Docker
```bash
docker pull vllm/vllm-openai:gemma4-0505-cu129 # NVIDIA Hopper (H100/H200, CUDA 12.9)
docker pull vllm/vllm-openai:gemma4-0505-cu130 # NVIDIA Blackwell (B200/B300, CUDA 13.0)
docker pull vllm/vllm-openai-rocm:latest # AMD
docker pull vllm/vllm-openai-cpu:latest-x86_64 # For Intel Xeon 6
```
## Deployment Configurations
### Quick Start (Single GPU)
```bash
vllm serve google/gemma-4-E2B-it \
--max-model-len 32768
```
### With Audio Support
```bash
vllm serve google/gemma-4-E2B-it \
--max-model-len 8192 \
--limit-mm-per-prompt '{"image": 4, "audio": 1}'
```
### Full-Featured Server Launch
Enables text, image, audio, thinking, and tool calling:
```bash
vllm serve google/gemma-4-E2B-it \
--max-model-len 16384 \
--gpu-memory-utilization 0.90 \
--enable-auto-tool-choice \
--reasoning-parser gemma4 \
--tool-call-parser gemma4 \
--chat-template examples/tool_chat_template_gemma4.jinja \
--limit-mm-per-prompt '{"image": 4, "audio": 1}' \
--async-scheduling \
--host 0.0.0.0 \
--port 8000
```
### Docker (NVIDIA)
```bash
docker run -itd --name gemma4-e2b \
--ipc=host --network host --shm-size 16G --gpus all \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai:gemma4-0505-cu129 \
--model google/gemma-4-E2B-it \
--max-model-len 32768 \
--host 0.0.0.0 --port 8000
```
Swap `vllm/vllm-openai:gemma4-0505-cu129` for `vllm/vllm-openai:gemma4-0505-cu130` on Blackwell (B200/B300).
### Docker (AMD MI300X/MI325X/MI350X/MI355X)
```bash
docker run -itd --name gemma4-rocm \
--ipc=host --network=host --privileged \
--cap-add=CAP_SYS_ADMIN --device=/dev/kfd --device=/dev/dri \
--group-add=video --cap-add=SYS_PTRACE \
--security-opt=seccomp=unconfined --shm-size 16G \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai-rocm:latest \
--model google/gemma-4-E2B-it \
--host 0.0.0.0 --port 8000
```
### Docker (Cloud TPU — Trillium / Ironwood)
TPU uses the separate `vllm/vllm-tpu` image (no pip wheel). Pull the tag specified by the upstream [Trillium](https://github.com/AI-Hypercomputer/tpu-recipes/tree/main/inference/trillium/vLLM/Gemma4) or [Ironwood](https://github.com/AI-Hypercomputer/tpu-recipes/blob/main/inference/ironwood/vLLM/Gemma4/) recipe, then run:
```bash
docker run -itd --name gemma4-tpu \
--privileged --network host --shm-size 16G \
-v /dev/shm:/dev/shm -e HF_TOKEN=$HF_TOKEN \
vllm/vllm-tpu:latest \
--model google/gemma-4-E2B-it \
--max-model-len 16384 \
--disable_chunked_mm_input \
--host 0.0.0.0 --port 8000
```
### Intel Xeon 6 Deployment via Docker
Launch the x86 CPU vLLM Docker container for `google/gemma-4-E2B-it`:
```bash
docker run \
--privileged --ipc=host -p 8000:8000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai-cpu:latest-x86_64 google/gemma-4-E2B-it \
--tensor-parallel-size 1 \
--enable-auto-tool-choice \
--tool-call-parser gemma4 \
--chat-template examples/tool_chat_template_gemma4.jinja \
--reasoning-parser gemma4
```
The following settings are intentionally not prescribed as portable CPU model
defaults because they depend on the workload, hardware, or runtime environment:
- `--max-num-batched-tokens`: scheduler/throughput tuning.
- `--max-num-seqs`: concurrency and scheduler-capacity tuning.
- `--gpu-memory-utilization`: platform memory-budget tuning.
- `--no-enable-prefix-caching`: workload/benchmark cache-policy tuning.
- `VLLM_ENGINE_ITERATION_TIMEOUT_S`: operational runtime timeout.
These settings may still appear in validated hardware-specific overrides. Tune
them at deployment time based on platform resources, workload shape, and
latency/throughput goals.
## Client Usage
### Audio Transcription
```python
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
response = client.chat.completions.create(
model="google/gemma-4-E2B-it",
messages=[{"role": "user", "content": [
{"type": "audio_url", "audio_url": {"url": "https://upload.wikimedia.org/wikipedia/commons/2/22/Beatbox_by_Wikipedia_user_Wikipedia_Brown.ogg"}},
{"type": "text", "text": "Provide a verbatim, word-for-word transcription of the audio."},
]}],
max_tokens=512,
)
print(response.choices[0].message.content)
```
### Image Understanding
```python
response = client.chat.completions.create(
model="google/gemma-4-E2B-it",
messages=[{"role": "user", "content": [
{"type": "image_url", "image_url": {"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg"}},
{"type": "text", "text": "Describe this image in detail."},
]}],
max_tokens=1024,
)
```
### Thinking Mode
Launch with reasoning parser, then enable per-request:
```bash
vllm serve google/gemma-4-E2B-it \
--max-model-len 16384 \
--reasoning-parser gemma4 \
--tool-call-parser gemma4 \
--enable-auto-tool-choice \
--chat-template examples/tool_chat_template_gemma4.jinja
```
Enable per-request via `extra_body={"chat_template_kwargs": {"enable_thinking": True}}`.
## Configuration Tips
- Set `--max-model-len` to match your workload (max 131072).
- Image-only workloads: `--limit-mm-per-prompt.audio 0`.
- Text-only workloads: `--limit-mm-per-prompt '{"image": 0, "audio": 0}'` to skip MM profiling.
- `--async-scheduling` improves throughput.
- FP8 KV cache (`--kv-cache-dtype fp8`) saves ~50% KV memory.
## Quantized Variant
[`RedHatAI/gemma-4-E2B-it-FP8-dynamic`](https://huggingface.co/RedHatAI/gemma-4-E2B-it-FP8-dynamic) is a pre-quantized FP8 (E4M3) checkpoint — linear weights with dynamic per-token activation quantization, vision/audio encoders kept in BF16. Runs on Hopper and Blackwell. Pick the **fp8** variant above, or pass the repo id directly to `vllm serve`.
## Speculative Decoding (MTP)
Enable the **Spec Decoding** feature toggle (above) or add `--speculative-config` manually to use MTP drafting with the [assistant model](https://huggingface.co/google/gemma-4-E2B-it-assistant). Recommended `num_speculative_tokens`: 2 for this model. The E2B assistant uses centroids masking for efficient sparse logit computation. See the [Gemma 4 usage guide](../../Google/Gemma4) for details and benchmarks.
> **Note:** MTP speculative decoding for Gemma 4 is only available on the vLLM nightly build — it has not yet landed in a stable release. Install via the nightly wheel (`uv pip install -U vllm --pre --extra-index-url https://wheels.vllm.ai/nightly/cu129 …`) or use the `vllm/vllm-openai:gemma4-0505-cu129` / `vllm/vllm-openai:gemma4-0505-cu130` images above; the standard `:latest` stable tag does not include this feature.
## References
- [Model card](https://huggingface.co/google/gemma-4-E2B-it)
- [FP8 variant](https://huggingface.co/RedHatAI/gemma-4-E2B-it-FP8-dynamic)
- [Gemma docs](https://ai.google.dev/gemma/docs)
- [vLLM Gemma 4 tool-call template](https://github.com/vllm-project/vllm/blob/main/examples/tool_chat_template_gemma4.jinja)
- [TPU recipes: Trillium](https://github.com/AI-Hypercomputer/tpu-recipes/tree/main/inference/trillium/vLLM/Gemma4)
- [TPU recipes: Ironwood](https://github.com/AI-Hypercomputer/tpu-recipes/blob/main/inference/ironwood/vLLM/Gemma4/)
+322
View File
@@ -0,0 +1,322 @@
meta:
title: "Gemma 4 E4B IT"
slug: "gemma-4-e4b-it"
provider: "Google"
description: "Google's compact Gemma 4 multimodal model (effective 4B) with native text, image, and audio, plus thinking mode and tool-use protocol."
date_added: 2026-04-02
date_updated: 2026-09-12
tasks:
- multimodal
- text
performance_headline: "Effective-4B unified multimodal model with audio, thinking, and function calling — runs on a single 24 GB+ GPU"
related_recipes:
- google/gemma-4-E2B-it
- google/gemma-4-31B-it
- google/gemma-4-26B-A4B-it
hardware:
h100: verified
mi300x: verified
mi325x: verified
mi355x: verified
trillium: verified
ironwood: verified
xeon6: verified
model:
model_id: "google/gemma-4-E4B-it"
min_vllm_version: "0.19.1"
architecture: dense
parameter_count: "8B"
active_parameters: "8B"
context_length: 131072
base_args: []
base_env: {}
dependencies:
- note: "Audio extras — needed to serve the audio modality"
command: 'uv pip install "vllm[audio]"'
optional: true
features:
tool_calling:
description: "Enable automatic tool choice with Gemma 4 parser and chat template"
args:
- "--enable-auto-tool-choice"
- "--tool-call-parser"
- "gemma4"
- "--chat-template"
- "examples/tool_chat_template_gemma4.jinja"
reasoning:
description: "Enable structured thinking/reasoning output"
args:
- "--reasoning-parser"
- "gemma4"
text_only:
description: "Skip loading the vision and audio encoders for text-only workloads — frees VRAM for KV cache. Mutually exclusive with encoder_parallel."
args:
- "--language-model-only"
spec_decoding:
description: "MTP speculative decoding with centroids masking for accelerated inference"
args:
- "--speculative-config"
- '{"model":"google/gemma-4-E4B-it-assistant","num_speculative_tokens":4}'
opt_in_features:
- text_only
- spec_decoding
variants:
default:
precision: bf16
vram_minimum_gb: 20
description: "Full BF16 — single 24 GB+ NVIDIA GPU or 1x MI300X/MI325X/MI350X/MI355Xi or 2x Xeon6/Xeon5 NUMA nodes"
supported_hardware: [h100, mi300x, mi325x, mi355x, trillium, ironwood, xeon6]
fp8:
model_id: "RedHatAI/gemma-4-E4B-it-FP8-dynamic"
precision: fp8
vram_minimum_gb: 10
description: "FP8 (E4M3) linear weights with dynamic per-token activation quantization (vision/audio encoders stay BF16) — Hopper or Blackwell"
supported_hardware: [h100]
extra_args:
- "--kv-cache-dtype"
- "fp8"
w4a16:
model_id: "google/gemma-4-E4B-it-qat-w4a16-ct"
precision: int4
vram_minimum_gb: 10
description: "W4A16 QAT (4-bit weights, 16-bit activations, group_size=32) via compressed-tensors — runs on any GPU"
supported_hardware: [h100, mi300x, mi325x, mi355x]
mobile:
model_id: "google/gemma-4-E4B-it-qat-mobile-ct"
precision: int2/4/8
vram_minimum_gb: 5
description: "Mobile QAT — mixed int2/4/8 compressed-tensors (int2 embeddings + lm_head + audio, int4 LLM attention + MLP, int8 vision + gates). 4.1× weight compression vs BF16, up to 1.5× faster decode at low batch"
supported_hardware: [h100, mi300x, mi325x, mi355x]
compatible_strategies:
- single_node_tp
- multi_node_tp
strategy_overrides:
single_node_tp:
tp: 1
guide: |
## Overview
[Gemma 4 E4B](https://huggingface.co/google/gemma-4-E4B-it) is Google's effective-4B unified multimodal model — text + images + audio in a single model, with structured thinking/reasoning, function calling, and dynamic vision resolution. It fits on a single 24 GB+ GPU.
Intel Xeon 6 CPU support remains verified. No additional benchmark-specific CPU
tuning is prescribed for general deployment.
### Key Features
- **Multimodal**: Text + images + audio natively (video via custom frame-extraction pipeline).
- **Dual Attention**: Alternating sliding-window (local) and global attention with different head dimensions.
- **Thinking Mode**: Structured reasoning via `<|channel>thought\n...<channel|>` delimiters.
- **Function Calling**: Custom tool-call protocol with dedicated special tokens.
- **Dynamic Vision Resolution**: Per-request configurable vision token budget (70, 140, 280, 560, 1120 tokens).
TPU support is provided through [vLLM TPU](https://github.com/vllm-project/tpu-inference) with recipes for [Trillium](https://github.com/AI-Hypercomputer/tpu-recipes/tree/main/inference/trillium/vLLM/Gemma4) and [Ironwood](https://github.com/AI-Hypercomputer/tpu-recipes/blob/main/inference/ironwood/vLLM/Gemma4/).
## Prerequisites
- Hardware: Intel Xeon 6/Xeon 5 CPUs
- vLLM >= 0.19.1
### pip (NVIDIA CUDA)
```bash
uv venv
source .venv/bin/activate
uv pip install -U vllm --pre \
--extra-index-url https://wheels.vllm.ai/nightly/cu129 \
--extra-index-url https://download.pytorch.org/whl/cu129 \
--index-strategy unsafe-best-match
```
### pip (AMD ROCm: MI300X, MI325X, MI350X, MI355X)
Requires Python 3.12, ROCm 7.2.1, glibc >= 2.35 (Ubuntu 22.04+).
```bash
uv venv --python 3.12
source .venv/bin/activate
uv pip install vllm --pre \
--extra-index-url https://wheels.vllm.ai/rocm/nightly/rocm721 --upgrade
```
### pip (Intel Xeon 6 CPUs)
For Intel and AMD x86 CPUs, follow the [CPU pre-built wheels](https://docs.vllm.ai/en/latest/getting_started/installation/cpu/#pre-built-wheels) installation instructions.
### Docker
```bash
docker pull vllm/vllm-openai:gemma4-0505-cu129 # NVIDIA Hopper (H100/H200, CUDA 12.9)
docker pull vllm/vllm-openai:gemma4-0505-cu130 # NVIDIA Blackwell (B200/B300, CUDA 13.0)
docker pull vllm/vllm-openai-rocm:latest # AMD
docker pull vllm/vllm-openai-cpu:latest-x86_64 # For Intel Xeon 6
```
## Deployment Configurations
### Quick Start (Single GPU)
```bash
vllm serve google/gemma-4-E4B-it \
--max-model-len 32768
```
### With Audio Support
```bash
vllm serve google/gemma-4-E4B-it \
--max-model-len 8192 \
--limit-mm-per-prompt '{"image": 4, "audio": 1}'
```
### Full-Featured Server Launch
Enables text, image, audio, thinking, and tool calling:
```bash
vllm serve google/gemma-4-E4B-it \
--max-model-len 16384 \
--gpu-memory-utilization 0.90 \
--enable-auto-tool-choice \
--reasoning-parser gemma4 \
--tool-call-parser gemma4 \
--chat-template examples/tool_chat_template_gemma4.jinja \
--limit-mm-per-prompt '{"image": 4, "audio": 1}' \
--async-scheduling \
--host 0.0.0.0 \
--port 8000
```
### Docker (NVIDIA)
```bash
docker run -itd --name gemma4-e4b \
--ipc=host --network host --shm-size 16G --gpus all \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai:gemma4-0505-cu129 \
--model google/gemma-4-E4B-it \
--max-model-len 32768 \
--host 0.0.0.0 --port 8000
```
Swap `vllm/vllm-openai:gemma4-0505-cu129` for `vllm/vllm-openai:gemma4-0505-cu130` on Blackwell (B200/B300).
### Docker (AMD MI300X/MI325X/MI350X/MI355X)
```bash
docker run -itd --name gemma4-rocm \
--ipc=host --network=host --privileged \
--cap-add=CAP_SYS_ADMIN --device=/dev/kfd --device=/dev/dri \
--group-add=video --cap-add=SYS_PTRACE \
--security-opt=seccomp=unconfined --shm-size 16G \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai-rocm:latest \
--model google/gemma-4-E4B-it \
--host 0.0.0.0 --port 8000
```
### Docker (Cloud TPU — Trillium / Ironwood)
TPU uses the separate `vllm/vllm-tpu` image (no pip wheel). Pull the tag specified by the upstream [Trillium](https://github.com/AI-Hypercomputer/tpu-recipes/tree/main/inference/trillium/vLLM/Gemma4) or [Ironwood](https://github.com/AI-Hypercomputer/tpu-recipes/blob/main/inference/ironwood/vLLM/Gemma4/) recipe, then run:
```bash
docker run -itd --name gemma4-tpu \
--privileged --network host --shm-size 16G \
-v /dev/shm:/dev/shm -e HF_TOKEN=$HF_TOKEN \
vllm/vllm-tpu:latest \
--model google/gemma-4-E4B-it \
--max-model-len 16384 \
--disable_chunked_mm_input \
--host 0.0.0.0 --port 8000
```
### Intel Xeon 6 Deployment via Docker
Launch the x86 CPU vLLM Docker container for `google/gemma-4-E4B-it`:
```bash
docker run \
--privileged --ipc=host -p 8000:8000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai-cpu:latest-x86_64 google/gemma-4-E4B-it \
--tensor-parallel-size 1 \
--enable-auto-tool-choice \
--tool-call-parser gemma4 \
--chat-template examples/tool_chat_template_gemma4.jinja \
--reasoning-parser gemma4
```
For additional Intel Xeon 6 deployment details, see the Intel Software Catalog entries for [Gemma 4 E4B IT](https://aiswcatalog.intel.com/models/google-gemma-4-e4b-it).
The following settings are intentionally not prescribed as portable CPU model
defaults because they depend on the workload, hardware, or runtime environment:
- `--max-num-batched-tokens`: scheduler/throughput tuning.
- `--max-num-seqs`: concurrency and scheduler-capacity tuning.
- `--gpu-memory-utilization`: platform memory-budget tuning.
- `--no-enable-prefix-caching`: workload/benchmark cache-policy tuning.
- `VLLM_ENGINE_ITERATION_TIMEOUT_S`: operational runtime timeout.
These settings may still appear in validated hardware-specific overrides. Tune
them at deployment time based on platform resources, workload shape, and
latency/throughput goals.
## Client Usage
### Audio Transcription
```python
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
response = client.chat.completions.create(
model="google/gemma-4-E4B-it",
messages=[{"role": "user", "content": [
{"type": "audio_url", "audio_url": {"url": "https://example.com/audio.wav"}},
{"type": "text", "text": "Transcribe this audio."},
]}],
max_tokens=512,
)
print(response.choices[0].message.content)
```
### Image Understanding
```python
response = client.chat.completions.create(
model="google/gemma-4-E4B-it",
messages=[{"role": "user", "content": [
{"type": "image_url", "image_url": {"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg"}},
{"type": "text", "text": "Describe this image in detail."},
]}],
max_tokens=1024,
)
```
### Thinking Mode
```bash
vllm serve google/gemma-4-E4B-it \
--max-model-len 16384 \
--reasoning-parser gemma4 \
--tool-call-parser gemma4 \
--enable-auto-tool-choice \
--chat-template examples/tool_chat_template_gemma4.jinja
```
Enable per-request via `extra_body={"chat_template_kwargs": {"enable_thinking": True}}`.
## Configuration Tips
- Set `--max-model-len` to match your workload (max 131072).
- Image-only workloads: `--limit-mm-per-prompt.audio 0`.
- Text-only workloads: `--limit-mm-per-prompt '{"image": 0, "audio": 0}'` to skip MM profiling.
- `--async-scheduling` improves throughput.
- FP8 KV cache (`--kv-cache-dtype fp8`) saves ~50% KV memory.
## Quantized Variant
[`RedHatAI/gemma-4-E4B-it-FP8-dynamic`](https://huggingface.co/RedHatAI/gemma-4-E4B-it-FP8-dynamic) is a pre-quantized FP8 (E4M3) checkpoint — linear weights with dynamic per-token activation quantization, vision/audio encoders kept in BF16. Runs on Hopper and Blackwell. Pick the **fp8** variant above, or pass the repo id directly to `vllm serve`.
## Speculative Decoding (MTP)
Enable the **Spec Decoding** feature toggle (above) or add `--speculative-config` manually to use MTP drafting with the [assistant model](https://huggingface.co/google/gemma-4-E4B-it-assistant). Recommended `num_speculative_tokens`: 4 for this model. The E4B assistant uses centroids masking for efficient sparse logit computation. See the [Gemma 4 usage guide](../../Google/Gemma4) for details and benchmarks.
> **Note:** MTP speculative decoding for Gemma 4 is only available on the vLLM nightly build — it has not yet landed in a stable release. Install via the nightly wheel (`uv pip install -U vllm --pre --extra-index-url https://wheels.vllm.ai/nightly/cu129 …`) or use the `vllm/vllm-openai:gemma4-0505-cu129` / `vllm/vllm-openai:gemma4-0505-cu130` images above; the standard `:latest` stable tag does not include this feature.
## References
- [Model card](https://huggingface.co/google/gemma-4-E4B-it)
- [FP8 variant](https://huggingface.co/RedHatAI/gemma-4-E4B-it-FP8-dynamic)
- [Gemma docs](https://ai.google.dev/gemma/docs)
- [vLLM Gemma 4 tool-call template](https://github.com/vllm-project/vllm/blob/main/examples/tool_chat_template_gemma4.jinja)
- [TPU recipes: Trillium](https://github.com/AI-Hypercomputer/tpu-recipes/tree/main/inference/trillium/vLLM/Gemma4)
- [TPU recipes: Ironwood](https://github.com/AI-Hypercomputer/tpu-recipes/blob/main/inference/ironwood/vLLM/Gemma4/)
- [Xeon 6 recipe: Gemma 4 E4B IT](https://aiswcatalog.intel.com/models/google-gemma-4-e4b-it)
@@ -0,0 +1,122 @@
meta:
title: "TranslateGemma 27B IT"
slug: "translategemma-27b-it"
provider: "Google"
description: "Lightweight open translation model from Google (based on Gemma 3) supporting 55 languages. Served via the vLLM-optimized Infomaniak-AI checkpoint."
date_added: 2026-03-06
date_updated: 2026-04-17
tasks:
- text
performance_headline: "Deployable on laptops/desktops and cloud GPUs; vLLM-optimized checkpoint removes custom JSON inputs"
related_recipes: []
model:
model_id: "google/translategemma-27b-it"
min_vllm_version: "0.14.1"
architecture: dense
parameter_count: "27B"
active_parameters: "27B"
context_length: 131072
base_args: []
base_env: {}
features: {}
opt_in_features: []
variants:
default:
precision: bf16
vram_minimum_gb: 65
description: "Original Google checkpoint in BF16 (has vLLM compatibility issues — prefer vllm-optimized variant)"
vllm_optimized:
model_id: "Infomaniak-AI/vllm-translategemma-27b-it"
precision: bf16
vram_minimum_gb: 65
description: "Infomaniak-AI vLLM-optimized checkpoint — recommended. Fixes RoPE config, EOS token, and replaces custom JSON inputs with string delimiters."
small_4b:
model_id: "google/translategemma-4b-it"
precision: bf16
vram_minimum_gb: 10
description: "4B variant for lower-resource deployments (prefer Infomaniak-AI/vllm-translategemma-4b-it)"
compatible_strategies:
- single_node_tp
- multi_node_tp
hardware_overrides: {}
strategy_overrides: {}
guide: |
## Overview
[TranslateGemma](https://huggingface.co/collections/google/translategemma) is a family of lightweight, state-of-the-art open translation models from Google, based on the Gemma 3 family. TranslateGemma models handle translation across 55 languages and are small enough to deploy on laptops, desktops, and modest cloud GPU environments.
### Original Models
- [google/translategemma-27b-it](https://huggingface.co/google/translategemma-27b-it)
- [google/translategemma-4b-it](https://huggingface.co/google/translategemma-4b-it)
### Optimized vLLM Models
- [Infomaniak-AI/vllm-translategemma-27b-it](https://huggingface.co/Infomaniak-AI/vllm-translategemma-27b-it)
- [Infomaniak-AI/vllm-translategemma-4b-it](https://huggingface.co/Infomaniak-AI/vllm-translategemma-4b-it)
### Why use the vLLM-optimized models?
The original Google models have compatibility issues with standard inference engines like vLLM. The optimized versions from Infomaniak-AI ([detailed changes](https://huggingface.co/Infomaniak-AI/vllm-translategemma-27b-it#changes-from-original-model)):
- **vLLM Compatibility**: Originals require custom JSON parameters (`source_lang_code`/`target_lang_code`). The optimized version uses string delimiters.
- **RoPE Simplification**: Originals use a complex RoPE configuration for sliding attention. Optimized uses a standard linear RoPE format (`factor: 8.0`).
- **EOS Token Fix**: Corrects the EOS token from `<end_of_turn>` to `<eos>`.
## Prerequisites
### Docker
```bash
docker pull vllm/vllm-openai:latest
```
## Deployment Configurations
Verified for both 4B and 27B:
```bash
docker run -itd --name google-translategemma-27b-it \
--ipc=host \
--network host \
--shm-size 16G \
--gpus all \
-v ~/.cache/huggingface:/root/.cache/huggingface \
vllm/vllm-openai:latest \
Infomaniak-AI/vllm-translategemma-27b-it \
--served-model-name translategemma-27b-it \
--gpu-memory-utilization 0.8 \
--host 0.0.0.0 \
--port 8000
```
## Client Usage
Tips:
- **Prompt Delimiters**: Encode language metadata directly in the content string:
`<<<source>>>{src_lang}<<<target>>>{tgt_lang}<<<text>>>{text}`
- **Language Codes**: ISO 639-1 Alpha-2 (e.g. `en`, `zh`) and regional variants (e.g. `en_US`, `zh_CN`).
- **Context Limit**: ~2K tokens.
### cURL
```bash
curl -X POST http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "translategemma-27b-it",
"messages": [{
"role": "user",
"content": "<<<source>>>en<<<target>>>zh<<<text>>>We distribute two models for language identification, which can recognize 176 languages."
}]
}'
```
## References
- [TranslateGemma collection](https://huggingface.co/collections/google/translategemma)
- [Infomaniak-AI optimized 27B](https://huggingface.co/Infomaniak-AI/vllm-translategemma-27b-it)
- [Infomaniak-AI optimized 4B](https://huggingface.co/Infomaniak-AI/vllm-translategemma-4b-it)