Repository navigation
Description
Summary
head_bits is the EXL3 option for the output-head rate (docs/exl3-runtime-weights.md: "The same 1.5, 2.5 and 3.5 rates are accepted for head_bits"). In exllamav3's own converter, head_bits is what quantizes the head. In GPT-QModel, EXL3Config(bits=4, head_bits=6) is accepted. Quantization logs the head rate as if it applies:
INFO Estimated Quantization BPW (bits per weight): 4 bpw, based on [bits: 4, head_bits: 6]
"head_bits": 6 is written to config.json. The head, however, is only visited when quantize_config.lm_head is True. Without that flag, lm_head stays a dense nn.Linear and the checkpoint stores lm_head.weight [32000, 2048] in BF16. No warning or error says that head_bits was ignored. On an untied 7-8B model (Qwen2.5-7B, Llama-3.1-8B, Mistral-7B) the head is 0.27-1.09 GB of BF16 that the user configured to be 6-bit.
Introduced by
Pre-existing (the head is gated only on quantize_config.lm_head). Still present on origin/main b050965.
Location (87e424a)
gptqmodel/looper/module_looper.py:2172/:2302/:2364-2371andgptqmodel/looper/stage_layer.py:683: the head step exists onlyif self.gptq_model.quantize_config.lm_head.gptqmodel/looper/exllamav3_processor.py:2560-2565:head_bitsis consumed only for a module that already is the head:if self._is_lm_head(module) and module_qcfg.head_bits is not None: return module_qcfg.head_bits
gptqmodel/quantization/config.py:10592-10602(EXL3Config.__post_init__) normalizeshead_bitsbut never checks it againstlm_head.calculate_bits_per_weight(:10736) reports it as applied.
Reproduction (ran it: RTX 5090, 87e424a)
from datasets import load_dataset
from safetensors import safe_open
from gptqmodel import GPTQModel, CalibrationConfig
from gptqmodel.quantization import EXL3Config
ds = load_dataset("allenai/c4", data_files="en/c4-train.00001-of-01024.json.gz", split="train")
calib = [r["text"] for r in ds.select(range(256)) if len(r["text"]) > 300][:32]
m = GPTQModel.load("TinyLlama/TinyLlama-1.1B-Chat-v1.0", EXL3Config(bits=4, head_bits=6)) # untied head
m.quantize(CalibrationConfig(dataset=calib, batch_size=4))
print(type(m.model.lm_head).__name__)
m.save("tinyllama-exl3-hb6")
with safe_open("tinyllama-exl3-hb6/model.safetensors", "pt") as s:
print([(k, s.get_slice(k).get_shape()) for k in s.keys() if k.startswith("lm_head")])Output:
INFO Estimated Quantization BPW (bits per weight): 4 bpw, based on [bits: 4, head_bits: 6]
Linear
[('lm_head.weight', [32000, 2048])]
config.json quantization_config: {'head_bits': 6, 'lm_head': False, 'dynamic': None}
With lm_head=True added, the head becomes ExllamaV3Linear with a 6-bit trellis ([128, 2000, 96]), so head_bits itself works. Only the gating is wrong. (That checkpoint then hits #6216 on reload.)
Expected vs actual
Expected: either head_bits quantizes the head (exllamav3 semantics), or the config rejects or warns about head_bits without lm_head=True.
Actual: the option is accepted, logged as applied and persisted, and the head silently stays BF16.
Suggested fix
In EXL3Config.__post_init__, treat head_bits is not None as a request to quantize the head (set lm_head=True), or raise ValueError("head_bits requires lm_head=True"). Make calculate_bits_per_weight report the head rate only when the head is actually quantized.
Activity
fix(exl3): honor head_bits and reload injected dynamic rules (#6224, #…
fix(exl3): resolve head_bits against tied output heads (#6347) (#6354)