Repository navigation
fix(quantize): do not pack with an inherited inference-only backend (#6154) - #6162
Merged
Merged
Conversation
`AwqGEMMLinear.pack` keeps the source scale width (`scales.dtype if scales.dtype in (fp16, bf16) else fp16`), so a BF16 model's committed bundle holds BF16 `scales`. `restore_packed_module` rebuilt the template from the kernel constructor, which allocates `scales` at FP16, and `packed_module_config` recorded no scale dtype. Every resume of a BF16 AWQ run therefore failed `checkpoint tensor schema differs` before layer 0. Record `scales_dtype` when the stored width is not the FP16 template default, and restore it on the meta template the same way `bias_dtype` is restored (#4324). FP16 needs no entry, so existing GPTQ and FP16 AWQ checkpoint configs are unchanged. The recorded width always equals the bundle's, because capture serializes the live `state_dict()`. Fixes #6153
…6154) `quantize(backend=AUTO)` inherits the backend given to the dense `GPTQModel.load(...)`. Marlin, ExLlamaV2 and AWQ-Marlin have no pack API, so the inherited selection failed the pack validation before calibration: ValueError: Selected backend `BACKEND.MARLIN` with kernel `MarlinLinear` cannot pack quantized weights for format `FORMAT.GPTQ`. That is the documented `load(..., backend=MarlinConfig(...))` + `quantize()` example in docs/backend-selection.md. Inherit only a selection that can pack. An inference-only retained backend now packs with the method default, exactly as an un-retained AUTO request does, and warns once; an explicit `quantize(backend=...)` is not inherited and still raises. The inheritance rule moves into `inherited_quantize_backend` so the resolver and `quantize()` cannot disagree about which requests are inherited. Fixes #6154
Qubitium
marked this pull request as ready for review
November 28, 2026 08:53
This was referenced Nov 28, 2026
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.
Summary
quantize(backend=AUTO)inherits the backend given to the denseGPTQModel.load(...). Marlin, ExLlamaV2 and AWQ-Marlin are inference-only: theyhave no pack API. The inherited selection therefore failed the pack validation
before calibration:
That is exactly the documented example in
docs/backend-selection.md(
load(..., backend=MarlinConfig(fp32=False))+quantize()), and the plainenum spelling regressed the same way in #4606.
Fixes #6154
What Changed
gptqmodel/utils/backend_config.py:inherited_quantize_backend(qcfg, backend)is now the single owner of the "would this call inherit the load's backend?"
rule;
resolve_quantize_backenduses it, so callers cannot disagree.gptqmodel/models/base.py:_backend_can_packselects the backend's kernel withoutpack=Trueand asks_supports_pack_api, instead of provoking the validation error.resolve_pack_backendkeeps a retained selection that can pack and fallsback to
BACKEND.AUTO(the method default, exactly as an un-retained AUTOrequest) with one warning when it cannot.
quantize()uses it before the AUTO/device branch, so the packed modules andself.quantize_backendsee the packable choice.tests/test_backend_config.pyfamily.Behaviour change: a retained inference-only load backend no longer becomes the
packing backend; it is used only for the dense load (device selection), which is
the pre-#4606 behaviour. An explicit
quantize(backend=BACKEND.MARLIN)is notinherited, so it still raises - as the issue allows. Out of scope: making Marlin
itself packable ("marlin padding"), and the
docs/backend-selection.mdwording,which remains accurate.
Tests
Red - end-to-end, HEAD source, documented flow on a cached tiny model:
Green - same script with the fix:
Reproduced twice: with
device="cuda:0"and with the loader's default device.Unit tests (new nodes in
tests/test_backend_config.py):Backend/policy families:
Lint:
ruff check0.14.2 on all three changed files: all checks passed.No skips in any run above.
Measured Impact
Functional, not a speed change. The extra
select_quant_linear(pack=False)callruns once per
quantize()and only when a load backend was retained.MarlinConfig(fp32=False)+quantize()ValueError: cannot pack quantized weightsBACKEND.GPTQ_TORCHBACKEND.EXLLAMA_V2+quantize()ValueErrorBACKEND.TRITON(can pack)quantize(backend=BACKEND.MARLIN)Model Support / Module Plan
Not applicable: no model, alias, definition, or module-plan change.
AWQ onboarding safety
Not applicable to onboarding: no new model/alias/definition. The change is
method-agnostic and only decides which backend packs; AWQ grouping, search,
replay and fold are untouched.
Logic Flow Documentation
It inserts one guard between backend inheritance and the existing AUTO/device
branch; the ordering after it is unchanged.
Review Requirements
Kernel Accuracy Requirements
Not applicable: no kernel change.
Notes
_supports_pack_apiis imported fromgptqmodel.utils.importer(it alreadybacks the error this change avoids). The fallback keeps the previous behaviour
for every packable selection and for un-retained AUTO requests, so only the
crashing case changes.