Skip to content

fix(exl3): honor head_bits and reload injected dynamic rules (#6224, #6216) - #6246

Merged
Qubitium merged 2 commits into
mainfrom
fix/6224-issue
Nov 29, 2026
Merged

Qubitium merged 2 commits into
mainfrom
fix/6224-issue

Conversation

@Qubitium

@Qubitium Qubitium commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This PR now fixes both EXL3 head-configuration issues.

#6224 — head_bits was silently ignored

EXL3Config(bits=4, head_bits=6) was accepted, logged, and serialized, but the looper only visits lm_head when quantize_config.lm_head is true. The head stayed dense BF16.

Following exllamav3 semantics, head_bits is a request to quantize the output head, so EXL3Config.__post_init__ now enables lm_head. The serialized config records lm_head: true instead of claiming a 6-bit head that was never applied. calculate_bits_per_weight only reports a head_bits rate when head quantization is requested.

#6216 — saved EXL3 head checkpoints could not reload

ModuleLooper._loop_impl injects the GPTQ-style implicit rule dynamic["lm_head"] = {"bits": 8, "group_size": 32, "sym": True, "desc_act": False, "mse": 2.4} for every method when lm_head=True. EXL3 ignores those keys, but they were serialized. Reload then failed with:

ValueError: EXL3Config: `group_size` is not used; keep it at `-1`.

The fix is config-side only, in gptqmodel/quantization/config.py (no changes to gptqmodel/looper/module_looper.py, avoiding a conflict with #6240):

  • EXL3 drops the unused dynamic keys group_size, sym, desc_act, and mse during normalization and before serialization.
  • bits and head_bits semantics are kept.
  • to_dict() also sanitizes rules injected after construction by the looper, so saved quantize_config.json / config.json contain only {"lm_head": {"bits": 8}} in the dynamic entry.
  • Unknown keys and invalid EXL3 rates still raise.

Test evidence

New #6224 tests

  • tests/test_exl3_fractional_bits.py::test_head_bits_enables_lm_head_quantization
  • tests/test_exl3_fractional_bits.py::test_head_bits_overrides_an_explicit_lm_head_false
  • tests/test_exl3_fractional_bits.py::test_head_bits_absent_does_not_enable_lm_head_quantization

Red at 2d3261d: 2 failed, 1 passed.

test_head_bits_enables_lm_head_quantization FAILED
E   AssertionError: assert False is True
E    +  where False = EXL3Config(... lm_head=False ... head_bits=6 ...).lm_head

test_head_bits_overrides_an_explicit_lm_head_false FAILED
E   AssertionError: assert False is True

Green: 3 passed.

New #6216 tests

  • tests/test_exl3_fractional_bits.py::test_injected_gptq_lm_head_dynamic_rule_loads_for_exl3
  • tests/test_exl3_fractional_bits.py::test_exl3_save_load_save_drops_injected_lm_head_group_size
  • tests/test_exl3_fractional_bits.py::test_exl3_dynamic_unknown_option_still_raises_after_sanitizing
  • tests/test_exl3_fractional_bits.py::test_exl3_dynamic_invalid_bits_still_raises_after_sanitizing

Red at 95c1a88 (the previous PR head, config file restored):

test_injected_gptq_lm_head_dynamic_rule_loads_for_exl3 FAILED
E   ValueError: EXL3Config: `group_size` is not used; keep it at `-1`.

test_exl3_save_load_save_drops_injected_lm_head_group_size FAILED
E   AssertionError: assert {'lm_head': {..., 'mse': 2.4}} == {'lm_head': {'bits': 8}}
E   {'lm_head': {'bits': 8, 'group_size': 32, 'sym': True, 'desc_act': False, 'mse': 2.4}}

Green: 4 passed.

Full commands and results

cd tests && CUDA_VISIBLE_DEVICES="" PYTHONPATH=/root/openai-audit/issue-6224:/root/openai-audit/issue-6224/tests /root/venv/bin/python -m pytest test_exl3_fractional_bits.py -q -rs -p no:cacheprovider

Result: 43 passed.

cd tests && CUDA_VISIBLE_DEVICES="" PYTHONPATH=/root/openai-audit/issue-6224:/root/openai-audit/issue-6224/tests /root/venv/bin/python -m pytest test_exllamav3.py -q -rs -p no:cacheprovider

Result: 17 passed, 2 skipped (ROCm GPU required).

cd tests && CUDA_VISIBLE_DEVICES="" PYTHONPATH=/root/openai-audit/issue-6224:/root/openai-audit/issue-6224/tests /root/venv/bin/python -m pytest qcfg/test_config_serialization.py test_quant_bits_validation.py -q -rs -p no:cacheprovider

Result: 38 passed and 202 passed.

Ruff:

/root/venv/bin/ruff check gptqmodel/quantization/config.py tests/test_exl3_fractional_bits.py

Result: All checks passed!

Unverified

  • End-to-end EXL3 quantization of an untied model was not run here (CUDA required). The regression asserts the looper gate, the injected dynamic payload, and the load/save/re-save config path.
  • Top-level group_size remains the EXL3 -1 sentinel; only the unused per-module dynamic key is removed.

Fixes #6224
Fixes #6216

@Qubitium Qubitium changed the title fix(exl3): make head_bits enable lm_head quantization (#6224) fix(exl3): honor head_bits and reload injected dynamic rules (#6224, #6216) Nov 29, 2026
@Qubitium
Qubitium marked this pull request as ready for review November 29, 2026 08:23
@Qubitium
Qubitium merged commit 0558c6e into main Nov 29, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/6224-issue branch November 29, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant