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] #5164 (fix of #5096) incomplete: Paro rotation extension (rotation.cuh) indexes the activation as int row*h - every non-identity Paro layer faults (HSA MEMORY_FAULT / illegal address) once rows x in_features > 2^31, before the widened GEMM runs #5196
Found on main @ 396b5f0, AMD Radeon AI PRO R9700 (gfx1201), torch 2.16.0.dev+rocm10.1 (the Paro rotation extension builds and loads on ROCm).
What is wrong
#5164 (fix for #5096) widened the Paro Triton GEMM row offsets to int64. It also sends long ParoLinear prefills to cuBLAS. But every Paro forward with a learned (non-identity) rotation first runs the fused rotation extension (apply_paro_rotation -> gptqmodel_ext/paro) over the same [rows, in_features] activation. That kernel still computes the activation and output addresses in 32-bit int:
gptqmodel_ext/paro/rotation.cuh:54-55: x[row * h + base0], x[row * h + base1] (fp16/generic load)
:99-100: out[row * h + base0] / out[row * h + base1] (store)
:129, :189: x + row * h + offset, out + row * h + base (half2 path)
:253, :310: the same in the bf16 specialisation
Here row = j * CTA_M + i and h are both int. The launchers also narrow seq_len = x.numel() / x.size(-1) to int (:129, :165, :290). Once rows * in_features > 2^31, the address wraps and the device faults.
This is the activation-side half of #5096 ("rows x in_features > 2^31"). #5164 fixed it only in the GEMM, so a long prefill still dies before the GEMM is reached. ParoTritonLinear (AUTO on ROCm since #5053) and ParoLinear (CUDA AUTO) both call _rotate_inputs -> apply_paro_rotation for every non-identity layer.
The row counts where this happens are realistic. It needs rows > 2^31 / in_features: about 150K tokens for a 14336-wide down_proj (Llama-3-8B), 262K for an 8192-wide layer, and 72.6K for Qwen2.5-72B's 29568-wide down_proj.
Repro (rotation only)
importtorchfromgptqmodel.utils.paroimportapply_paro_rotation, build_identity_rotation_buffersK=8192pairs, theta, cs=build_identity_rotation_buffers(in_features=K, group_size=128, krot=1, dtype=torch.float16)
pairs, cs=pairs.cuda(), cs.cuda()
theta=torch.rand(theta.shape).mul(3).half().cuda() # non-identity, as in any real Paro checkpointforrowsin (262000, 262160): # rows*K just below / just above 2^31x=torch.zeros(rows, K, dtype=torch.float16, device="cuda")
x[-16:] =torch.randn(16, K, dtype=torch.float16, device="cuda")
ref=apply_paro_rotation(x[-16:].contiguous(), pairs, theta, scales=cs, group_size=128)
out=apply_paro_rotation(x, pairs, theta, scales=cs, group_size=128)
torch.cuda.synchronize()
print(f"rows={rows} rows*K/2^31={rows*K/2**31:.4f} tail maxdiff={(out[-16:]-ref).abs().max().item()}")
rows=262000 rows*K/2^31=0.9995 tail maxdiff=0.0
Warning: Queue error - HSA_STATUS_ERROR_MEMORY_FAULT
RuntimeError: Paro rotation autotune failed to synchronize CUDA stream: an illegal memory access was encountered
Through the module, I built a ParoTritonLinear(in_features=8192, out_features=128, krot=1) with random packed weights and a random theta. Its forward matches a 16-row reference bitwise at 4096 and 262000 rows. At 262160 rows it fails with the same HSA_STATUS_ERROR_MEMORY_FAULT / hipErrorIllegalAddress, which kills the HIP context. The #5164 regressions in tests/kernels/test_paro.py (test_paro_triton_prefill_reads_activations_above_int32_row_stride_product and the others) all pass on this box. They call paro_gemm_triton_prefill directly, or use a module built with the default identity rotation, so the rotation is skipped.
I did not run this on CUDA in this round. The source is the same .cuh, so the same wrap is expected there.
Suggested fix
Do the row arithmetic in 64-bit in every rotation kernel: const int64_t row = ...; and static_cast<int64_t>(row) * h. Keep seq_len as int64_t in the launchers (rotation.cu already does this for the gradient partials). Also add a non-identity-rotation module case to the #5096 regressions, using rows x in_features just above 2^31.
Severity
High: a device fault (context loss) on long-context prefill for every Paro checkpoint on ROCm (ParoTriton AUTO) and CUDA (ParoLinear AUTO). This leaves #5096 incomplete.
Activity
Qubitium commentedon Nov 18, 2026
Agent claim released:
agent-fb5145b84190finished this issue.Pull request: #5253
Widen Paro rotation row arithmetic to int64 + regression test above 2^31 elements
fix(paro): index fused rotation rows in 64 bits (#5196) (#5253)