Skip to content

[BUG] Dense-load backend is inherited by quantize() only when typed: load(backend=BACKEND.AWQ_TORCH) is silently replaced by AUTO, load(backend=AwqTorchConfig()) is honored (#4375) #4582

Closed

Description

@Qubitium

Found on main @ 4b65923, RTX 4090 (sm89), torch 2.15 + CUDA 13.2.

What is wrong

Since #4375, BaseQModel.quantize() calls resolve_quantize_backend(backend, self.quantize_config, inherit=True) (gptqmodel/models/base.py:2127-2129). That carries the dense load's backend into quantize(backend=AUTO), but only when the load used a typed BackendConfig. resolve_quantize_backend sets qcfg._backend_config only for a typed backend (gptqmodel/utils/backend_config.py:302). An enum passed to the same load (backend=BACKEND.AWQ_TORCH) is used only for auto_select_device in ModelLoader.from_pretrained and is then dropped, with no warning. The two spellings of the same explicit request therefore quantize and pack with different kernels:

dense load quantize() packs with
GPTQModel.load(src, AWQConfig(), backend=AwqTorchConfig()) AwqTorchLinear (inherited)
GPTQModel.load(src, AWQConfig(), backend=BACKEND.AWQ_TORCH) AwqGEMMLinear (AUTO; the request is silently replaced)

This is not cosmetic. The packer decides which shapes can be quantized. For example, AwqGEMMLinear needs out_features % 64 == 0 (see #4567).

Repro

Same 2-layer FalconMamba as #4567 (falcon-mamba-7b-instruct config, num_hidden_layers=2, random weights; x_proj is 8192->288):

from gptqmodel.utils.backend_config import AwqTorchConfig
for be in (AwqTorchConfig(), BACKEND.AWQ_TORCH):
    m = GPTQModel.load(src, AWQConfig(bits=4, group_size=128), dtype=torch.bfloat16, backend=be)
    m.quantize(calib)

Output:

load backend = typed AwqTorchConfig()  -> quantize() OK, kernels ['AwqTorchLinear']
load backend = enum BACKEND.AWQ_TORCH  -> quantize() FAILED NotImplementedError <class '...gemm_awq.AwqGEMMLinear'>: `out_features`: 288 must be divisible by [64].

Suggested fix

Record an explicit, non-AUTO enum the same way as a typed choice: qcfg._backend_config = backend (or a separate _load_backend) whenever normalize_backend(backend) != AUTO, so quantize(backend=AUTO) inherits it. If enum inheritance is deliberately unsupported, GPTQModel.load(..., quantize_config, backend=<enum>) should at least warn that the enum does not apply to quantization, and docs/backend-selection.md should say so. Today it is silently ignored.

Test that should have caught it

tests/test_backend_config_reuse_4446.py covers typed inheritance only. Parametrize it over AwqTorchConfig() vs BACKEND.AWQ_TORCH (and TorchConfig() vs BACKEND.GPTQ_TORCH) and assert the same packing kernel.

Severity

Low-medium. An explicit backend request is silently replaced. It turns into a crash on shapes only the requested kernel supports.

🤖 Generated with Claude Code

Activity

  1. Qubitium commented on Nov 17, 2026

    @Qubitium
    CollaboratorAuthor

    Claimed. This issue is now owned by a dedicated worker; a fix PR referencing it will follow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions