Views
No views yet
| Property | Value |
|---|---|
| Average bpw | 7.0 |
| Quantization scheme | uniform |
| File size | 7.98 GB (1.87× smaller than bf16) |
| gsm8k limit=50 chat+thinking strict-match | 90% (bf16 baseline: 86%) |
| Recommended max_new_tokens for thinking mode | 2K |
1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3import glq, glq.hf_integration # registers the GLQ quantization config
4
5model_id = "xv0y5ncu/Gemma-4-E4B-it-GLQ-7bpw"
6tok = AutoTokenizer.from_pretrained(model_id)
7model = AutoModelForCausalLM.from_pretrained(
8 model_id, device_map="cuda", dtype=torch.bfloat16,
9)
10
11# For thinking-mode (math reasoning, multi-step problems):
12prompt = tok.apply_chat_template(
13 [{"role": "user", "content": "What is 12 * 17?"}],
14 tokenize=False, add_generation_prompt=True,
15 enable_thinking=True,
16)
17ids = tok(prompt, return_tensors="pt").input_ids.cuda()
18with torch.no_grad():
19 out = model.generate(ids, max_new_tokens=2048, do_sample=False)
20print(tok.decode(out[0, ids.shape[1]:], skip_special_tokens=False))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.torch>=2.0, transformers>=5.0, CUDA 12.x.max_new_tokensenable_thinking=True
and may require a larger thinking budget than bf16 to converge to the
final answer. Empirically:| Variant | Recommended max_new_tokens for thinking |
|---|---|
| 8bpw, 7bpw | 2048 |
| 4bpw, 5bpw mix, 6bpw | 8192-16384 |
lm-evaluation-harness does not currently expose
enable_thinking=True through apply_chat_template. Until upstream
support lands, monkey-patch the tokenizer before evaluating:1def patch_thinking(tokenizer):
2 orig = tokenizer.apply_chat_template
3 def patched(*args, **kwargs):
4 kwargs.setdefault("enable_thinking", True)
5 return orig(*args, **kwargs)
6 tokenizer.apply_chat_template = patched