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] AUTO on CPU selects TorchAtenLinear / TorchFusedLinear for shapes the int4pack op rejects; their dequantize_model breaks bias-less layers #4181
Severity: medium (crash on first forward with AUTO) Version: 7.11.0 @ 6c3421c
1. Odd output width
TorchAtenLinear and TorchFusedLinear declare SUPPORTS_OUT_FEATURES_DIVISIBLE_BY=[1] (torch_aten_kernel.py:82, torch_fused.py:147).
transform_cpu does zero_codes.reshape(self.scales.shape) (torch_aten_kernel.py:313, torch_fused.py:404), which fails when N is not a multiple of 8.
With N=100, the AUTO order is [CpuAvx512, Aten, Fused, Torch]. Avx512 rejects; Aten and Fused accept, then raise:
RuntimeError: shape '[8, 100]' is invalid for input of size 832
TorchLinear handles the same layer (rel 3e-4).
2. group_size == in_features
The base validation escape at nn_modules/qlinear/__init__.py:~1004 (group_size != in_features) lets TorchAten accept gs=512 with K=512 and gs=1024 with K=1024.
The aten op then raises expect qGroupSize to be 32, 64, 128 or 256.
Fix for 1 and 2: declare the real constraints (SUPPORTS_OUT_FEATURES_DIVISIBLE_BY=[8], and an explicit group-size set that also applies when gs == K) so AUTO falls through to TorchLinear.
3. dequantize_model builds a broken bias
In torch_fused.py:~542 and torch_aten_kernel.py:~441, nn.Parameter(module.bias) with bias=None creates a shape-[0] bias. Every bias-less layer (e.g. all of Llama) then fails in forward.
The weight is also hard-coded to fp16.
The torch.py version is correct.
Found during an AI-assisted review (Claude Code) of 6c3421c; repros were run on RTX 4090/5090 (CUDA 13) and Radeon AI PRO R9700 (ROCm) unless marked static/suspected.
Round-12 check at def6e61, after c9fb1ed: the N%16 and gs==K contracts now fall through correctly, but CPU AUTO still picks TorchAtenLinear / TorchFusedLinear when in_features % group_size != 0, and the first forward crashes.
Where:
nn_modules/qlinear/torch_aten_kernel.py:95 and torch_fused.py:169 declare SUPPORTS_AUTO_PADDING = True.
Because of that, GroupedQuantLinear._validate (nn_modules/qlinear/__init__.py:1064-1065) skips the K % gs check.
Neither kernel actually pads, and _weight_int4pack_mm_cpu requires K % gs == 0.
Repro:
Take a Llama with hidden_size=576 (the SmolLM2-135M shape).
Quantize with GPTQ, bits=4, gs=128, and save.
Load with GPTQModel.load(path, device="cpu").
AUTO resolves to TorchAtenLinear, and the forward raises _weight_int4pack_mm_cpu: expect K to be divisible by qGroupSize, got K:576, qGroupSize:128.
An explicit GPTQ_TORCH_FUSED fails the same way.
BACKEND.TORCH works.
Fuzz: K ∈ {64…1024}, N ∈ {8…256}, several group sizes, with and without bias, sym and asym. All 180 failures are this K % gs class.
Activity
fix(cpu): align int4pack kernel contracts with the packed op (#4181) (#…
Qubitium commentedon Nov 16, 2026
Claimed. This issue is now owned by a dedicated worker; a fix PR referencing it will follow. Please avoid duplicating work on it in the meantime.
Qubitium commentedon Nov 16, 2026
Round-12 check at
def6e61, after c9fb1ed: the N%16 and gs==K contracts now fall through correctly, but CPU AUTO still picksTorchAtenLinear/TorchFusedLinearwhenin_features % group_size != 0, and the first forward crashes.Where:
nn_modules/qlinear/torch_aten_kernel.py:95andtorch_fused.py:169declareSUPPORTS_AUTO_PADDING = True.GroupedQuantLinear._validate(nn_modules/qlinear/__init__.py:1064-1065) skips the K % gs check._weight_int4pack_mm_cpurequires K % gs == 0.Repro:
GPTQModel.load(path, device="cpu").AUTO resolves to
TorchAtenLinear, and the forward raises_weight_int4pack_mm_cpu: expect K to be divisible by qGroupSize, got K:576, qGroupSize:128.GPTQ_TORCH_FUSEDfails the same way.BACKEND.TORCHworks.Fuzz: K ∈ {64…1024}, N ∈ {8…256}, several group sizes, with and without bias, sym and asym. All 180 failures are this K % gs class.
test(cpu): cover #4181 int4pack dispatch and dequantize regressions (#…