Views
No views yet
| Original (BF16) | NVFP4A16 (this) | |
|---|---|---|
| Size on disk | ~49 GB | ~16.5 GB |
| Compression | — | 3.0x |
| Total parameters | 25.2B | 25.2B |
| Active parameters | 3.8B | 3.8B |
| Architecture | MoE: 128 experts, 8 active/token | same |
| Context window | 256K tokens | 256K tokens |
| Modalities | Text, Image, Video | Text, Image, Video (all verified) |
| Quantization | — | W4A16 (FP4 weights, FP16 activations) |
transformers >= 5.4 (for Gemma 4 architecture support)--tf5 flaggemma4_patched.py for NVFP4 MoE scale key loading (see vLLM Patch)1docker run -d \
2 --name vllm-gemma-4 \
3 --gpus all --ipc=host --network host \
4 -e VLLM_NVFP4_GEMM_BACKEND=marlin \
5 -v /path/to/Gemma-4-26B-A4B-it-NVFP4A16:/model \
6 -v ~/.cache/huggingface:/root/.cache/huggingface \
7 -v /path/to/gemma4_patched.py:/usr/local/lib/python3.12/dist-packages/vllm/model_executor/models/gemma4.py \
8 <your-vllm-image> \
9 vllm serve /model \
10 --served-model-name gemma-4 \
11 --host 0.0.0.0 --port 8888 \
12 --quantization modelopt \
13 --dtype auto \
14 --kv-cache-dtype fp8 \
15 --gpu-memory-utilization 0.85 \
16 --max-model-len 65536 \
17 --max-num-seqs 4 \
18 --moe-backend marlin \
19 --trust-remote-code| Flag | Why |
|---|---|
--quantization modelopt | modelopt NVFP4 checkpoint format |
--moe-backend marlin | Marlin kernel for MoE expert layers |
--kv-cache-dtype fp8 | Saves memory for longer contexts |
-e VLLM_NVFP4_GEMM_BACKEND=marlin | Marlin for non-MoE layers (needed on SM 12.1) |
--trust-remote-code | Required for Gemma 4 |
1curl http://localhost:8888/v1/chat/completions \
2 -H "Content-Type: application/json" \
3 -d '{
4 "model": "gemma-4",
5 "messages": [{"role": "user", "content": "Hello! Tell me a joke."}],
6 "max_tokens": 200
7 }'nn.Parameter of shape [128, dim, dim]) instead of individual nn.Linear modules. NVIDIA Model Optimizer (modelopt) only quantizes nn.Linear — it silently skips the 3D expert parameters, which are 91% of the model._QuantGemma4TextExperts modelopt plugin that unfuses the 3D expert tensors into 128 × 3 individual nn.Linear layers before quantization. This follows the same pattern modelopt uses for Qwen3.5, Llama4, and DBRX MoE models. After quantization, a post-processing step renames the exported keys to match vLLM's expected format._nvfp4_selective_quant_cfg(["*"], weight_only=True)expert_params_mapping doesn't correctly map NVFP4 scale keys (.weight_scale, .weight_scale_2, .input_scale) to FusedMoE parameter names. The included gemma4_patched.py fixes this. A PR to upstream vLLM is forthcoming.1pip install torch transformers>=5.4 accelerate datasets
2git clone https://github.com/NVIDIA/Model-Optimizer.git
3pip install -e Model-Optimizer[all]
4pip install --force-reinstall transformers>=5.4 huggingface_hub>=1.5
5
6python quantize_gemma4_moe.py --qformat nvfp4_w4a16quantize_gemma4_moe.py.transformers >= 5.4 and the included gemma4_patched.py--moe-backend marlin required for correct MoE computation