gemma-4-12B-it ยท NVFP4 (W4A4, FP4)
4-bit quantization of google/gemma-4-12B-it, produced for efficient vLLM serving. Quantized by axteam.
| Base model | google/gemma-4-12B-it |
| Method | NVFP4 (W4A4, FP4) |
| Format | compressed-tensors nvfp4-pack-quantized |
| Weights / activations | W4A4 โ FP4 (E2M1) weights group 16 (FP8 E4M3 scale + per-tensor FP32 global scale), FP4 activations |
| Architecture | Gemma 4 ยท Dense |
| Size on disk | ~8.3 GB |
| Calibration | 224 samples (Korean-heavy; no thinking-mode answers โ none were generated for this model) |
| License | Gemma 4 / Apache-2.0 |
Quantization details
- Scheme โ W4A4 โ FP4 (E2M1) weights group 16 (FP8 E4M3 scale + per-tensor FP32 global scale), FP4 activations, stored as compressed-tensors
nvfp4-pack-quantized. - Kept in BF16 โ the patch embedder (
vision_embedder), vision/audio projections, token embeddings (tied with lm_head), and all norms โ this Unified model has no separate vision encoder, so image/audio tokens pass through the quantized decoder. These stay unquantized to preserve quality โ about 9% of all parameters in this build. - Tokenizer /
chat_template/processor_config/generation_configare byte-identical to the original, including Google's July-2026 correctedchat_template.config.jsonis the original plus aquantization_configblock. Quantized fromgoogle/gemma-4-12B-itat commit707f0a3; Google replacedtokenizer.jsonon 2026-10-30 (commit43c9d01, glitch-token fix), which this repo does not include yet.
Quantization method โ PTQ (AWQ / RTN) vs QAT
This model is a post-training quantization (PTQ): the released BF16 weights are quantized after training, with no retraining. How close each build stays to BF16 is reported in the measured sections where available.
- RTN (round-to-nearest) โ weights are simply rounded to the quantization grid with per-group scales; no calibration data. Fastest, but outliers aren't compensated, so 4-bit fidelity is the lowest. Not used for this model's AWQ-8bit, AWQ-4bit, NVFP4A16 and NVFP4 builds, which all apply AWQ (see each repo's
recipe.yaml). - AWQ (activation-aware weight quantization) โ a small calibration set finds the weight channels that multiply the largest activations; those salient channels are protected by per-channel scaling (the scale is folded into adjacent layers, e.g. LayerNorm โ q/k/v) before rounding. Still PTQ (no gradient, secondsโminutes), and far better than RTN at 4-bit.
- QAT (quantization-aware training) โ the model is fine-tuned with quantization simulated in the forward pass, so the weights adapt to quantization error via gradient descent. Best low-bit fidelity, but needs the full training stack, data and GPU hours. Google ships separate Gemma QAT checkpoints; this repo is not one of them.
Rough low-bit fidelity: QAT โฅ AWQ > RTN. Cost: QAT โซ AWQ > RTN. This build: AWQ โ a calibration-based PTQ (224-sample calibration, no gradient).
Benchmarks (measured)
Every column was measured with the same harness and settings โ lm-evaluation-harness on vLLM, greedy, completion-style prompts without a chat template (0- or 5-shot, as listed in each row). MMLU here is lm-eval's generative variant (mmlu_generative: the model writes the answer letter and only an exact match on the first line counts), so it is not directly comparable with MMLU scores measured another way (e.g. log-likelihood scoring). Percentages are recovery vs. the BF16 original.
| Benchmark | BF16 (original) | FP8-dynamic | AWQ-8bit | NVFP4A16 | NVFP4 (this repo) | AWQ-4bit |
|---|---|---|---|---|---|---|
| MMLU (5-shot, generative) | 65.40 | 65.90 (100.8%) | 65.80 (100.6%) | 67.00 (102.4%) | 62.78 (96.0%) | 63.42 (97.0%) |
| GSM8K (5-shot, strict) | 63.38 | 68.99 (108.9%) | 65.05 (102.6%) | 64.59 (101.9%) | 60.42 (95.3%) | 63.46 (100.1%) |
| ARC-Challenge (0-shot) | 42.32 | 41.64 (98.4%) | 39.59 (93.5%) | 37.63 (88.9%) | 40.96 (96.8%) | 40.61 (96.0%) |
| Winogrande (5-shot) | 61.80 | 61.56 (99.6%) | 62.75 (101.5%) | 60.14 (97.3%) | 58.72 (95.0%) | 61.17 (99.0%) |
| KMMLU (5-shot, direct) | 43.28 | 42.59 (98.4%) | 43.60 (100.7%) | 39.00 (90.1%) | 33.66 (77.8%) | 34.01 (78.6%) |
| HAE-RAE (0-shot) | 64.62 | 64.62 (100.0%) | 65.08 (100.7%) | 62.51 (96.7%) | 58.75 (90.9%) | 59.30 (91.8%) |
| Average | 56.80 | 57.55 (101.3%) | 56.98 (100.3%) | 55.15 (97.1%) | 52.55 (92.5%) | 53.66 (94.5%) |
โ ๏ธ Note: average recovery is 92.5% โ noticeable degradation at this precision; prefer an 8-bit build if quality matters most.
Evaluation (measured)
Measured against the BF16 original on an internal mixed English/Korean set. Quantization variant: AWQ attention + MLP(gate/up).
| Metric | This model | BF16 original |
|---|---|---|
| Perplexity (lower is better) | 1.4465 | 1.1488 (+25.9%) |
| Top-1 next-token agreement | 87.4% | 99.2% |
These numbers measure fidelity to the base model, not absolute task scores.
Requirements
| Runtime | vLLM โ the architecture is in vLLM โฅ 0.23.0; tested here with vLLM 0.32.0. |
| vLLM install | vLLM 0.32 itself needs Python 3.11โ3.14, torch 2.13 (CUDA 13.0 build, so an NVIDIA driver with CUDA 13 support), transformers โฅ5.16.1,<5.20 and compressed-tensors 0.17.0 (both pinned by vLLM; 0.17.0 reads this checkpoint, which was saved with 0.19.0 โ do not upgrade it separately). |
| GPU | Full FP4 (W4A4) speed on Blackwell โ B200/GB200 (sm100), B300 (sm103), RTX 50xx / RTX PRO 6000 (sm120). TuringโHopper (sm75โ90) fall back to weight-only FP4 (slower, vLLM warns). V100 (sm70) is not supported. (Kernel choice per GPU from vLLM 0.32's selection code; only B200 was run here.) |
| Memory | Weights: 8.3 GB. Add KV cache (grows with context length ร concurrent requests) and a few GB for activations / CUDA graphs; use --tensor-parallel-size N when the weights do not fit one GPU. |
| Transformers (without vLLM) | transformers>=5.10.1 + compressed-tensors>=0.15.0 for text. Image input under Transformers is broken for the AWQ / NVFP4 builds (their ignore list misses the renamed vision modules). |
| trust_remote_code | not needed |
Usage (vLLM)
vllm serve axteam/gemma-4-12B-it-NVFP4
from vllm import LLM, SamplingParams
llm = LLM(model="axteam/gemma-4-12B-it-NVFP4")
params = SamplingParams(temperature=1.0, top_p=0.95, top_k=64, max_tokens=1024)
out = llm.chat(
[{"role": "user", "content": "Write a short joke about saving RAM."}],
params,
)
print(out[0].outputs[0].text)
Recommended sampling (per Google):
temperature=1.0,top_p=0.95,top_k=64. Thinking mode is off by default; turn it on withchat_template_kwargs={"enable_thinking": True}(Pythonllm.chat(..., chat_template_kwargs=...)or the request body), and add--reasoning-parser gemma4tovllm serveto return the reasoning separately. Full speed needs Blackwell FP4 tensor cores (e.g. B200, RTX PRO 6000); older GPUs run it through slower fallback kernels.
Reducing KV-cache memory (optional, serve-time)
The KV cache is unquantized (BF16) here โ the standard for quantized checkpoints (RedHatAI, NVIDIA, etc. ship the same way). KV-cache precision is a runtime choice, independent of the weight quantization above. For long context or large batches you can roughly halve KV-cache memory with FP8:
vllm serve axteam/gemma-4-12B-it-NVFP4 --kv-cache-dtype fp8
--kv-cache-dtypeacceptsauto(default, BF16),fp8/fp8_e4m3,fp8_e5m2. For a GGUF build the llama.cpp equivalent is--cache-type-k q8_0 --cache-type-v q8_0.
License
This is a quantized derivative of Google's Gemma 4. Use is governed by the Gemma 4 license. All original weights, tokenizer, and chat template belong to Google DeepMind.
ํ๊ตญ์ด ์์ฝ
google/gemma-4-12B-it์ NVFP4 (W4A4) ์์ํ ๋น๋ ยท ์ ์ axteam
๊ฐ์
| ํญ๋ชฉ | ๋ด์ฉ |
|---|---|
| ์๋ณธ ๋ชจ๋ธ | google/gemma-4-12B-it |
| ์์ํ ๋ฐฉ์ | NVFP4 (W4A4, ๊ฐ์ค์นยทํ์ฑํ FP4) |
| ์ ์ฅ ํ์ | compressed-tensors nvfp4-pack-quantized |
| ๋ชจ๋ธ ๊ตฌ์กฐ | Gemma 4 ยท Dense |
| ์ฉ๋ | ์ฝ 8.3 GB |
| ๋ณด์ ๋ฐ์ดํฐ | ์ํ 224๊ฐ (ํ๊ตญ์ด ์์ฃผ, thinking ๋ชจ๋ ๋ต๋ณ ์์) |
์์ํ ์์ธ
- ๊ฐ์ค์น: FP4(E2M1), ๊ทธ๋ฃน ํฌ๊ธฐ 16 (๊ทธ๋ฃน๋ณ FP8(E4M3) ์ค์ผ์ผ + ํ ์๋ณ FP32 ์ ์ญ ์ค์ผ์ผ)
- ํ์ฑํ: ์คํ ์ FP4 (Blackwell FP4 ํ ์์ฝ์ด์์ ๊ฐ์)
- ์์ํ ์ ์ฐจ: PTQ(ํ์ต ํ ์์ํ, ์ฌํ์ต ์์), AWQ ๋ฐฉ์ โ ๋ณด์ ๋ฐ์ดํฐ๋ก ํ์ฑํ๊ฐ ํฐ ๊ฐ์ค์น ์ฑ๋์ ์ฐพ์ ์ฑ๋๋ณ ์ค์ผ์ผ๋ก ๋ณดํธํ ๋ค FP4๋ก ๋ฐ์ฌ๋ฆผ
- AWQ ์ ์ฉ ๋ฒ์: ์ดํ ์ ์ ๋ ฅยทMLP(gate/up)
- BF16 ์ ์ง: ํจ์น ์๋ฒ ๋(
vision_embedder), ๋น์ ยท์ค๋์ค ํฌ์์ธต, ํ ํฐ ์๋ฒ ๋ฉ(LM ํค๋์ ๊ณต์ ), ๋ชจ๋ ์ ๊ทํ์ธต โ ์ ์ฒด ํ๋ผ๋ฏธํฐ์ ์ฝ 9% - ์์ํ ๋์: ๋์ฝ๋์ ์ดํ ์ ยทMLP ์ ํ์ธต(projection), ๋ณ๋ ๋น์ ์ธ์ฝ๋๊ฐ ์๋ Unified ๊ตฌ์กฐ๋ผ ์ด๋ฏธ์งยท์ค๋์ค ํ ํฐ๋ ์์ํ๋ ๋์ฝ๋๋ฅผ ๊ฑฐ์นจ
- ์๋ณธ ํ์ผ: ํ ํฌ๋์ด์ ยทchat template(Google์ 2026๋
7์ ์์ ๋ณธ)ยทprocessorยทgeneration config๋ฅผ ๋ฐ์ดํธ ๋จ์๋ก ๊ทธ๋๋ก ์ฌ์ฉ,
config.json์ ์๋ณธ์quantization_config๋ธ๋ก๋ง ์ถ๊ฐ - ์๋ณธ ์ปค๋ฐ:
google/gemma-4-12B-it์ปค๋ฐ707f0a3๊ธฐ์ค โ Google์ด 2026-10-30์ ๊ต์ฒดํtokenizer.json(์ปค๋ฐ43c9d01, glitch token ์์ )์ ์์ง ๋ฏธ๋ฐ์
ํ์ง (์ค์ธก)
- ์๋ณธ ๋๋น ์ถฉ์ค๋: PPL 1.4465 (์๋ณธ 1.1488, +25.9%, ๋ฎ์์๋ก ์๋ณธ์ ๊ฐ๊น์), ๋ค์ ํ ํฐ top-1 ์ผ์น์จ 87.4% (์๋ณธ ์์ฒด ๊ธฐ์ค๊ฐ 99.2%) โ ๋ด๋ถ ์์ดยทํ๊ตญ์ด ํผํฉ ํ๊ฐ์ , ์๋ณธ(BF16)๊ณผ ๋น๊ต ์ธก์
- ๋ฒค์น๋งํฌ ํ๊ท : 52.55 (์๋ณธ 56.80, 92.5%) โ MMLU(์์ฑํ)ยทGSM8KยทARC-ChallengeยทWinograndeยทKMMLUยทHAE-RAE 6์ข ํ๊ท , lm-evaluation-harness + vLLM, chat template ์๋ ์์ฑํ ํ๋กฌํํธ(๊ณผ์ ๋ณ 0ยท5-shot, ํ ์ฐธ๊ณ )ยทgreedy, ๋ชจ๋ ๋น๋๋ฅผ ๊ฐ์ ์ค์ ์ผ๋ก ์ธก์
- ํ๊ตญ์ด ๋ฒค์น๋งํฌ: KMMLU 33.66 (์๋ณธ 43.28, 77.8%) ยท HAE-RAE 58.75 (์๋ณธ 64.62, 90.9%)
- MMLU ๋ฐฉ์: lm-eval ์์ฑํ ๋ณํ(
mmlu_generative) โ ๋ชจ๋ธ์ด ๋ต ๊ธ์๋ฅผ ์์ฑํ๊ณ ์ฒซ ์ค์ด ์ ํํ ์ผ์นํด์ผ ์ ๋ต์ผ๋ก ์ฑ์ ํ๋ฏ๋ก, ๋ค๋ฅธ ๋ฐฉ์(์: log-likelihood ์ฑ์ )์ผ๋ก ์ฐ MMLU ์ ์์ ์ง์ ๋น๊ต ๋ถ๊ฐ - ์ฃผ์: โ ๏ธ ์ด ์ ๋ฐ๋์์ ํ์ง ์ ํ๊ฐ ๋๋ ทํจ (PPL +25.9%, ๋ฒค์น๋งํฌ ํ๊ท ์๋ณธ ๋๋น 92.5%) โ ํ์ง์ด ์ค์ํ๋ฉด 8๋นํธ(FP8ยทAWQ-8bit) ๋น๋ ๊ถ์ฅ
์๊ตฌ์ฌํญ
- ์คํ ์์ง: vLLM 0.23.0 ์ด์(์ด ๊ตฌ์กฐ๋ฅผ ์ง์ํ๋ ์ฒซ ๋ฒ์ ), ์ด ๋น๋๋ vLLM 0.32.0์์ ์คํ ํ์ธ
- vLLM 0.32 ์ค์น ์กฐ๊ฑด: Python 3.11~3.14, torch 2.13(CUDA 13.0 ๋น๋, CUDA 13 ์ง์ ๋๋ผ์ด๋ฒ ํ์), transformers 5.16.1 ์ด์ 5.20 ๋ฏธ๋ง, compressed-tensors 0.17.0 โ transformersยทcompressed-tensors๋ vLLM์ด ๋ฒ์ ์ ๊ณ ์ ํ๋ฏ๋ก compressed-tensors๋ฅผ ๋ฐ๋ก ์ ๊ทธ๋ ์ด๋ํ์ง ๋ง ๊ฒ (์ด ์ฒดํฌํฌ์ธํธ๋ 0.19.0์ผ๋ก ์ ์ฅ๋์ง๋ง 0.17.0์์๋ ๋ก๋๋จ)
- GPU: Blackwell(B200ยทGB200 sm100, B300 sm103, RTX 50xxยทRTX PRO 6000 sm120)์์ FP4(W4A4) ์ฐ์ฐ ๊ฐ์, V100(sm70) ๋ฏธ์ง์ โ Turing
Hopper(sm7590)๋ ๊ฐ์ค์น ์ ์ฉ FP4๋ก ์๋ ์ ํ๋์ด ์๋ ์ ํ, vLLM ๊ฒฝ๊ณ ์ถ๋ ฅ (GPU๋ณ ์ง์ ์ฌ๋ถ๋ vLLM 0.32 ์ปค๋ ์ ํ ์ฝ๋ ๊ธฐ์ค, ์ค์ ์คํ์ B200์์๋ง ํ์ธ) - ๋ฉ๋ชจ๋ฆฌ: ๊ฐ์ค์น 8.3 GB + KV ์บ์(์ปจํ
์คํธ ๊ธธ์ด ร ๋์ ์์ฒญ ์์ ๋น๋ก) + ํ์ฑํยทCUDA graph์ฉ ์ GB โ GPU ํ ์ฅ์ ๋ค ๋ค์ด๊ฐ์ง ์์ผ๋ฉด
--tensor-parallel-size N์ผ๋ก ๋ถ์ฐ - Transformers๋ก ์ง์ ์ฌ์ฉ: transformers 5.10.1 ์ด์ + compressed-tensors 0.15.0 ์ด์, ํ ์คํธ ์ ๋ ฅ๋ง โ ์ด ๋น๋๋ Transformers์์ ์ด๋ฏธ์ง ์ ๋ ฅ ๋ถ๊ฐ (ignore ๋ชฉ๋ก์ด ์ด๋ฆ์ด ๋ฐ๋ ๋น์ ๋ชจ๋์ ๋์นจ), ์ด๋ฏธ์ง๋ vLLM ์ฌ์ฉ
- trust_remote_code: ๋ถํ์
์ฌ์ฉ๋ฒ
- ์๋ฒ ์คํ:
vllm serve axteam/gemma-4-12B-it-NVFP4 - Python:
LLM(model="axteam/gemma-4-12B-it-NVFP4").chat(...)โ ์ ์ฒด ์์๋ ์ ์์ด ๋ณธ๋ฌธ 'Usage (vLLM)' ์ ์ฐธ๊ณ - ๊ถ์ฅ ์ํ๋ง:
temperature=1.0,top_p=0.95,top_k=64(Google ๊ถ์ฅ๊ฐ) - thinking ๋ชจ๋: ๊ธฐ๋ณธ ๊บผ์ง โ ์ผ๋ ค๋ฉด
chat_template_kwargs={"enable_thinking": True}์ ๋ฌ(Python์llm.chat()์ธ์, HTTP๋ ์์ฒญ ๋ณธ๋ฌธ์"chat_template_kwargs": {"enable_thinking": true}), ์ถ๋ก ๊ณผ์ ์ ๋ต๋ณ๊ณผ ๋ถ๋ฆฌํด ๋ฐ์ผ๋ ค๋ฉดvllm serve์--reasoning-parser gemma4์ถ๊ฐ - KV ์บ์ ์ ๊ฐ(์ ํ):
vllm serve์--kv-cache-dtype fp8์ถ๊ฐ โ ๊ธฐ๋ณธ BF16์ธ KV ์บ์๋ฅผ FP8๋ก ์ ์ฅํด KV ์บ์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฝ ์ ๋ฐ์ผ๋ก ์ค์ (๊ธด ์ปจํ ์คํธยท๋์ ์์ฒญ์ด ๋ง์ ๋ ์ ๋ฆฌ, ๊ฐ์ค์น ์์ํ์ ๋ณ๊ฐ์ธ ์คํ ์ต์ )
๋ผ์ด์ ์ค
- ๋ผ์ด์ ์ค: Apache-2.0 (Gemma 4 ๋ผ์ด์ ์ค ์๋ด) โ ์๋ณธ ๋ชจ๋ธ์ ๋ผ์ด์ ์ค๋ฅผ ๊ทธ๋๋ก ๋ฐ๋ฆ
- ๊ถ๋ฆฌ: ์๋ณธ ๊ฐ์ค์นยทํ ํฌ๋์ด์ ยทchat template์ Google DeepMind ์์ , ์ด ๋ฆฌํฌ๋ ์์ํ ํ์๋ฌผ