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] #5167 (fix of #5115) incomplete on GPU: ParoTritonLinear declares CUDAGRAPH, but every non-identity Paro layer graph-breaks on the rotation autotune disk lock (and the fused rotate op has no fake impl) - optimize() on ROCm: 52 breaks, 0.6x eager #5225
Found on main @ 396b5f0, AMD Radeon AI PRO R9700 (gfx1201), torch 2.16.0.dev+rocm10.1.
What is wrong
ParoTritonLinear (the ROCm AUTO kernel for Paro since #5053) declares SUPPORTS_COMPILE_LEVEL = COMPILE_LEVEL.CUDAGRAPH (paro_triton.py:37-40, "Measured on GB10"). The level test (tests/kernels/test_kernel_compile_levels_quant.py:304, _build_paro) uses an identity rotation. With identity, _rotate_inputs returns immediately and the rotation never runs. Every layer of a real Paro checkpoint has a non-identity rotation, and on the GPU path it breaks the graph inside apply_paro_rotation -> _apply_fused_rotation -> _resolve_rotation_launch -> _ensure_rotation_autotune_cache_loaded (gptqmodel/utils/paro.py:728-733):
Unsupported context manager
Explanation: Dynamo does not know how to enter a `lock` context manager.
... File "gptqmodel/utils/paro.py", line 732, in _ensure_rotation_autotune_cache_loaded
with _ROTATION_AUTOTUNE_DISK_LOCK:
The lock is taken on every call, before the "already loaded" check, so an eager warm-up does not help. The fused rotation op also has no fake/meta implementation (Operator does not support running with fake tensors).
This is the GPU half of #5115. #5167 fixed only the CPU rotation path (tensor_cache_key, bool(valid.any()), the AVX512 JIT lookup) and its test also covers only CPU.
Repro
Qwen2.5-0.5B-Instruct (2 layers) quantized with ParoConfig(bits=4, group_size=128) and reloaded with AUTO, which gives ParoTritonLinear on ROCm. Batch of 4 prompts, 32 new tokens, static cache:
The compiled run is 0.6x eager speed, with 52 graph breaks. The break reasons are the lock context manager above and the fake-tensor-less rotation op. A single real down_proj layer compiled fullgraph=True with backend="eager" fails the same way, so the measured level is EAGER against the declared CUDAGRAPH. Explicit torch.cuda.graph capture does work, and replay is bitwise equal to eager.
Suggested fix
In _ensure_rotation_autotune_cache_loaded, return early when device_index in _ROTATION_AUTOTUNE_DISK_LOADED before taking the lock, and skip the disk path under torch.compiler.is_compiling(), as fix(paro): keep the CPU rotation forward graph-safe (#5115) #5167 did for CPU.
Until then, declare ParoTritonLinear EAGER on GPU.
Severity
Medium-low. SUPPORTS_COMPILE = False keeps the HF auto-compile off, but optimize() on any Paro model makes ROCm decode 1.7x slower, and the declared level is false for every real checkpoint.
Agent claim:agent-4e3a0639ecaf is working on this issue now.
Started 2026-11-18T14:28:06Z. The claim expires 4.0h after this comment is last edited (heartbeat). Other agents: do not start this issue while the claim is live.
Scope: make ParoTritonLinear actually graph-capturable: remove the rotation-autotune disk-lock graph break and give the fused rotate op a fake/meta implementation (or drop the CUDAGRAPH claim if it cannot be met), with 0-break evidence and a perf check on GPU
Agent claim released:agent-4e3a0639ecaf finished this issue.
PR: #5258 — base main, head 23d82d19f (branch fix/5225-paro-triton-cudagraph), 7 files, +361/−4.
Fix
Both breaks are gone for a non-identity layer:
_ensure_rotation_autotune_cache_loaded checks the per-device loaded flag before taking _ROTATION_AUTOTUNE_DISK_LOCK, and _resolve_rotation_launch is trace-safe: while compiling it reads the process-local launch cache lock-free, and a cold shape returns the native legacy launch config instead of reading disk or benchmarking. A cold JIT build is also kept out of the trace (_rotation_extension_ready_for_call), with ParoLinear.optimize() prewarming it so the compiled graph keeps the fused op.
rotation.cu registers Meta implementations for rotate, rotate_pair, rotate_pair_grad and grad_theta, returning exactly the metadata the CUDA kernels allocate, so fake-tensor tracing no longer raises Operator does not support running with fake tensors.
ParoTritonLinear._select_plan returns the default plan while compiling instead of timing kernels on the host. The compile-level test now builds a non-identity rotation with group_size=128, which is why the false CUDAGRAPH claim previously passed.
Single non-identity layer: red 1 break / 2 graphs and fullgraph=True fails; green 0 breaks / 1 graph with exact match under eager, aot_eager, inductor and reduce-overhead CUDA-graph capture.
New tests/kernels/test_paro_triton_cudagraph_5225.py: 5 passed (5 failed pre-fix).
test_paro.py + test_kernel_compile_levels_quant.py + new file: 82 passed, 3 skipped.
docs/paro.md documents the contract; ruff clean.
Not verified: ROCm/gfx1201 hardware (the Meta impls are pure ATen metadata and the guards are device-independent, but the 0-break measurement is CUDA); the real ParoQuant checkpoint is not in the offline cache, so the model-level bench uses the same layer construction as tests/kernels/test_paro.py.
Activity
Qubitium commentedon Nov 18, 2026
Agent claim:
agent-4e3a0639ecafis working on this issue now.Started 2026-11-18T14:28:06Z. The claim expires 4.0h after this comment is last edited (heartbeat). Other agents: do not start this issue while the claim is live.
Scope: make ParoTritonLinear actually graph-capturable: remove the rotation-autotune disk-lock graph break and give the fused rotate op a fake/meta implementation (or drop the CUDAGRAPH claim if it cannot be met), with 0-break evidence and a perf check on GPU
Qubitium commentedon Nov 18, 2026
Agent claim released:
agent-4e3a0639ecaffinished this issue.PR: #5258 — base
main, head23d82d19f(branchfix/5225-paro-triton-cudagraph), 7 files, +361/−4.Fix
Both breaks are gone for a non-identity layer:
_ensure_rotation_autotune_cache_loadedchecks the per-device loaded flag before taking_ROTATION_AUTOTUNE_DISK_LOCK, and_resolve_rotation_launchis trace-safe: while compiling it reads the process-local launch cache lock-free, and a cold shape returns the native legacy launch config instead of reading disk or benchmarking. A cold JIT build is also kept out of the trace (_rotation_extension_ready_for_call), withParoLinear.optimize()prewarming it so the compiled graph keeps the fused op.rotation.curegisters Meta implementations forrotate,rotate_pair,rotate_pair_gradandgrad_theta, returning exactly the metadata the CUDA kernels allocate, so fake-tensor tracing no longer raisesOperator does not support running with fake tensors.ParoTritonLinear._select_planreturns the default plan while compiling instead of timing kernels on the host. The compile-level test now builds a non-identity rotation withgroup_size=128, which is why the false CUDAGRAPH claim previously passed.Evidence (RTX 5090 sm_120, torch 2.15.0+cu132)
4-layer
ParoTritonLinearmodel,optimize(backend="inductor"):upstream/main(7fcb03e85)Single non-identity layer: red 1 break / 2 graphs and
fullgraph=Truefails; green 0 breaks / 1 graph with exact match undereager,aot_eager,inductorandreduce-overheadCUDA-graph capture.tests/kernels/test_paro_triton_cudagraph_5225.py: 5 passed (5 failed pre-fix).test_paro.py+test_kernel_compile_levels_quant.py+ new file: 82 passed, 3 skipped.docs/paro.mddocuments the contract; ruff clean.Not verified: ROCm/gfx1201 hardware (the Meta impls are pure ATen metadata and the guards are device-independent, but the 0-break measurement is CUDA); the real ParoQuant checkpoint is not in the offline cache, so the model-level bench uses the same layer construction as
tests/kernels/test_paro.py.fix(paro): make the non-identity rotation trace- and capture-clean (#…
Merge origin/main into feat/anytorch-stable-abi