fix(torchvision): put libhipcxx's include dir on CPATH for torchvision #10244
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 610 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.384
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #10244"
general
weight: 0.35
stanleytsang-amd
Motivation
The torchvision and torchaudio wheels fails to compile once the ROCm devel package contains a rocThrust that requires libhipcxx (hipCCL 3.1 and later). pytorch builds fine; torchvision does not.
Failing include chain from a manual Multi-Arch Release workflow I ran earlier today (https://github.com/ROCm/TheRock/actions/runs/45270585505) against the upcoming hipccl 3.1 changes, which is already merged in rocm-libraries develop and will likely be promoted to TheRock imminently since rocm-libraries bump PRs/Multi-Arch CI don't cover torchvision builds like Multi-Arch Release does. edit: hipccl 3.1 has been promoted TheRock earlier today.
Technical Details
Cause:
rocThrust's thrust/detail/config/libcxx.h in hipCCL 3.1+ requires <cuda/std/version> or <hip/std/version> from libhipcxx 3.4 or newer, and stops with
#error Could not find libhipcxx!otherwise. Older rocThrust (the rocm-libraries commit main pins today) has no such #error and falls back to a built-in wrapper.libhipcxx installs its headers under <rocm>/include/hipccl/, not <rocm>/include/. Its install rules say consumers should reach it through find_package(libhipcxx) and the libhipcxx::libhipcxx target.
torch builds through CMake and gets that include path from the target. torchvision compiles with a bare hipcc through PyTorch's extension builder. Its compile line has -I<rocm>/include but not -I<rocm>/include/hipccl, so rocThrust's headers are found and libhipcxx's are not.
Fix:
build_prod_wheels.py: a new helper add_libhipcxx_include_path(env) puts <ROCM_PATH>/include/hipccl at the front of CPATH (keeping any existing value) when that directory exists. do_build_pytorch_vision calls it before setup.py bdist_wheel. If the directory is missing nothing changes, so older ROCm packages are unaffected. CPATH is used because hipcc wraps clang, which reads it for every compile.
Only the torchvision step is changed. torch uses the CMake target, and torchaudio built successfully in the failing runs (it runs before torchvision).
What this does not fix
The underlying problem is that, with this SDK layout, a bare
hipcc -I<rocm>/includecompile that includes rocThrust's headers cannot find libhipcxx. This change fixes the torchvision/torchaudio build only. Other consumers can hit the same error.Therefore we will also fix this in hipccl properly, but this PR is required to immediately prevent potential failures in Multi-Arch Release once hipccl 3.1 lands in TheRock.
Test Plan
Running local build of torchvision to verify. I have also triggered a Mutli-Arch Release build with my branch to verify this fix.
Test Result
Result: all 20 Build | py … | torch … jobs passed on both platforms (Python 3.11 to 3.15, each with torch nightly, release/2.13, release/2.14 and release/2.15). Every build produced torch, torchaudio and torchvision; the Linux builds also produced triton and apex.
Multi-Arch Release run: https://github.com/ROCm/TheRock/actions/runs/45425079920 Windows PyTorch wheels: https://github.com/ROCm/TheRock/actions/runs/45437257553 (20 of 20 builds passed) Linux PyTorch wheels: https://github.com/ROCm/TheRock/actions/runs/45455473433 (20 of 20 builds passed) Before and after. The same build jobs failed before this change with Could not find libhipcxx!:
Linux, before: https://github.com/ROCm/TheRock/actions/runs/45290518963 Windows, before: https://github.com/ROCm/TheRock/actions/runs/45282041761 The Windows jobs that failed in torchaudio's iir_hip compile before the torchaudio change now pass, for example:
py 3.12 | torch release/2.14: https://github.com/ROCm/TheRock/actions/runs/45437257553/job/138598611845 py 3.13 | torch release/2.13: https://github.com/ROCm/TheRock/actions/runs/45437257553/job/138598612122 py 3.13 | torch release/2.14: https://github.com/ROCm/TheRock/actions/runs/45437257553/job/138598612927 py 3.13 | torch release/2.15: https://github.com/ROCm/TheRock/actions/runs/45437257553/job/138598612213 Linux build logs I checked directly show CPATH=.../_rocm_sdk_devel/include/hipccl, no Could not find libhipcxx, and torch, torchaudio, torchvision, triton and apex all built:
py 3.12 | torch release/2.14: https://github.com/ROCm/TheRock/actions/runs/45455473433/job/138663841131 py 3.13 | torch nightly: https://github.com/ROCm/TheRock/actions/runs/45455473433/job/138663842185 I read the logs of those two Linux jobs; for the other builds I checked only the job results.
Submission Checklist
JIRA ID: AIPRIMS-2