gemma-4-31B ยท NVFP4 (W4A4, FP4)
4-bit quantization of google/gemma-4-31B (commit 5bbc2fb), produced for efficient vLLM serving. Quantized by axteam.
| Base model | google/gemma-4-31B (commit 5bbc2fb) |
| 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 | ~20.4 GB |
| Calibration | 256 samples (Korean-heavy; -it includes 32 self-generated thinking-mode answers) |
| 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 โ vision tower, vision projection, token embeddings (tied with lm_head), and all norms. These stay unquantized to preserve quality โ about 6% of all parameters in this build.
- Tokenizer /
processor_config/generation_configare byte-identical to the original. This is a base (pre-trained) model with no chat template โ use plain text completion, not chat.config.jsonis the original plus aquantization_configblock.
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 (256-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) | 84.59 | 84.71 (100.1%) | 84.52 (99.9%) | 83.70 (98.9%) | 83.09 (98.2%) | 84.02 (99.3%) |
| GSM8K (5-shot, strict) | 84.46 | 83.09 (98.4%) | 84.23 (99.7%) | 83.78 (99.2%) | 82.03 (97.1%) | 84.15 (99.6%) |
| ARC-Challenge (0-shot) | 69.62 | 68.94 (99.0%) | 69.11 (99.3%) | 68.43 (98.3%) | 67.49 (96.9%) | 69.11 (99.3%) |
| Winogrande (5-shot) | 83.90 | 84.29 (100.5%) | 84.29 (100.5%) | 84.45 (100.7%) | 82.64 (98.5%) | 83.58 (99.6%) |
| KMMLU (5-shot, direct) | 67.35 | 67.22 (99.8%) | 67.39 (100.1%) | 66.41 (98.6%) | 65.22 (96.8%) | 67.33 (100.0%) |
| HAE-RAE (0-shot) | 82.31 | 82.03 (99.7%) | 82.03 (99.7%) | 81.94 (99.6%) | 80.29 (97.6%) | 81.85 (99.4%) |
| Average | 78.71 | 78.38 (99.6%) | 78.60 (99.9%) | 78.12 (99.3%) | 76.79 (97.6%) | 78.34 (99.5%) |
Evaluation (measured)
Perplexity was measured against the BF16 original on public text โ the WikiText-2 test set (English) and a Korean Wikipedia sample, 2,048-token chunks. 8-bit builds (AWQ INT8, FP8) stayed within 0.5% of BF16; 4-bit builds (AWQ INT4, NVFP4) were 2.0โ6.6% higher (range across both base models and both 4-bit formats). Next-token top-1 agreement was not measured for the base models.
Requirements
| Runtime | vLLM โ the architecture is in vLLM โฅ 0.19.0; tested here with vLLM 0.32.0 (text input only โ the benchmarks above, run with image input disabled; image input not run for this build). |
| 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: 20.4 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.5.0 (5.5.2+ recommended; not run here for 31B). |
| trust_remote_code | not needed |
Usage (vLLM)
vllm serve axteam/gemma-4-31B-NVFP4
from vllm import LLM, SamplingParams
llm = LLM(model="axteam/gemma-4-31B-NVFP4")
params = SamplingParams(temperature=1.0, top_p=0.95, top_k=64, max_tokens=1024)
out = llm.generate("The three primary colors are", params)
print(out[0].outputs[0].text)
Recommended sampling (per Google):
temperature=1.0,top_p=0.95,top_k=64. 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-31B-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 and tokenizer belong to Google DeepMind.
ํ๊ตญ์ด ์์ฝ
google/gemma-4-31B์ NVFP4 (W4A4) ์์ํ ๋น๋ ยท ์ ์ axteam
๊ฐ์
| ํญ๋ชฉ | ๋ด์ฉ |
|---|---|
| ์๋ณธ ๋ชจ๋ธ | google/gemma-4-31B (์ปค๋ฐ 5bbc2fb) |
| ์์ํ ๋ฐฉ์ | NVFP4 (W4A4, ๊ฐ์ค์นยทํ์ฑํ FP4) |
| ์ ์ฅ ํ์ | compressed-tensors nvfp4-pack-quantized |
| ๋ชจ๋ธ ๊ตฌ์กฐ | Gemma 4 ยท Dense |
| ์ฉ๋ | ์ฝ 20.4 GB |
| ๋ณด์ ๋ฐ์ดํฐ | ์ํ 256๊ฐ (ํ๊ตญ์ด ์์ฃผ) |
์์ํ ์์ธ
- ๊ฐ์ค์น: FP4(E2M1), ๊ทธ๋ฃน ํฌ๊ธฐ 16 (๊ทธ๋ฃน๋ณ FP8(E4M3) ์ค์ผ์ผ + ํ ์๋ณ FP32 ์ ์ญ ์ค์ผ์ผ)
- ํ์ฑํ: ์คํ ์ FP4 (Blackwell FP4 ํ ์์ฝ์ด์์ ๊ฐ์)
- ์์ํ ์ ์ฐจ: PTQ(ํ์ต ํ ์์ํ, ์ฌํ์ต ์์), AWQ ๋ฐฉ์ โ ๋ณด์ ๋ฐ์ดํฐ๋ก ํ์ฑํ๊ฐ ํฐ ๊ฐ์ค์น ์ฑ๋์ ์ฐพ์ ์ฑ๋๋ณ ์ค์ผ์ผ๋ก ๋ณดํธํ ๋ค FP4๋ก ๋ฐ์ฌ๋ฆผ
- BF16 ์ ์ง: ๋น์ ํ์, ๋น์ ํฌ์์ธต, ํ ํฐ ์๋ฒ ๋ฉ(LM ํค๋์ ๊ณต์ ), ๋ชจ๋ ์ ๊ทํ์ธต โ ์ ์ฒด ํ๋ผ๋ฏธํฐ์ ์ฝ 6%
- ์๋ณธ ํ์ผ: ํ ํฌ๋์ด์ ยทprocessorยทgeneration config๋ฅผ ๋ฐ์ดํธ ๋จ์๋ก ๊ทธ๋๋ก ์ฌ์ฉ(์ฌ์ ํ์ต ๋ชจ๋ธ์ด๋ผ chat template์ ์์),
config.json์ ์๋ณธ์quantization_config๋ธ๋ก๋ง ์ถ๊ฐ
ํ์ง (์ค์ธก)
- ๊ณต๊ฐ ํ ์คํธ PPL: WikiText-2(์์ด)ยทํ๊ตญ์ด ์ํค ํ๋ณธ, 2,048ํ ํฐ ๋จ์ โ 8๋นํธ(AWQ INT8ยทFP8)๋ ์๋ณธ ๋๋น 0.5% ์ด๋ด, 4๋นํธ(AWQ INT4ยทNVFP4)๋ 2.0~6.6% ์์น (๋ base ๋ชจ๋ธยท๋ 4๋นํธ ํ์์ ํฉ์น ๋ฒ์, top-1์ ๋ฏธ์ธก์ )
- ๋ฒค์น๋งํฌ ํ๊ท : 76.79 (์๋ณธ 78.71, 97.6%) โ MMLU(์์ฑํ)ยทGSM8KยทARC-ChallengeยทWinograndeยทKMMLUยทHAE-RAE 6์ข ํ๊ท , lm-evaluation-harness + vLLM, chat template ์๋ ์์ฑํ ํ๋กฌํํธ(๊ณผ์ ๋ณ 0ยท5-shot, ํ ์ฐธ๊ณ )ยทgreedy, ๋ชจ๋ ๋น๋๋ฅผ ๊ฐ์ ์ค์ ์ผ๋ก ์ธก์
- ํ๊ตญ์ด ๋ฒค์น๋งํฌ: KMMLU 65.22 (์๋ณธ 67.35, 96.8%) ยท HAE-RAE 80.29 (์๋ณธ 82.31, 97.6%)
- MMLU ๋ฐฉ์: lm-eval ์์ฑํ ๋ณํ(
mmlu_generative) โ ๋ชจ๋ธ์ด ๋ต ๊ธ์๋ฅผ ์์ฑํ๊ณ ์ฒซ ์ค์ด ์ ํํ ์ผ์นํด์ผ ์ ๋ต์ผ๋ก ์ฑ์ ํ๋ฏ๋ก, ๋ค๋ฅธ ๋ฐฉ์(์: log-likelihood ์ฑ์ )์ผ๋ก ์ฐ MMLU ์ ์์ ์ง์ ๋น๊ต ๋ถ๊ฐ
์๊ตฌ์ฌํญ
- ์คํ ์์ง: vLLM 0.19.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์์๋ง ํ์ธ) - ๋ฉ๋ชจ๋ฆฌ: ๊ฐ์ค์น 20.4 GB + KV ์บ์(์ปจํ
์คํธ ๊ธธ์ด ร ๋์ ์์ฒญ ์์ ๋น๋ก) + ํ์ฑํยทCUDA graph์ฉ ์ GB โ GPU ํ ์ฅ์ ๋ค ๋ค์ด๊ฐ์ง ์์ผ๋ฉด
--tensor-parallel-size N์ผ๋ก ๋ถ์ฐ - Transformers๋ก ์ง์ ์ฌ์ฉ: transformers 5.5.0 ์ด์ (5.5.2 ์ด์ ๊ถ์ฅ) โ ์ด ๋ชจ๋ธ์ Transformers๋ก ์ง์ ์คํํด ๋ณด์ง ์์
- trust_remote_code: ๋ถํ์
์ฌ์ฉ๋ฒ
- ์๋ฒ ์คํ:
vllm serve axteam/gemma-4-31B-NVFP4 - Python:
LLM(model="axteam/gemma-4-31B-NVFP4").generate(...)โ ์ฌ์ ํ์ต ๋ชจ๋ธ์ด๋ผ ๋ํ๊ฐ ์๋ ํ ์คํธ ์ด์ด์ฐ๊ธฐ - ๊ถ์ฅ ์ํ๋ง:
temperature=1.0,top_p=0.95,top_k=64(Google ๊ถ์ฅ๊ฐ) - KV ์บ์ ์ ๊ฐ(์ ํ):
vllm serve์--kv-cache-dtype fp8์ถ๊ฐ โ ๊ธฐ๋ณธ BF16์ธ KV ์บ์๋ฅผ FP8๋ก ์ ์ฅํด KV ์บ์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฝ ์ ๋ฐ์ผ๋ก ์ค์ (๊ธด ์ปจํ ์คํธยท๋์ ์์ฒญ์ด ๋ง์ ๋ ์ ๋ฆฌ, ๊ฐ์ค์น ์์ํ์ ๋ณ๊ฐ์ธ ์คํ ์ต์ )
๋ผ์ด์ ์ค
- ๋ผ์ด์ ์ค: Apache-2.0 (Gemma 4 ๋ผ์ด์ ์ค ์๋ด) โ ์๋ณธ ๋ชจ๋ธ์ ๋ผ์ด์ ์ค๋ฅผ ๊ทธ๋๋ก ๋ฐ๋ฆ
- ๊ถ๋ฆฌ: ์๋ณธ ๊ฐ์ค์นยทํ ํฌ๋์ด์ ๋ Google DeepMind ์์ , ์ด ๋ฆฌํฌ๋ ์์ํ ํ์๋ฌผ