Skip to content

[BUG] QQQLinear workspace is zero-sized for out_features=64 → illegal memory access; undersized whenever N % 128 != 0 #4215

Closed

Description

@Qubitium

Severity: medium–high (crash that poisons the CUDA context)
Version: 7.11.0 @ 9dad249

Summary

  • nn_modules/qlinear/qqq.py:211 (__init__) and :498 (pack()) size the workspace as out_features // 128 * 16.
  • SUPPORTS_OUT_FEATURES_DIVISIBLE_BY = [64] (qqq.py:118) and validate() both accept N=64.
  • The kernel's guard (qqq_gemm.cu:~1084, numel >= prob_n/128*max_par) passes trivially for a zero-sized workspace.

Reproduce (CUDA)

import torch
from gptqmodel.nn_modules.qlinear.qqq import QQQLinear
K, N = 512, 64
raw = torch.rand(1, N) * 0.02 + 1e-3
lin = torch.nn.Linear(K, N, bias=False); lin.weight.data = (torch.randint(-8, 8, (K, N)) * raw).t().contiguous()
m = QQQLinear(bits=4, group_size=-1, desc_act=False, sym=True, in_features=K, out_features=N, bias=False, register_buffers=False)
m.pack(lin, raw.t().contiguous(), None); m = m.cuda(); m.post_init()
print(m.workspace.numel())                                   # 0
m(torch.randn(1, K, device="cuda").half()); torch.cuda.synchronize()   # illegal memory access

A later case in the same process hung at 100% GPU. N ≡ 64 (mod 128) is likely undersized too.

Expected

Size the workspace from ceil(N / 64) * max_par (or what the kernel actually indexes), or reject N % 128 != 0 in SUPPORTS_* / validate.


Found during an AI-assisted review (Claude Code) of 9dad249; repros were run on RTX 4090/5090 (CUDA 13) and/or Radeon AI PRO R9700 (ROCm) unless marked static/suspected.

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