Repository navigation
Description
Describe the bug
At 0b94d79c67, the cases below violate the stated supported contract. The validation scope for each case is explicit; source/dispatch proofs are not device numerical qualification.
AWQ clipping rejects shapes accepted by the selected portable packer
Severity: medium
Contract and impact
Every module shape admitted by the selected AWQ packer must also be handled by clip search, including a partial output-channel tile.
Supported quantize() aborts with a bare AssertionError after scale search and final scale folds; packing/save are never reached. This is a current latent shape-contract defect, not a demonstrated recent reintroduction.
To reproduce / evidence
One-layer native Qwen3, hidden_size=96, intermediate_size=192, four attention and KV heads, head_dim=24, AWQ W4 GEMM group_size=32, CPU BACKEND.TORCH. No unusual dtype or remote code is required.
Run from the pinned repository with its requirements and CPU Torch installed:
from pathlib import Path
from tempfile import TemporaryDirectory
from transformers import Qwen3Config, Qwen3ForCausalLM
from gptqmodel import BACKEND, GPTQModel, QuantizeConfig
from gptqmodel.quantization import METHOD, FORMAT
from tests.test_tiny_moe_quant_smoke import _build_local_tokenizer, _build_calibration_dataset
with TemporaryDirectory() as td:
p = Path(td)
cfg = Qwen3Config(num_hidden_layers=1, hidden_size=96, intermediate_size=192,
num_attention_heads=4, num_key_value_heads=4, head_dim=24, vocab_size=128,
pad_token_id=0, bos_token_id=1, eos_token_id=2)
Qwen3ForCausalLM(cfg).save_pretrained(p)
tok = _build_local_tokenizer(p)
qc = QuantizeConfig(bits=4, group_size=32, desc_act=False, device='cpu',
method=METHOD.AWQ, format=FORMAT.GEMM, offload_to_disk=False)
m = GPTQModel.load(str(p), quantize_config=qc, backend=BACKEND.TORCH)
m.quantize(_build_calibration_dataset(tok), batch_size=1,
backend=BACKEND.TORCH, calibration_data_min_length=1)Independently executed in reproduce.py, not an AST copy or mocked quantizer. Traceback: BaseQModel.quantize -> ModuleLooper -> AWQProcessor.process -> _quantize_layer:2574 -> _search_best_clip:3023 -> _compute_best_clip:3078 -> AssertionError. A saved random native checkpoint and local tokenizer are tiny test fixtures, not downloaded trained weights.
Observed native trace: AWQProcessor._compute_best_clip -> awq_processor.py:3078 -> AssertionError. Actual script uses torch.manual_seed(31) and one CPU Torch thread. No scale, clip, pack or routing function was replaced.
Observed and expected behavior
Observed: AssertionError at 96 % 64 != 0. Expected: process 64+32 output rows (or otherwise support the declared packer shape), returning bounds for all 96 rows. Smallest structural correction: clipping owns only a tile size, not a second module-shape support predicate; derive tail extents from the resolved module geometry and assert returned bounds cover every row before mutation.
Public source and history
GPTQModel/gptqmodel/looper/awq_processor.py
Lines 3077 to 3078 in 0b94d79
| oc_batch_size = 256 if org_w_shape[0] % 256 == 0 else 64 # prevent OOM | |
| assert org_w_shape[0] % oc_batch_size == 0 |
GPTQModel/gptqmodel/nn_modules/qlinear/torch_awq.py
Lines 25 to 42 in 0b94d79
| SUPPORTS_METHODS = [METHOD.AWQ] | |
| SUPPORTS_FORMATS = {FORMAT.GEMM: 10} | |
| SUPPORTS_BITS = [2, 3, 4, 5, 6, 7, 8] | |
| SUPPORTS_GROUP_SIZE = [-1, 16, 32, 64, 128] | |
| SUPPORTS_DESC_ACT = [True, False] | |
| SUPPORTS_SYM = [True, False] | |
| SUPPORTS_SHARDS = True | |
| SUPPORTS_TRAINING = True | |
| SUPPORTS_AUTO_PADDING = False | |
| SUPPORTS_IN_FEATURES_DIVISIBLE_BY = [1] | |
| SUPPORTS_OUT_FEATURES_DIVISIBLE_BY = [8] | |
| SUPPORTS_DEVICES = [DEVICE.CPU, DEVICE.CUDA, DEVICE.ROCM, DEVICE.XPU, DEVICE.NPU, DEVICE.MPS] | |
| SUPPORTS_PLATFORM = [PLATFORM.ALL] | |
| SUPPORTS_PACK_DTYPES = [torch.int32] | |
| SUPPORTS_ADAPTERS = [Lora] | |
| SUPPORTS_DTYPES = [torch.float16, torch.bfloat16] |
GPTQModel/gptqmodel/looper/awq_processor.py
Lines 2504 to 2598 in 0b94d79
| try: | |
| apply_scale( | |
| layer_module_ref, | |
| scales_list, | |
| input_feat_dict=input_feat, | |
| consumer_map=consumer_map, | |
| ) | |
| except RuntimeError as exc: | |
| debug_entries = [] | |
| for prev_op_name, layer_names, scales, _loss in scales_list: | |
| entry = {"prev": prev_op_name, "prev_shape": None, "layer_shapes": [], "scale_elems": None} | |
| try: | |
| prev_module = get_op_by_name(layer_module_ref, prev_op_name) | |
| except Exception: | |
| prev_module = None | |
| weight = getattr(prev_module, "weight", None) if prev_module is not None else None | |
| if isinstance(weight, torch.Tensor): | |
| entry["prev_shape"] = tuple(weight.shape) | |
| elif prev_module is None: | |
| entry["prev_shape"] = "missing" | |
| else: | |
| entry["prev_shape"] = f"{type(prev_module).__name__} (no weight)" | |
| layer_shapes = [] | |
| for lname in layer_names: | |
| try: | |
| layer_module = get_op_by_name(layer_module_ref, lname) | |
| except Exception: | |
| layer_shapes.append((lname, "missing")) | |
| continue | |
| weight = getattr(layer_module, "weight", None) | |
| if isinstance(weight, torch.Tensor): | |
| layer_shapes.append((lname, tuple(weight.shape))) | |
| else: | |
| layer_shapes.append((lname, f"{type(layer_module).__name__} (no weight)")) | |
| entry["layer_shapes"] = layer_shapes | |
| if hasattr(scales, "numel"): | |
| try: | |
| entry["scale_elems"] = int(scales.numel()) | |
| except Exception: | |
| entry["scale_elems"] = "unknown" | |
| debug_entries.append(entry) | |
| log.error( | |
| "AWQProcessor: apply_scale failed at layer %s with %s. Shape summary (first 5 groups): %s", | |
| layer_index, | |
| exc, | |
| debug_entries[:5], | |
| ) | |
| raise | |
| scales_list = append_str_prefix( | |
| scales_list, | |
| get_op_name(self.model, layer_module_ref) + ".", | |
| ) | |
| staged_teacher = None | |
| staged_gsq = getattr(self.qcfg, "gsq_training", None) | |
| if staged_gsq is not None and staged_gsq.enabled: | |
| from .gsq_training_awq import capture_awq_staged_teacher | |
| plan = _model_module_plan(self.gptq_model) | |
| projections = tuple( | |
| name for name, named in named_childs.items() | |
| if plan is None or plan.roles(name) | |
| ) | |
| staged_teacher = capture_awq_staged_teacher( | |
| self, layer_module_ref, named_childs, fallback_names, projections=projections, | |
| ) | |
| if self.apply_clip: | |
| clip_list = self._search_best_clip( | |
| layer_module_ref, | |
| {name: named.module for name, named in named_childs.items() if name not in fallback_names}, | |
| input_feat, | |
| ) | |
| apply_clip(layer_module_ref, clip_list) | |
| clip_list = append_str_prefix( | |
| clip_list, | |
| get_op_name(self.model, layer_module_ref) + ".", | |
| ) | |
| fallback_named_childs = { | |
| n: named_childs[n] | |
| for n in fallback_names | |
| if n in named_childs | |
| } | |
| named_childs = {name: named for name, named in named_childs.items() if name in input_feat and name not in fallback_names} | |
| self.apply_quant(named_childs, scales_list) | |
| if staged_teacher is not None: | |
| from .gsq_training_awq import refine_awq_staged_layer | |
| refine_awq_staged_layer(self, staged_teacher, named_childs, layer_index=layer_index) |
Already present in the AWQ introduction 2d8f35f (#1703, 2025-09-18), where _compute_best_clip lines 434-435 contain the same 64/256 selection and assertion. It predates the audit baseline. Later vectorization 3333ed5 retained the invariant mismatch; it did not newly introduce the 64-row restriction.
Existing reports
Searched OPEN and CLOSED issues using AWQ, AWQ clip output, AWQ "64" "clip", and AWQ "out_features". No exact clipping-row duplicate was located. #4095 is a separate native GEMM out_features/group_size constraint; it is not this portable clipping restriction. #4401 concerns allocator scratch, not this shape error. Search is not proof that no duplicate exists.
Software / device info and validation limits
Independently reproduced using real native CPU quantize at the pin: CPython 3.12.16, torch 2.15.0+cpu, transformers 5.23.0. Historical introduction checked from actual source/path history. No GPU arithmetic, quality or performance claim. Failing run aborts before save/pack. Separate uniform-g32 staged-GSQ control completed safetensors save/reload and finite forward; it is not a post-fix control for the 96-row clip failure.
Model / datasets
The evidence uses tiny synthetic tensors or local fixtures derived from the public tests; no private model or dataset is required. Device execution that remains untested is stated above.
Activity
Qubitium commentedon Nov 17, 2026
Taking this. I'll investigate against current
main, add a targeted regression test, and open a PR. Will report back here if the claim turns out to be invalid or already fixed.Qubitium commentedon Nov 17, 2026
Claimed by an AI agent. Will reproduce on CPU, fix, add a focused regression test, and open a PR.
test(awq): cover the partial output tile and explicit non-2-D error (#…