Skip to content

[TEST] #5070 declares base INDUCTOR for TorchFused/TorchAten (GPTQ+AWQ) and GGUFTorchLinear: 3 compile-level tests red on every GPU host; bf16 (CPU AUTO dtype) and biased layers never reach inductor #5110

Closed

Description

@Qubitium

Found on main @ 7b8f127, RTX 4090 (torch 2.15.0+cu132) and AMD R9700 (ROCm, torch 2.16.0.dev rocm10.1).

What is wrong

#5070 (caa5bb13e, "make quantized CPU kernels torch-compilable") raised the class-wide SUPPORTS_COMPILE_LEVEL to INDUCTOR for TorchFusedLinear, TorchAtenLinear, TorchFusedAwqLinear, TorchAtenAwqLinear and GGUFTorchLinear. The other kernels in the same PR use SUPPORTS_COMPILE_LEVEL_BY_DEVICE = {"cpu": INDUCTOR}. Neither claim holds as declared:

  1. GGUFTorchLinear (gptqmodel/nn_modules/qlinear/gguf.py:1222-1243). The comment right above the declaration still says that on CUDA "dynamo breaks on tensor.is_inference() in tensor_cache_key, so only EAGER is reachable". The class nevertheless declares base INDUCTOR, so the CUDA level now over-claims. CPU really does reach INDUCTOR, so the CPU-only override is the right shape.
  2. int4pack kernels (GPTQ and AWQ, TorchFused and TorchAten). INDUCTOR is reached only for an fp16, bias-free layer. A bf16 activation, or any biased layer, goes through the @torch.compiler.disabled _cpu_int4pack_mm_cast (torch_fused.py:167) and graph-breaks on every linear. bf16 is the CPU AUTO dtype for these kernels (utils/model.py:2251-2253, "Auto dtype (CPU + Torch Fused): bfloat16"), so the default configuration never reaches the declared level. docs/kernel-compile-matrix.md publishes INDUCTOR / INDUCTOR for all of them.

Measured with the repo's own tests/kernels/compile_probe.probe on CPU (512x256, g128, 4 rows):

kernel fp16 no bias bf16 no bias fp16 bias bf16 bias
TorchFusedLinear (GPTQ) inductor 1 break 1 break 1 break
TorchAtenLinear (GPTQ) inductor 1 break 1 break 1 break
TorchFusedAwqLinear inductor 1 break 1 break 1 break
TorchAtenAwqLinear inductor 1 break (fp32 also inductor) 1 break 1 break
GGUFTorchLinear (CPU) inductor inductor inductor inductor

The break reason is always Skip calling `torch.compiler.disable()`d function _cpu_int4pack_mm_cast.

Consequence: three tests red on every GPU host since #5070

