Repository navigation
Conversation
Reroutes GPU_ARCH_TYPE=rocm through the same set_desired_python ->
build_env_setup -> build_install_deps -> build_wheel -> repair_wheel
chain that x86/aarch64 CUDA and CPU already use, and deletes the
standalone build_rocm.sh.
build_env_setup.py:
Add ROCM_BUILD_ENV_STATIC and a rocm branch in main() that mirrors
the original build_rocm.sh exports (ROCM_HOME, MAGMA_HOME,
USE_STATIC_*, BUILD_DEBUG_INFO, FORCE_RPATH) and normalizes
DESIRED_CUDA to the rocm-prefixed form expected by build_amd.py.
repair_wheel.py:
- Generalize the bundle pipeline with two small dataclasses:
BundledLib (a shared lib copied into torch/lib/, optionally
triggering a NEEDED rewrite to a renamed copy) and AuxFile
(a source-to-relative-dest mapping for tree content like MIOpen
kernel db, RCCL algorithms, gfx-specific rocBLAS/hipblaslt/
hipsparselt files).
- Add rocm_bundle() which discovers the ROCm shared libs under
$ROCM_HOME/{lib,lib64}, picks up the OS runtime deps
(libnuma/libelf/libtinfo/libdw/libdrm), and assembles the per-gfx
kernel-file copy list using PYTORCH_ROCM_ARCH.
- Versioned ROCm sonames are renamed to bare .so (mirrors
fname_without_so_number) and NEEDED entries inside the wheel are
rewritten via a new replace_needed() helper.
- main() picks the ROCm branch based on GPU_ARCH_TYPE/DESIRED_CUDA
and forces --force-rpath to match the legacy script.
build.sh:
Move the rocm case into the new pipeline alongside cuda/cpu; drops
the bash build_rocm.sh fallback.
XPU and cpu-s390x continue to flow through build_common.sh
unchanged.
Authored with Claude.
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/182696
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ⏳ No Failures, 108 PendingAs of commit 0b52d9c with merge base 0f4b594 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
huydhn
left a comment
There was a problem hiding this comment.
LGTM! Do we have some smoke tests in place to test ROCm wheels with this change?
Reroutes GPU_ARCH_TYPE=rocm through the same set_desired_python ->
build_env_setup -> build_install_deps -> build_wheel -> repair_wheel
chain that x86/aarch64 CUDA and CPU already use, and deletes the
standalone build_rocm.sh.
build_env_setup.py:
Add ROCM_BUILD_ENV_STATIC and a rocm branch in main() that mirrors
the original build_rocm.sh exports (ROCM_HOME, MAGMA_HOME,
USE_STATIC_*, BUILD_DEBUG_INFO, FORCE_RPATH) and normalizes
DESIRED_CUDA to the rocm-prefixed form expected by build_amd.py.
repair_wheel.py:
- Generalize the bundle pipeline with two small dataclasses:
BundledLib (a shared lib copied into torch/lib/, optionally
triggering a NEEDED rewrite to a renamed copy) and AuxFile
(a source-to-relative-dest mapping for tree content like MIOpen
kernel db, RCCL algorithms, gfx-specific rocBLAS/hipblaslt/
hipsparselt files).
- Add rocm_bundle() which discovers the ROCm shared libs under
$ROCM_HOME/{lib,lib64}, picks up the OS runtime deps
(libnuma/libelf/libtinfo/libdw/libdrm), and assembles the per-gfx
kernel-file copy list using PYTORCH_ROCM_ARCH.
- Versioned ROCm sonames are renamed to bare .so (mirrors
fname_without_so_number) and NEEDED entries inside the wheel are
rewritten via a new replace_needed() helper.
- main() picks the ROCm branch based on GPU_ARCH_TYPE/DESIRED_CUDA
and forces --force-rpath to match the legacy script.
build.sh:
Move the rocm case into the new pipeline alongside cuda/cpu; drops
the bash build_rocm.sh fallback.
XPU and cpu-s390x continue to flow through build_common.sh
unchanged.
Authored with Claude.
cc jeffdaily sunway513 jithunnair-amd pruthvistony ROCmSupport jataylo hongxiayang naromero77amd pragupta jerrymannil xinyazhang
[ghstack-poisoned]
Reroutes GPU_ARCH_TYPE=rocm through the same set_desired_python ->
build_env_setup -> build_install_deps -> build_wheel -> repair_wheel
chain that x86/aarch64 CUDA and CPU already use, and deletes the
standalone build_rocm.sh.
build_env_setup.py:
Add ROCM_BUILD_ENV_STATIC and a rocm branch in main() that mirrors
the original build_rocm.sh exports (ROCM_HOME, MAGMA_HOME,
USE_STATIC_*, BUILD_DEBUG_INFO, FORCE_RPATH) and normalizes
DESIRED_CUDA to the rocm-prefixed form expected by build_amd.py.
repair_wheel.py:
- Generalize the bundle pipeline with two small dataclasses:
BundledLib (a shared lib copied into torch/lib/, optionally
triggering a NEEDED rewrite to a renamed copy) and AuxFile
(a source-to-relative-dest mapping for tree content like MIOpen
kernel db, RCCL algorithms, gfx-specific rocBLAS/hipblaslt/
hipsparselt files).
- Add rocm_bundle() which discovers the ROCm shared libs under
$ROCM_HOME/{lib,lib64}, picks up the OS runtime deps
(libnuma/libelf/libtinfo/libdw/libdrm), and assembles the per-gfx
kernel-file copy list using PYTORCH_ROCM_ARCH.
- Versioned ROCm sonames are renamed to bare .so (mirrors
fname_without_so_number) and NEEDED entries inside the wheel are
rewritten via a new replace_needed() helper.
- main() picks the ROCm branch based on GPU_ARCH_TYPE/DESIRED_CUDA
and forces --force-rpath to match the legacy script.
build.sh:
Move the rocm case into the new pipeline alongside cuda/cpu; drops
the bash build_rocm.sh fallback.
XPU and cpu-s390x continue to flow through build_common.sh
unchanged.
Authored with Claude.
ghstack-source-id: 3cd17ff
Pull Request resolved: #182696
## Summary Port the XPU manylinux build from the legacy bash scripts (`build_xpu.sh` + `build_common.sh`) to the Python pipeline (`build_env_setup.py` + `build_install_deps.py` + `build_wheel.py` + `repair_wheel.py`), following the same pattern as #182409 (CUDA/CPU) and #182696 (ROCm). - Add `XPU_BUILD_ENV` and `source_oneapi_env()` to `build_env_setup.py` to source Intel oneAPI environment and set build flags - Always build small wheel for XPU, following the same practice as CUDA - Add XPU RPATH handling in `repair_wheel.py` (following CUDA pattern — runtime libs from pypi packages) - XPU wheels are now retagged to `manylinux_2_28_x86_64` - Delete `build_xpu.sh` cpu-s390x continues to flow through `build_common.sh` unchanged. Pull Request resolved: #182942 Approved by: https://github.com/atalman
## Summary Port the XPU manylinux build from the legacy bash scripts (`build_xpu.sh` + `build_common.sh`) to the Python pipeline (`build_env_setup.py` + `build_install_deps.py` + `build_wheel.py` + `repair_wheel.py`), following the same pattern as pytorch#182409 (CUDA/CPU) and pytorch#182696 (ROCm). - Add `XPU_BUILD_ENV` and `source_oneapi_env()` to `build_env_setup.py` to source Intel oneAPI environment and set build flags - Always build small wheel for XPU, following the same practice as CUDA - Add XPU RPATH handling in `repair_wheel.py` (following CUDA pattern — runtime libs from pypi packages) - XPU wheels are now retagged to `manylinux_2_28_x86_64` - Delete `build_xpu.sh` cpu-s390x continues to flow through `build_common.sh` unchanged. Pull Request resolved: pytorch#182942 Approved by: https://github.com/atalman
Reroutes GPU_ARCH_TYPE=rocm through the same set_desired_python ->
build_env_setup -> build_install_deps -> build_wheel -> repair_wheel
chain that x86/aarch64 CUDA and CPU already use, and deletes the
standalone build_rocm.sh.
build_env_setup.py:
Add ROCM_BUILD_ENV_STATIC and a rocm branch in main() that mirrors
the original build_rocm.sh exports (ROCM_HOME, MAGMA_HOME,
USE_STATIC_*, BUILD_DEBUG_INFO, FORCE_RPATH) and normalizes
DESIRED_CUDA to the rocm-prefixed form expected by build_amd.py.
repair_wheel.py:
- Generalize the bundle pipeline with two small dataclasses:
BundledLib (a shared lib copied into torch/lib/, optionally
triggering a NEEDED rewrite to a renamed copy) and AuxFile
(a source-to-relative-dest mapping for tree content like MIOpen
kernel db, RCCL algorithms, gfx-specific rocBLAS/hipblaslt/
hipsparselt files).
- Add rocm_bundle() which discovers the ROCm shared libs under
$ROCM_HOME/{lib,lib64}, picks up the OS runtime deps
(libnuma/libelf/libtinfo/libdw/libdrm), and assembles the per-gfx
kernel-file copy list using PYTORCH_ROCM_ARCH.
- Versioned ROCm sonames are renamed to bare .so (mirrors
fname_without_so_number) and NEEDED entries inside the wheel are
rewritten via a new replace_needed() helper.
- main() picks the ROCm branch based on GPU_ARCH_TYPE/DESIRED_CUDA
and forces --force-rpath to match the legacy script.
build.sh:
Move the rocm case into the new pipeline alongside cuda/cpu; drops
the bash build_rocm.sh fallback.
XPU and cpu-s390x continue to flow through build_common.sh
unchanged.
Authored with Claude.
cc jeffdaily sunway513 jithunnair-amd pruthvistony ROCmSupport jataylo hongxiayang naromero77amd pragupta jerrymannil xinyazhang
[ghstack-poisoned]
Reroutes GPU_ARCH_TYPE=rocm through the same set_desired_python ->
build_env_setup -> build_install_deps -> build_wheel -> repair_wheel
chain that x86/aarch64 CUDA and CPU already use, and deletes the
standalone build_rocm.sh.
build_env_setup.py:
Add ROCM_BUILD_ENV_STATIC and a rocm branch in main() that mirrors
the original build_rocm.sh exports (ROCM_HOME, MAGMA_HOME,
USE_STATIC_*, BUILD_DEBUG_INFO, FORCE_RPATH) and normalizes
DESIRED_CUDA to the rocm-prefixed form expected by build_amd.py.
repair_wheel.py:
- Generalize the bundle pipeline with two small dataclasses:
BundledLib (a shared lib copied into torch/lib/, optionally
triggering a NEEDED rewrite to a renamed copy) and AuxFile
(a source-to-relative-dest mapping for tree content like MIOpen
kernel db, RCCL algorithms, gfx-specific rocBLAS/hipblaslt/
hipsparselt files).
- Add rocm_bundle() which discovers the ROCm shared libs under
$ROCM_HOME/{lib,lib64}, picks up the OS runtime deps
(libnuma/libelf/libtinfo/libdw/libdrm), and assembles the per-gfx
kernel-file copy list using PYTORCH_ROCM_ARCH.
- Versioned ROCm sonames are renamed to bare .so (mirrors
fname_without_so_number) and NEEDED entries inside the wheel are
rewritten via a new replace_needed() helper.
- main() picks the ROCm branch based on GPU_ARCH_TYPE/DESIRED_CUDA
and forces --force-rpath to match the legacy script.
build.sh:
Move the rocm case into the new pipeline alongside cuda/cpu; drops
the bash build_rocm.sh fallback.
XPU and cpu-s390x continue to flow through build_common.sh
unchanged.
Authored with Claude.
ghstack-source-id: 5444567
Pull Request resolved: #182696
Reroutes GPU_ARCH_TYPE=rocm through the same set_desired_python ->
build_env_setup -> build_install_deps -> build_wheel -> repair_wheel
chain that x86/aarch64 CUDA and CPU already use, and deletes the
standalone build_rocm.sh.
build_env_setup.py:
Add ROCM_BUILD_ENV_STATIC and a rocm branch in main() that mirrors
the original build_rocm.sh exports (ROCM_HOME, MAGMA_HOME,
USE_STATIC_*, BUILD_DEBUG_INFO, FORCE_RPATH) and normalizes
DESIRED_CUDA to the rocm-prefixed form expected by build_amd.py.
repair_wheel.py:
- Generalize the bundle pipeline with two small dataclasses:
BundledLib (a shared lib copied into torch/lib/, optionally
triggering a NEEDED rewrite to a renamed copy) and AuxFile
(a source-to-relative-dest mapping for tree content like MIOpen
kernel db, RCCL algorithms, gfx-specific rocBLAS/hipblaslt/
hipsparselt files).
- Add rocm_bundle() which discovers the ROCm shared libs under
$ROCM_HOME/{lib,lib64}, picks up the OS runtime deps
(libnuma/libelf/libtinfo/libdw/libdrm), and assembles the per-gfx
kernel-file copy list using PYTORCH_ROCM_ARCH.
- Versioned ROCm sonames are renamed to bare .so (mirrors
fname_without_so_number) and NEEDED entries inside the wheel are
rewritten via a new replace_needed() helper.
- main() picks the ROCm branch based on GPU_ARCH_TYPE/DESIRED_CUDA
and forces --force-rpath to match the legacy script.
build.sh:
Move the rocm case into the new pipeline alongside cuda/cpu; drops
the bash build_rocm.sh fallback.
XPU and cpu-s390x continue to flow through build_common.sh
unchanged.
Authored with Claude.
cc jeffdaily sunway513 jithunnair-amd pruthvistony ROCmSupport jataylo hongxiayang naromero77amd pragupta jerrymannil xinyazhang
[ghstack-poisoned]
Reroutes GPU_ARCH_TYPE=rocm through the same set_desired_python ->
build_env_setup -> build_install_deps -> build_wheel -> repair_wheel
chain that x86/aarch64 CUDA and CPU already use, and deletes the
standalone build_rocm.sh.
build_env_setup.py:
Add ROCM_BUILD_ENV_STATIC and a rocm branch in main() that mirrors
the original build_rocm.sh exports (ROCM_HOME, MAGMA_HOME,
USE_STATIC_*, BUILD_DEBUG_INFO, FORCE_RPATH) and normalizes
DESIRED_CUDA to the rocm-prefixed form expected by build_amd.py.
repair_wheel.py:
- Generalize the bundle pipeline with two small dataclasses:
BundledLib (a shared lib copied into torch/lib/, optionally
triggering a NEEDED rewrite to a renamed copy) and AuxFile
(a source-to-relative-dest mapping for tree content like MIOpen
kernel db, RCCL algorithms, gfx-specific rocBLAS/hipblaslt/
hipsparselt files).
- Add rocm_bundle() which discovers the ROCm shared libs under
$ROCM_HOME/{lib,lib64}, picks up the OS runtime deps
(libnuma/libelf/libtinfo/libdw/libdrm), and assembles the per-gfx
kernel-file copy list using PYTORCH_ROCM_ARCH.
- Versioned ROCm sonames are renamed to bare .so (mirrors
fname_without_so_number) and NEEDED entries inside the wheel are
rewritten via a new replace_needed() helper.
- main() picks the ROCm branch based on GPU_ARCH_TYPE/DESIRED_CUDA
and forces --force-rpath to match the legacy script.
build.sh:
Move the rocm case into the new pipeline alongside cuda/cpu; drops
the bash build_rocm.sh fallback.
XPU and cpu-s390x continue to flow through build_common.sh
unchanged.
Authored with Claude.
ghstack-source-id: 1380abe
Pull Request resolved: #182696
@atalman We can add smoke testing for nightly builds to linux.rocm.gpu.gfx950.1 runner labels. I assume these jobs would be very low frequency and low duration as well? |
| "TH_BINARY_BUILD": "1", | ||
| "USE_STATIC_CUDNN": "1", | ||
| "USE_STATIC_NCCL": "1", | ||
| "ATEN_STATIC_CUDA": "1", | ||
| "USE_CUDA_STATIC_LINK": "1", |
There was a problem hiding this comment.
@atalman All these static-linking related env vars are not relevant to ROCm afaict. We should not carry them forward
There was a problem hiding this comment.
@jithunnair-amd will be publishing this as followup changes
@jithunnair-amd Current pipeline uses |
| "USE_STATIC_NCCL": "1", | ||
| "ATEN_STATIC_CUDA": "1", | ||
| "USE_CUDA_STATIC_LINK": "1", | ||
| "INSTALL_TEST": "0", |
There was a problem hiding this comment.
@atalman Should INSTALL_TEST not be 0 for all binary builds?
There was a problem hiding this comment.
@jithunnair-amd it comes from old build_rocm.sh:
export INSTALL_TEST=0 # dont install test binaries into site-packages
Co-authored-by: Jithun Nair <[email protected]>
|
@pytorchmergebot merge -f "lint is good. rocm binaries where already tested" |
Merge failedReason: PR 182696 is out of sync with the corresponding revision f5f1974 on branch gh/atalman/17/orig that would be merged into main. This usually happens because there is a non ghstack change in the PR. Please sync them and try again (ex. make the changes on origin/gh/atalman/17/orig and run ghstack). Details for Dev Infra teamRaised by workflow job |
Reroutes GPU_ARCH_TYPE=rocm through the same set_desired_python ->
build_env_setup -> build_install_deps -> build_wheel -> repair_wheel
chain that x86/aarch64 CUDA and CPU already use, and deletes the
standalone build_rocm.sh.
build_env_setup.py:
Add ROCM_BUILD_ENV_STATIC and a rocm branch in main() that mirrors
the original build_rocm.sh exports (ROCM_HOME, MAGMA_HOME,
USE_STATIC_*, BUILD_DEBUG_INFO, FORCE_RPATH) and normalizes
DESIRED_CUDA to the rocm-prefixed form expected by build_amd.py.
repair_wheel.py:
- Generalize the bundle pipeline with two small dataclasses:
BundledLib (a shared lib copied into torch/lib/, optionally
triggering a NEEDED rewrite to a renamed copy) and AuxFile
(a source-to-relative-dest mapping for tree content like MIOpen
kernel db, RCCL algorithms, gfx-specific rocBLAS/hipblaslt/
hipsparselt files).
- Add rocm_bundle() which discovers the ROCm shared libs under
$ROCM_HOME/{lib,lib64}, picks up the OS runtime deps
(libnuma/libelf/libtinfo/libdw/libdrm), and assembles the per-gfx
kernel-file copy list using PYTORCH_ROCM_ARCH.
- Versioned ROCm sonames are renamed to bare .so (mirrors
fname_without_so_number) and NEEDED entries inside the wheel are
rewritten via a new replace_needed() helper.
- main() picks the ROCm branch based on GPU_ARCH_TYPE/DESIRED_CUDA
and forces --force-rpath to match the legacy script.
build.sh:
Move the rocm case into the new pipeline alongside cuda/cpu; drops
the bash build_rocm.sh fallback.
XPU and cpu-s390x continue to flow through build_common.sh
unchanged.
Authored with Claude.
cc jeffdaily sunway513 jithunnair-amd pruthvistony ROCmSupport jataylo hongxiayang naromero77amd pragupta jerrymannil xinyazhang
[ghstack-poisoned]
## Summary Port the XPU manylinux build from the legacy bash scripts (`build_xpu.sh` + `build_common.sh`) to the Python pipeline (`build_env_setup.py` + `build_install_deps.py` + `build_wheel.py` + `repair_wheel.py`), following the same pattern as pytorch#182409 (CUDA/CPU) and pytorch#182696 (ROCm). - Add `XPU_BUILD_ENV` and `source_oneapi_env()` to `build_env_setup.py` to source Intel oneAPI environment and set build flags - Always build small wheel for XPU, following the same practice as CUDA - Add XPU RPATH handling in `repair_wheel.py` (following CUDA pattern — runtime libs from pypi packages) - XPU wheels are now retagged to `manylinux_2_28_x86_64` - Delete `build_xpu.sh` cpu-s390x continues to flow through `build_common.sh` unchanged. Pull Request resolved: pytorch#182942 Approved by: https://github.com/atalman
Reroutes GPU_ARCH_TYPE=rocm through the same set_desired_python ->
build_env_setup -> build_install_deps -> build_wheel -> repair_wheel
chain that x86/aarch64 CUDA and CPU already use, and deletes the
standalone build_rocm.sh.
build_env_setup.py:
Add ROCM_BUILD_ENV_STATIC and a rocm branch in main() that mirrors
the original build_rocm.sh exports (ROCM_HOME, MAGMA_HOME,
USE_STATIC_*, BUILD_DEBUG_INFO, FORCE_RPATH) and normalizes
DESIRED_CUDA to the rocm-prefixed form expected by build_amd.py.
repair_wheel.py:
- Generalize the bundle pipeline with two small dataclasses:
BundledLib (a shared lib copied into torch/lib/, optionally
triggering a NEEDED rewrite to a renamed copy) and AuxFile
(a source-to-relative-dest mapping for tree content like MIOpen
kernel db, RCCL algorithms, gfx-specific rocBLAS/hipblaslt/
hipsparselt files).
- Add rocm_bundle() which discovers the ROCm shared libs under
$ROCM_HOME/{lib,lib64}, picks up the OS runtime deps
(libnuma/libelf/libtinfo/libdw/libdrm), and assembles the per-gfx
kernel-file copy list using PYTORCH_ROCM_ARCH.
- Versioned ROCm sonames are renamed to bare .so (mirrors
fname_without_so_number) and NEEDED entries inside the wheel are
rewritten via a new replace_needed() helper.
- main() picks the ROCm branch based on GPU_ARCH_TYPE/DESIRED_CUDA
and forces --force-rpath to match the legacy script.
build.sh:
Move the rocm case into the new pipeline alongside cuda/cpu; drops
the bash build_rocm.sh fallback.
XPU and cpu-s390x continue to flow through build_common.sh
unchanged.
Authored with Claude.
Pull Request resolved: pytorch#182696
Approved by: https://github.com/huydhn
Co-authored-by: Jithun Nair <[email protected]>
…no-GPU import deadlock) `import torch` from ROCm wheels hangs forever on hosts without the AMD kfd driver (no /dev/kfd: CPU-only nodes, or GPU nodes where amdgpu/amdkfd is not loaded) -- it deadlocks in a native static initializer at dlopen time, in librocprofiler-sdk.so's kfd-topology probe (agent.cpp spawns a thread and join()s it). Root cause is an ordering bug introduced by pytorch#182696 ("[CD] Port ROCm manywheel build to the Python pipeline"). In rocm_bundle() the versioned ROCm sonames are renamed to bare .so, and repair_wheel() rewrites the matching NEEDED entries via patchelf. But the rewrite ran *inline* in the copy loop: replace_needed() only touches .so files already present in the tree, so any lib copied after its dependency kept a stale versioned NEEDED. E.g. libamd_comgr.so is bundled early and librocprofiler-sdk.so late, so rocprofiler-sdk kept "libamd_comgr.so.3" while the wheel only ships bare "libamd_comgr.so". readelf across the 05-13 (good) vs 05-14 (bad) nightlies shows this affects most bundled ROCm libs (libamdhip64.so.7, libamd_comgr.so.3, libhsa-runtime64.so.1, librocblas.so.5, libroctx64.so.4, ...): their bundled copies are orphaned and resolution falls through to system ROCm, which for librocprofiler-sdk drags in the deadlocking kfd probe. Fix: copy all bundled libs first, then rewrite NEEDED in a second pass over the fully-populated tree -- mirroring the pre-pytorch#182696 build_common.sh single final patchelf pass. This keeps the wheel self-contained and resolves the no-GPU import deadlock.
…ch` deadlock (pytorch#189110) `import torch` from ROCm 2.13 wheels intermittently hangs forever on hosts without a usable GPU / kfd (CPU-only nodes, or GPU nodes without amdgpu/amdkfd loaded). Root cause chain (native backtrace): import torch -> dlopen(_C) -> static init of libtorch_rocshmem.so -> rocshmem::NUMAWrapper::NUMAWrapper() (upstream rocSHMEM global ctor) -> dlopen("libnuma.so") == NULL -> exit(1) -> atexit -> rocprofiler::registration::finalize() -> ThreadPool::destroy_threadpool() -> std::thread::join() # HANGS Why it regressed at pytorch#182696: the old build_rocm.sh renamed bundled OS deps to bare sonames, so torch/lib shipped `libnuma.so`. The new repair_wheel.py keeps them versioned (`libnuma.so.1`) only. rocSHMEM's NUMAWrapper ctor does `dlopen("libnuma.so")` (bare) via libtorch_rocshmem.so's $ORIGIN RPATH; with only `libnuma.so.1` present that dlopen fails and NUMAWrapper calls exit() at library-load time, which trips a racy rocprofiler-sdk atexit finalize deadlock (hence the intermittency). The good (0513) wheel shipped bare `libnuma.so` and never hangs; the bad (0514+) wheel ships only `libnuma.so.1` and does. Fix: when bundling a versioned OS dep, also create a bare-name symlink (libnuma.so -> libnuma.so.1, etc.), restoring build_rocm.sh behavior. The bare symlink satisfies rocSHMEM's dlopen while the versioned file still satisfies NEEDED references. Verified: adding this symlink to an installed wheel makes `import torch` succeed deterministically on a no-kfd host. The underlying rocSHMEM bug (NUMAWrapper must not exit() from a global ctor; should dlopen "libnuma.so.1") is fixed upstream after our pinned commit (ROCm/rocm-systems pytorch#5918, pytorch#6640) and should be picked up via a pin bump too.
…ock (#189114) ## Summary `import torch` from ROCm 2.13 wheels **intermittently hangs forever** on hosts without a usable GPU / kfd (CPU-only nodes, or GPU nodes where `amdgpu`/`amdkfd` isn't loaded). Fixes #189110. This is related to this fix PR in upstream: ROCm/rocm-systems#6640 (this is not included in pytorch, hence a failure) ### Root cause (native backtrace) ``` import torch → dlopen(_C) → static init of libtorch_rocshmem.so → rocshmem::NUMAWrapper::NUMAWrapper() (upstream rocSHMEM global ctor) → dlopen("libnuma.so") == NULL → exit(1) (at library-load time!) → atexit → rocprofiler::registration::finalize() → ThreadPool::destroy_threadpool() → std::thread::join() # HANGS ``` ### Why it regressed here (and why 0513 was fine but 0514 hangs) This is a **packaging** regression from the ROCm manywheel pipeline port (#182696), not the rocSHMEM binary: | | bundled `libnuma` | `dlopen("libnuma.so")` from `$ORIGIN` | result | |---|---|---|---| | old `build_rocm.sh` (0513) | **`libnuma.so`** (bare) | resolves | ✅ no `exit()` → never hangs | | new `repair_wheel.py` (0514+) | **`libnuma.so.1`** only | fails (no bare name in-wheel) | ❌ `exit(1)` → rocprofiler atexit deadlock → intermittent hang | The old `build_rocm.sh` renamed bundled OS deps to **bare** sonames, so `torch/lib` shipped `libnuma.so`. `repair_wheel.py` keeps them **versioned** (`libnuma.so.1`). rocSHMEM's `NUMAWrapper` global ctor does `dlopen("libnuma.so")` (bare) via `libtorch_rocshmem.so`'s `$ORIGIN` RPATH — with only `libnuma.so.1` present it fails and `exit(1)`s at load, tripping a **racy** rocprofiler-sdk atexit `finalize()` deadlock (hence the intermittency; the `agent.cpp:608` kfd warning is a red herring). Same rocSHMEM binary in both wheels — only the bundled `libnuma` filename differs. ## Fix When bundling a versioned OS dep, also create a **bare-name symlink** (`libnuma.so` → `libnuma.so.1`, etc.), restoring `build_rocm.sh` behavior. The bare symlink satisfies rocSHMEM's `dlopen`; the versioned file still satisfies `NEEDED` references. **Verified:** adding this symlink to an installed wheel makes `import torch` succeed deterministically on a no-`kfd` host (loop-tested; the hang no longer reproduces). ## Follow-ups (upstream) The underlying rocSHMEM bug — `NUMAWrapper` must not `exit()` from a global constructor, and should `dlopen("libnuma.so.1")` — is already fixed upstream *after* PyTorch's pinned commit (`cb8a2d6`): ROCm/rocm-systems **#5918** (runtime numalib check) and **#6640** (link numa directly, no `dlopen` — removes `numa_wrapper.cpp`). Bumping `ROCSHMEM_VERSION` in `.ci/docker/common/install_rocSHMEM.sh` would also fix it and is worth doing separately. The rocprofiler-sdk atexit `finalize()` deadlock ("does not exit cleanly") is a separate AMD-side bug. Pull Request resolved: #189114 Approved by: https://github.com/huydhn, https://github.com/albanD
## Summary Port the XPU manylinux build from the legacy bash scripts (`build_xpu.sh` + `build_common.sh`) to the Python pipeline (`build_env_setup.py` + `build_install_deps.py` + `build_wheel.py` + `repair_wheel.py`), following the same pattern as pytorch#182409 (CUDA/CPU) and pytorch#182696 (ROCm). - Add `XPU_BUILD_ENV` and `source_oneapi_env()` to `build_env_setup.py` to source Intel oneAPI environment and set build flags - Always build small wheel for XPU, following the same practice as CUDA - Add XPU RPATH handling in `repair_wheel.py` (following CUDA pattern — runtime libs from pypi packages) - XPU wheels are now retagged to `manylinux_2_28_x86_64` - Delete `build_xpu.sh` cpu-s390x continues to flow through `build_common.sh` unchanged. Pull Request resolved: pytorch#182942 Approved by: https://github.com/atalman
Reroutes GPU_ARCH_TYPE=rocm through the same set_desired_python ->
build_env_setup -> build_install_deps -> build_wheel -> repair_wheel
chain that x86/aarch64 CUDA and CPU already use, and deletes the
standalone build_rocm.sh.
build_env_setup.py:
Add ROCM_BUILD_ENV_STATIC and a rocm branch in main() that mirrors
the original build_rocm.sh exports (ROCM_HOME, MAGMA_HOME,
USE_STATIC_*, BUILD_DEBUG_INFO, FORCE_RPATH) and normalizes
DESIRED_CUDA to the rocm-prefixed form expected by build_amd.py.
repair_wheel.py:
- Generalize the bundle pipeline with two small dataclasses:
BundledLib (a shared lib copied into torch/lib/, optionally
triggering a NEEDED rewrite to a renamed copy) and AuxFile
(a source-to-relative-dest mapping for tree content like MIOpen
kernel db, RCCL algorithms, gfx-specific rocBLAS/hipblaslt/
hipsparselt files).
- Add rocm_bundle() which discovers the ROCm shared libs under
$ROCM_HOME/{lib,lib64}, picks up the OS runtime deps
(libnuma/libelf/libtinfo/libdw/libdrm), and assembles the per-gfx
kernel-file copy list using PYTORCH_ROCM_ARCH.
- Versioned ROCm sonames are renamed to bare .so (mirrors
fname_without_so_number) and NEEDED entries inside the wheel are
rewritten via a new replace_needed() helper.
- main() picks the ROCm branch based on GPU_ARCH_TYPE/DESIRED_CUDA
and forces --force-rpath to match the legacy script.
build.sh:
Move the rocm case into the new pipeline alongside cuda/cpu; drops
the bash build_rocm.sh fallback.
XPU and cpu-s390x continue to flow through build_common.sh
unchanged.
Authored with Claude.
Pull Request resolved: pytorch#182696
Approved by: https://github.com/huydhn
Co-authored-by: Jithun Nair <[email protected]>
…ock (pytorch#189114) ## Summary `import torch` from ROCm 2.13 wheels **intermittently hangs forever** on hosts without a usable GPU / kfd (CPU-only nodes, or GPU nodes where `amdgpu`/`amdkfd` isn't loaded). Fixes pytorch#189110. This is related to this fix PR in upstream: ROCm/rocm-systems#6640 (this is not included in pytorch, hence a failure) ### Root cause (native backtrace) ``` import torch → dlopen(_C) → static init of libtorch_rocshmem.so → rocshmem::NUMAWrapper::NUMAWrapper() (upstream rocSHMEM global ctor) → dlopen("libnuma.so") == NULL → exit(1) (at library-load time!) → atexit → rocprofiler::registration::finalize() → ThreadPool::destroy_threadpool() → std::thread::join() # HANGS ``` ### Why it regressed here (and why 0513 was fine but 0514 hangs) This is a **packaging** regression from the ROCm manywheel pipeline port (pytorch#182696), not the rocSHMEM binary: | | bundled `libnuma` | `dlopen("libnuma.so")` from `$ORIGIN` | result | |---|---|---|---| | old `build_rocm.sh` (0513) | **`libnuma.so`** (bare) | resolves | ✅ no `exit()` → never hangs | | new `repair_wheel.py` (0514+) | **`libnuma.so.1`** only | fails (no bare name in-wheel) | ❌ `exit(1)` → rocprofiler atexit deadlock → intermittent hang | The old `build_rocm.sh` renamed bundled OS deps to **bare** sonames, so `torch/lib` shipped `libnuma.so`. `repair_wheel.py` keeps them **versioned** (`libnuma.so.1`). rocSHMEM's `NUMAWrapper` global ctor does `dlopen("libnuma.so")` (bare) via `libtorch_rocshmem.so`'s `$ORIGIN` RPATH — with only `libnuma.so.1` present it fails and `exit(1)`s at load, tripping a **racy** rocprofiler-sdk atexit `finalize()` deadlock (hence the intermittency; the `agent.cpp:608` kfd warning is a red herring). Same rocSHMEM binary in both wheels — only the bundled `libnuma` filename differs. ## Fix When bundling a versioned OS dep, also create a **bare-name symlink** (`libnuma.so` → `libnuma.so.1`, etc.), restoring `build_rocm.sh` behavior. The bare symlink satisfies rocSHMEM's `dlopen`; the versioned file still satisfies `NEEDED` references. **Verified:** adding this symlink to an installed wheel makes `import torch` succeed deterministically on a no-`kfd` host (loop-tested; the hang no longer reproduces). ## Follow-ups (upstream) The underlying rocSHMEM bug — `NUMAWrapper` must not `exit()` from a global constructor, and should `dlopen("libnuma.so.1")` — is already fixed upstream *after* PyTorch's pinned commit (`cb8a2d6`): ROCm/rocm-systems **pytorch#5918** (runtime numalib check) and **pytorch#6640** (link numa directly, no `dlopen` — removes `numa_wrapper.cpp`). Bumping `ROCSHMEM_VERSION` in `.ci/docker/common/install_rocSHMEM.sh` would also fix it and is worth doing separately. The rocprofiler-sdk atexit `finalize()` deadlock ("does not exit cleanly") is a separate AMD-side bug. Pull Request resolved: pytorch#189114 Approved by: https://github.com/huydhn, https://github.com/albanD
…ock (pytorch#189114) ## Summary `import torch` from ROCm 2.13 wheels **intermittently hangs forever** on hosts without a usable GPU / kfd (CPU-only nodes, or GPU nodes where `amdgpu`/`amdkfd` isn't loaded). Fixes pytorch#189110. This is related to this fix PR in upstream: ROCm/rocm-systems#6640 (this is not included in pytorch, hence a failure) ### Root cause (native backtrace) ``` import torch → dlopen(_C) → static init of libtorch_rocshmem.so → rocshmem::NUMAWrapper::NUMAWrapper() (upstream rocSHMEM global ctor) → dlopen("libnuma.so") == NULL → exit(1) (at library-load time!) → atexit → rocprofiler::registration::finalize() → ThreadPool::destroy_threadpool() → std::thread::join() # HANGS ``` ### Why it regressed here (and why 0513 was fine but 0514 hangs) This is a **packaging** regression from the ROCm manywheel pipeline port (pytorch#182696), not the rocSHMEM binary: | | bundled `libnuma` | `dlopen("libnuma.so")` from `$ORIGIN` | result | |---|---|---|---| | old `build_rocm.sh` (0513) | **`libnuma.so`** (bare) | resolves | ✅ no `exit()` → never hangs | | new `repair_wheel.py` (0514+) | **`libnuma.so.1`** only | fails (no bare name in-wheel) | ❌ `exit(1)` → rocprofiler atexit deadlock → intermittent hang | The old `build_rocm.sh` renamed bundled OS deps to **bare** sonames, so `torch/lib` shipped `libnuma.so`. `repair_wheel.py` keeps them **versioned** (`libnuma.so.1`). rocSHMEM's `NUMAWrapper` global ctor does `dlopen("libnuma.so")` (bare) via `libtorch_rocshmem.so`'s `$ORIGIN` RPATH — with only `libnuma.so.1` present it fails and `exit(1)`s at load, tripping a **racy** rocprofiler-sdk atexit `finalize()` deadlock (hence the intermittency; the `agent.cpp:608` kfd warning is a red herring). Same rocSHMEM binary in both wheels — only the bundled `libnuma` filename differs. ## Fix When bundling a versioned OS dep, also create a **bare-name symlink** (`libnuma.so` → `libnuma.so.1`, etc.), restoring `build_rocm.sh` behavior. The bare symlink satisfies rocSHMEM's `dlopen`; the versioned file still satisfies `NEEDED` references. **Verified:** adding this symlink to an installed wheel makes `import torch` succeed deterministically on a no-`kfd` host (loop-tested; the hang no longer reproduces). ## Follow-ups (upstream) The underlying rocSHMEM bug — `NUMAWrapper` must not `exit()` from a global constructor, and should `dlopen("libnuma.so.1")` — is already fixed upstream *after* PyTorch's pinned commit (`cb8a2d6`): ROCm/rocm-systems **pytorch#5918** (runtime numalib check) and **pytorch#6640** (link numa directly, no `dlopen` — removes `numa_wrapper.cpp`). Bumping `ROCSHMEM_VERSION` in `.ci/docker/common/install_rocSHMEM.sh` would also fix it and is worth doing separately. The rocprofiler-sdk atexit `finalize()` deadlock ("does not exit cleanly") is a separate AMD-side bug. Pull Request resolved: pytorch#189114 Approved by: https://github.com/huydhn, https://github.com/albanD
…ock (pytorch#189114) ## Summary `import torch` from ROCm 2.13 wheels **intermittently hangs forever** on hosts without a usable GPU / kfd (CPU-only nodes, or GPU nodes where `amdgpu`/`amdkfd` isn't loaded). Fixes pytorch#189110. This is related to this fix PR in upstream: ROCm/rocm-systems#6640 (this is not included in pytorch, hence a failure) ### Root cause (native backtrace) ``` import torch → dlopen(_C) → static init of libtorch_rocshmem.so → rocshmem::NUMAWrapper::NUMAWrapper() (upstream rocSHMEM global ctor) → dlopen("libnuma.so") == NULL → exit(1) (at library-load time!) → atexit → rocprofiler::registration::finalize() → ThreadPool::destroy_threadpool() → std::thread::join() # HANGS ``` ### Why it regressed here (and why 0513 was fine but 0514 hangs) This is a **packaging** regression from the ROCm manywheel pipeline port (pytorch#182696), not the rocSHMEM binary: | | bundled `libnuma` | `dlopen("libnuma.so")` from `$ORIGIN` | result | |---|---|---|---| | old `build_rocm.sh` (0513) | **`libnuma.so`** (bare) | resolves | ✅ no `exit()` → never hangs | | new `repair_wheel.py` (0514+) | **`libnuma.so.1`** only | fails (no bare name in-wheel) | ❌ `exit(1)` → rocprofiler atexit deadlock → intermittent hang | The old `build_rocm.sh` renamed bundled OS deps to **bare** sonames, so `torch/lib` shipped `libnuma.so`. `repair_wheel.py` keeps them **versioned** (`libnuma.so.1`). rocSHMEM's `NUMAWrapper` global ctor does `dlopen("libnuma.so")` (bare) via `libtorch_rocshmem.so`'s `$ORIGIN` RPATH — with only `libnuma.so.1` present it fails and `exit(1)`s at load, tripping a **racy** rocprofiler-sdk atexit `finalize()` deadlock (hence the intermittency; the `agent.cpp:608` kfd warning is a red herring). Same rocSHMEM binary in both wheels — only the bundled `libnuma` filename differs. ## Fix When bundling a versioned OS dep, also create a **bare-name symlink** (`libnuma.so` → `libnuma.so.1`, etc.), restoring `build_rocm.sh` behavior. The bare symlink satisfies rocSHMEM's `dlopen`; the versioned file still satisfies `NEEDED` references. **Verified:** adding this symlink to an installed wheel makes `import torch` succeed deterministically on a no-`kfd` host (loop-tested; the hang no longer reproduces). ## Follow-ups (upstream) The underlying rocSHMEM bug — `NUMAWrapper` must not `exit()` from a global constructor, and should `dlopen("libnuma.so.1")` — is already fixed upstream *after* PyTorch's pinned commit (`cb8a2d6`): ROCm/rocm-systems **pytorch#5918** (runtime numalib check) and **pytorch#6640** (link numa directly, no `dlopen` — removes `numa_wrapper.cpp`). Bumping `ROCSHMEM_VERSION` in `.ci/docker/common/install_rocSHMEM.sh` would also fix it and is worth doing separately. The rocprofiler-sdk atexit `finalize()` deadlock ("does not exit cleanly") is a separate AMD-side bug. Pull Request resolved: pytorch#189114 Approved by: https://github.com/huydhn, https://github.com/albanD
## Summary Port the XPU manylinux build from the legacy bash scripts (`build_xpu.sh` + `build_common.sh`) to the Python pipeline (`build_env_setup.py` + `build_install_deps.py` + `build_wheel.py` + `repair_wheel.py`), following the same pattern as pytorch#182409 (CUDA/CPU) and pytorch#182696 (ROCm). - Add `XPU_BUILD_ENV` and `source_oneapi_env()` to `build_env_setup.py` to source Intel oneAPI environment and set build flags - Always build small wheel for XPU, following the same practice as CUDA - Add XPU RPATH handling in `repair_wheel.py` (following CUDA pattern — runtime libs from pypi packages) - XPU wheels are now retagged to `manylinux_2_28_x86_64` - Delete `build_xpu.sh` cpu-s390x continues to flow through `build_common.sh` unchanged. Pull Request resolved: pytorch#182942 Approved by: https://github.com/atalman
Reroutes GPU_ARCH_TYPE=rocm through the same set_desired_python ->
build_env_setup -> build_install_deps -> build_wheel -> repair_wheel
chain that x86/aarch64 CUDA and CPU already use, and deletes the
standalone build_rocm.sh.
build_env_setup.py:
Add ROCM_BUILD_ENV_STATIC and a rocm branch in main() that mirrors
the original build_rocm.sh exports (ROCM_HOME, MAGMA_HOME,
USE_STATIC_*, BUILD_DEBUG_INFO, FORCE_RPATH) and normalizes
DESIRED_CUDA to the rocm-prefixed form expected by build_amd.py.
repair_wheel.py:
- Generalize the bundle pipeline with two small dataclasses:
BundledLib (a shared lib copied into torch/lib/, optionally
triggering a NEEDED rewrite to a renamed copy) and AuxFile
(a source-to-relative-dest mapping for tree content like MIOpen
kernel db, RCCL algorithms, gfx-specific rocBLAS/hipblaslt/
hipsparselt files).
- Add rocm_bundle() which discovers the ROCm shared libs under
$ROCM_HOME/{lib,lib64}, picks up the OS runtime deps
(libnuma/libelf/libtinfo/libdw/libdrm), and assembles the per-gfx
kernel-file copy list using PYTORCH_ROCM_ARCH.
- Versioned ROCm sonames are renamed to bare .so (mirrors
fname_without_so_number) and NEEDED entries inside the wheel are
rewritten via a new replace_needed() helper.
- main() picks the ROCm branch based on GPU_ARCH_TYPE/DESIRED_CUDA
and forces --force-rpath to match the legacy script.
build.sh:
Move the rocm case into the new pipeline alongside cuda/cpu; drops
the bash build_rocm.sh fallback.
XPU and cpu-s390x continue to flow through build_common.sh
unchanged.
Authored with Claude.
Pull Request resolved: pytorch#182696
Approved by: https://github.com/huydhn
Co-authored-by: Jithun Nair <[email protected]>
…ock (pytorch#189114) ## Summary `import torch` from ROCm 2.13 wheels **intermittently hangs forever** on hosts without a usable GPU / kfd (CPU-only nodes, or GPU nodes where `amdgpu`/`amdkfd` isn't loaded). Fixes pytorch#189110. This is related to this fix PR in upstream: ROCm/rocm-systems#6640 (this is not included in pytorch, hence a failure) ### Root cause (native backtrace) ``` import torch → dlopen(_C) → static init of libtorch_rocshmem.so → rocshmem::NUMAWrapper::NUMAWrapper() (upstream rocSHMEM global ctor) → dlopen("libnuma.so") == NULL → exit(1) (at library-load time!) → atexit → rocprofiler::registration::finalize() → ThreadPool::destroy_threadpool() → std::thread::join() # HANGS ``` ### Why it regressed here (and why 0513 was fine but 0514 hangs) This is a **packaging** regression from the ROCm manywheel pipeline port (pytorch#182696), not the rocSHMEM binary: | | bundled `libnuma` | `dlopen("libnuma.so")` from `$ORIGIN` | result | |---|---|---|---| | old `build_rocm.sh` (0513) | **`libnuma.so`** (bare) | resolves | ✅ no `exit()` → never hangs | | new `repair_wheel.py` (0514+) | **`libnuma.so.1`** only | fails (no bare name in-wheel) | ❌ `exit(1)` → rocprofiler atexit deadlock → intermittent hang | The old `build_rocm.sh` renamed bundled OS deps to **bare** sonames, so `torch/lib` shipped `libnuma.so`. `repair_wheel.py` keeps them **versioned** (`libnuma.so.1`). rocSHMEM's `NUMAWrapper` global ctor does `dlopen("libnuma.so")` (bare) via `libtorch_rocshmem.so`'s `$ORIGIN` RPATH — with only `libnuma.so.1` present it fails and `exit(1)`s at load, tripping a **racy** rocprofiler-sdk atexit `finalize()` deadlock (hence the intermittency; the `agent.cpp:608` kfd warning is a red herring). Same rocSHMEM binary in both wheels — only the bundled `libnuma` filename differs. ## Fix When bundling a versioned OS dep, also create a **bare-name symlink** (`libnuma.so` → `libnuma.so.1`, etc.), restoring `build_rocm.sh` behavior. The bare symlink satisfies rocSHMEM's `dlopen`; the versioned file still satisfies `NEEDED` references. **Verified:** adding this symlink to an installed wheel makes `import torch` succeed deterministically on a no-`kfd` host (loop-tested; the hang no longer reproduces). ## Follow-ups (upstream) The underlying rocSHMEM bug — `NUMAWrapper` must not `exit()` from a global constructor, and should `dlopen("libnuma.so.1")` — is already fixed upstream *after* PyTorch's pinned commit (`cb8a2d6`): ROCm/rocm-systems **pytorch#5918** (runtime numalib check) and **pytorch#6640** (link numa directly, no `dlopen` — removes `numa_wrapper.cpp`). Bumping `ROCSHMEM_VERSION` in `.ci/docker/common/install_rocSHMEM.sh` would also fix it and is worth doing separately. The rocprofiler-sdk atexit `finalize()` deadlock ("does not exit cleanly") is a separate AMD-side bug. Pull Request resolved: pytorch#189114 Approved by: https://github.com/huydhn, https://github.com/albanD
The ROCm manywheel repair step renames bundled ROCm libs to bare .so filenames and rewrites NEEDED references to match. #182696 ported this from build_common.sh to repair_wheel.py and collapsed the shell script's two phases (copy every DEPS_LIST lib into torch/lib, then run replace_needed_sofiles for every soname) into a single per-lib loop that copies a lib and immediately rewrites references to it. replace_needed only visits files present in the wheel at call time, so references from a bundled lib to any lib listed earlier in ROCM_SO_FILES are never rewritten: the dependent has not been copied in yet when its dependency's rewrite pass runs. The 2.13.0+rocm7.2 wheel ships 27 such dangling NEEDED entries (libhiprtc.so -> libamd_comgr.so.3, librocblas.so -> libamdhip64.so.7, libmagma.so -> libhipblas.so.3, ...). Most resolve at runtime by luck (the bundled file keeps its versioned SONAME, so a copy already loaded under that SONAME satisfies the ref) or from a system ROCm install via ldconfig, which is why this went unnoticed until the cold dlopen introduced by #183515 hit the libamd_comgr.so.3 ref on a machine with no ROCm (#189194). The fix restores the two-phase structure: copy all bundled libs (and their bare-name dlopen symlinks from #189110) first, then run the rewrite passes. A new check_no_dangling_bundled_needed pass then fails the build if any lib in torch/lib still references a versioned soname whose stem is bundled but whose exact name is not shipped, so a future ordering or list regression breaks the build instead of shipping a wheel that silently depends on a system ROCm install. This complements #189900, which makes the inductor VecISA probe recover from such wheels at runtime; this change makes newly built wheels self-contained again. Test Plan: Ran the real repair_wheel() from before and after the change on a minimal fake torch wheel bundling this host's actual ROCm libs in the regression order (libhsa-runtime64 listed before libroctracer64, which NEEDs libhsa-runtime64.so.1): the old code ships the stale versioned ref with no error, the new code rewrites it to libhsa-runtime64.so and the new check passes. Aimed check_no_dangling_bundled_needed at the torch/lib of the actual torch==2.13.0+rocm7.2 wheel (installed from download.pytorch.org/whl/test/rocm7.2): it fails the build listing all 27 dangling references, including the libamd_comgr.so.3 ones from #189194. ``` python validate_repair_wheel.py # A/B harness driving repair_wheel() from both revisions ``` Authored with Claude (AI assistant).
#189906) The ROCm manywheel repair step renames bundled ROCm libs to bare `.so` filenames and rewrites NEEDED references to match. #182696 ported this from build_common.sh to repair_wheel.py and collapsed the shell script's two phases (copy every DEPS_LIST lib into torch/lib, then run replace_needed_sofiles for every soname) into a single per-lib loop that copies a lib and immediately rewrites references to it. `replace_needed` only visits files present in the wheel at call time, so references from a bundled lib to any lib listed earlier in ROCM_SO_FILES are never rewritten: the dependent has not been copied in yet when its dependency's rewrite pass runs. The 2.13.0+rocm7.2 wheel ships 27 such dangling NEEDED entries (`libhiprtc.so -> libamd_comgr.so.3`, `librocblas.so -> libamdhip64.so.7`, `libmagma.so -> libhipblas.so.3`, ...). Most resolve at runtime by luck (the bundled file keeps its versioned SONAME, so a copy already loaded under that SONAME satisfies the ref) or from a system ROCm install via ldconfig, which is why this went unnoticed until the cold dlopen introduced by #183515 hit the `libamd_comgr.so.3` ref on a machine with no ROCm (#189194). The fix restores the two-phase structure: copy all bundled libs (and their bare-name dlopen symlinks from #189110) first, then run the rewrite passes. A new `check_no_dangling_bundled_needed` pass then fails the build if any lib in torch/lib still references a versioned soname whose stem is bundled but whose exact name is not shipped, so a future ordering or list regression breaks the build instead of shipping a wheel that silently depends on a system ROCm install. This complements #189900, which makes the inductor VecISA probe recover from such wheels at runtime; this change makes newly built wheels self-contained again. Validated by running the real `repair_wheel()` from before and after the change on a minimal fake torch wheel bundling actual ROCm libs in the regression order (libhsa-runtime64 listed before libroctracer64, which NEEDs libhsa-runtime64.so.1): the old code ships the stale versioned ref with no error, the new code rewrites it to libhsa-runtime64.so and the new check passes. Aiming `check_no_dangling_bundled_needed` at the torch/lib of the actual torch==2.13.0+rocm7.2 wheel fails the build listing all 27 dangling references, including the `libamd_comgr.so.3` ones from #189194. This PR was authored with Claude (AI assistant). Pull Request resolved: #189906 Approved by: https://github.com/atalman, https://github.com/jithunnair-amd
#193600) [ROCm] Rewrite bundled-lib NEEDED entries after all libs are copied in (#189906) The ROCm manywheel repair step renames bundled ROCm libs to bare `.so` filenames and rewrites NEEDED references to match. #182696 ported this from build_common.sh to repair_wheel.py and collapsed the shell script's two phases (copy every DEPS_LIST lib into torch/lib, then run replace_needed_sofiles for every soname) into a single per-lib loop that copies a lib and immediately rewrites references to it. `replace_needed` only visits files present in the wheel at call time, so references from a bundled lib to any lib listed earlier in ROCM_SO_FILES are never rewritten: the dependent has not been copied in yet when its dependency's rewrite pass runs. The 2.13.0+rocm7.2 wheel ships 27 such dangling NEEDED entries (`libhiprtc.so -> libamd_comgr.so.3`, `librocblas.so -> libamdhip64.so.7`, `libmagma.so -> libhipblas.so.3`, ...). Most resolve at runtime by luck (the bundled file keeps its versioned SONAME, so a copy already loaded under that SONAME satisfies the ref) or from a system ROCm install via ldconfig, which is why this went unnoticed until the cold dlopen introduced by #183515 hit the `libamd_comgr.so.3` ref on a machine with no ROCm (#189194). The fix restores the two-phase structure: copy all bundled libs (and their bare-name dlopen symlinks from #189110) first, then run the rewrite passes. A new `check_no_dangling_bundled_needed` pass then fails the build if any lib in torch/lib still references a versioned soname whose stem is bundled but whose exact name is not shipped, so a future ordering or list regression breaks the build instead of shipping a wheel that silently depends on a system ROCm install. This complements #189900, which makes the inductor VecISA probe recover from such wheels at runtime; this change makes newly built wheels self-contained again. Validated by running the real `repair_wheel()` from before and after the change on a minimal fake torch wheel bundling actual ROCm libs in the regression order (libhsa-runtime64 listed before libroctracer64, which NEEDs libhsa-runtime64.so.1): the old code ships the stale versioned ref with no error, the new code rewrites it to libhsa-runtime64.so and the new check passes. Aiming `check_no_dangling_bundled_needed` at the torch/lib of the actual torch==2.13.0+rocm7.2 wheel fails the build listing all 27 dangling references, including the `libamd_comgr.so.3` ones from #189194. This PR was authored with Claude (AI assistant). Pull Request resolved: #189906 Approved by: https://github.com/atalman, https://github.com/jithunnair-amd (cherry picked from commit 4973620) Co-authored-by: Jeff Daily <[email protected]>
pytorch#189906) The ROCm manywheel repair step renames bundled ROCm libs to bare `.so` filenames and rewrites NEEDED references to match. pytorch#182696 ported this from build_common.sh to repair_wheel.py and collapsed the shell script's two phases (copy every DEPS_LIST lib into torch/lib, then run replace_needed_sofiles for every soname) into a single per-lib loop that copies a lib and immediately rewrites references to it. `replace_needed` only visits files present in the wheel at call time, so references from a bundled lib to any lib listed earlier in ROCM_SO_FILES are never rewritten: the dependent has not been copied in yet when its dependency's rewrite pass runs. The 2.13.0+rocm7.2 wheel ships 27 such dangling NEEDED entries (`libhiprtc.so -> libamd_comgr.so.3`, `librocblas.so -> libamdhip64.so.7`, `libmagma.so -> libhipblas.so.3`, ...). Most resolve at runtime by luck (the bundled file keeps its versioned SONAME, so a copy already loaded under that SONAME satisfies the ref) or from a system ROCm install via ldconfig, which is why this went unnoticed until the cold dlopen introduced by pytorch#183515 hit the `libamd_comgr.so.3` ref on a machine with no ROCm (pytorch#189194). The fix restores the two-phase structure: copy all bundled libs (and their bare-name dlopen symlinks from pytorch#189110) first, then run the rewrite passes. A new `check_no_dangling_bundled_needed` pass then fails the build if any lib in torch/lib still references a versioned soname whose stem is bundled but whose exact name is not shipped, so a future ordering or list regression breaks the build instead of shipping a wheel that silently depends on a system ROCm install. This complements pytorch#189900, which makes the inductor VecISA probe recover from such wheels at runtime; this change makes newly built wheels self-contained again. Validated by running the real `repair_wheel()` from before and after the change on a minimal fake torch wheel bundling actual ROCm libs in the regression order (libhsa-runtime64 listed before libroctracer64, which NEEDs libhsa-runtime64.so.1): the old code ships the stale versioned ref with no error, the new code rewrites it to libhsa-runtime64.so and the new check passes. Aiming `check_no_dangling_bundled_needed` at the torch/lib of the actual torch==2.13.0+rocm7.2 wheel fails the build listing all 27 dangling references, including the `libamd_comgr.so.3` ones from pytorch#189194. This PR was authored with Claude (AI assistant). Pull Request resolved: pytorch#189906 Approved by: https://github.com/atalman, https://github.com/jithunnair-amd
…el and re-enable CI tests (#195658) Advances the `rocm-composable-kernel` pin and generates the one CK header the wheel does not ship. Restores CK autotuning in CI disabled due to stale pin. ## Motivation ROCm 7.14 stopped installing the CK headers system-wide, so the inductor CK backends now compile against what the `ck4inductor` wheel ships. Every header they `#include` is checked into CK except one: `ck/config.h` is generated by CK's build from `include/ck/config.h.in`, so it exists in neither ROCm nor the wheel's source tree. Without it every CK choice fails to compile and is silently discarded, so the CK backends contribute no autotune candidates at all rather than reporting a missing header. Scope: this restores CK autotuning in CI. The ROCm CD path has routed through the Python build pipeline since #182696 and has no CK step. ## Changes **Generate `ck/config.h`** (`.ci/pytorch/rocm_utils.sh`, `.ci/pytorch/generate_ck_config_h.cmake`) `build_rocm_ck_wheel()` now generates the header for `gfx90a;gfx942;gfx950` and packages it with the rest of `include/ck`. This replaces the `ck_tile` `pyproject.toml` patch, which the new pin makes a no-op. CK's own CMake cannot produce it in the wheel-build container: `CMakeLists.txt` calls `find_package(ROCM)`, `find_package(hip REQUIRED)` and `enable_language(HIP)`, and the image has `hipcc` but no ROCm CMake packages. `config.h.in` substitutes only plain variables, so the helper sets them and runs the same `configure_file` in `cmake -P` script mode. The helper mirrors CK's arch rules rather than referencing them, so it assigns every variable unconditionally — `"ON"` or empty — instead of only in the true branch. Leaving one undefined would be indistinguishable from a deliberate OFF, which both defeats the drift check and makes the script reject any target list that does not happen to enable everything. > **Note for CI:** this step shells out to `cmake -P`, so the wheel-build image must > provide `cmake`. **Pin bump** `4266f867` → `e2daf442` The outgoing pin is from February. The new one packages the `ck_tile` headers in `pyproject.toml`, which makes the patch #189646 added to `rocm_utils.sh` a no-op. It also makes instance enumeration deterministic and duplicate-free, so a given wheel offers the same candidates on every machine instead of depending on filesystem order. This pin is also a prerequisite for follow-up PRs adding gfx1250 WMMA support. **Re-enable version-skipped tests** (`test/inductor/test_ck_backend.py`) Removes seven `skipIfRocmVersionAtLeast([7, 14])` decorators, added in #188593 (and one in #188429) for known 7.14 failures. The predicate is `>=`, so on ROCm 10.x it evaluates true and these subtests are skipped on every current ROCm CI job rather than only on the 7.14 release they were written for. ## Test plan Verified on hardware with both wheels built from this branch — the CK wheel by the real `build_rocm_ck_wheel()`, so the code under test is what produced the artifact. | Arch | Collected | Result | |---|---|---| | gfx942 (MI300X) | 84 | 76 passed, 8 skipped | | gfx942 (MI325X) | 84 | 76 passed, 8 skipped | The 8 skips are the `scaled_mm` cells, skipped upstream for unrelated reasons. @pytorchbot label "topic: not user facing" Pull Request resolved: #195658 Approved by: https://github.com/jeffdaily
Stack from ghstack (oldest at bottom):
Reroutes GPU_ARCH_TYPE=rocm through the same set_desired_python ->
build_env_setup -> build_install_deps -> build_wheel -> repair_wheel
chain that x86/aarch64 CUDA and CPU already use, and deletes the
standalone build_rocm.sh.
build_env_setup.py:
Add ROCM_BUILD_ENV_STATIC and a rocm branch in main() that mirrors
the original build_rocm.sh exports (ROCM_HOME, MAGMA_HOME,
USE_STATIC_*, BUILD_DEBUG_INFO, FORCE_RPATH) and normalizes
DESIRED_CUDA to the rocm-prefixed form expected by build_amd.py.
repair_wheel.py:
BundledLib (a shared lib copied into torch/lib/, optionally
triggering a NEEDED rewrite to a renamed copy) and AuxFile
(a source-to-relative-dest mapping for tree content like MIOpen
kernel db, RCCL algorithms, gfx-specific rocBLAS/hipblaslt/
hipsparselt files).
$ROCM_HOME/{lib,lib64}, picks up the OS runtime deps
(libnuma/libelf/libtinfo/libdw/libdrm), and assembles the per-gfx
kernel-file copy list using PYTORCH_ROCM_ARCH.
fname_without_so_number) and NEEDED entries inside the wheel are
rewritten via a new replace_needed() helper.
and forces --force-rpath to match the legacy script.
build.sh:
Move the rocm case into the new pipeline alongside cuda/cpu; drops
the bash build_rocm.sh fallback.
XPU and cpu-s390x continue to flow through build_common.sh
unchanged.
Authored with Claude.
cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang