Views
No views yet
nvidia/Gemma-4-31B-IT-NVFP4),
only the MLP / feed-forward linear layers are quantized to 4-bit, while the
attention projections (q/k/v/o) are kept in BF16. Gemma 4's attention
activations carry large per-channel outliers that 4-bit quantization cannot
represent well, so quantizing attention degrades quality and breaks several
inference kernels. Keeping attention in BF16 avoids this.lm_head are also kept at full
precision.| Base model | google/gemma-4-12B-it (dense, 11.95B params) |
| Method | auto-round, RTN mode (--iters 0 --disable_opt_rtn) |
| Scheme | W4A16, group size 128, symmetric |
| Quantized layers | MLP only (gate_proj, up_proj, down_proj) |
| Kept in BF16 | attention (q/k/v/o), embeddings, lm_head, vision/audio |
| Format | auto_gptq (GPTQ-compatible) |
| Checkpoint size | ~11 GB (vs ~24 GB BF16) |
cu129 URLs on CUDA 12.9 hosts):1uv pip install -U vllm --pre \
2 --extra-index-url https://wheels.vllm.ai/nightly/cu130 \
3 --extra-index-url https://download.pytorch.org/whl/cu130 \
4 --index-strategy unsafe-best-match1export VLLM_USE_FLASHINFER_SAMPLER=0
2vllm serve <path-to-this-model> \
3 --served-model-name gemma4-12b \
4 --max-model-len 8192 \
5 --gpu-memory-utilization 0.90 \
6 --host 0.0.0.0 --port 8000--max-model-len accordingly). Recommended sampling for Gemma 4:
temperature=1.0, top_p=0.95, top_k=64.1curl http://localhost:8000/v1/chat/completions \
2 -H "Content-Type: application/json" \
3 -d '{
4 "model": "gemma4-12b",
5 "messages": [{"role": "user", "content": "Explain quantization in one paragraph."}],
6 "max_tokens": 200, "temperature": 1.0, "top_p": 0.95, "top_k": 64
7 }'gptqmodel):pip install transformers torch gptqmodel optimum1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_id = "aleksandard/gemma-4-12B-it-int4-MLPonly-AutoRound"
4tok = AutoTokenizer.from_pretrained(model_id)
5model = AutoModelForCausalLM.from_pretrained(
6 model_id, torch_dtype="auto", device_map="cuda"
7)
8
9messages = [{"role": "user", "content": "Explain quantization in one paragraph."}]
10ids = tok.apply_chat_template(
11 messages, add_generation_prompt=True, return_tensors="pt", return_dict=False
12).to("cuda")
13out = model.generate(ids, max_new_tokens=256)
14print(tok.decode(out[0][ids.shape[-1]:], skip_special_tokens=True))VLLM_USE_FLASHINFER_SAMPLER=0 is required to avoid a
FlashInfer JIT-compile failure during sampling.1auto-round \
2 --model google/gemma-4-12B-it \
3 --scheme W4A16 \
4 --iters 0 \
5 --disable_opt_rtn \
6 --layer_config '{"model.language_model.layers.\d+.self_attn.q_proj":{"bits":16},"model.language_model.layers.\d+.self_attn.k_proj":{"bits":16},"model.language_model.layers.\d+.self_attn.v_proj":{"bits":16},"model.language_model.layers.\d+.self_attn.o_proj":{"bits":16}}' \
7 --format auto_gptq \
8 --output_dir ./gemma-4-12B-it-int4-MLPonly