Views
No views yet
| Base Model | google/gemma-4-31B-it |
| Architecture | Gemma4ForConditionalGeneration (multimodal: text + vision) |
| Parameters | 31 B text decoder (quantized) + vision tower & embeddings kept in BF16 |
| Quantization | W8A8 INT8 (per-channel weight + per-token dynamic activation) |
| Quantizer | AMD Quark 0.11.1 (ptpc_int8 scheme, pack_method='order') |
| Model Size | ~32 GB (single model.safetensors) |
| Original Size | ~62.5 GB (BF16) |
| Compression | ~2× size reduction |
| Component | dtype | Granularity | Mode |
|---|---|---|---|
| Weight | INT8 | per-channel (ch_axis=0) | symmetric, static |
| Activation | INT8 | per-token (ch_axis=1) | symmetric, dynamic |
lm_head | BF16 | — | unquantized |
embed_tokens | BF16 | — | unquantized |
vision_tower / embed_vision | BF16 | — | unquantized (multimodal preserved) |
temperature=0, concurrency=16, max_tokens=512, standard chat template with #### answer format):| Model | Scheme | Accuracy | Correct |
|---|---|---|---|
google/gemma-4-31B-it (BF16 baseline) | — | 96.74% | 1276 / 1319 |
| This model (Quark W8A8 INT8) | per-channel weight + per-token act. | 96.66% | 1275 / 1319 |
1# Start the server (single MI300X / MI350X / MI355X is enough; A100-80G also works)
2vllm serve nameistoken/Gemma-4-31B-it-Quark-W8A8-INT8 \
3 --tensor-parallel-size 1 \
4 --max-model-len 8192 \
5 --gpu-memory-utilization 0.9 \
6 --trust-remote-code
7
8# Chat completion
9curl http://localhost:8000/v1/chat/completions -H "Content-Type: application/json" -d '{
10 "model": "nameistoken/Gemma-4-31B-it-Quark-W8A8-INT8",
11 "messages": [{"role": "user", "content": "Hello! What is the capital of France?"}],
12 "max_tokens": 256,
13 "temperature": 0.7
14}'lm_head, *embed_tokens*, *vision_tower*, *embed_vision* (output head + token embedding + the entire vision tower remain in BF16).pack_method='order', weight_format='real_quantized', custom_mode='quark' → real INT8 weights with BF16 scales (no fake-quant, no zero-point).1# 1. Environment
2pip install amd-quark==0.11.1 datasets accelerate
3git clone https://github.com/huggingface/transformers.git
4cd transformers && pip install -e . --no-deps # transformers main (>= 5.6.0.dev0)1# quark_gemma4_int8.py
2import os, torch
3from transformers import AutoTokenizer, Gemma4ForConditionalGeneration
4from quark.torch import ModelQuantizer
5from quark.torch.quantization.config.config import (
6 QTensorConfig, QuantizationConfig, Config, Dtype,
7)
8from quark.torch.quantization.config.type import (
9 RoundType, ScaleType, QSchemeType,
10)
11from quark.torch.quantization.observer import PerChannelMinMaxObserver
12
13MODEL_IN = "google/gemma-4-31B-it"
14MODEL_OUT = "./Gemma-4-31B-it-Quark-W8A8-INT8"
15
16tokenizer = AutoTokenizer.from_pretrained(MODEL_IN, trust_remote_code=True)
17model = Gemma4ForConditionalGeneration.from_pretrained(
18 MODEL_IN, torch_dtype=torch.bfloat16,
19 device_map="auto", trust_remote_code=True,
20)
21
22weight_spec = QTensorConfig(
23 dtype=Dtype.int8, observer_cls=PerChannelMinMaxObserver,
24 symmetric=True, is_dynamic=False,
25 qscheme=QSchemeType.per_channel, ch_axis=0,
26 round_method=RoundType.round, scale_type=ScaleType.float,
27)
28input_spec = QTensorConfig(
29 dtype=Dtype.int8, observer_cls=PerChannelMinMaxObserver,
30 symmetric=True, is_dynamic=True,
31 qscheme=QSchemeType.per_channel, ch_axis=1,
32 round_method=RoundType.round, scale_type=ScaleType.float,
33)
34
35q_cfg = Config(
36 global_quant_config=QuantizationConfig(
37 input_tensors=input_spec, weight=weight_spec,
38 ),
39 exclude=[
40 "lm_head", "*embed_tokens*",
41 "*vision_tower*", "*embed_vision*",
42 ],
43)
44
45quantizer = ModelQuantizer(q_cfg, multi_device=True)
46model = quantizer.quantize_model(model, dataloader=None) # PTQ, no calibration data needed for dynamic act
47quantizer.freeze(model)
48
49quantizer.export_model(
50 model, MODEL_OUT,
51 pack_method="order",
52 weight_format="real_quantized",
53 custom_mode="quark",
54)
55tokenizer.save_pretrained(MODEL_OUT)1@misc{google2026gemma4,
2 title = {Gemma 4},
3 author = {Google DeepMind},
4 year = {2026},
5 url = {https://huggingface.co/google/gemma-4-31B-it}
6}google/gemma-4-31B-it weights are distributed by Google DeepMind.google/gemma-4-31B-it. Per Apache 2.0 §4:model.safetensors and the appended quantization_config block in config.json) carry this notice as part of the model card.NOTICE).LICENSE.LICENSE §7–8).