Repository navigation
fix(init): refuse only GPT-QModel's bitsandbytes layout (#4731) - #4750
Merged
Merged
Conversation
transformers' own `BitsAndBytesConfig` reports `quant_method == "bitsandbytes"`, and `AutoHfQuantizer.from_config` only appends the `_4bit`/`_8bit` suffix after the point where #4706 intercepted that name. Raising for every occurrence therefore refused every genuine HF bnb load in a process that imported GPT-QModel: `from_pretrained(..., quantization_config=BitsAndBytesConfig(...))` (QLoRA) and reloading any Hub bnb checkpoint both failed with "GPT-QModel BitsAndBytes checkpoints cannot be loaded by transformers". The guard now refuses only GPT-QModel's layout: - a dict is GPT-QModel's when it carries neither `load_in_4bit` nor `load_in_8bit` (`AutoQuantizationConfig.from_dict` maps a dict with either flag to a real `BitsAndBytesConfig` through `bitsandbytes_4bit`/`_8bit`); - an object is GPT-QModel's when it is not a `transformers.BitsAndBytesConfig`. GPT-QModel's own bnb layouts (`bits: 4` and `bits: 8`, no `load_in_*`) are still refused with the actionable message in both the object and dict forms. Tests: tests/test_bnb_hf_refusal_4664.py gains the positive HF cases (4-bit and 8-bit objects, 4-bit and 8-bit saved config dicts) and the negative GPT-QModel-layout cases for both bit widths. The three positive cases fail on the parent commit (the refusal fires) and pass here: 12 passed. Related suites: test_hf_refusal_remedy_4676.py and test_checkpoint_compat.py -> 66 passed, 1 failed; the failure is `test_untied_lm_head_quantizes_and_reloads`, which fails identically on pristine origin/main from the Marlin JIT build (CUDA_HOME unset).
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
_patch_transformers_refusing_quantizersrefused every config whosequant_method == "bitsandbytes". transformers' ownBitsAndBytesConfigcarries the same plain name, so importinggptqmodelbroke every genuine HF bnb load in that process — on-the-flyBitsAndBytesConfig(load_in_4bit=True)and reloading any HF-saved bnb checkpoint — with an error that blamed GPT-QModel checkpoints.Fixes #4731 (regression from #4706).
Fix
Refuse only GPT-QModel's layout, via a new
_is_gptqmodel_bitsandbytes_layout():load_in_4bitnorload_in_8bitis set.AutoQuantizationConfig.from_dictmaps a flagged dict to a real HFBitsAndBytesConfigthrough thebitsandbytes_4bit/bitsandbytes_8bitnames.transformers.BitsAndBytesConfig.GPT-QModel's
bits: 4/bits: 8checkpoint layouts (noload_in_*) are still refused with the actionable message, in both object and dict form.Evidence
test_hf_bitsandbytes_config_is_not_refused,test_hf_saved_bitsandbytes_config_dict_is_not_refused[4],[8]— all raised the GPT-QModel refusal. 9 passed.tests/test_bnb_hf_refusal_4664.py→ 12 passed.test_hf_refusal_remedy_4676.py+test_bnb_hf_refusal_4664.py→ 48 passed.Bnb4BitHfQuantizer/Bnb8BitHfQuantizer; GPT-QModel dict and object still raise the actionableValueError.ruff check gptqmodel testsclean.Residual:
test_checkpoint_compat.py::test_untied_lm_head_quantizes_and_reloadsfails identically on pristineorigin/main(Marlin JIT,CUDA_HOMEunset).