Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
28c0a43
[None][feat] Add Gemma4 MTP assistant support
lfr-0531 Jul 1, 2026
80522a4
[None][docs] Document Gemma4 MTP support
lfr-0531 Jul 1, 2026
66faefd
[None][docs] Remove Gemma4 MTP footnote
lfr-0531 Jul 1, 2026
b075c1c
[None][fix] Avoid Gemma4 Bandit false positive
lfr-0531 Jul 2, 2026
2276ccd
[None][fix] Fix Gemma4 MTP decoding correctness
lfr-0531 Jul 21, 2026
ff036a4
[None][perf] Restore Gemma4 assistant CUDA graph replay
lfr-0531 Jul 21, 2026
2c91e64
[None][fix] Harden Gemma4 MTP runtime integration
lfr-0531 Jul 21, 2026
a0470c2
[None][fix] Avoid redundant Gemma4 assistant KV cache
lfr-0531 Jul 24, 2026
02fd45e
[None][test] Clarify Gemma4 MTP graph pool coverage
lfr-0531 Jul 24, 2026
8ac60c4
feat: move Gemma4 MTP to one-model shared KV
lfr-0531 Jul 24, 2026
e567d43
[None][refactor] minimize Gemma4 MTP integration
lfr-0531 Jul 26, 2026
02f6283
[None][refactor] minimize Gemma4 MTP VLM proxies
lfr-0531 Jul 27, 2026
988d31d
[None][refactor] use native FlashInfer decode for Gemma4 MTP
lfr-0531 Jul 27, 2026
0d2bb3c
[None][refactor] generalize shared-KV MTP integration
lfr-0531 Jul 27, 2026
da665e4
[None][refactor] generalize shared-KV draft capability
lfr-0531 Jul 27, 2026
f58eac0
[None][refactor] refine shared-KV FlashInfer integration
lfr-0531 Jul 27, 2026
192d76b
[None][refactor] scope shared-KV config to Gemma4
lfr-0531 Jul 27, 2026
9529bbb
[None][fix] stabilize Gemma4 shared-KV MTP
lfr-0531 Jul 28, 2026
b89c10b
[None][feat] support separate-KV FlashInfer drafting
lfr-0531 Jul 28, 2026
2e8c4de
[None][refactor] simplify Gemma4 shared-KV MTP integration
lfr-0531 Jul 28, 2026
5ade312
[None][refactor] simplify Gemma4 MTP helpers and tests
lfr-0531 Jul 28, 2026
a9881dc
[None][refactor] simplify Gemma4 config and embedding sharing
lfr-0531 Jul 28, 2026
1937164
[None][refactor] address Gemma4 review feedback
lfr-0531 Jul 29, 2026
660735f
[None][fix] fix speculative decoding CI regressions
lfr-0531 Jul 29, 2026
5dcaf06
[None][fix] harden Gemma4 speculative draft setup
lfr-0531 Jul 31, 2026
8df01d7
[None][fix] scope FlashInfer one-engine guard
lfr-0531 Aug 3, 2026
4207c44
Merge branch 'main' into user/fanrongl/gemma4-mtp-support
lfr-0531 Aug 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/source/models/supported-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The following is a table of supported models for the PyTorch backend:
| `Gemma3nForConditionalGeneration` [^7]| Gemma 3n | `google/gemma-3n-E2B-it`, `google/gemma-3n-E4B-it` |
| `Gemma4ForConditionalGeneration` | Gemma 4 | `google/gemma-4-E2B-it`, `google/gemma-4-E4B-it`, `google/gemma-4-26B-A4B-it` [^6], `google/gemma-4-31B-it` [^6] |
| `Gemma4UnifiedForConditionalGeneration` | Gemma 4 12B Unified (encoder-free) | `google/gemma-4-12B`, `google/gemma-4-12B-it` |
| `Gemma4AssistantForCausalLM` | Gemma 4 MTP assistant | `google/gemma-4-E2B-it-assistant`, `google/gemma-4-E4B-it-assistant`, `google/gemma-4-26B-A4B-it-assistant`, `google/gemma-4-31B-it-assistant` |
| `Glm4MoeForCausalLM` | GLM-4.5, GLM-4.6, GLM-4.7 | `THUDM/GLM-4-100B-A10B` |
| `Glm4MoeLiteForCausalLM` [^5] | GLM-4.7-Flash | `zai-org/GLM-4.7-Flash` |
| `GlmMoeDsaForCausalLM` | GLM-5 | `zai-org/GLM-5` |
Expand Down Expand Up @@ -76,7 +77,7 @@ Note: Support for other models may vary. Features marked "N/A" are not applicabl
| `GptOssForCausalLM` | Yes | Yes | Yes | Yes | Yes | No | Yes | No | Yes | Yes | Yes | Yes | N/A | Yes | Yes |
| `Glm4MoeLiteForCausalLM` [^5] | Yes | Yes | Untested | Untested | Yes | No | No | No | No | Yes | Untested | Untested | N/A | Untested | Untested |
| `NemotronHForCausalLM` | Yes | Yes | Yes | Yes | Yes | Yes | No | No | No | Yes | Yes | Yes | N/A | Untested | Untested |
| `Gemma4ForConditionalGeneration` | Untested | Yes | Untested | No | Yes | No | No | No | No | Yes | Untested | No | Yes | Untested | Untested |
| `Gemma4ForConditionalGeneration` | Untested | Yes | Untested | No | Yes | Yes | No | No | No | Yes | Untested | No | Yes | Untested | Untested |
| `Gemma4UnifiedForConditionalGeneration` | Untested | Untested | Untested | No | Yes | No | No | No | No | Yes | Untested | No | Yes | Untested | Untested |
| `Step3p7ForConditionalGeneration`| Yes | Yes | Yes | Untested | Untested | Yes | No | No | No | Yes | Untested | Untested | Yes | Untested | Untested |
| `MiniMaxM3SparseForConditionalGeneration` [^12] | Yes | Yes | Yes | Untested | Untested | No | No | No | No | Yes | Untested | No | N/A | Untested | Untested |
Expand Down
4 changes: 3 additions & 1 deletion examples/llm-api/quickstart_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ def setup_llm(args, **kwargs):
if spec_decode_algo == 'MTP':
if not args.use_one_model:
print("Running MTP eagle with two model style.")
speculative_model = (args.draft_model_dir if args.draft_model_dir
is not None else args.model_dir)
spec_config = MTPDecodingConfig(
max_draft_len=args.spec_decode_max_draft_len,
use_relaxed_acceptance_for_thinking=args.
Expand All @@ -318,7 +320,7 @@ def setup_llm(args, **kwargs):
use_dynamic_tree=args.use_dynamic_tree,
dynamic_tree_max_topK=args.dynamic_tree_max_topK,
max_total_draft_tokens=args.max_total_draft_tokens,
speculative_model=args.model_dir)
speculative_model=speculative_model)
elif spec_decode_algo == "EAGLE3":
spec_config = Eagle3DecodingConfig(
max_draft_len=args.spec_decode_max_draft_len,
Expand Down
55 changes: 49 additions & 6 deletions examples/models/core/gemma/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ loaded directly. The legacy TensorRT engine flow (`convert_checkpoint.py` /

Gemma 4 runs on the **PyTorch backend** — HuggingFace checkpoints are loaded directly. The legacy TensorRT engine flow (`convert_checkpoint.py` / `trtllm-build`) is not required and is not covered here.

| HuggingFace checkpoint | Modalities | Notes |
|-------------------------------|----------------------------------|----------------------------------------|
| `google/gemma-4-E2B-it` | text + image + video + audio | Single-GPU friendly |
| `google/gemma-4-E4B-it` | text + image + video + audio | Single-GPU friendly |
| `google/gemma-4-26B-A4B-it` | text + image + video (MoE) | Multi-GPU recommended; no audio tower |
| `google/gemma-4-31B-it` | text + image + video | Multi-GPU recommended; no audio tower |
| HuggingFace checkpoint | Modalities | Matching MTP assistant | Notes |
| --------------------------- | ---------------------------- | ---------------------------------------------- | ------------------------------------- |
| `google/gemma-4-E2B-it` | text + image + video + audio | `google/gemma-4-E2B-it-assistant` | Single-GPU friendly |
| `google/gemma-4-E4B-it` | text + image + video + audio | `google/gemma-4-E4B-it-assistant` | Single-GPU friendly |
| `google/gemma-4-26B-A4B-it` | text + image + video (MoE) | `google/gemma-4-26B-A4B-it-assistant` | Multi-GPU recommended; no audio tower |
| `google/gemma-4-31B-it` | text + image + video | `google/gemma-4-31B-it-assistant` | Multi-GPU recommended; no audio tower |

All four variants ship the vision tower (image + video). The audio tower is only present on `E2B` / `E4B`. The examples below use `google/gemma-4-E4B-it` (small, full multimodal) — swap the model name for the other variants and bump `--tp_size` (e.g. `4` or `8`) for the larger checkpoints.

Expand Down Expand Up @@ -47,6 +47,49 @@ curl http://localhost:8000/v1/chat/completions \

The `/v1/chat/completions` endpoint applies the Gemma 4 chat template automatically.

### MTP speculative decoding

Gemma 4 supports Multi-Token Prediction (MTP) speculative decoding through the
PyTorch execution path. The target loads its matching assistant checkpoint,
and the Q-only assistant reads the target model's KV cache. Create a server
configuration for the target/assistant pair:

```bash
cat > gemma4_mtp.yaml <<'EOF'
speculative_config:
decoding_type: MTP
max_draft_len: 3
mtp_eagle_one_model: true
speculative_model: google/gemma-4-E4B-it-assistant
kv_cache_config:
enable_block_reuse: false
EOF

trtllm-serve google/gemma-4-E4B-it \
--host 0.0.0.0 \
--port 8000 \
--config gemma4_mtp.yaml
```

The assistant shares the target model's KV cache, so TensorRT-LLM does not
allocate a second full-size GPU KV cache for it. The current implementation
supports the `Gemma4AssistantForCausalLM` assistants for E2B, E4B, 26B-A4B,
and 31B. Gemma 4 12B uses the `Gemma4UnifiedForConditionalGeneration` and
`Gemma4UnifiedAssistantForCausalLM` architectures, which are not supported.
Comment thread
coderabbitai[bot] marked this conversation as resolved.

For offline inference, pass both checkpoints to the advanced LLM API example:

```bash
python3 examples/llm-api/quickstart_advanced.py \
--model_dir google/gemma-4-E4B-it \
--draft_model_dir google/gemma-4-E4B-it-assistant \
--spec_decode_algo MTP \
--spec_decode_max_draft_len 3 \
--use_one_model \
--disable_kv_cache_reuse \
--apply_chat_template
```

### Accuracy evaluation with `trtllm-eval`

`trtllm-eval` is the canonical entry point for accuracy benchmarks. Two tasks relevant to Gemma 4:
Expand Down
Loading
Loading