Skip to content

[BUG] AUTO on CPU selects TorchAtenLinear / TorchFusedLinear for shapes the int4pack op rejects; their dequantize_model breaks bias-less layers #4181

Closed

Description

@Qubitium

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.

Activity

  1. added
    bug
    on Nov 16, 2026
  2. Qubitium commented on Nov 16, 2026

    @Qubitium
    CollaboratorAuthor

    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.

  3. Qubitium commented on Nov 16, 2026

    @Qubitium
    CollaboratorAuthor

    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:

    1. Take a Llama with hidden_size=576 (the SmolLM2-135M shape).
    2. Quantize with GPTQ, bits=4, gs=128, and save.
    3. 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.

  4. added a commit that references this issue on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions