Skip to content

fix(load): forward the AWQ bridge's quantization_config backend (#4729) - #4756

Merged
Qubitium merged 2 commits into
mainfrom
fix/issue-4729
Nov 17, 2026
Merged

Qubitium merged 2 commits into
mainfrom
fix/issue-4729

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

What

#4702 forwarded getattr(self, "backend", None) from both HF load bridges. Only Optimum's GPTQQuantizer has that attribute. transformers' AwqQuantizer is a plain HfQuantizer that keeps the choice on quantization_config.backend, so the AWQ bridge always forwarded None, _resolve_backend_for_checkpoint resolved AUTO, and every explicit AWQ backend was silently ignored:

  • docs/peft.md's config.quantization_config["backend"] = "torch_awq" training recipe loaded the AUTO kernel;
  • a deliberately impossible marlin on a CPU host was accepted without a word, while the GPTQ bridge raises.

Fixes #4729.

Fix

gptqmodel/__init__.py: new _hf_quantizer_backend(quantizer) — the quantizer's own .backend when present, otherwise quantization_config.backend. Both the GPTQ and AWQ bridges use it, so Optimum's path is unchanged and an AWQ config is honoured.

Tests

  • test_awq_bridge_forwards_the_quantizer_backend now builds a real AwqQuantizer(AwqConfig(bits=4, group_size=128, backend="torch_awq")) and asserts a real quantizer has no .backend. The old test set .backend by hand on a bare __new__ instance, so it passed against code that could not work.
  • New test_awq_bridge_forwards_a_trainable_backend_alias: auto_trainable reaches the selector unchanged.
  • New end-to-end test_awq_hf_load_honours_the_config_backend: quantizes a tiny Llama with AWQ on CPU, saves, then loads through AutoModelForCausalLM.from_pretrained — torch_awq installs AwqTorchLinear; marlin on CPU raises ValueError: Marlin ....

Evidence

  • Red on parent (source change stashed, tests kept): 3 failed — both unit tests and the E2E.
  • Green: tests/test_hf_gptqmodel_load_bridge.py → 27 passed.
  • ruff check gptqmodel tests clean.

#4702 forwarded `getattr(self, "backend", None)` from both HF load bridges,
but only Optimum's GPTQQuantizer has that attribute. transformers' AwqQuantizer
keeps the choice on `quantization_config.backend`, so the AWQ bridge always
passed None, _resolve_backend_for_checkpoint resolved AUTO, and every explicit
AWQ backend (docs/peft.md's torch_awq training recipe, or an impossible marlin
on CPU) was silently ignored.

Read the quantizer's own backend first, then its quantization_config, in both
bridges. The AWQ test built a bare `AwqQuantizer.__new__` and set `.backend`
by hand, which a real quantizer never has; it now builds a real
AwqQuantizer(AwqConfig(backend=...)), and a new end-to-end test loads a saved
GPT-QModel AWQ checkpoint through AutoModelForCausalLM and asserts the
installed kernel (torch_awq -> AwqTorchLinear, marlin on CPU -> ValueError).
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