Views
No views yet
google/gemma-4-31B-it using a trellis-coded codebook (QTIP TCQ) + randomized Hadamard transform (RHT) + LDLQ. Weights stay compressed in memory and are decoded on the fly by a fused CUDA kernel.Where GLQ shines: the size-vs-accuracy win is strongest at 2–4 bits/weight. For even more headroom, combine it with the E8 KV cache (≈4× smaller KV cache → longer context in the same VRAM).
google/gemma-4-31B-it3inst variant) + RHT + LDLQ — 4.0 bpw uniform (native trellis rate — one decode pass, no residual stacking)pip install glq "transformers>=5.13.1,<5.15"config.head_dim raises and vLLM dies before loading a single weight. Verified on
5.14.1 with vLLM 0.27.1. Not specific to GLQ: stock bf16 gemma-4 fails the same way.Requiresglq >= 0.8.2— this checkpoint stores the trellis in the kernel (MMA-fragment) layout that the lookup-free 3INST CUDA kernels consume.The 31B specifically needsglq >= 0.8.2. On earlier versions vLLM aborts at engine init withshard-batched output RHT needs pow2 max_bs <= 8192, got 16384: its 21504-wide FFN projections decompose to a 16384 Hadamard block that the batched output-RHT kernel cannot hold in shared memory. 0.8.2 routes those layers to the per-shard path. The checkpoint itself is unaffected — no re-export needed.If you served this model before upgrading, clear~/.cache/vllm/torch_compile_cache; vLLM's compile cache is not keyed on the plugin source, so a stale graph will replay the old call and the error will appear to persist.
Model loading took X GiB
line, not nvidia-smi.| Loaded weights | 18.04 GiB (bf16 reference ≈ 62.5 GB) |
| Decode, batch 1 | 34.3 tok/s |
| Avg weight SQNR | 22.42 dB |
| AIME-2026 (avg@8, thinking) | not yet measured |
1from vllm import LLM, SamplingParams
2
3
4def main():
5 llm = LLM(
6 model="xv0y5ncu/gemma-4-31B-it-GLQ-trellis-3inst-4bpw",
7 quantization="glq",
8 dtype="bfloat16",
9 max_model_len=4096,
10 limit_mm_per_prompt={"image": 0, "video": 0, "audio": 0}, # text-only serving
11 )
12 out = llm.generate(["The capital city of New Zealand is"],
13 SamplingParams(max_tokens=64, temperature=0))
14 print(out[0].outputs[0].text)
15
16# The __main__ guard is REQUIRED when running this as a script. vLLM switches to the
17# "spawn" multiprocessing start method once CUDA is initialised, so its worker processes
18# re-import this file; without the guard the script spawns itself recursively and dies
19# with "An attempt has been made to start a new process before the current process has
20# finished its bootstrapping phase" -- before the model ever loads.
21if __name__ == "__main__":
22 main()glq registers with vLLM automatically via its plugin entry point — no extra import needed.1import glq.hf_integration # registers the GLQ quantization method
2from transformers import AutoModelForImageTextToText, AutoTokenizer
3import torch
4
5model = AutoModelForImageTextToText.from_pretrained(
6 "xv0y5ncu/gemma-4-31B-it-GLQ-trellis-3inst-4bpw", device_map="cuda", dtype=torch.bfloat16)
7tok = AutoTokenizer.from_pretrained("xv0y5ncu/gemma-4-31B-it-GLQ-trellis-3inst-4bpw")
8
9msgs = [{"role": "user", "content": "What is the capital city of New Zealand?"}]
10ids = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt").to("cuda")
11print(tok.decode(model.generate(ids, max_new_tokens=64)[0][ids.shape[1]:], skip_special_tokens=True))This is a multimodal base model. GLQ quantizes the text decoder (the vision/audio towers are kept in their native format). vLLM is the recommended runtime.
vllm serve xv0y5ncu/gemma-4-31B-it-GLQ-trellis-3inst-4bpw --port 8000~/.pi/agent/models.json:1{
2 "providers": {
3 "glq": {
4 "baseUrl": "http://localhost:8000/v1",
5 "api": "openai-completions",
6 "apiKey": "glq",
7 "models": [
8 {
9 "id": "xv0y5ncu/gemma-4-31B-it-GLQ-trellis-3inst-4bpw"
10 }
11 ]
12 }
13 }
14}~/.config/opencode/opencode.json:1{
2 "$schema": "https://opencode.ai/config.json",
3 "provider": {
4 "glq": {
5 "npm": "@ai-sdk/openai-compatible",
6 "name": "GLQ (local vLLM)",
7 "options": {
8 "baseURL": "http://localhost:8000/v1",
9 "apiKey": "glq"
10 },
11 "models": {
12 "xv0y5ncu/gemma-4-31B-it-GLQ-trellis-3inst-4bpw": {
13 "name": "gemma-4-31B-it-trellis-3inst-4bpw"
14 }
15 }
16 }
17 }
18}1GLQ_KV_QUANT=e8_relaxed:2 \
2GLQ_KV_E8_SIDECAR=1 GLQ_KV_E8_SIDECAR_READ=1 GLQ_KV_E8_COMPRESSED_ALLOC=1 \
3GLQ_KV_E8_FUSED_GATHER=1 GLQ_KV_E8_FUSED_WRITE=1 \
4vllm serve xv0y5ncu/gemma-4-31B-it-GLQ-trellis-3inst-4bpwe8_relaxed:2 ≈ 4-bit KV, :1 ≈ 2-bit, :3 ≈ 6-bit. This is the part of GLQ that keeps paying off above 4-bit weights.
system role, enabling more structured and controllable conversations.| Property | E2B | E4B | 12B Unified | 31B Dense |
|---|---|---|---|---|
| Total Parameters | 2.3B effective (5.1B with embeddings) | 4.5B effective (8B with embeddings) | 11.95B | 30.7B |
| Layers | 35 | 42 | 48 | 60 |
| Sliding Window | 512 tokens | 512 tokens | 1024 tokens | 1024 tokens |
| Context Length | 128K tokens | 128K tokens | 256K tokens | 256K tokens |
| Vocabulary Size | 262K | 262K | 262K | 262K |
| Supported Modalities | Text, Image, Audio | Text, Image, Audio | Text, Image, Audio | Text, Image |
| Vision Encoder Parameters | ~150M | ~150M | - | ~550M |
| Audio Encoder Parameters | ~300M | ~300M | - | No Audio |
| Property | 26B A4B MoE |
|---|---|
| Total Parameters | 25.2B |
| Active Parameters | 3.8B |
| Layers | 30 |
| Sliding Window | 1024 tokens |
| Context Length | 256K tokens |
| Vocabulary Size | 262K |
| Expert Count | 8 active / 128 total and 1 shared |
| Supported Modalities | Text, Image |
| Vision Encoder Parameters | ~550M |
These are Google's published figures for the original bf16 models, not for this quantization. They are reproduced from the base model card for context. Google reports AIME-2026 (no tools) 89.2% for this model at bf16. This checkpoint's own AIME number is not yet measured.
| Gemma 4 31B | Gemma 4 26B A4B | Gemma 4 12B Unified | Gemma 4 E4B | Gemma 4 E2B | Gemma 3 27B (no think) | |
|---|---|---|---|---|---|---|
| MMLU Pro | 85.2% | 82.6% | 77.2% | 69.4% | 60.0% | 67.6% |
| AIME 2026 no tools | 89.2% | 88.3% | 77.5% | 42.5% | 37.5% | 20.8% |
| LiveCodeBench v6 | 80.0% | 77.1% | 72.0% | 52.0% | 44.0% | 29.1% |
| Codeforces ELO | 2150 | 1718 | 1659 | 940 | 633 | 110 |
| GPQA Diamond | 84.3% | 82.3% | 78.8% | 58.6% | 43.4% | 42.4% |
| Tau2 (average over 3) | 76.9% | 68.2% | 69.0% | 42.2% | 24.5% | 16.2% |
| HLE no tools | 19.5% | 8.7% | 5.2% | - | - | - |
| HLE with search | 26.5% | 17.2% | - | - | - | - |
| BigBench Extra Hard | 74.4% | 64.8% | 53.0% | 33.1% | 21.9% | 19.3% |
| MMMLU | 88.4% | 86.3% | 83.4% | 76.6% | 67.4% | 70.7% |
| Vision | ||||||
| MMMU Pro | 76.9% | 73.8% | 69.1% | 52.6% | 44.2% | 49.7% |
| OmniDocBench 1.5 (average edit distance, lower is better) | 0.131 | 0.149 | 0.164 | 0.181 | 0.290 | 0.365 |
| MATH-Vision | 85.6% | 82.4% | 79.7% | 59.5% | 52.4% | 46.0% |
| MedXPertQA MM | 61.3% | 58.1% | 48.7% | 28.7% | 23.5% | - |
| Audio | ||||||
| CoVoST | - | - | 38.5* | 35.54 | 33.47 | - |
| FLEURS (lower is better) | - | - | 0.069* | 0.08 | 0.09 | - |
| Long Context | ||||||
| MRCR v2 8 needle 128k (average) | 66.4% | 44.1% | 43.4% | 25.4% | 19.1% | 13.5% |
pip install -U transformers torch accelerate1from transformers import AutoProcessor, AutoModelForMultimodalLM
2
3MODEL_ID = "google/gemma-4-31B-it"
4
5# Load model
6processor = AutoProcessor.from_pretrained(MODEL_ID)
7model = AutoModelForMultimodalLM.from_pretrained(
8 MODEL_ID,
9 dtype="auto",
10 device_map="auto"
11)1# Prompt
2messages = [
3 {"role": "system", "content": "You are a helpful assistant."},
4 {"role": "user", "content": "Write a short joke about saving RAM."},
5]
6
7# Process input
8inputs = processor.apply_chat_template(
9 messages,
10 tokenize=True,
11 return_dict=True,
12 return_tensors="pt",
13 add_generation_prompt=True,
14 enable_thinking=False
15).to(model.device)
16input_len = inputs["input_ids"].shape[-1]
17
18# Generate output
19outputs = model.generate(**inputs, max_new_tokens=1024)
20response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
21
22# Parse output
23processor.parse_response(response, prefix=inputs["input_ids"])enable_thinking=True and the parse_response function will take care of parsing the thinking output.pip install -U transformers torch torchvision librosa accelerate1from transformers import AutoProcessor, AutoModelForMultimodalLM
2
3MODEL_ID = "google/gemma-4-E2B-it"
4
5# Load model
6processor = AutoProcessor.from_pretrained(MODEL_ID)
7model = AutoModelForMultimodalLM.from_pretrained(
8 MODEL_ID,
9 dtype="auto",
10 device_map="auto"
11)1# Prompt - add audio after text
2messages = [
3 {
4 "role": "user",
5 "content": [
6 {"type": "text", "text": "Transcribe the following speech segment in its original language. Follow these specific instructions for formatting the answer:\n* Only output the transcription, with no newlines.\n* When transcribing numbers, write the digits, i.e. write 1.7 and not one point seven, and write 3 instead of three."},
7 {"type": "audio", "audio": "https://raw.githubusercontent.com/google-gemma/cookbook/refs/heads/main/apps/sample-data/journal1.wav"},
8 ]
9 }
10]
11
12# Process input
13inputs = processor.apply_chat_template(
14 messages,
15 tokenize=True,
16 return_dict=True,
17 return_tensors="pt",
18 add_generation_prompt=True,
19).to(model.device)
20input_len = inputs["input_ids"].shape[-1]
21
22# Generate output
23outputs = model.generate(**inputs, max_new_tokens=512)
24response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
25
26# Parse output
27processor.parse_response(response, prefix=inputs["input_ids"])pip install -U transformers torch torchvision accelerate1from transformers import AutoProcessor, AutoModelForMultimodalLM
2
3MODEL_ID = "google/gemma-4-31B-it"
4
5# Load model
6processor = AutoProcessor.from_pretrained(MODEL_ID)
7model = AutoModelForMultimodalLM.from_pretrained(
8 MODEL_ID,
9 dtype="auto",
10 device_map="auto"
11)1# Prompt - add image before text
2messages = [
3 {
4 "role": "user", "content": [
5 {"type": "image", "url": "https://raw.githubusercontent.com/google-gemma/cookbook/refs/heads/main/apps/sample-data/GoldenGate.png"},
6 {"type": "text", "text": "What is shown in this image?"}
7 ]
8 }
9]
10
11# Process input
12inputs = processor.apply_chat_template(
13 messages,
14 tokenize=True,
15 return_dict=True,
16 return_tensors="pt",
17 add_generation_prompt=True,
18).to(model.device)
19input_len = inputs["input_ids"].shape[-1]
20
21# Generate output
22outputs = model.generate(**inputs, max_new_tokens=512)
23response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
24
25# Parse output
26processor.parse_response(response, prefix=inputs["input_ids"])pip install -U transformers torch torchvision librosa accelerate1from transformers import AutoProcessor, AutoModelForMultimodalLM
2
3MODEL_ID = "google/gemma-4-31B-it"
4
5# Load model
6processor = AutoProcessor.from_pretrained(MODEL_ID)
7model = AutoModelForMultimodalLM.from_pretrained(
8 MODEL_ID,
9 dtype="auto",
10 device_map="auto"
11)1# Prompt - add video before text
2messages = [
3 {
4 'role': 'user',
5 'content': [
6 {"type": "video", "video": "https://github.com/bebechien/gemma/raw/refs/heads/main/videos/ForBiggerBlazes.mp4"},
7 {'type': 'text', 'text': 'Describe this video.'}
8 ]
9 }
10]
11
12# Process input
13inputs = processor.apply_chat_template(
14 messages,
15 tokenize=True,
16 return_dict=True,
17 return_tensors="pt",
18 add_generation_prompt=True,
19).to(model.device)
20input_len = inputs["input_ids"].shape[-1]
21
22# Generate output
23outputs = model.generate(**inputs, max_new_tokens=512)
24response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
25
26# Parse output
27processor.parse_response(response, prefix=inputs["input_ids"])temperature=1.0top_p=0.95top_k=64system, assistant, and user roles. To properly manage the thinking process, use the following control tokens:<|think|> token at the start of the system prompt. To disable thinking, remove the token.<|channel>thought\n[Internal reasoning]<channel|><|channel>thought\n<channel|>[Final answer][!Note] Note that many libraries like Transformers and llama.cpp handle the complexities of the chat template for you.
1Transcribe the following speech segment in {LANGUAGE} into {LANGUAGE} text.
2
3Follow these specific instructions for formatting the answer:
4* Only output the transcription, with no newlines.
5* When transcribing numbers, write the digits, i.e. write 1.7 and not one point seven, and write 3 instead of three.1Transcribe the following speech segment in {SOURCE_LANGUAGE}, then translate it into {TARGET_LANGUAGE}.
2When formatting the answer, first output the transcription in {SOURCE_LANGUAGE}, then one newline, then output the string '{TARGET_LANGUAGE}: ', then the translation in {TARGET_LANGUAGE}.1@misc{gemmateam2026gemma4,
2 title={Gemma 4 Technical Report},
3 author={Gemma Team},
4 year={2026},
5 eprint={2607.02770},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2607.02770},
9}google/gemma-4-31B-it, quantized with GLQ. It inherits the base model's license (apache-2.0) — please respect the base model's terms.