You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] transformers load of GPT-QModel-made checkpoints silently ignores quantization_config["backend"] (docs/peft.md's gptq_torch, even marlin on CPU): #4084 bridge never forwards the Optimum backend #4680
Found on main @ 12c1273, CPU (x86-64), transformers 5.22.1, optimum (installed in the CUDA venv), PEFT.
What is wrong
docs/peft.md says to pick a trainable kernel through the HF config before training: config.quantization_config["backend"] = "gptq_torch", because "the default inference kernels do not propagate gradients through the quantized layers, so a backward pass will fail". For checkpoints made by GPT-QModel, that setting is silently ignored.
The #4084 HF load bridge replaces GPTQQuantizer.convert_model (gptqmodel/__init__.py:447-460) and calls
It never passes backend=self.backend. hf_gptqmodel_prepare_model_for_load has a backend parameter (gptqmodel/utils/hf_load.py:246), but it is always None, so _resolve_backend_for_checkpoint turns it into BACKEND.AUTO. Optimum-owned (third-party) checkpoints still go through original_convert_model, which does honor backend. So the user's backend choice works or not depending on who made the checkpoint.
Repro
Kernel classes after AutoModelForCausalLM.from_pretrained(path, config=cfg, device_map="cpu", dtype=torch.bfloat16) with cfg.quantization_config["backend"] = <backend> (gptqmodel imported), compared with GPTQModel.load(path, backend=<backend>):
Even an impossible backend (marlin on a CPU-only host) is accepted without a word for the native checkpoint.
Impact
On a CUDA host, AUTO picks Marlin for a 4-bit GPTQ checkpoint (SUPPORTS_TRAINING = False, qlinear/marlin.py:96). Following docs/peft.md for a checkpoint quantized with GPT-QModel therefore gives a model whose kernel is not the trainable one the doc tells you to select. The documented FSDP recipe used hugging-quants/Meta-Llama-3.1-8B-Instruct-GPTQ-INT4, an Optimum-path checkpoint, so it never went through the bridge. The same ignore applies to every inference-side backend choice made through transformers (for example exllama_v2 or torch_fused for determinism or performance).
I could not run the CUDA training failure on this host. The kernel-selection evidence above was gathered on CPU.
Suggested fix
Forward the quantizer's backend: hf_gptqmodel_prepare_model_for_load(model, ..., backend=getattr(self, "backend", None), ...). Add a bridge test that asserts quantization_config["backend"] selects the same kernel class as GPTQModel.load(backend=...) for a native checkpoint, and that an incompatible backend raises.
Tests that should have caught it
tests/test_hf_gptqmodel_load_bridge.py only checks that Optimum's hooks call the bridge, not that the caller's backend reaches make_quant.
Severity
Medium. An explicit user setting is silently dropped, and the documented PEFT training recipe does not do what it says for GPT-QModel-made checkpoints (regression from #4084).
Claimed. The #4084 bridge never forwards the quantizer's backend, so quantization_config["backend"] is always resolved to AUTO for GPT-QModel-made checkpoints. Will forward it and add a bridge test asserting the selected kernel class matches GPTQModel.load(backend=...), plus that an incompatible backend raises.
Activity
Qubitium commentedon Nov 17, 2026
Claimed. The #4084 bridge never forwards the quantizer's
backend, soquantization_config["backend"]is always resolved to AUTO for GPT-QModel-made checkpoints. Will forward it and add a bridge test asserting the selected kernel class matchesGPTQModel.load(backend=...), plus that an incompatible backend raises.fix(hf): forward quantization_config["backend"] through the load brid…