gemma-4-E4B-it · NVFP4 (W4A4, FP4)

4-bit quantization of google/gemma-4-E4B-it, produced for efficient vLLM serving. Quantized by axteam.

Revision 2026-11-01 (rebuilt): This rebuild applies AWQ smoothing to the attention inputs (q/k/v; q only in the KV-shared layers), the MLP inputs (gate/up) and the down-projection input with 128 calibration samples (checked: all 84 smoothed norms differ from the original, and every smoothing pair was searched with a non-zero calibration error). The first upload of this repo was produced through an llm-compressor pipeline path in which AWQ smoothing silently did not apply, so it was effectively round-to-nearest despite its AWQ label. If you downloaded this repo before 2026-11-01 09:15:44 UTC (revision 4424b6f), download it again. The benchmark and fidelity figures on this card were measured on the rebuilt files.

Base model google/gemma-4-E4B-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 ~10.3 GB
Calibration 128 samples (Korean-heavy; no 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, audio tower, vision/audio projections, token embeddings (tied with lm_head), the per-layer embedding table (embed_tokens_per_layer), the per-layer input gates and projections (per_layer_input_gate, per_layer_projection, per_layer_model_projection), and all norms. These stay unquantized to preserve quality — about 51% of all parameters in this build.
  • Tokenizer / chat_template / processor_config / generation_config are byte-identical to the original, including Google's July-2026 corrected chat_template. config.json is the original plus a quantization_config block.

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 on purpose for this model's AWQ-8bit, AWQ-4bit, NVFP4A16 and NVFP4 builds, which apply AWQ; the first upload of this repo was effectively RTN by accident (see the revision note above).
  • 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 (128-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) 62.16 63.20 (101.7%) 62.40 (100.4%) 64.48 (103.7%) 62.14 (100.0%) 64.16 (103.2%)
GSM8K (5-shot, strict) 84.31 84.00 (99.6%) 84.08 (99.7%) 82.71 (98.1%) 79.83 (94.7%) 81.73 (96.9%)
ARC-Challenge (0-shot) 56.91 57.34 (100.7%) 56.66 (99.6%) 56.66 (99.6%) 55.20 (97.0%) 55.97 (98.4%)
Winogrande (5-shot) 66.30 65.75 (99.2%) 66.85 (100.8%) 65.51 (98.8%) 66.46 (100.2%) 65.43 (98.7%)
KMMLU (5-shot, direct) 51.46 51.24 (99.6%) 51.46 (100.0%) 50.15 (97.5%) 49.11 (95.4%) 51.31 (99.7%)
HAE-RAE (0-shot) 69.84 69.02 (98.8%) 69.57 (99.6%) 69.48 (99.5%) 68.10 (97.5%) 68.10 (97.5%)
Average 65.16 65.09 (99.9%) 65.17 (100.0%) 64.83 (99.5%) 63.47 (97.4%) 64.45 (98.9%)

Evaluation (measured)

Fidelity to the BF16 original on an internal mixed English/Korean set (100 prompts: the BF16 original's greedy answers, scored under each build with the same prompts and scoring code). This build was measured on the rebuilt files with vLLM 0.32 on 2026-11-01; the BF16 reference column was measured on 2026-10-11.

Metric This model BF16 original
Perplexity (lower = closer) 1.4769 1.3032 (+13.3%)
Top-1 next-token agreement 88.0% 99.2%

These measure fidelity to the base model, not absolute task scores.

Requirements

Runtime vLLM — the architecture is in vLLM ≥ 0.19.0; tested here with vLLM 0.32.0 (text: the benchmarks above; image: an image-description prompt in the 2026-11-01 fidelity run).
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: 10.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.5.2 (5.5.0/5.5.1 cannot run the KV-shared layers).
trust_remote_code not needed

Usage (vLLM)

vllm serve axteam/gemma-4-E4B-it-NVFP4
from vllm import LLM, SamplingParams

llm = LLM(model="axteam/gemma-4-E4B-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: add the <|think|> token at the start of the system prompt to enable step-by-step reasoning. 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-E4B-it-NVFP4 --kv-cache-dtype fp8

--kv-cache-dtype accepts auto (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-E4B-it의 NVFP4 (W4A4) 양자화 빌드 · 제작 axteam

개요

항목 내용
원본 모델 google/gemma-4-E4B-it
양자화 방식 NVFP4 (W4A4, 가중치·활성화 FP4)
저장 형식 compressed-tensors nvfp4-pack-quantized
모델 구조 Gemma 4 · Dense
용량 약 10.3 GB
보정 데이터 샘플 128개 (한국어 위주, thinking 모드 답변 없음)

양자화 상세

  • 가중치: FP4(E2M1), 그룹 크기 16 (그룹별 FP8(E4M3) 스케일 + 텐서별 FP32 전역 스케일)
  • 활성화: 실행 시 FP4 (Blackwell FP4 텐서코어에서 가속)
  • 양자화 절차: PTQ(학습 후 양자화, 재학습 없음), AWQ 방식 — 보정 데이터로 활성화가 큰 가중치 채널을 찾아 채널별 스케일로 보호한 뒤 FP4로 반올림
  • BF16 유지: 비전 타워, 오디오 타워, 비전·오디오 투영층, 토큰 임베딩(LM 헤드와 공유), 층별 임베딩 표(embed_tokens_per_layer), 층별 입력 게이트·투영층(per_layer_input_gate·per_layer_projection·per_layer_model_projection), 모든 정규화층 — 전체 파라미터의 약 51%
  • 원본 파일: 토크나이저·chat template(Google의 2026년 7월 수정본)·processor·generation config를 바이트 단위로 그대로 사용, config.json은 원본에 quantization_config 블록만 추가

품질 (실측)

  • 원본 대비 충실도: PPL 1.4769 (원본 1.3032, +13.3%, 낮을수록 원본에 가까움), 다음 토큰 top-1 일치율 88.0% (원본 자체 기준값 99.2%) — 내부 영어·한국어 혼합 프롬프트 100개, 원본(BF16)의 greedy 답변을 기준 텍스트로 측정
  • 벤치마크 평균: 63.47 (원본 65.16, 97.4%) — MMLU(생성형)·GSM8K·ARC-Challenge·Winogrande·KMMLU·HAE-RAE 6종 평균, lm-evaluation-harness + vLLM, chat template 없는 완성형 프롬프트(과제별 0·5-shot, 표 참고)·greedy, 모든 빌드를 같은 설정으로 측정
  • 한국어 벤치마크: KMMLU 49.11 (원본 51.46, 95.4%) · HAE-RAE 68.10 (원본 69.84, 97.5%)
  • MMLU 방식: lm-eval 생성형 변형(mmlu_generative) — 모델이 답 글자를 생성하고 첫 줄이 정확히 일치해야 정답으로 채점하므로, 다른 방식(예: log-likelihood 채점)으로 잰 MMLU 점수와 직접 비교 불가

요구사항

  • 실행 엔진: vLLM 0.19.0 이상(이 구조를 지원하는 첫 버전), 이 빌드는 vLLM 0.32.0에서 실행 확인 (텍스트 — 위 벤치마크, 이미지 — 2026-11-01 충실도 평가의 그림 설명 질문)
  • 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) 미지원 — TuringHopper(sm7590)는 가중치 전용 FP4로 자동 전환되어 속도 저하, vLLM 경고 출력 (GPU별 지원 여부는 vLLM 0.32 커널 선택 코드 기준, 실제 실행은 B200에서만 확인)
  • 메모리: 가중치 10.3 GB + KV 캐시(컨텍스트 길이 × 동시 요청 수에 비례) + 활성화·CUDA graph용 수 GB — GPU 한 장에 다 들어가지 않으면 --tensor-parallel-size N으로 분산
  • Transformers로 직접 사용: transformers 5.5.2 이상 (5.5.0·5.5.1은 KV 공유 층 실행 불가)
  • trust_remote_code: 불필요

사용법

  • 서버 실행: vllm serve axteam/gemma-4-E4B-it-NVFP4
  • Python: LLM(model="axteam/gemma-4-E4B-it-NVFP4").chat(...) — 전체 예시는 위 영어 본문 'Usage (vLLM)' 절 참고
  • 권장 샘플링: temperature=1.0, top_p=0.95, top_k=64 (Google 권장값)
  • thinking 모드: 기본 꺼짐 — 켜려면 시스템 프롬프트 맨 앞에 <|think|> 토큰 추가
  • KV 캐시 절감(선택): vllm serve에 --kv-cache-dtype fp8 추가 — 기본 BF16인 KV 캐시를 FP8로 저장해 KV 캐시 메모리를 약 절반으로 줄임 (긴 컨텍스트·동시 요청이 많을 때 유리, 가중치 양자화와 별개인 실행 옵션)

참고

  • 수정 이력 (2026-11-01, 재양자화): 어텐션 입력(q/k/v, KV 공유 층은 q만)·MLP 입력(gate/up)·down 투영 입력에 AWQ 스무딩을 실제로 적용, 보정 샘플 128개 (스무딩 대상 norm 84개가 모두 원본과 달라졌고 모든 스무딩 짝을 0이 아닌 보정 오차로 탐색했음을 확인) — 이전 업로드의 결함: 첫 번째 업로드는 AWQ 스무딩이 실제로 적용되지 않아 사실상 단순 반올림(RTN) — 2026-11-01 09:15:44 UTC(리비전 4424b6f) 이전에 받았다면 다시 받을 것, 품질 항목의 벤치마크·충실도는 재양자화 빌드로 잰 값

라이선스

  • 라이선스: Apache-2.0 (Gemma 4 라이선스 안내) — 원본 모델의 라이선스를 그대로 따름
  • 권리: 원본 가중치·토크나이저·chat template은 Google DeepMind 소유, 이 리포는 양자화 파생물
Downloads last month
230
Safetensors
Model size
8B params
Tensor type
BF16
·
U8
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for axteam/gemma-4-E4B-it-NVFP4

Quantized
(440)
this model

Collection including axteam/gemma-4-E4B-it-NVFP4