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] AWQ GEMM quantize on CUDA rejects any per-module dynamic width (bits 3/8): model-wide AwqGEMMLinear gate runs before the per-module AwqTorchLinear fallback #5408
Found on main @ 1405751, RTX 5090 (sm_120), transformers 5.23.0.
What is wrong
AWQConfig accepts a per-module width through dynamic (for example {"bits": 8} on one layer of a 4-bit run). tests/test_awq_per_module_bits.py and AWQProcessor._resolve_qlinear_kernel (looper/awq_processor.py:726-735) document this: "RCO can allocate a different width per module. The CUDA GEMM/GEMV kernels unpack 4-bit codes only, so a non-4-bit module must use the portable torch kernel". The per-module fallback to AwqTorchLinear exists, but it never runs on a CUDA host with the default backend:
BaseQModel.quantize picks awq_gemm_pack_backend(...), which returns BACKEND.AWQ_GEMM on CUDA (utils/backend.py:279-281, models/base.py:2691-2698).
quantize then runs a model-wide select_quant_linear(..., dynamic=self.quantize_config.dynamic, backend=BACKEND.AWQ_GEMM) (models/base.py:2781). This validates AwqGEMMLinear against every dynamic width (nn_modules/qlinear/__init__.py:1028_validate_dynamic_bits) and raises before calibration starts.
So any AWQ GEMM run with a non-4-bit dynamic width fails on CUDA unless the caller passes backend=BACKEND.AWQ_TORCH. With that backend the identical config quantizes, saves and reloads with the requested widths. So the format and the packer both support it, and only the up-front gate rejects it.
File "gptqmodel/models/base.py", line 2781, in quantize
File "gptqmodel/utils/importer.py", line 1868, in select_quant_linear
ValueError: <class 'gptqmodel.nn_modules.qlinear.gemm_awq.AwqGEMMLinear'> not supported dynamic_bits, only support `[4]` bits
The same model and config with m.quantize(CalibrationConfig(dataset=c4_rows[:16]), backend=BACKEND.AWQ_TORCH) works. Save and GPTQModel.load give layers.0.mlp.down_proj as AwqMarlinLinear bits 4 and layers.1.mlp.down_proj as AwqMarlinLinear bits 8. The same failure occurs with regex rules ({"+:.*layers\\.1\\..*": {"bits": 8}}).
Suggested fix
When awq_gemm_pack_backend would choose AWQ_GEMM and dynamic assigns any width outside AwqGEMMLinear.SUPPORTS_BITS, either validate the model-wide candidate against the global width only (the per-module _resolve_qlinear_kernel already picks AwqTorchLinear for those modules), or choose AWQ_TORCH as the pack backend. Apply the same to GEMV/GEMV_FAST if they share the gate.
Test that should have caught it
tests/test_awq_per_module_bits.py uses stubs only and never calls quantize(). Add an end-to-end CUDA AWQ GEMM quantize with one {"bits": 8} module, then save, reload and check the per-module width.
Severity
Medium. A documented per-module configuration (and RCO's AWQ allocation, which writes such dynamic widths) is refused on the default CUDA path. It fails loudly before any work, and backend=BACKEND.AWQ_TORCH is a workaround.
AWQ: the model-wide select_quant_linear gate must validate the global width only, so per-module non-4-bit dynamic widths fall back to AwqTorchLinear in _resolve_qlinear_kernel instead of failing before calibration.
Activity
Qubitium commentedon Nov 19, 2026
Agent claim released:
agent-fb5145b84190finished this issue.Pull request: #5443
AWQ: the model-wide select_quant_linear gate must validate the global width only, so per-module non-4-bit dynamic widths fall back to AwqTorchLinear in _resolve_qlinear_kernel instead of failing before calibration.
fix(awq): gate the model-wide GEMM pack kernel on the global width (#…