Repository navigation
fix(paro): pick the native Triton kernel on ROCm AUTO and make the dense fallback graph-capturable (#4914) - #5053
Merged
Conversation
…nse fallback graph-capturable (ModelCloud#4914) `ParoLinear` declares `SUPPORTS_FORMATS = {FORMAT.PARO: 55}` and its fast path is the CUDA-only AWQ GEMM extension. On ROCm `_cuda_awq_kernel_supported()` is always false, so every forward fell through to `_forward_dense()` and re-dequantized the whole packed weight: 438 us vs 69 us per layer, 17.2 vs 47.6 tok/s on Qwen2.5-0.5B ParoQuant (gfx1201). `ParoTritonLinear` is the native ROCm path but kept priority 0, which opts a kernel out of AUTO selection entirely. - Give `ParoTritonLinear` a positive declared priority and a device-aware `auto_select_priority()`: it outranks `ParoLinear` on ROCm and stays behind the measured CUDA kernel on CUDA. `ParoLinear` demotes itself on ROCm, where its dense fallback is the only reachable path. Explicit `BACKEND.PARO_TRITON` requests are unchanged. - `dequantize_gemm()` built its four-bit extraction offsets with `torch.tensor([...], device=...)`, a host-to-device copy that an explicit `torch.cuda.graph` capture rejects. Derive the constant with device-side arithmetic and cache one buffer per device, which also removes one H2D copy from every portable AWQ forward. The dense Paro path now captures with output matching eager, so `SUPPORTS_GRAPH_CAPTURE = True` is truthful on ROCm as well. Verified on a Radeon AI PRO R9700 (gfx1201, torch 2.16+rocm10.1): AUTO now selects `ParoTritonLinear`, and a dense `ParoLinear` forward survives capture for fp16 and bf16. `tests/test_paro_rocm_auto_4914.py` fails on unmodified `main` (6 of 8 nodes red, including both capture cases with the reported `Cannot copy between CPU and CUDA tensors during CUDA graph capture`).
This was referenced Nov 18, 2026
Qubitium
added a commit
that referenced
this pull request
Nov 18, 2026
#5094) (#5180) `_awq_shifts()` builds `_AWQ_SHIFTS_CACHE` with device arithmetic so a capture does not need a host-to-device copy (#5053). Device work inside a capture is recorded, not run, so a table first built there holds uninitialized memory (zeros). Because the table was published immediately, an abandoned capture left every later eager AWQ dense dequant decoding with those zeros; a capture that succeeded but had not been replayed had the same problem for an eager call in between. Only publish from an eager call. A capture now gets a fresh uncached table that is recorded into the graph and is valid on replay; the next eager call derives and publishes the real one. The fast path is unchanged: a warm eager call still returns the one cached tensor with no allocation or H2D copy. The shared `dequantize_gemm()` fixes `AwqTorchLinear`, `ParoLinear`'s dense path, and the CPU kernels. `AwqTorchLinear` now declares `SUPPORTS_GRAPH_CAPTURE = True`, which a first-call capture/replay test measures. Tests: tests/test_awq_shift_capture_5094.py covers an abandoned capture, an eager call before replay, a replayed first-call capture, AwqTorchLinear, dense ParoLinear, the CPU kernel, and eager table reuse. Co-authored-by: GPTQModel Agent <[email protected]>
This was referenced Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4914.
Problem
ParoLineardeclaresSUPPORTS_FORMATS = {FORMAT.PARO: 55}and its fast path is the CUDA-only AWQ GEMM extension. On ROCm_cuda_awq_kernel_supported()is always false, so every forward fell through to_forward_dense()and re-dequantized the whole packed weight:layers.0.mlp.down_projM=1generate64 tokensParoTritonLinearis the native ROCm path but kept priority 0, which opts a kernel out of AUTO selection entirely. The same dense fallback also built its extraction offsets withtorch.tensor([...], device=...), a host-to-device copy that an explicittorch.cuda.graphcapture rejects — soSUPPORTS_GRAPH_CAPTURE = Truewas false on every ROCm host.Fix
ParoTritonLinear: positive declared priority (AUTO-eligible) plus a device-awareauto_select_priority()that outranksParoLinearon ROCm and stays behind the measuredPARO_CUDAkernel on CUDA.ParoLinear:auto_select_priority()demotes the per-forward dense fallback on ROCm only. ExplicitBACKEND.PARO_TRITONrequests are unchanged.dequantize_gemm(): derive the four-bit extraction offsets with device-side arithmetic and cache one buffer per device. This removes one H2D copy from every portable AWQ forward and makes the dense Paro path capturable, so theSUPPORTS_GRAPH_CAPTURE = Truedeclaration is truthful on ROCm.Verification
Radeon AI PRO R9700 (gfx1201), torch 2.16.0.dev+rocm10.1:
ParoTritonLinearon ROCm; on a CUDA build the ordering still putsParoLinearfirst.ParoLinearforward survivestorch.cuda.graphcapture with output matching eager, fp16 and bf16.tests/test_paro_rocm_auto_4914.py: 8/8 pass with the fix; 6/8 fail on unmodifiedmain, including both capture nodes withRuntimeError: Cannot copy between CPU and CUDA tensors during CUDA graph capture.tests/kernels/test_paro.py,tests/test_paro.py,tests/kernels/test_selection.py,tests/kernels/test_kernel_compile_protocol.py: 401 passed, 298 skipped.tests/kernels/test_awq_dequantize_tiling.py,test_awq_torch.py,test_awq_runtime_dtype_storage.py: 155 passed, 5 skipped.tests/test_rocm_backend_gating.py: one pre-existing unrelated failure (MarlinLinearmessage wording) also red onmain.No CUDA behaviour change: the
PARO_CUDAkernel keeps the higher rank and Triton remains an explicit backend on CUDA.