Bisected with the HEAD tests over 3867c82af..7b8f12785. The first bad commit is caa5bb13e (#5070) for all three. All three fail deterministically on CUDA and on ROCm (CPU-only runs skip them, see below):

FAILED tests/kernels/test_kernel_compile_levels_awq.py::test_awq_kernel_reaches_declared_compile_level[TorchFusedAwqLinear]
  declared INDUCTOR but probe reported eager=True graph_breaks=1 ... max=EAGER errors={'dynamo': 'Unsupported: Skip calling `torch.compiler.disable()`d function ... _cpu_int4pack_mm_cast'
FAILED tests/kernels/test_kernel_compile_levels_awq.py::test_awq_kernel_reaches_declared_compile_level[TorchAtenAwqLinear]   (same)
FAILED tests/kernels/test_kernel_compile_levels_quant.py::test_kernel_reaches_declared_compile_level[GGUFTorchLinear]
  declared INDUCTOR but probe reported eager=True graph_breaks=2 ... errors={'dynamo': 'Unsupported: Encountered tensor.is_inference() during tracing ...'

Why CI did not catch it (coverage gap)

  • tests/kernels/compile_probe.py:251-274 (skip_without_measurable_device) skips any kernel that declares >= INDUCTOR when CUDA is unavailable. The AWQ case builds the module on CPU (_checkpoint(..., device="cpu")), so it needs no GPU at all. Yet raising the declaration to INDUCTOR turned it into a skip on CPU-only CI, and it only runs, and fails, on a GPU host.
  • The new tests/kernels/test_kernel_compile_levels_cpu.py probes TorchFusedLinear/TorchAtenLinear and the two AWQ int4pack kernels only in the single passing configuration: fp16 with bias=False (lines 285-298, DTYPE = torch.float16). It never probes bf16, the CPU AUTO dtype. So it confirms a level that the default load cannot reach.

Minimal repro (CPU only)

import torch
from tests.kernels.compile_probe import probe
from tests.kernels import test_kernel_compile_levels_cpu as C
from gptqmodel.nn_modules.qlinear.torch_fused import TorchFusedLinear
for bias in (False, True):
    for dt in (torch.float16, torch.bfloat16):
        torch._dynamo.reset()
        m = C._pack_gptq(TorchFusedLinear, bias=bias).to(dt)
        r = probe(m, (torch.randn(4, C.IN_FEATURES, dtype=dt),), check_cuda_graph=False)
        print(bias, dt, r.graph_breaks, r.levels["inductor"])
# False torch.float16 0 True
# False torch.bfloat16 1 False
# True torch.float16 1 False
# True torch.bfloat16 1 False

Suggested fix

  • GGUFTorchLinear: restore base EAGER (as its own comment documents for CUDA) and declare SUPPORTS_COMPILE_LEVEL_BY_DEVICE = {"cpu": COMPILE_LEVEL.INDUCTOR}.
  • int4pack kernels: either make the cast path traceable (materialize the cast outside the extern op, or cast once at post_init so scales_and_zeros already carries fp32 for bf16/biased layers), or declare the level that bf16 and biased layers actually reach (EAGER/DYNAMO) and document fp16 bias-free as the exception, not the rule. Then regenerate docs/kernel-compile-matrix.md.
  • Tests: let skip_without_measurable_device skip only cases that actually need CUDA, so CPU-built cases run on CPU CI. Also parametrize test_kernel_compile_levels_cpu over bf16 and bias.

Severity: low/medium. There is no wrong output: the compiled path still runs, with a graph break per quantized linear. But the published capability matrix is wrong for the CPU default dtype, and three compile-level tests have been red on every GPU host since #5070.

🤖 Generated with Claude Code

Activity

  1. Qubitium commented on Nov 18, 2026

    @Qubitium
    CollaboratorAuthor

    Agent claim: agent-23b36fc8bb79 is working on this issue now.

    Started 2026-11-18T05:25:25Z. The claim expires 4.0h after this comment was last edited (heartbeat). Other agents: do not start this issue while the claim is live.

    Auditing the compile-level declarations and probe coverage on GB10 (sm_121, aarch64); will post a fix PR.

  2. self-assigned this
    on Nov 18, 2026
  3. Qubitium commented on Nov 18, 2026

    @Qubitium
    CollaboratorAuthor

    Fix PR opened: #5139.

    The declaration was wrong for two different reasons, and both are addressed:

    1. int4pack (GPTQ/AWQ, TorchFused/TorchAten) — the casting product is now a custom op (gptqmodel::int4pack_mm_cast) with a FakeTensor impl instead of a torch.compiler.disabled Python helper. Eager math is unchanged (cast operands, call _weight_int4pack_mm_for_cpu, cast result), the casts live inside the op so [BUG] Follow-up on #4060/#4062: model.optimize() TypeError on all CPU AUTO kernels, torch.compile int4pack LoweringException for fp16+bias (regression) and bf16, max_memory still ignored with device="cuda:0" #4068 no longer forces a break, and all four kernels now trace with 0 graph breaks for fp16/bf16 x biased/bias-free with byte-identical output.
    2. GGUFTorchLinear — base level restored to EAGER with SUPPORTS_COMPILE_LEVEL_BY_DEVICE = {"cpu": INDUCTOR}.

    Also fixed the coverage gap: skip_without_measurable_device no longer skips a CPU-built INDUCTOR case on a CPU-only runner, the AWQ case passes its build device, and the CPU level test now parametrizes the full int4pack dtype/bias matrix. docs/kernel-compile-matrix.md regenerated.

    Measured on GB10 (sm_121, aarch64, torch 2.11.0+cu130): the three tests named in the issue pass; test_kernel_compile_levels_cpu.py -k int4pack 16 passed; protocol test 63 passed.

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