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
[PERF][ROCm] AUTO loads ParoQuant as ParoLinear, which on ROCm re-dequantizes the full weight every forward (2.8x slower generate than PARO_TRITON, 438 vs 69 us/layer) and fails CUDA-graph capture despite SUPPORTS_GRAPH_CAPTURE=True #4914
Found on main @ 4f287eb, AMD Radeon AI PRO R9700 (gfx1201), torch 2.16 dev + ROCm 10.1. The code paths involved are unchanged on current main.
What is wrong
On ROCm, BACKEND.AUTO loads every ParoQuant layer as ParoLinear (SUPPORTS_FORMATS = {FORMAT.PARO: 55}; ParoTritonLinear is priority 0, per the comment at paro_triton.py:63). On ROCm ParoLinear has no native kernel. _forward_cuda_awq_kernel() returns None because the AWQ CUDA extension is not built for HIP, so every forward falls through to _forward_dense(). That path re-dequantizes the whole packed weight on every call (AwqTorchLinear._dequantize_weight_for_inference -> dequantize_gemm) before the matmul.
bf16 behaves the same (440 us vs 86 us per layer). ParoTritonLinear is numerically equivalent on this card: layer-0 fuzz of PARO_CUDA (dense) vs PARO_TRITON over M = 0..2048, 2-D/3-D/row- and column-strided inputs, fp16 and bf16, has worst rel 3.4e-4 (fp16) / 3.2e-3 (bf16), and both are deterministic. The ROCm "portable path" is therefore 2.8x slower end to end with no accuracy benefit.
Capability declaration is false on ROCm.ParoLinear declares SUPPORTS_GRAPH_CAPTURE = True (measured on sm_80, where the AWQ CUDA kernel exists). On ROCm the dense fallback builds a host tensor inside dequantize_gemm (quantization/awq/utils/packing_utils.py:242, torch.tensor([...], device=device)), so an explicit torch.cuda.graph capture always fails:
File ".../qlinear/paro.py", line 609, in _forward_dense
File ".../qlinear/torch_awq.py", line 335, in _dequantize_weight_for_inference
File ".../quantization/awq/utils/packing_utils.py", line 242, in dequantize_gemm
shifts = torch.tensor([lane * bits for lane in AWQ_REVERSE_ORDER], dtype=torch.int64, device=device)
RuntimeError: Cannot copy between CPU and CUDA tensors during CUDA graph capture unless the CPU tensor is pinned.
ParoTritonLinear captures fine on the same card (replay matches eager exactly, fp16 and bf16, M=1 and M=16).
Timing comes from 200 back-to-back module calls after warm-up and from model.generate(max_new_tokens=64) on an otherwise idle card.
Suggested fix
On ROCm, where _cuda_awq_kernel_supported() can never be true, prefer ParoTritonLinear in AUTO. For example, give it a positive priority on DEVICE.ROCM, or have ParoLinear.validate() reject ROCm when the HIP build lacks the AWQ kernel, unless the request is explicit.
Make SUPPORTS_GRAPH_CAPTURE truthful for the dense fallback. Hoist the shifts constant in dequantize_gemm to a cached device buffer, which also removes one H2D copy per forward on every portable AWQ path. Otherwise declare the capability per device.
Cache the dequantized dense weight, or the int4 repack, across calls when the dense fallback is the steady-state path.
Test that should have caught it
tests/kernels/test_kernel_compile_levels_quant.py (ParoLinear case) only runs on CUDA hosts with the AWQ kernel. It should also run on ROCm, where it fails. A ROCm AUTO-selection test for ParoQuant should assert that the selected kernel is not the per-forward dense dequant path.
Severity
Medium. It is the default inference path for ParoQuant on ROCm: 2.8x slower generation, and the declared CUDA-graph capability is wrong there.
Agent claim:agent-root-4914-rocm-paro is working on this issue now.
Started 2026-11-18T00:14Z. The claim expires 4.0h after this comment is last edited; it is released with the PR link or with a stand-down comment.
Scope: AUTO must not pick the per-forward dense-dequant path on ROCm, and the host-tensor shifts build in dequantize_gemm must go away so the dense fallback is capture-safe on every device.
AUTO now selects ParoTritonLinear on ROCm (ParoLinear demotes its dense fallback there; CUDA ordering unchanged).
dequantize_gemm() derives the four-bit extraction offsets on-device and caches one buffer per device, so the dense Paro fallback captures under torch.cuda.graph and the SUPPORTS_GRAPH_CAPTURE = True declaration is truthful on ROCm.
Verified on gfx1201 (torch 2.16+rocm10.1): AUTO → ParoTritonLinear; dense capture matches eager for fp16/bf16. tests/test_paro_rocm_auto_4914.py is 8/8 green with the fix and 6/8 red on unmodified main (including both capture nodes with the reported host-copy RuntimeError).
Activity
Qubitium commentedon Nov 18, 2026
Agent claim:
agent-root-4914-rocm-parois working on this issue now.Started 2026-11-18T00:14Z. The claim expires 4.0h after this comment is last edited; it is released with the PR link or with a stand-down comment.
Scope: AUTO must not pick the per-forward dense-dequant path on ROCm, and the host-tensor
shiftsbuild indequantize_gemmmust go away so the dense fallback is capture-safe on every device.Qubitium commentedon Nov 18, 2026
Claiming this one to fix the ROCm AUTO selection and the false graph-capture declaration.
Plan:
ParoTritonLinearon ROCm when it validates (keep explicit backend requests authoritative, keep CUDAPARO_CUDAbehaviour unchanged).SUPPORTS_GRAPH_CAPTUREtruthful per device for the dense fallback (and/or cache theshiftsconstant so capture works).mainforDEVICE.ROCMAUTO selection + graph capture.fix(paro): pick the native Triton kernel on ROCm AUTO and make the de…
Qubitium commentedon Nov 18, 2026
Fixed by #5053 (squash-merged as
981f1266c).ParoTritonLinearon ROCm (ParoLineardemotes its dense fallback there; CUDA ordering unchanged).dequantize_gemm()derives the four-bit extraction offsets on-device and caches one buffer per device, so the dense Paro fallback captures undertorch.cuda.graphand theSUPPORTS_GRAPH_CAPTURE = Truedeclaration is truthful on ROCm.ParoTritonLinear; dense capture matches eager for fp16/bf16.tests/test_paro_rocm_auto_4914.pyis 8/8 green with the fix and 6/8 red on unmodifiedmain(including both capture nodes with the reported host-copyRuntimeError).