Skip to content

[BUG] ParoQuant GPU kernels crash (illegal memory access) once rows x out_features > 2^31: ParoLinear calls the native AWQ GEMM (int32 store) for every M, ParoTriton prefill uses int32 output offsets #5096

Closed

Description

@Qubitium

Found on main @ e75181d, RTX 4090 (sm_89), torch 2.15 + CUDA 13.2, Triton 3.9.

What is wrong

Both ParoQuant GPU kernels fault with an illegal memory access once a forward produces more than 2^31 output elements (rows x out_features). The failure is exact at the 32-bit boundary and kills the CUDA context. Every other kernel I ran on the same layer, the same M and the same Qwen2.5-0.5B checkpoints passes: GGUF Triton/Torch/CPP-CUDA, FP8, BnB4, QQQ, MACaQ, VPTQ, NF12, W4AFP8 and EXL3.

  1. ParoLinear (PARO_CUDA, the CUDA AUTO pick): paro.py:794 _forward_cuda_awq_kernel always calls the native AWQ GEMM _awq_cuda_gemm_forward, which stores through row_offset * OC in 32-bit int (gptqmodel_ext/awq/quantization/gemm_cuda_gen.cu:396 and :536). AwqGEMMLinear never reaches that overflow, because it switches to dequantize + matmul above 1024 rows (gemm_awq.py:125). Paro has no such row cap, so a long prefill hits the native kernel. This is the same 32-bit store class as [BUG] AWQ GEMV (gemmv2, rows>8) and GEMV_FAST prefill CUDA kernels index the output with 32-bit int: illegal memory access once rows x out_features > 2^31 (long-context prefill) #5091 (AWQ GEMV), reached through a different entry point.
  2. ParoTritonLinear (PARO_TRITON, the ROCm AUTO pick since fix(paro): pick the native Triton kernel on ROCm AUTO and make the dense fallback graph-capturable (#4914) #5053): gptqmodel/quantization/paro/modules/triton/gemm.py:310, c_ptrs = c_ptr + N * offs_cm[:, None] + offs_cn[None, :]. offs_cm is int32, so the offset wraps. This is the same pattern [BUG] Kernels: non-contiguous input wrong/crash (BitBLAS, EXL3, ParoQuant), GGUF multi-GPU crash + current-device leak + stream race, int32 overflow, Hadamard M=0 crash, per-M Triton recompiles #4042 fixed in the other Triton kernels with .to(tl.int64).

The table uses layer 0 mlp.up_proj (K=896, N=4864) of a ParoQuant 4-bit Qwen2.5-0.5B-Instruct checkpoint. Each row checks sampled output rows against the same kernel at small M.

kernel dtype M = 441285 (M*N = 0.9997 x 2^31) M = 441727 (1.0005 x 2^31)
ParoLinear (PARO_CUDA) fp16 OK, bitwise CUDA error: an illegal memory access
ParoLinear (PARO_CUDA) bf16 OK illegal memory access
ParoTritonLinear fp16 OK Triton Error [CUDA]: an illegal memory access
ParoTritonLinear bf16 OK illegal memory access

Traceback, with CUDA_LAUNCH_BLOCKING=1:

paro.py:979 forward -> paro.py:794 _forward_cuda_awq_kernel -> gemm_awq.py:35 _awq_cuda_gemm_forward
-> utils/awq.py:145 awq_gemm_forward -> torch.AcceleratorError: CUDA error: an illegal memory access was encountered
paro_triton.py:218 _run_plan -> :195 _forward_triton_prefill -> paro/modules/triton/gemm.py:494 -> :432 _paro_gemm_triton
-> RuntimeError: Triton Error [CUDA]: an illegal memory access was encountered

Repro

import torch
from gptqmodel import GPTQModel, BACKEND
m = GPTQModel.load("<ParoQuant 4-bit Qwen2.5-0.5B-Instruct>", backend=BACKEND.PARO_CUDA, dtype=torch.float16, device="cuda:0")
lin = m.model.model.layers[0].mlp.up_proj            # K=896, N=4864
for M in (441285, 441727):                           # M*N just below / just above 2**31
    x = torch.randn(M, 896, device="cuda", dtype=torch.float16)
    with torch.inference_mode():
        y = lin(x); torch.cuda.synchronize()          # second one: illegal memory access

The same repro with BACKEND.PARO_TRITON triggers the Triton error. A real long-context prefill reaches this size too: one 128K-token sequence through an MLP projection wider than 16384 needs no batching at all.

Suggested fix

  • ParoLinear: reuse AwqGEMMLinear's dispatch, which dequantizes and calls cuBLAS above 1024 rows (also the faster choice for large M), or chunk M. Independently, make the native AWQ GEMM store offsets 64-bit (static_cast<int64_t>(row_offset) * OC). That fixes every caller of awq_gemm_forward.
  • ParoTriton: compute offs_cm.to(tl.int64) * N (and the A-side row offsets the same way) in _paro_gemm_triton.

Tests that should have caught it

There is no large-shape case for the Paro kernels. The #4042 sweep covered only the Triton kernels that existed at the time. A guarded test with rows x N just above 2^31 and small K is cheap: about 1 GB in and 4 GB out.

Severity

Medium. It is a hard crash that takes down the process's CUDA context on a supported long prefill, including on the ROCm AUTO path.

🤖 Generated with Claude Code

Activity

  1. Qubitium commented on Nov 18, 2026

    @Qubitium
    CollaboratorAuthor

    Additional data for item 1 (ParoLinear has no row cap, so every long prefill uses the native split-K AWQ GEMM). Well below the 2^31 crash, the same missing dispatch already costs a lot of VRAM and time on the default CUDA AUTO Paro path. The AwqGEMMLinear-style dispatch suggested above (rotate, dequantize, cuBLAS above 1024 rows) would fix this too.

    Found on main @ 7b8f127, RTX 5090 (sm_120), torch 2.15 + CUDA 13.2. ParoQuant 4-bit Qwen2.5-0.5B-Instruct (g128), fp16. AUTO resolves to ParoLinear. The "dense" column is the same module emulating the >1024-row dispatch: m._rotate_inputs(x) @ m._dequantize_weight_for_inference(xr, fp16). Its rel diff vs the native output is 2e-5 to 5e-5. Times are CUDA-event medians on a GPU that other jobs were also using; the peaks are exact.

    layer 1 module, M rows ParoLinear ms / peak extra MiB rotate+dequant+cuBLAS ms / peak ParoTritonLinear ms / peak output size MiB
    gate_proj (896->4864), 2048 0.26 / 174 0.33 / 63 0.12 / 82 19
    gate_proj, 8192 1.09 / 698 0.43 / 130 0.52 / 250 76
    gate_proj, 32000 4.93 / 2727 1.35 / 392 1.94 / 954 297
    down_proj (4864->896), 32000 5.28 / 789 1.78 / 392 1.80 / 469 55

    At M=32000, gate_proj peaks at 2727 MiB for a 297 MiB output. That matches the fp32 split-K partial buffer: _PARO_AWQ_SPLIT_K = 4 x 32000 x 4864 x 4 B = 2.37 GiB. The call is also 3.6x slower than dequantize + cuBLAS.

    Whole-model prefill (model(input_ids, use_cache=False, logits_to_keep=1)), same checkpoint:

    prompt tokens AUTO (ParoLinear) ms / peak MiB PARO_TRITON ms / peak MiB
    2048 53.9 / 208 40.5 / 115
    16384 568 / 1664 408 / 760
    32000 1372 / 3250 1260 / 1477

    So the default CUDA Paro kernel needs 2.2x the prefill VRAM of the Triton kernel, and it is slower at every length. A real 16k-32k prompt reaches this through generate(). The 32k peak goes from 1.8 GiB with PARO_TRITON to 3.5 GiB with AUTO, as a separate 16k/32k long-context comparison also showed. Logits agree between the two backends (prefill rel 2.4e-3, top1 0.996).

    Repro (module level):

    lin = GPTQModel.load(paro_ckpt, backend=BACKEND.AUTO, dtype=torch.float16).model.model.layers[1].mlp.gate_proj  # ParoLinear
    x = torch.randn(32000, 896, device="cuda", dtype=torch.float16)
    torch.cuda.reset_peak_memory_stats(); b = torch.cuda.memory_allocated()
    with torch.inference_mode(): y = lin(x)
    print((torch.cuda.max_memory_allocated() - b) / 2**20)   # 2727 MiB (output is 297 MiB)

    🤖 Generated with Claude Code

  2. ZX-ModelCloud commented on Nov 18, 2026

    @ZX-ModelCloud
    Collaborator

    Agent claim: agent-81fd1440b5e3 is working on this issue now.

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

    Reproducing the ParoQuant 32-bit output-offset crash above 2^31 elements, then fixing the AWQ GEMM store and Triton offsets

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