Instructions to use xv0y5ncu/Gemma-4-E4B-it-GLQ-3.5bpw-mix3-8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use xv0y5ncu/Gemma-4-E4B-it-GLQ-3.5bpw-mix3-8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="xv0y5ncu/Gemma-4-E4B-it-GLQ-3.5bpw-mix3-8") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("xv0y5ncu/Gemma-4-E4B-it-GLQ-3.5bpw-mix3-8") model = AutoModelForMultimodalLM.from_pretrained("xv0y5ncu/Gemma-4-E4B-it-GLQ-3.5bpw-mix3-8", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use xv0y5ncu/Gemma-4-E4B-it-GLQ-3.5bpw-mix3-8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "xv0y5ncu/Gemma-4-E4B-it-GLQ-3.5bpw-mix3-8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "xv0y5ncu/Gemma-4-E4B-it-GLQ-3.5bpw-mix3-8", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/xv0y5ncu/Gemma-4-E4B-it-GLQ-3.5bpw-mix3-8
- SGLang
How to use xv0y5ncu/Gemma-4-E4B-it-GLQ-3.5bpw-mix3-8 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "xv0y5ncu/Gemma-4-E4B-it-GLQ-3.5bpw-mix3-8" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "xv0y5ncu/Gemma-4-E4B-it-GLQ-3.5bpw-mix3-8", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "xv0y5ncu/Gemma-4-E4B-it-GLQ-3.5bpw-mix3-8" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "xv0y5ncu/Gemma-4-E4B-it-GLQ-3.5bpw-mix3-8", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use xv0y5ncu/Gemma-4-E4B-it-GLQ-3.5bpw-mix3-8 with Docker Model Runner:
docker model run hf.co/xv0y5ncu/Gemma-4-E4B-it-GLQ-3.5bpw-mix3-8
Gemma-4-E4B-it — GLQ 3.5 bpw (mixed 3–8)
GLQ (Golay–Leech Quantization) of google/gemma-4-E4B-it at 3.5 bpw param-weighted average, with sensitivity-driven mixed precision over the range 3–8 bpw. Layers are ranked by proxy loss; the most sensitive ones (typically k_proj, o_proj, per_layer_input_gate) get more bits; the bulk MLP layers (gate_proj, up_proj, down_proj) get 3 bpw.
Quick start
pip install glq "transformers>=5.13.1,<5.15"
Pin transformers below 5.15 — 5.15.0 moved gemma-4 to a per-layer config, so
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.
import glq.hf_integration # registers the GLQ quantization config
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"xv0y5ncu/Gemma-4-E4B-it-GLQ-3.5bpw-mix3-8",
torch_dtype="bfloat16",
device_map="cuda",
)
tokenizer = AutoTokenizer.from_pretrained("xv0y5ncu/Gemma-4-E4B-it-GLQ-3.5bpw-mix3-8")
vLLM (pip install vllm + pip install glq):
vllm serve xv0y5ncu/Gemma-4-E4B-it-GLQ-3.5bpw-mix3-8 --quantization glq
Quality vs other 3-bpw-class quants
mmlu_pro at 2% sample (n = 247), all generation with enable_thinking=true:
| Variant | bpw (param-weighted) | acc | stderr | engine | vs bf16 |
|---|---|---|---|---|---|
| bf16 | 16.0 | 0.6640 | 0.0289 | vLLM | 100% |
| GLQ 3.5 mix 3–8 (this model) | 3.50 | 0.5628 | 0.0310 | vLLM | 84.8% |
| GGUF Q3_K_S | 3.89 | 0.4696 | 0.0300 | llama.cpp | 70.7% |
| GGUF UD-IQ3_XXS (calibrated) | 3.75 | 0.4818 | 0.0295 | llama.cpp | 72.6% |
| GLQ uniform 3.0 | 3.00 | 0.4413 | 0.0311 | vLLM | 66.5% |
At 3.5 bpw — lower than both GGUF Q3 variants — GLQ outperforms them by ~9pp thanks to sensitivity-driven bit allocation.
Bit allocation summary
Total quantized weights: 3,945,267,200
3 bpw: 113 sublayers (2,941,255,680 weights, 74.6%) — mostly mlp.{gate,up,down}_proj
4 bpw: 41 sublayers ( 525,598,720 weights, 13.3%)
5 bpw: 35 sublayers ( 200,540,160 weights, 5.1%)
6 bpw: 32 sublayers ( 110,755,840 weights, 2.8%)
7 bpw: 72 sublayers ( 121,896,960 weights, 3.1%)
8 bpw: 49 sublayers ( 45,219,840 weights, 1.1%) — most sensitive: k_proj, per_layer_*
PLE embedding: 4 bpw (separate)
embed_tokens, lm_head, norms: bf16
Average SQNR: 21.77 dB
Quantization details
- Method: E8 lattice codebook (65 536 entries) + RHT (random Hadamard transform) + LDLQ optimal rounding, with a 256-entry second-stage codebook for residual quantization (RVQ).
- Calibration: 128 samples × 2048 tokens from C4.
- Allocator: greedy marginal-gain over per-layer proxy losses, profiled at 3–8 bpw.
- Quantizer:
glq.quantize_model. - Hardware: NVIDIA RTX PRO 6000 Blackwell, 96 GB VRAM. Total quantization wall time: ~8 min (profile + allocate + quantize).
License
License: Apache 2.0 — see https://ai.google.dev/gemma/docs/gemma_4_license
Original model: https://huggingface.co/google/gemma-4-E4B-it
Derivative quantization work; the base Gemma 4 model and the GLQ tooling (https://github.com/cnygaard/glq) are both Apache 2.0. Quantizing the weights does not change the license.
🔗 GLQ on GitHub: https://github.com/cnygaard/glq — if you like it, a ⭐ is appreciated.
- Downloads last month
- 13