> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/automodel/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/automodel/_mcp/server.

# Gemma 4

[Gemma 4](https://ai.google.dev/gemma) is Google's next-generation multimodal Gemma family, supporting image-text inputs with a Mixture-of-Experts (MoE) language backbone at larger scales. NeMo AutoModel replaces the HF-native dense matmul over experts with the NeMo `GroupedExperts` backend, enabling Expert Parallelism (EP) through the standard MoE parallelizer.

|                  |                                         |
| ---------------- | --------------------------------------- |
| **Task**         | Image-Text-to-Text                      |
| **Architecture** | `Gemma4ForConditionalGeneration`        |
| **Parameters**   | 2B – 31B (dense) · 26B-A4B (MoE)        |
| **HF Org**       | [google](https://huggingface.co/google) |

## Available Models

* **Gemma 4 E2B IT** (VL, dense, kv-shared layers)
* **Gemma 4 E4B IT** (VL, dense, kv-shared layers), **Gemma 4 E4B IT Assistant** (Assistant/drafter model for MTP)
* **Gemma 4 31B IT** (VL, dense)
* **Gemma 4 26B-A4B IT** (VL, MoE)

## Architecture

* `Gemma4ForConditionalGeneration`
* `Gemma4AssistantForCausalLM` (MTP drafter / assistant head for speculative decoding; co-trainable with the target Gemma 4 base using `Gemma4WithDrafter`)

## Example HF Models

| Model                    | HF ID                                                                           |
| ------------------------ | ------------------------------------------------------------------------------- |
| Gemma 4 E2B IT           | [`google/gemma-4-E2B-it`](https://huggingface.co/google/gemma-4-E2B-it)         |
| Gemma 4 E4B IT           | [`google/gemma-4-E4B-it`](https://huggingface.co/google/gemma-4-E4B-it)         |
| Gemma 4 31B IT           | [`google/gemma-4-31B-it`](https://huggingface.co/google/gemma-4-31B-it)         |
| Gemma 4 26B-A4B IT (MoE) | [`google/gemma-4-26B-A4B-it`](https://huggingface.co/google/gemma-4-26B-A4B-it) |

## Example Recipes

| Recipe                                                                                                                                           | Description                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------- |
| [gemma4\_2b.yaml](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/vlm_finetune/gemma4/gemma4_2b.yaml)                                | SFT — Gemma 4 E2B on MedPix                    |
| [gemma4\_2b\_peft.yaml](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/vlm_finetune/gemma4/gemma4_2b_peft.yaml)                     | LoRA — Gemma 4 E2B on MedPix                   |
| [gemma4\_4b.yaml](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/vlm_finetune/gemma4/gemma4_4b.yaml)                                | SFT — Gemma 4 E4B on MedPix                    |
| [gemma4\_4b\_peft.yaml](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/vlm_finetune/gemma4/gemma4_4b_peft.yaml)                     | LoRA — Gemma 4 E4B on MedPix                   |
| [gemma4\_31b.yaml](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/vlm_finetune/gemma4/gemma4_31b.yaml)                              | SFT — Gemma 4 31B on MedPix                    |
| [gemma4\_31b\_peft.yaml](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/vlm_finetune/gemma4/gemma4_31b_peft.yaml)                   | LoRA — Gemma 4 31B on MedPix                   |
| [gemma4\_31b\_tp4.yaml](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/vlm_finetune/gemma4/gemma4_31b_tp4.yaml)                     | SFT — Gemma 4 31B with TP=4                    |
| [gemma4\_31b\_tp4\_pp2.yaml](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/vlm_finetune/gemma4/gemma4_31b_tp4_pp2.yaml)            | SFT — Gemma 4 31B with TP=4, PP=2              |
| [gemma4\_31b\_tp4\_pp4.yaml](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/vlm_finetune/gemma4/gemma4_31b_tp4_pp4.yaml)            | SFT — Gemma 4 31B with TP=4, PP=4 (multi-node) |
| [gemma4\_26b\_a4b\_moe.yaml](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/vlm_finetune/gemma4/gemma4_26b_a4b_moe.yaml)            | SFT — Gemma 4 26B-A4B MoE on MedPix            |
| [gemma4\_26b\_a4b\_moe\_peft.yaml](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/vlm_finetune/gemma4/gemma4_26b_a4b_moe_peft.yaml) | LoRA — Gemma 4 26B-A4B MoE on MedPix           |

## Try with NeMo AutoModel

**1. Install** ([full instructions](/get-started/installation)):

```bash
pip install nemo-automodel
```

**2. Clone the repo** to get the example recipes:

```bash
git clone https://github.com/NVIDIA-NeMo/Automodel.git
cd Automodel
```

**3. Run the recipe** from inside the repo:

```bash
automodel --nproc-per-node=8 examples/vlm_finetune/gemma4/gemma4_4b.yaml
```

**1. Pull the container** and mount a checkpoint directory:

```bash
docker run --gpus all -it --rm \
  --shm-size=8g \
  -v $(pwd)/checkpoints:/opt/Automodel/checkpoints \
  nvcr.io/nvidia/nemo-automodel:26.06.00
```

**2. Navigate to the AutoModel directory** (where the recipes are):

```bash
cd /opt/Automodel
```

**3. Run the recipe**:

```bash
automodel --nproc-per-node=8 examples/vlm_finetune/gemma4/gemma4_4b.yaml
```

See the [Installation Guide](/get-started/installation) and [VLM Fine-Tuning Guide](/recipes-e2e-examples/gemma-3-3n).

## Fine-Tuning

See the [VLM Fine-Tuning Guide](/recipes-e2e-examples/gemma-3-3n).

## Hugging Face Model Cards

* [google/gemma-4-E2B-it](https://huggingface.co/google/gemma-4-E2B-it)
* [google/gemma-4-E4B-it](https://huggingface.co/google/gemma-4-E4B-it)
* [google/gemma-4-31B-it](https://huggingface.co/google/gemma-4-31B-it)
* [google/gemma-4-26B-A4B-it](https://huggingface.co/google/gemma-4-26B-A4B-it)