Repository navigation
fix(load): forward the AWQ bridge's quantization_config backend (#4729) - #4756
Merged
Merged
Conversation
#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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
#4702 forwarded
getattr(self, "backend", None)from both HF load bridges. Only Optimum'sGPTQQuantizerhas that attribute. transformers'AwqQuantizeris a plainHfQuantizerthat keeps the choice onquantization_config.backend, so the AWQ bridge always forwardedNone,_resolve_backend_for_checkpointresolved AUTO, and every explicit AWQ backend was silently ignored:docs/peft.md'sconfig.quantization_config["backend"] = "torch_awq"training recipe loaded the AUTO kernel;marlinon 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.backendwhen present, otherwisequantization_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_backendnow builds a realAwqQuantizer(AwqConfig(bits=4, group_size=128, backend="torch_awq"))and asserts a real quantizer has no.backend. The old test set.backendby hand on a bare__new__instance, so it passed against code that could not work.test_awq_bridge_forwards_a_trainable_backend_alias:auto_trainablereaches the selector unchanged.test_awq_hf_load_honours_the_config_backend: quantizes a tiny Llama with AWQ on CPU, saves, then loads throughAutoModelForCausalLM.from_pretrained—torch_awqinstallsAwqTorchLinear;marlinon CPU raisesValueError: Marlin ....Evidence
tests/test_hf_gptqmodel_load_bridge.py→ 27 passed.ruff check gptqmodel testsclean.