Skip to content

[ROCm] Preload TheRock ROCm deps so wheels are self-contained (_preload_rocm_deps) - #188454

Closed
amdfaa wants to merge 2 commits into
pytorch:mainfrom
amdfaa:rocm-sysdeps-ldconfig
Closed

amdfaa wants to merge 2 commits into
pytorch:mainfrom
amdfaa:rocm-sysdeps-ldconfig

Conversation

@amdfaa

@amdfaa amdfaa commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR makes PyTorch ROCm/TheRock wheels self-contained: it fixes the two import torch failures that occur on the wheel (_rocm_sdk_* site-packages) layout, so import torch works without LD_LIBRARY_PATH or a sourced ROCm env (e.g. the ROCm distributed preflight python .ci/pytorch/rocm_preflight.py, which never sources /etc/rocm_env.sh).

Both fixes live in torch source, so they travel with any build (including a bare python -m build in a TheRock env), not just CI-produced wheels. This is the minimal, consolidated PR carrying both import-discovery fixes — a two-file diff (torch/__init__.py + torch/cuda/__init__.py).

Both changes are no-ops on the traditional tarball /opt/rocm install: each early-returns when the wheel package's _rocm_sdk_core is absent, so non-wheel ROCm CI (apt//opt/rocm, whose libs are already on the loader path), CUDA, and CPU builds are unaffected.

Fixes

1. torch/__init__.py — _preload_rocm_deps()

Fixes ImportError: librocm_sysdeps_liblzma.so.5: cannot open shared object file at from torch._C import *

  • Adds _preload_rocm_deps(), the ROCm analogue of _preload_cuda_deps() (which handles the nvidia-*-cu12 wheels). At import time, before import torch._C, it locates the rocm pip package's _rocm_sdk_core via importlib.util.find_spec (the same anchor torch.utils.cpp_extension._find_rocm_home() uses) and ctypes.CDLL-preloads (RTLD_GLOBAL) the vendored sysdeps (librocm_sysdeps_*) and core ROCm runtime libs from _rocm_sdk_core/lib and _rocm_sdk_core/lib/rocm_sysdeps/lib. Wired into _load_global_deps().
  • Guarded to no-op on non-Linux, on non-ROCm builds (torch.version.hip is None → CUDA/CPU), and on OS-managed ROCm where _rocm_sdk_core is absent (the apt//opt/rocm path).

2. torch/cuda/__init__.py — amdsmi / libamd_smi.so discovery hook + non-fatal guard

Fixes the next failure that surfaces once _preload_rocm_deps() gets import torch past the librocm_sysdeps error: KeyError: 'libamd_smi.so' raised from the amdsmi Python binding at import amdsmi (inside _C._initExtension)

On TheRock wheels the amdsmi package installs the native library as a versioned soname under _rocm_sdk_core/lib (e.g. libamd_smi.so.26), which amdsmi's own find_smi_library() fails to locate when $ROCM_HOME/$ROCM_PATH and the loader path are unset; its wrapper then does _libraries['libamd_smi.so'] → KeyError, which escaped the existing guard (only ModuleNotFoundError was tolerated) and killed import torch. Two-part torch-side hardening:

  • Make _amdsmi_cdll_hook TheRock-aware: locate _rocm_sdk_core via importlib.util.find_spec and add its lib/libamd_smi.so* (glob, incl. versioned sonames) as last-resort candidate paths; match names whose basename starts with libamd_smi.so so amdsmi's bare CDLL("libamd_smi.so") is redirected to the real versioned file. Existing ROCM_HOME/ROCM_PATH behavior preserved; guarded to Linux.
  • Make a non-discoverable amdsmi non-fatal: broaden the guard so KeyError/OSError degrade to _HAS_AMDSMI=False instead of aborting import torch, matching the existing missing-module path.

Consolidation note

The amdsmi discovery fix (#2 above) originally shipped as standalone PR #188724. That PR has been closed and folded into this PR so both import-discovery fixes travel together in a single minimal two-file change.

Scope note: the TheRock tarball→wheels migration and the earlier CI-only RPATH/ldconfig workarounds are not part of this PR. The wheels migration is tracked separately by #188429, which rebases on top of this change.

Validation (TheRock wheel path) — PASSED

Validated end-to-end by temporarily stacking Ethan's wheels-migration PR #188429 (which adds the rocm-preview wheel CI) on top of the two source fixes and running ciflow/rocm-preview (run 28581558341) on the stacked head. The temporary stack was then removed, so this PR remains the minimal two-file source diff.

rocm-preview distributed shards (register fat binary failed)

Reference/evidence for the register fat binary failed (code_object.cpp:1038) investigation — the rocm-preview (TheRock wheel-path) distributed shards from run 28581558341 (linux-noble-rocm-preview-py3.12-gfx942), all FAILED:

Failure log the amdsmi fix addresses (pre-fix, run 28524549808)
/var/lib/jenkins/workspace/libamd_smi.so: cannot open shared object file: No such file or directory
Unable to find libamd_smi.so library try installing amd-smi-lib from your package manager
Traceback (most recent call last):
  File "/var/lib/jenkins/workspace/.ci/pytorch/rocm_preflight.py", line 21, in <module>
    import torch
  File ".../site-packages/torch/cuda/__init__.py", line 114, in <module>
    import amdsmi  # type: ignore[import]
  File ".../site-packages/amdsmi/amdsmi_wrapper.py", line 218, in <module>
    amdsmi_free_name_value_pairs = _libraries['libamd_smi.so'].amdsmi_free_name_value_pairs
KeyError: 'libamd_smi.so'

Notes: amdsmi discovery + fat-binary logs

  • Bare CDLL("libamd_smi.so") comes from amdsmi's own find_smi_library() (unversioned candidate), not torch; torch's _amdsmi_cdll_hook intercepts it and retries the versioned _rocm_sdk_core/lib/libamd_smi.so*.
  • Not just preload amdsmi via _rocm_core_libs: amdsmi resolves by exact filename, so an RTLD_GLOBAL versioned libamd_smi.so.26 won't satisfy it, and eager-preloading a non-DT_NEEDED lib reintroduces the ODR double-load the hook prevents — the CDLL-redirect hook is the correct fix.
  • E0702 … code_object.cpp:1038 register fat binary failed is not caused by this PR: it's emitted by the HIP/clr C++ runtime, appears ambiently (~4,774×/run across rocm-preview gfx942 jobs incl. the distributed shards above), and is non-fatal — a pre-existing TheRock rocm-preview build/toolchain matter, orthogonal to these two Python-only changes.
  • Fix-plan pointer (fat-binary): prove pre-existing on a PR-free main rocm-preview baseline → localize via AMD_LOG_LEVEL=3/4 → scoped clr-log suppress/demote (escalate to clr/comgr pin or PYTORCH_ROCM_ARCH only on a real running-arch failure) → validate via ciflow/rocm-preview. Belongs in the build/CI layer, not torch source. Tracked in ROCm/frameworks-internal Feature request: torch.broadcast_to #17160.

Test plan

  • Validate on the TheRock wheel path via ciflow/rocm-preview (see Validation above).
  • ast.parse both changed files (torch/__init__.py, torch/cuda/__init__.py).
  • Confirm CUDA and CPU builds are unaffected (both fixes no-op when torch.version.hip is None / _rocm_sdk_core absent).

Fixes #188561

cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang

Made with Cursor

@amdfaa
amdfaa requested a review from jeffdaily as a code owner June 29, 2026 18:17
@pytorch-bot

pytorch-bot Bot commented Jun 29, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/188454

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (9 Unrelated Failures)

As of commit a3e4b78 with merge base 332fabd (image):

UNSTABLE - The following jobs are marked as unstable, possibly due to flakiness on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot Bot added ciflow/docker module: rocm AMD GPU support for Pytorch topic: not user facing topic category labels Jun 29, 2026
@pytorch-bot

pytorch-bot Bot commented Jun 29, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@jithunnair-amd jithunnair-amd added the ciflow/periodic-rocm-mi300 Trigger "distributed" config CI on ROCm MI300/MI325 label Jun 29, 2026
@soulitzer soulitzer added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Jun 29, 2026
@amdfaa
amdfaa requested a review from a team as a code owner June 30, 2026 16:05
@jithunnair-amd jithunnair-amd added the ciflow/rocm-preview Trigger unit tests CI on a preview build of ROCm from theRock on MI300 label Jun 30, 2026
@pytorch-bot

pytorch-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

Warning: Unknown label ciflow/rocm-preview.
Currently recognized labels are

  • ciflow/b200
  • ciflow/b200-distributed
  • ciflow/b200-symm-mem
  • ciflow/binaries
  • ciflow/binaries_libtorch
  • ciflow/binaries_wheel
  • ciflow/docker
  • ciflow/dtensor
  • ciflow/dynamo
  • ciflow/h100
  • ciflow/h100-cutlass-backend
  • ciflow/h100-distributed
  • ciflow/h100-symm-mem
  • ciflow/inductor
  • ciflow/inductor-cu126
  • ciflow/inductor-micro-benchmark
  • ciflow/inductor-micro-benchmark-cpu-x86
  • ciflow/inductor-pallas
  • ciflow/inductor-perf-compare
  • ciflow/inductor-perf-test-nightly-rocm-mi300
  • ciflow/inductor-perf-test-nightly-rocm-mi350
  • ciflow/inductor-perf-test-nightly-x86-zen
  • ciflow/inductor-perf-test-nightly-xpu
  • ciflow/inductor-periodic
  • ciflow/inductor-rocm-mi200
  • ciflow/inductor-rocm-mi300
  • ciflow/mps
  • ciflow/nightly
  • ciflow/op-benchmark
  • ciflow/periodic
  • ciflow/periodic-rocm-mi200
  • ciflow/periodic-rocm-mi300
  • ciflow/pull
  • ciflow/riscv64
  • ciflow/rocm-mi200
  • ciflow/rocm-mi300
  • ciflow/rocm-navi31
  • ciflow/rocm-nightly
  • ciflow/s390
  • ciflow/slow
  • ciflow/slow-rocm-mi200
  • ciflow/torchtitan
  • ciflow/triton_binaries
  • ciflow/trunk
  • ciflow/tsan
  • ciflow/unstable
  • ciflow/vllm
  • ciflow/win-arm64
  • ciflow/xpu

Please add the new label to .github/pytorch-probot.yml

chinmaydk99 added a commit to ROCm/TheRock that referenced this pull request Jul 1, 2026
… /dev/shm

Three environment/config fixes that make genuinely-failing tests pass on the
2.14 ROCm wheels. Each is a harness/CI-environment gap, not a test or PyTorch
bug; verified locally on MI300X (gfx942) via run_test.py. No skip-list changes
here — validate via a debug (skipped-tests-only) run.

1. TORCH_SERIALIZATION_DEBUG=1 in setup_env: upstream .ci/pytorch/test.sh exports
   this for all CI; TheRock did not, so test_serialization
   TestSerialization/TestOldSerialization::test_debug_set_in_ci failed (they assert
   the flag is set under IS_CI). Fixes both.

2. Register TheRock's wheel-shipped ROCm lib dirs (_rocm_sdk_core/lib +
   rocm_sysdeps/lib, _rocm_sdk_devel/lib) with ldconfig in setup_env. Those dirs
   aren't on the default loader/link search path, so:
     - test_multiprocessing test_fs*: torch_shm_manager subprocess exits 127
       (librocprofiler-sdk.so.1 / libamdhip64.so.7 not found)
     - test_utils TestStandaloneCPPJIT::test_load_standalone: ld undefined
       reference to hipModuleLoadDataEx@hip_4.2 (libaotriton link)
   LIMITATION: the proper fix bakes $ORIGIN-relative RPATH into the torch .so's at
   wheel-build time (upstream pytorch/pytorch#188454 does exactly this via
   patch_rocm_sysdeps_rpath + ldconfig). We can't patch an already-built wheel from
   the test harness, so we register with ldconfig here as the test-side equivalent;
   drop once #188454 / the RPATH bake lands. Best-effort (no-ops if non-root).

3. Bump the test container --shm-size 10g -> 64g: the 8-rank FSDP HSDP 3D-mesh
   test (TestFullyShardHSDP3DTraining::test_3d_mlp_with_nd_mesh) exhausts a 10g
   /dev/shm with RCCL shared-memory segments ("No space left on device"); passes at
   64g. Matches upstream ROCm CI shm size.

Co-Authored-By: Claude <[email protected]>
…m_deps`)

Add `_preload_rocm_deps()` in torch/__init__.py, the ROCm analogue of
`_preload_cuda_deps`. At import time (before `import torch._C`), it locates the
`rocm` pip package's `_rocm_sdk_core` via importlib.util.find_spec and
RTLD_GLOBAL-preloads the vendored sysdeps (librocm_sysdeps_*) and the core ROCm
runtime libs from `_rocm_sdk_core/lib{,/rocm_sysdeps/lib}`, wired into
`_load_global_deps()`.

Because it lives in torch source it travels with any build, so a bare
`setup.py` / `python -m build` in a TheRock env yields an importable,
self-contained wheel without relying on LD_LIBRARY_PATH. Guarded to no-op on
non-Linux, on non-ROCm builds (torch.version.hip is None -> CUDA/CPU), and on
OS-managed ROCm where `_rocm_sdk_core` is absent (apt/opt-rocm path).

Made with Cursor
@amdfaa
amdfaa force-pushed the rocm-sysdeps-ldconfig branch from e112afd to 5e6d1e2 Compare July 1, 2026 18:29
@amdfaa amdfaa changed the title [ROCm][CI] Register theRock sysdeps libs with ldconfig [ROCm] Preload TheRock ROCm deps so wheels are self-contained (_preload_rocm_deps) Jul 1, 2026
On TheRock ROCm wheels, `import torch` aborts with
`KeyError: 'libamd_smi.so'`: the amdsmi python package installs the native
library as a versioned soname under `_rocm_sdk_core/lib` (e.g.
`libamd_smi.so.26`), which amdsmi's own `find_smi_library()` fails to locate
when `$ROCM_HOME`/`$ROCM_PATH` and the loader path are unset. Its wrapper then
does `_libraries['libamd_smi.so']`, raising `KeyError`, which escapes the
existing guard (only `ModuleNotFoundError` was tolerated) and kills
`import torch`.

Two-part torch-side hardening (mirrors the `_preload_rocm_deps()` philosophy):

1. Make `_amdsmi_cdll_hook` TheRock-aware: locate `_rocm_sdk_core` via
   `importlib.util.find_spec` and add its `lib/libamd_smi.so*` (glob, incl.
   versioned sonames) as last-resort candidate paths; match names whose
   basename starts with `libamd_smi.so` so amdsmi's bare
   `CDLL("libamd_smi.so")` is redirected to the real versioned file. Existing
   `ROCM_HOME`/`ROCM_PATH` behavior is preserved; guarded to Linux.

2. Make a non-discoverable amdsmi non-fatal: a half-installed amdsmi (python
   package present, `.so` undiscoverable) now degrades to `_HAS_AMDSMI=False`
   instead of aborting `import torch`, matching the existing missing-module
   path.

Downstream follow-up to `_preload_rocm_deps()` (pytorch#188454) for the TheRock
wheels world.

Made with Cursor
@amdfaa
amdfaa requested review from Aidyn-A, eqy and syed-ahmed as code owners July 1, 2026 20:09
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 2, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

@cursor
cursor Bot force-pushed the rocm-sysdeps-ldconfig branch 4 times, most recently from f88ae7f to 68fd788 Compare July 2, 2026 09:44
@amdfaa
amdfaa force-pushed the rocm-sysdeps-ldconfig branch 3 times, most recently from 51d3aca to a3e4b78 Compare July 3, 2026 00:11
@jithunnair-amd jithunnair-amd added keep-going Don't stop on first failure, keep running tests until the end ciflow/rocm-nightly Trigger "default" config CI on a nightly build of ROCm from theRock on MI300 ci-no-td Do not run TD on this PR labels Jul 8, 2026
chinmaydk99 pushed a commit to chinmaydk99/pytorch that referenced this pull request Jul 8, 2026
On TheRock ROCm wheels, `import torch` aborts with
`KeyError: 'libamd_smi.so'`: the amdsmi python package installs the native
library as a versioned soname under `_rocm_sdk_core/lib` (e.g.
`libamd_smi.so.26`), which amdsmi's own `find_smi_library()` fails to locate
when `$ROCM_HOME`/`$ROCM_PATH` and the loader path are unset. Its wrapper then
does `_libraries['libamd_smi.so']`, raising `KeyError`, which escapes the
existing guard (only `ModuleNotFoundError` was tolerated) and kills
`import torch`.

Two-part torch-side hardening (mirrors the `_preload_rocm_deps()` philosophy):

1. Make `_amdsmi_cdll_hook` TheRock-aware: locate `_rocm_sdk_core` via
   `importlib.util.find_spec` and add its `lib/libamd_smi.so*` (glob, incl.
   versioned sonames) as last-resort candidate paths; match names whose
   basename starts with `libamd_smi.so` so amdsmi's bare
   `CDLL("libamd_smi.so")` is redirected to the real versioned file. Existing
   `ROCM_HOME`/`ROCM_PATH` behavior is preserved; guarded to Linux.

2. Make a non-discoverable amdsmi non-fatal: a half-installed amdsmi (python
   package present, `.so` undiscoverable) now degrades to `_HAS_AMDSMI=False`
   instead of aborting `import torch`, matching the existing missing-module
   path.

Downstream follow-up to `_preload_rocm_deps()` (pytorch#188454) for the TheRock
wheels world.

Made with Cursor
chinmaydk99 pushed a commit to chinmaydk99/pytorch that referenced this pull request Jul 8, 2026
On TheRock ROCm wheels, `import torch` aborts with
`KeyError: 'libamd_smi.so'`: the amdsmi python package installs the native
library as a versioned soname under `_rocm_sdk_core/lib` (e.g.
`libamd_smi.so.26`), which amdsmi's own `find_smi_library()` fails to locate
when `$ROCM_HOME`/`$ROCM_PATH` and the loader path are unset. Its wrapper then
does `_libraries['libamd_smi.so']`, raising `KeyError`, which escapes the
existing guard (only `ModuleNotFoundError` was tolerated) and kills
`import torch`.

Two-part torch-side hardening (mirrors the `_preload_rocm_deps()` philosophy):

1. Make `_amdsmi_cdll_hook` TheRock-aware: locate `_rocm_sdk_core` via
   `importlib.util.find_spec` and add its `lib/libamd_smi.so*` (glob, incl.
   versioned sonames) as last-resort candidate paths; match names whose
   basename starts with `libamd_smi.so` so amdsmi's bare
   `CDLL("libamd_smi.so")` is redirected to the real versioned file. Existing
   `ROCM_HOME`/`ROCM_PATH` behavior is preserved; guarded to Linux.

2. Make a non-discoverable amdsmi non-fatal: a half-installed amdsmi (python
   package present, `.so` undiscoverable) now degrades to `_HAS_AMDSMI=False`
   instead of aborting `import torch`, matching the existing missing-module
   path.

Downstream follow-up to `_preload_rocm_deps()` (pytorch#188454) for the TheRock
wheels world.

Made with Cursor
@jithunnair-amd

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -f "Lint clean. PR is only updating ROCm-specific logic in the files. rocm-nightly failures are understood as being unrelated"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@mgehre-amd

Copy link
Copy Markdown
Contributor

@amdfaa, are you going to backport this to 2.12 and 2.13?

@ScottTodd ScottTodd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is misguided, please revert then file issues in TheRock for rocm python package bugs and involve myself and/or @marbre in such discussions.

Documentation for how to work with the ROCm python packages is here: https://github.com/ROCm/TheRock/blob/main/docs/packaging/python_packaging.md#using-packages-from-frameworks, and this PR does the opposite.

The description here has a lot of text but is missing a description of what the actual problems are that this is trying to solve. It jumps to root cause analysis that appears wrong.

Comment thread torch/cuda/__init__.py
Comment on lines +146 to +156
except (KeyError, OSError) as err:
# The amdsmi python package is installed but its native library
# (libamd_smi.so) could not be discovered/loaded -- e.g. TheRock
# ROCm wheels lay amdsmi out so that its own find_smi_library()
# misses the versioned libamd_smi.so.* and raises KeyError. Treat
# this like a missing optional dependency (degrade to
# _HAS_AMDSMI=False) instead of aborting `import torch`.
_AMDSMI_ERR = err
raise ModuleNotFoundError(
"amdsmi is installed but libamd_smi.so could not be loaded"
) from err

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"TheRock ROCm wheels lay amdsmi out so that its own find_smi_library() misses the versioned libamd_smi.so.* and raises KeyError." is exactly the kind of issue that needs to be resolved in the ROCm packages themselves by TheRock and/or amdsmi, not worked around by pytorch. Please work with us directly on such issues instead of add this sort of code to individual frameworks.

Comment thread torch/__init__.py
Comment on lines +384 to +410
# ROCm runtime libs a TheRock-built libtorch DT_NEEDEDs, mirroring the set
# bundled by .ci/manywheel/repair_wheel.py::ROCM_SO_FILES. Ordered leaf-first so
# that RTLD_GLOBAL preloading satisfies inter-lib NEEDED entries as we go.
_rocm_core_libs: list[str] = [
"libamd_comgr.so",
"libhsa-runtime64.so",
"libamdhip64.so",
"libhiprtc.so",
"librocm-core.so",
"librocm_smi64.so",
"libroctx64.so",
"libroctracer64.so",
"librocblas.so",
"libhipblas.so",
"libhipblaslt.so",
"librocfft.so",
"libhipfft.so",
"librocrand.so",
"libhiprand.so",
"librocsolver.so",
"libhipsolver.so",
"librocsparse.so",
"libhipsparse.so",
"libhipsparselt.so",
"libMIOpen.so",
"librccl.so",
]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This list of rocm libraries is dependent on the rocm version (which can change from commit to commit as libraries are added, removed, or merged). Because of this, the list belongs in rocm itself, and we already built the dedicated _rocm_init.initialize() code path for this, see the documentation at https://github.com/ROCm/TheRock/blob/main/docs/packaging/python_packaging.md#performing-initialization.

What you could do would be to generate the _rocm_init.py file as part of some build script in torch, modeled after what we do in TheRock's build scripts: https://github.com/ROCm/TheRock/blob/802f1c98a315a25215e641aa1e5ea42b057a3561/external-builds/pytorch/build_prod_wheels.py#L356-L371, as I had prototyped back on #160776 with tools/amd_build/write_rocm_init.py. Take special note of the comments in that file:

The expectation is that the https://github.com/pytorch/pytorch repo will build
"PyTorch HEAD on ROCm stable", while https://github.com/ROCm/TheRock downstream
will build "PyTorch HEAD on ROCm HEAD". However, while the ROCm Python packages
continue to mature, the "stable" version pinned in this file will be
periodically updated. Eventually a pattern like `7.1.*` may be preffered here,
allowing for changes in patch versions but warning about changes to major or
minor versions.

Available versions can be seen on the index pages at
https://github.com/ROCm/TheRock/blob/main/RELEASES.md#installing-releases-using-pip.
Currently (August 2025), only 7.0.0rcYYYYMMDD versions are available, but in the
future there may be non-rc versions, possibly pushed to PyPI.

The lists of library preloads available are likely to change from ROCm version
to ROCm version, while the lists of preloads _used directly by PyTorch_ should
be dependent on code in PyTorch itself. Indirect dependencies like a ROCm
library taking a dependency on another ROCm library, are possible too and would
require changes here during a version bump, even with no other PyTorch changes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, these libraries exist on Windows as .dll files, so there shouldn't be just a Linux-specific list and only Linux-specific preload/init code.

Comment thread torch/__init__.py
Comment on lines +413 to +429
def _preload_rocm_deps() -> None:
"""Preload TheRock ROCm runtime libs, the ROCm analogue of _preload_cuda_deps.

TheRock ships the ROCm runtime as the ``rocm`` pip package, unpacked to
``<site-packages>/_rocm_sdk_core`` (a sibling of ``torch/``; the same layout
torch.utils.cpp_extension._find_rocm_home() keys off). Its runtime libs live
in ``_rocm_sdk_core/lib`` and the vendored OS-side "sysdeps" (libdrm, liblzma,
... renamed to ``librocm_sysdeps_*.so``) live in
``_rocm_sdk_core/lib/rocm_sysdeps/lib``. Neither dir is on the default loader
search path, so a wheel built against TheRock -- whose torch .so files carry
NEEDED entries such as ``librocm_sysdeps_liblzma.so.5`` and
``libamdhip64.so`` -- is only importable when those dirs are reachable
(e.g. via LD_LIBRARY_PATH from /etc/rocm_env.sh). Preloading the libs here
(RTLD_GLOBAL, before ``import torch._C``) makes the wheel self-resolving
regardless of the environment, the same way _preload_cuda_deps handles the
nvidia-*-cu12 wheels. Because this lives in torch source it travels with any
build (bare ``setup.py`` / ``python -m build``), not just the CI script.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chinmaydk99 added a commit to ROCm/TheRock that referenced this pull request Jul 15, 2026
… /dev/shm

Three environment/config fixes that make genuinely-failing tests pass on the
2.14 ROCm wheels. Each is a harness/CI-environment gap, not a test or PyTorch
bug; verified locally on MI300X (gfx942) via run_test.py. No skip-list changes
here — validate via a debug (skipped-tests-only) run.

1. TORCH_SERIALIZATION_DEBUG=1 in setup_env: upstream .ci/pytorch/test.sh exports
   this for all CI; TheRock did not, so test_serialization
   TestSerialization/TestOldSerialization::test_debug_set_in_ci failed (they assert
   the flag is set under IS_CI). Fixes both.

2. Register TheRock's wheel-shipped ROCm lib dirs (_rocm_sdk_core/lib +
   rocm_sysdeps/lib, _rocm_sdk_devel/lib) with ldconfig in setup_env. Those dirs
   aren't on the default loader/link search path, so:
     - test_multiprocessing test_fs*: torch_shm_manager subprocess exits 127
       (librocprofiler-sdk.so.1 / libamdhip64.so.7 not found)
     - test_utils TestStandaloneCPPJIT::test_load_standalone: ld undefined
       reference to hipModuleLoadDataEx@hip_4.2 (libaotriton link)
   LIMITATION: the proper fix bakes $ORIGIN-relative RPATH into the torch .so's at
   wheel-build time (upstream pytorch/pytorch#188454 does exactly this via
   patch_rocm_sysdeps_rpath + ldconfig). We can't patch an already-built wheel from
   the test harness, so we register with ldconfig here as the test-side equivalent;
   drop once #188454 / the RPATH bake lands. Best-effort (no-ops if non-root).

3. Bump the test container --shm-size 10g -> 64g: the 8-rank FSDP HSDP 3D-mesh
   test (TestFullyShardHSDP3DTraining::test_3d_mlp_with_nd_mesh) exhausts a 10g
   /dev/shm with RCCL shared-memory segments ("No space left on device"); passes at
   64g. Matches upstream ROCm CI shm size.

Co-Authored-By: Claude <[email protected]>
vishalgoyal316 pushed a commit to vishalgoyal316/pytorch that referenced this pull request Jul 16, 2026
…oad_rocm_deps`) (pytorch#188454)

## Summary

This PR makes PyTorch ROCm/TheRock wheels **self-contained**: it fixes the two `import torch` failures that occur on the wheel (`_rocm_sdk_*` site-packages) layout, so `import torch` works without `LD_LIBRARY_PATH` or a sourced ROCm env (e.g. the ROCm distributed preflight `python .ci/pytorch/rocm_preflight.py`, which never sources `/etc/rocm_env.sh`).

Both fixes live in torch **source**, so they travel with any build (including a bare `python -m build` in a TheRock env), not just CI-produced wheels. This is the **minimal, consolidated PR** carrying **both** import-discovery fixes — a **two-file** diff (`torch/__init__.py` + `torch/cuda/__init__.py`).

Both changes are **no-ops on the traditional tarball `/opt/rocm` install**: each early-returns when the wheel package's `_rocm_sdk_core` is absent, so non-wheel ROCm CI (apt/`/opt/rocm`, whose libs are already on the loader path), CUDA, and CPU builds are unaffected.

## Fixes

### 1. `torch/__init__.py` — `_preload_rocm_deps()`

Fixes `ImportError: librocm_sysdeps_liblzma.so.5: cannot open shared object file` at `from torch._C import *`

- Adds `_preload_rocm_deps()`, the ROCm analogue of `_preload_cuda_deps()` (which handles the `nvidia-*-cu12` wheels). At import time, **before** `import torch._C`, it locates the `rocm` pip package's `_rocm_sdk_core` via `importlib.util.find_spec` (the same anchor `torch.utils.cpp_extension._find_rocm_home()` uses) and `ctypes.CDLL`-preloads (`RTLD_GLOBAL`) the vendored sysdeps (`librocm_sysdeps_*`) and core ROCm runtime libs from `_rocm_sdk_core/lib` and `_rocm_sdk_core/lib/rocm_sysdeps/lib`. Wired into `_load_global_deps()`.
- Guarded to no-op on non-Linux, on non-ROCm builds (`torch.version.hip is None` → CUDA/CPU), and on OS-managed ROCm where `_rocm_sdk_core` is absent (the apt/`/opt/rocm` path).

### 2. `torch/cuda/__init__.py` — amdsmi / `libamd_smi.so` discovery hook + non-fatal guard

Fixes the *next* failure that surfaces once `_preload_rocm_deps()` gets `import torch` past the `librocm_sysdeps` error: `KeyError: 'libamd_smi.so'` raised from the `amdsmi` Python binding at `import amdsmi` (inside `_C._initExtension`)

On TheRock wheels the amdsmi package installs the native library as a versioned soname under `_rocm_sdk_core/lib` (e.g. `libamd_smi.so.26`), which amdsmi's own `find_smi_library()` fails to locate when `$ROCM_HOME`/`$ROCM_PATH` and the loader path are unset; its wrapper then does `_libraries['libamd_smi.so']` → `KeyError`, which escaped the existing guard (only `ModuleNotFoundError` was tolerated) and killed `import torch`. Two-part torch-side hardening:

- Make `_amdsmi_cdll_hook` **TheRock-aware**: locate `_rocm_sdk_core` via `importlib.util.find_spec` and add its `lib/libamd_smi.so*` (glob, incl. versioned sonames) as last-resort candidate paths; match names whose basename **starts with** `libamd_smi.so` so amdsmi's bare `CDLL("libamd_smi.so")` is redirected to the real versioned file. Existing `ROCM_HOME`/`ROCM_PATH` behavior preserved; guarded to Linux.
- Make a non-discoverable amdsmi **non-fatal**: broaden the guard so `KeyError`/`OSError` degrade to `_HAS_AMDSMI=False` instead of aborting `import torch`, matching the existing missing-module path.

## Consolidation note

The amdsmi discovery fix (#2 above) originally shipped as standalone PR pytorch#188724. That PR has been **closed** and folded into this PR so **both** import-discovery fixes travel together in a single minimal two-file change.

Scope note: the TheRock tarball→wheels migration and the earlier CI-only RPATH/ldconfig workarounds are **not** part of this PR. The wheels migration is tracked separately by pytorch#188429, which rebases on top of this change.

## Validation (TheRock wheel path) — PASSED

Validated end-to-end by **temporarily** stacking Ethan's wheels-migration PR pytorch#188429 (which adds the `rocm-preview` wheel CI) on top of the two source fixes and running `ciflow/rocm-preview` (run [28581558341](https://github.com/pytorch/pytorch/actions/runs/28581558341)) on the stacked head. The temporary stack was then **removed**, so this PR remains the minimal two-file source diff.

- **`build-osdc` (TheRock wheel-path build): SUCCESS** — [job 84742887851](https://github.com/pytorch/pytorch/actions/runs/28581558341/job/84742887851).
- **`import torch` works on the `_rocm_sdk_*` wheel layout** — proven by the passing shard [`test (default, 5/6)` job 84772673709](https://github.com/pytorch/pytorch/actions/runs/28581558341/job/84772673709), which imports torch and prints the HIP 7.14 / MIOpen 3.5.2 build config.
- **No** `ImportError: librocm_sysdeps*` (incl. `librocm_sysdeps_liblzma`) and **no** `KeyError: 'libamd_smi.so'` anywhere in the run → **both** fixes are validated on the **real TheRock wheel path**.
- Remaining rocm-preview shard failures were **unrelated** to this PR — test-content failures (`test_CTCLoss_cudnn_cuda`, `test_cxx_flags` `RuntimeError map::at`, `test_hip_device_count`, `test_lazy_imports_are_lazy`) and infra (`ROCm pre-flight: no GPUs visible to the container` on the distributed shards).
- Run: https://github.com/pytorch/pytorch/actions/runs/28581558341

### rocm-preview distributed shards (register fat binary failed)

Reference/evidence for the `register fat binary failed` (`code_object.cpp:1038`) investigation — the rocm-preview (TheRock wheel-path) distributed shards from run [28581558341](https://github.com/pytorch/pytorch/actions/runs/28581558341) (`linux-noble-rocm-preview-py3.12-gfx942`), all FAILED:

- distributed 1/3: https://github.com/pytorch/pytorch/actions/runs/28581558341/job/84772673683 (`test (distributed, 1, 3, linux.rocm.gpu.gfx942.4, module:rocm, oncall:distributed)`)
- distributed 2/3: https://github.com/pytorch/pytorch/actions/runs/28581558341/job/84772673678 (`test (distributed, 2, 3, linux.rocm.gpu.gfx942.4, module:rocm, oncall:distributed)`)
- distributed 3/3: https://github.com/pytorch/pytorch/actions/runs/28581558341/job/84772673727 (`test (distributed, 3, 3, linux.rocm.gpu.gfx942.4, module:rocm, oncall:distributed)`)

<details>
<summary>Failure log the amdsmi fix addresses (pre-fix, run 28524549808)</summary>

```
/var/lib/jenkins/workspace/libamd_smi.so: cannot open shared object file: No such file or directory
Unable to find libamd_smi.so library try installing amd-smi-lib from your package manager
Traceback (most recent call last):
  File "/var/lib/jenkins/workspace/.ci/pytorch/rocm_preflight.py", line 21, in <module>
    import torch
  File ".../site-packages/torch/cuda/__init__.py", line 114, in <module>
    import amdsmi  # type: ignore[import]
  File ".../site-packages/amdsmi/amdsmi_wrapper.py", line 218, in <module>
    amdsmi_free_name_value_pairs = _libraries['libamd_smi.so'].amdsmi_free_name_value_pairs
KeyError: 'libamd_smi.so'
```

</details>

## Notes: amdsmi discovery + fat-binary logs

- **Bare `CDLL("libamd_smi.so")`** comes from amdsmi's own `find_smi_library()` (unversioned candidate), not torch; torch's `_amdsmi_cdll_hook` intercepts it and retries the versioned `_rocm_sdk_core/lib/libamd_smi.so*`.
- **Not just preload amdsmi via `_rocm_core_libs`:** amdsmi resolves by exact filename, so an RTLD_GLOBAL versioned `libamd_smi.so.26` won't satisfy it, and eager-preloading a non-`DT_NEEDED` lib reintroduces the ODR double-load the hook prevents — the CDLL-redirect hook is the correct fix.
- **`E0702 … code_object.cpp:1038 register fat binary failed` is not caused by this PR:** it's emitted by the HIP/clr C++ runtime, appears ambiently (~4,774×/run across rocm-preview gfx942 jobs incl. the distributed shards above), and is non-fatal — a pre-existing TheRock rocm-preview build/toolchain matter, orthogonal to these two Python-only changes.
- **Fix-plan pointer (fat-binary):** prove pre-existing on a PR-free `main` rocm-preview baseline → localize via `AMD_LOG_LEVEL=3/4` → scoped clr-log suppress/demote (escalate to clr/comgr pin or `PYTORCH_ROCM_ARCH` only on a real running-arch failure) → validate via `ciflow/rocm-preview`. Belongs in the build/CI layer, not torch source. Tracked in ROCm/frameworks-internal pytorch#17160.

## Test plan

- [x] Validate on the TheRock wheel path via `ciflow/rocm-preview` (see **Validation** above).
- [x] `ast.parse` both changed files (`torch/__init__.py`, `torch/cuda/__init__.py`).
- [x] Confirm CUDA and CPU builds are unaffected (both fixes no-op when `torch.version.hip is None` / `_rocm_sdk_core` absent).

Fixes pytorch#188561

Made with Cursor

Pull Request resolved: pytorch#188454
Approved by: https://github.com/jeffdaily
DamJanusz pushed a commit to DamJanusz/pytorch that referenced this pull request Jul 21, 2026
…oad_rocm_deps`) (pytorch#188454)

## Summary

This PR makes PyTorch ROCm/TheRock wheels **self-contained**: it fixes the two `import torch` failures that occur on the wheel (`_rocm_sdk_*` site-packages) layout, so `import torch` works without `LD_LIBRARY_PATH` or a sourced ROCm env (e.g. the ROCm distributed preflight `python .ci/pytorch/rocm_preflight.py`, which never sources `/etc/rocm_env.sh`).

Both fixes live in torch **source**, so they travel with any build (including a bare `python -m build` in a TheRock env), not just CI-produced wheels. This is the **minimal, consolidated PR** carrying **both** import-discovery fixes — a **two-file** diff (`torch/__init__.py` + `torch/cuda/__init__.py`).

Both changes are **no-ops on the traditional tarball `/opt/rocm` install**: each early-returns when the wheel package's `_rocm_sdk_core` is absent, so non-wheel ROCm CI (apt/`/opt/rocm`, whose libs are already on the loader path), CUDA, and CPU builds are unaffected.

## Fixes

### 1. `torch/__init__.py` — `_preload_rocm_deps()`

Fixes `ImportError: librocm_sysdeps_liblzma.so.5: cannot open shared object file` at `from torch._C import *`

- Adds `_preload_rocm_deps()`, the ROCm analogue of `_preload_cuda_deps()` (which handles the `nvidia-*-cu12` wheels). At import time, **before** `import torch._C`, it locates the `rocm` pip package's `_rocm_sdk_core` via `importlib.util.find_spec` (the same anchor `torch.utils.cpp_extension._find_rocm_home()` uses) and `ctypes.CDLL`-preloads (`RTLD_GLOBAL`) the vendored sysdeps (`librocm_sysdeps_*`) and core ROCm runtime libs from `_rocm_sdk_core/lib` and `_rocm_sdk_core/lib/rocm_sysdeps/lib`. Wired into `_load_global_deps()`.
- Guarded to no-op on non-Linux, on non-ROCm builds (`torch.version.hip is None` → CUDA/CPU), and on OS-managed ROCm where `_rocm_sdk_core` is absent (the apt/`/opt/rocm` path).

### 2. `torch/cuda/__init__.py` — amdsmi / `libamd_smi.so` discovery hook + non-fatal guard

Fixes the *next* failure that surfaces once `_preload_rocm_deps()` gets `import torch` past the `librocm_sysdeps` error: `KeyError: 'libamd_smi.so'` raised from the `amdsmi` Python binding at `import amdsmi` (inside `_C._initExtension`)

On TheRock wheels the amdsmi package installs the native library as a versioned soname under `_rocm_sdk_core/lib` (e.g. `libamd_smi.so.26`), which amdsmi's own `find_smi_library()` fails to locate when `$ROCM_HOME`/`$ROCM_PATH` and the loader path are unset; its wrapper then does `_libraries['libamd_smi.so']` → `KeyError`, which escaped the existing guard (only `ModuleNotFoundError` was tolerated) and killed `import torch`. Two-part torch-side hardening:

- Make `_amdsmi_cdll_hook` **TheRock-aware**: locate `_rocm_sdk_core` via `importlib.util.find_spec` and add its `lib/libamd_smi.so*` (glob, incl. versioned sonames) as last-resort candidate paths; match names whose basename **starts with** `libamd_smi.so` so amdsmi's bare `CDLL("libamd_smi.so")` is redirected to the real versioned file. Existing `ROCM_HOME`/`ROCM_PATH` behavior preserved; guarded to Linux.
- Make a non-discoverable amdsmi **non-fatal**: broaden the guard so `KeyError`/`OSError` degrade to `_HAS_AMDSMI=False` instead of aborting `import torch`, matching the existing missing-module path.

## Consolidation note

The amdsmi discovery fix (pytorch#2 above) originally shipped as standalone PR pytorch#188724. That PR has been **closed** and folded into this PR so **both** import-discovery fixes travel together in a single minimal two-file change.

Scope note: the TheRock tarball→wheels migration and the earlier CI-only RPATH/ldconfig workarounds are **not** part of this PR. The wheels migration is tracked separately by pytorch#188429, which rebases on top of this change.

## Validation (TheRock wheel path) — PASSED

Validated end-to-end by **temporarily** stacking Ethan's wheels-migration PR pytorch#188429 (which adds the `rocm-preview` wheel CI) on top of the two source fixes and running `ciflow/rocm-preview` (run [28581558341](https://github.com/pytorch/pytorch/actions/runs/28581558341)) on the stacked head. The temporary stack was then **removed**, so this PR remains the minimal two-file source diff.

- **`build-osdc` (TheRock wheel-path build): SUCCESS** — [job 84742887851](https://github.com/pytorch/pytorch/actions/runs/28581558341/job/84742887851).
- **`import torch` works on the `_rocm_sdk_*` wheel layout** — proven by the passing shard [`test (default, 5/6)` job 84772673709](https://github.com/pytorch/pytorch/actions/runs/28581558341/job/84772673709), which imports torch and prints the HIP 7.14 / MIOpen 3.5.2 build config.
- **No** `ImportError: librocm_sysdeps*` (incl. `librocm_sysdeps_liblzma`) and **no** `KeyError: 'libamd_smi.so'` anywhere in the run → **both** fixes are validated on the **real TheRock wheel path**.
- Remaining rocm-preview shard failures were **unrelated** to this PR — test-content failures (`test_CTCLoss_cudnn_cuda`, `test_cxx_flags` `RuntimeError map::at`, `test_hip_device_count`, `test_lazy_imports_are_lazy`) and infra (`ROCm pre-flight: no GPUs visible to the container` on the distributed shards).
- Run: https://github.com/pytorch/pytorch/actions/runs/28581558341

### rocm-preview distributed shards (register fat binary failed)

Reference/evidence for the `register fat binary failed` (`code_object.cpp:1038`) investigation — the rocm-preview (TheRock wheel-path) distributed shards from run [28581558341](https://github.com/pytorch/pytorch/actions/runs/28581558341) (`linux-noble-rocm-preview-py3.12-gfx942`), all FAILED:

- distributed 1/3: https://github.com/pytorch/pytorch/actions/runs/28581558341/job/84772673683 (`test (distributed, 1, 3, linux.rocm.gpu.gfx942.4, module:rocm, oncall:distributed)`)
- distributed 2/3: https://github.com/pytorch/pytorch/actions/runs/28581558341/job/84772673678 (`test (distributed, 2, 3, linux.rocm.gpu.gfx942.4, module:rocm, oncall:distributed)`)
- distributed 3/3: https://github.com/pytorch/pytorch/actions/runs/28581558341/job/84772673727 (`test (distributed, 3, 3, linux.rocm.gpu.gfx942.4, module:rocm, oncall:distributed)`)

<details>
<summary>Failure log the amdsmi fix addresses (pre-fix, run 28524549808)</summary>

```
/var/lib/jenkins/workspace/libamd_smi.so: cannot open shared object file: No such file or directory
Unable to find libamd_smi.so library try installing amd-smi-lib from your package manager
Traceback (most recent call last):
  File "/var/lib/jenkins/workspace/.ci/pytorch/rocm_preflight.py", line 21, in <module>
    import torch
  File ".../site-packages/torch/cuda/__init__.py", line 114, in <module>
    import amdsmi  # type: ignore[import]
  File ".../site-packages/amdsmi/amdsmi_wrapper.py", line 218, in <module>
    amdsmi_free_name_value_pairs = _libraries['libamd_smi.so'].amdsmi_free_name_value_pairs
KeyError: 'libamd_smi.so'
```

</details>

## Notes: amdsmi discovery + fat-binary logs

- **Bare `CDLL("libamd_smi.so")`** comes from amdsmi's own `find_smi_library()` (unversioned candidate), not torch; torch's `_amdsmi_cdll_hook` intercepts it and retries the versioned `_rocm_sdk_core/lib/libamd_smi.so*`.
- **Not just preload amdsmi via `_rocm_core_libs`:** amdsmi resolves by exact filename, so an RTLD_GLOBAL versioned `libamd_smi.so.26` won't satisfy it, and eager-preloading a non-`DT_NEEDED` lib reintroduces the ODR double-load the hook prevents — the CDLL-redirect hook is the correct fix.
- **`E0702 … code_object.cpp:1038 register fat binary failed` is not caused by this PR:** it's emitted by the HIP/clr C++ runtime, appears ambiently (~4,774×/run across rocm-preview gfx942 jobs incl. the distributed shards above), and is non-fatal — a pre-existing TheRock rocm-preview build/toolchain matter, orthogonal to these two Python-only changes.
- **Fix-plan pointer (fat-binary):** prove pre-existing on a PR-free `main` rocm-preview baseline → localize via `AMD_LOG_LEVEL=3/4` → scoped clr-log suppress/demote (escalate to clr/comgr pin or `PYTORCH_ROCM_ARCH` only on a real running-arch failure) → validate via `ciflow/rocm-preview`. Belongs in the build/CI layer, not torch source. Tracked in ROCm/frameworks-internal pytorch#17160.

## Test plan

- [x] Validate on the TheRock wheel path via `ciflow/rocm-preview` (see **Validation** above).
- [x] `ast.parse` both changed files (`torch/__init__.py`, `torch/cuda/__init__.py`).
- [x] Confirm CUDA and CPU builds are unaffected (both fixes no-op when `torch.version.hip is None` / `_rocm_sdk_core` absent).

Fixes pytorch#188561

Made with Cursor

Pull Request resolved: pytorch#188454
Approved by: https://github.com/jeffdaily
youlituao pushed a commit to youlituao/pytorch that referenced this pull request Jul 28, 2026
…oad_rocm_deps`) (pytorch#188454)

## Summary

This PR makes PyTorch ROCm/TheRock wheels **self-contained**: it fixes the two `import torch` failures that occur on the wheel (`_rocm_sdk_*` site-packages) layout, so `import torch` works without `LD_LIBRARY_PATH` or a sourced ROCm env (e.g. the ROCm distributed preflight `python .ci/pytorch/rocm_preflight.py`, which never sources `/etc/rocm_env.sh`).

Both fixes live in torch **source**, so they travel with any build (including a bare `python -m build` in a TheRock env), not just CI-produced wheels. This is the **minimal, consolidated PR** carrying **both** import-discovery fixes — a **two-file** diff (`torch/__init__.py` + `torch/cuda/__init__.py`).

Both changes are **no-ops on the traditional tarball `/opt/rocm` install**: each early-returns when the wheel package's `_rocm_sdk_core` is absent, so non-wheel ROCm CI (apt/`/opt/rocm`, whose libs are already on the loader path), CUDA, and CPU builds are unaffected.

## Fixes

### 1. `torch/__init__.py` — `_preload_rocm_deps()`

Fixes `ImportError: librocm_sysdeps_liblzma.so.5: cannot open shared object file` at `from torch._C import *`

- Adds `_preload_rocm_deps()`, the ROCm analogue of `_preload_cuda_deps()` (which handles the `nvidia-*-cu12` wheels). At import time, **before** `import torch._C`, it locates the `rocm` pip package's `_rocm_sdk_core` via `importlib.util.find_spec` (the same anchor `torch.utils.cpp_extension._find_rocm_home()` uses) and `ctypes.CDLL`-preloads (`RTLD_GLOBAL`) the vendored sysdeps (`librocm_sysdeps_*`) and core ROCm runtime libs from `_rocm_sdk_core/lib` and `_rocm_sdk_core/lib/rocm_sysdeps/lib`. Wired into `_load_global_deps()`.
- Guarded to no-op on non-Linux, on non-ROCm builds (`torch.version.hip is None` → CUDA/CPU), and on OS-managed ROCm where `_rocm_sdk_core` is absent (the apt/`/opt/rocm` path).

### 2. `torch/cuda/__init__.py` — amdsmi / `libamd_smi.so` discovery hook + non-fatal guard

Fixes the *next* failure that surfaces once `_preload_rocm_deps()` gets `import torch` past the `librocm_sysdeps` error: `KeyError: 'libamd_smi.so'` raised from the `amdsmi` Python binding at `import amdsmi` (inside `_C._initExtension`)

On TheRock wheels the amdsmi package installs the native library as a versioned soname under `_rocm_sdk_core/lib` (e.g. `libamd_smi.so.26`), which amdsmi's own `find_smi_library()` fails to locate when `$ROCM_HOME`/`$ROCM_PATH` and the loader path are unset; its wrapper then does `_libraries['libamd_smi.so']` → `KeyError`, which escaped the existing guard (only `ModuleNotFoundError` was tolerated) and killed `import torch`. Two-part torch-side hardening:

- Make `_amdsmi_cdll_hook` **TheRock-aware**: locate `_rocm_sdk_core` via `importlib.util.find_spec` and add its `lib/libamd_smi.so*` (glob, incl. versioned sonames) as last-resort candidate paths; match names whose basename **starts with** `libamd_smi.so` so amdsmi's bare `CDLL("libamd_smi.so")` is redirected to the real versioned file. Existing `ROCM_HOME`/`ROCM_PATH` behavior preserved; guarded to Linux.
- Make a non-discoverable amdsmi **non-fatal**: broaden the guard so `KeyError`/`OSError` degrade to `_HAS_AMDSMI=False` instead of aborting `import torch`, matching the existing missing-module path.

## Consolidation note

The amdsmi discovery fix (pytorch#2 above) originally shipped as standalone PR pytorch#188724. That PR has been **closed** and folded into this PR so **both** import-discovery fixes travel together in a single minimal two-file change.

Scope note: the TheRock tarball→wheels migration and the earlier CI-only RPATH/ldconfig workarounds are **not** part of this PR. The wheels migration is tracked separately by pytorch#188429, which rebases on top of this change.

## Validation (TheRock wheel path) — PASSED

Validated end-to-end by **temporarily** stacking Ethan's wheels-migration PR pytorch#188429 (which adds the `rocm-preview` wheel CI) on top of the two source fixes and running `ciflow/rocm-preview` (run [28581558341](https://github.com/pytorch/pytorch/actions/runs/28581558341)) on the stacked head. The temporary stack was then **removed**, so this PR remains the minimal two-file source diff.

- **`build-osdc` (TheRock wheel-path build): SUCCESS** — [job 84742887851](https://github.com/pytorch/pytorch/actions/runs/28581558341/job/84742887851).
- **`import torch` works on the `_rocm_sdk_*` wheel layout** — proven by the passing shard [`test (default, 5/6)` job 84772673709](https://github.com/pytorch/pytorch/actions/runs/28581558341/job/84772673709), which imports torch and prints the HIP 7.14 / MIOpen 3.5.2 build config.
- **No** `ImportError: librocm_sysdeps*` (incl. `librocm_sysdeps_liblzma`) and **no** `KeyError: 'libamd_smi.so'` anywhere in the run → **both** fixes are validated on the **real TheRock wheel path**.
- Remaining rocm-preview shard failures were **unrelated** to this PR — test-content failures (`test_CTCLoss_cudnn_cuda`, `test_cxx_flags` `RuntimeError map::at`, `test_hip_device_count`, `test_lazy_imports_are_lazy`) and infra (`ROCm pre-flight: no GPUs visible to the container` on the distributed shards).
- Run: https://github.com/pytorch/pytorch/actions/runs/28581558341

### rocm-preview distributed shards (register fat binary failed)

Reference/evidence for the `register fat binary failed` (`code_object.cpp:1038`) investigation — the rocm-preview (TheRock wheel-path) distributed shards from run [28581558341](https://github.com/pytorch/pytorch/actions/runs/28581558341) (`linux-noble-rocm-preview-py3.12-gfx942`), all FAILED:

- distributed 1/3: https://github.com/pytorch/pytorch/actions/runs/28581558341/job/84772673683 (`test (distributed, 1, 3, linux.rocm.gpu.gfx942.4, module:rocm, oncall:distributed)`)
- distributed 2/3: https://github.com/pytorch/pytorch/actions/runs/28581558341/job/84772673678 (`test (distributed, 2, 3, linux.rocm.gpu.gfx942.4, module:rocm, oncall:distributed)`)
- distributed 3/3: https://github.com/pytorch/pytorch/actions/runs/28581558341/job/84772673727 (`test (distributed, 3, 3, linux.rocm.gpu.gfx942.4, module:rocm, oncall:distributed)`)

<details>
<summary>Failure log the amdsmi fix addresses (pre-fix, run 28524549808)</summary>

```
/var/lib/jenkins/workspace/libamd_smi.so: cannot open shared object file: No such file or directory
Unable to find libamd_smi.so library try installing amd-smi-lib from your package manager
Traceback (most recent call last):
  File "/var/lib/jenkins/workspace/.ci/pytorch/rocm_preflight.py", line 21, in <module>
    import torch
  File ".../site-packages/torch/cuda/__init__.py", line 114, in <module>
    import amdsmi  # type: ignore[import]
  File ".../site-packages/amdsmi/amdsmi_wrapper.py", line 218, in <module>
    amdsmi_free_name_value_pairs = _libraries['libamd_smi.so'].amdsmi_free_name_value_pairs
KeyError: 'libamd_smi.so'
```

</details>

## Notes: amdsmi discovery + fat-binary logs

- **Bare `CDLL("libamd_smi.so")`** comes from amdsmi's own `find_smi_library()` (unversioned candidate), not torch; torch's `_amdsmi_cdll_hook` intercepts it and retries the versioned `_rocm_sdk_core/lib/libamd_smi.so*`.
- **Not just preload amdsmi via `_rocm_core_libs`:** amdsmi resolves by exact filename, so an RTLD_GLOBAL versioned `libamd_smi.so.26` won't satisfy it, and eager-preloading a non-`DT_NEEDED` lib reintroduces the ODR double-load the hook prevents — the CDLL-redirect hook is the correct fix.
- **`E0702 … code_object.cpp:1038 register fat binary failed` is not caused by this PR:** it's emitted by the HIP/clr C++ runtime, appears ambiently (~4,774×/run across rocm-preview gfx942 jobs incl. the distributed shards above), and is non-fatal — a pre-existing TheRock rocm-preview build/toolchain matter, orthogonal to these two Python-only changes.
- **Fix-plan pointer (fat-binary):** prove pre-existing on a PR-free `main` rocm-preview baseline → localize via `AMD_LOG_LEVEL=3/4` → scoped clr-log suppress/demote (escalate to clr/comgr pin or `PYTORCH_ROCM_ARCH` only on a real running-arch failure) → validate via `ciflow/rocm-preview`. Belongs in the build/CI layer, not torch source. Tracked in ROCm/frameworks-internal pytorch#17160.

## Test plan

- [x] Validate on the TheRock wheel path via `ciflow/rocm-preview` (see **Validation** above).
- [x] `ast.parse` both changed files (`torch/__init__.py`, `torch/cuda/__init__.py`).
- [x] Confirm CUDA and CPU builds are unaffected (both fixes no-op when `torch.version.hip is None` / `_rocm_sdk_core` absent).

Fixes pytorch#188561

Made with Cursor

Pull Request resolved: pytorch#188454
Approved by: https://github.com/jeffdaily
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…oad_rocm_deps`) (pytorch#188454)

## Summary

This PR makes PyTorch ROCm/TheRock wheels **self-contained**: it fixes the two `import torch` failures that occur on the wheel (`_rocm_sdk_*` site-packages) layout, so `import torch` works without `LD_LIBRARY_PATH` or a sourced ROCm env (e.g. the ROCm distributed preflight `python .ci/pytorch/rocm_preflight.py`, which never sources `/etc/rocm_env.sh`).

Both fixes live in torch **source**, so they travel with any build (including a bare `python -m build` in a TheRock env), not just CI-produced wheels. This is the **minimal, consolidated PR** carrying **both** import-discovery fixes — a **two-file** diff (`torch/__init__.py` + `torch/cuda/__init__.py`).

Both changes are **no-ops on the traditional tarball `/opt/rocm` install**: each early-returns when the wheel package's `_rocm_sdk_core` is absent, so non-wheel ROCm CI (apt/`/opt/rocm`, whose libs are already on the loader path), CUDA, and CPU builds are unaffected.

## Fixes

### 1. `torch/__init__.py` — `_preload_rocm_deps()`

Fixes `ImportError: librocm_sysdeps_liblzma.so.5: cannot open shared object file` at `from torch._C import *`

- Adds `_preload_rocm_deps()`, the ROCm analogue of `_preload_cuda_deps()` (which handles the `nvidia-*-cu12` wheels). At import time, **before** `import torch._C`, it locates the `rocm` pip package's `_rocm_sdk_core` via `importlib.util.find_spec` (the same anchor `torch.utils.cpp_extension._find_rocm_home()` uses) and `ctypes.CDLL`-preloads (`RTLD_GLOBAL`) the vendored sysdeps (`librocm_sysdeps_*`) and core ROCm runtime libs from `_rocm_sdk_core/lib` and `_rocm_sdk_core/lib/rocm_sysdeps/lib`. Wired into `_load_global_deps()`.
- Guarded to no-op on non-Linux, on non-ROCm builds (`torch.version.hip is None` → CUDA/CPU), and on OS-managed ROCm where `_rocm_sdk_core` is absent (the apt/`/opt/rocm` path).

### 2. `torch/cuda/__init__.py` — amdsmi / `libamd_smi.so` discovery hook + non-fatal guard

Fixes the *next* failure that surfaces once `_preload_rocm_deps()` gets `import torch` past the `librocm_sysdeps` error: `KeyError: 'libamd_smi.so'` raised from the `amdsmi` Python binding at `import amdsmi` (inside `_C._initExtension`)

On TheRock wheels the amdsmi package installs the native library as a versioned soname under `_rocm_sdk_core/lib` (e.g. `libamd_smi.so.26`), which amdsmi's own `find_smi_library()` fails to locate when `$ROCM_HOME`/`$ROCM_PATH` and the loader path are unset; its wrapper then does `_libraries['libamd_smi.so']` → `KeyError`, which escaped the existing guard (only `ModuleNotFoundError` was tolerated) and killed `import torch`. Two-part torch-side hardening:

- Make `_amdsmi_cdll_hook` **TheRock-aware**: locate `_rocm_sdk_core` via `importlib.util.find_spec` and add its `lib/libamd_smi.so*` (glob, incl. versioned sonames) as last-resort candidate paths; match names whose basename **starts with** `libamd_smi.so` so amdsmi's bare `CDLL("libamd_smi.so")` is redirected to the real versioned file. Existing `ROCM_HOME`/`ROCM_PATH` behavior preserved; guarded to Linux.
- Make a non-discoverable amdsmi **non-fatal**: broaden the guard so `KeyError`/`OSError` degrade to `_HAS_AMDSMI=False` instead of aborting `import torch`, matching the existing missing-module path.

## Consolidation note

The amdsmi discovery fix (#2 above) originally shipped as standalone PR pytorch#188724. That PR has been **closed** and folded into this PR so **both** import-discovery fixes travel together in a single minimal two-file change.

Scope note: the TheRock tarball→wheels migration and the earlier CI-only RPATH/ldconfig workarounds are **not** part of this PR. The wheels migration is tracked separately by pytorch#188429, which rebases on top of this change.

## Validation (TheRock wheel path) — PASSED

Validated end-to-end by **temporarily** stacking Ethan's wheels-migration PR pytorch#188429 (which adds the `rocm-preview` wheel CI) on top of the two source fixes and running `ciflow/rocm-preview` (run [28581558341](https://github.com/pytorch/pytorch/actions/runs/28581558341)) on the stacked head. The temporary stack was then **removed**, so this PR remains the minimal two-file source diff.

- **`build-osdc` (TheRock wheel-path build): SUCCESS** — [job 84742887851](https://github.com/pytorch/pytorch/actions/runs/28581558341/job/84742887851).
- **`import torch` works on the `_rocm_sdk_*` wheel layout** — proven by the passing shard [`test (default, 5/6)` job 84772673709](https://github.com/pytorch/pytorch/actions/runs/28581558341/job/84772673709), which imports torch and prints the HIP 7.14 / MIOpen 3.5.2 build config.
- **No** `ImportError: librocm_sysdeps*` (incl. `librocm_sysdeps_liblzma`) and **no** `KeyError: 'libamd_smi.so'` anywhere in the run → **both** fixes are validated on the **real TheRock wheel path**.
- Remaining rocm-preview shard failures were **unrelated** to this PR — test-content failures (`test_CTCLoss_cudnn_cuda`, `test_cxx_flags` `RuntimeError map::at`, `test_hip_device_count`, `test_lazy_imports_are_lazy`) and infra (`ROCm pre-flight: no GPUs visible to the container` on the distributed shards).
- Run: https://github.com/pytorch/pytorch/actions/runs/28581558341

### rocm-preview distributed shards (register fat binary failed)

Reference/evidence for the `register fat binary failed` (`code_object.cpp:1038`) investigation — the rocm-preview (TheRock wheel-path) distributed shards from run [28581558341](https://github.com/pytorch/pytorch/actions/runs/28581558341) (`linux-noble-rocm-preview-py3.12-gfx942`), all FAILED:

- distributed 1/3: https://github.com/pytorch/pytorch/actions/runs/28581558341/job/84772673683 (`test (distributed, 1, 3, linux.rocm.gpu.gfx942.4, module:rocm, oncall:distributed)`)
- distributed 2/3: https://github.com/pytorch/pytorch/actions/runs/28581558341/job/84772673678 (`test (distributed, 2, 3, linux.rocm.gpu.gfx942.4, module:rocm, oncall:distributed)`)
- distributed 3/3: https://github.com/pytorch/pytorch/actions/runs/28581558341/job/84772673727 (`test (distributed, 3, 3, linux.rocm.gpu.gfx942.4, module:rocm, oncall:distributed)`)

<details>
<summary>Failure log the amdsmi fix addresses (pre-fix, run 28524549808)</summary>

```
/var/lib/jenkins/workspace/libamd_smi.so: cannot open shared object file: No such file or directory
Unable to find libamd_smi.so library try installing amd-smi-lib from your package manager
Traceback (most recent call last):
  File "/var/lib/jenkins/workspace/.ci/pytorch/rocm_preflight.py", line 21, in <module>
    import torch
  File ".../site-packages/torch/cuda/__init__.py", line 114, in <module>
    import amdsmi  # type: ignore[import]
  File ".../site-packages/amdsmi/amdsmi_wrapper.py", line 218, in <module>
    amdsmi_free_name_value_pairs = _libraries['libamd_smi.so'].amdsmi_free_name_value_pairs
KeyError: 'libamd_smi.so'
```

</details>

## Notes: amdsmi discovery + fat-binary logs

- **Bare `CDLL("libamd_smi.so")`** comes from amdsmi's own `find_smi_library()` (unversioned candidate), not torch; torch's `_amdsmi_cdll_hook` intercepts it and retries the versioned `_rocm_sdk_core/lib/libamd_smi.so*`.
- **Not just preload amdsmi via `_rocm_core_libs`:** amdsmi resolves by exact filename, so an RTLD_GLOBAL versioned `libamd_smi.so.26` won't satisfy it, and eager-preloading a non-`DT_NEEDED` lib reintroduces the ODR double-load the hook prevents — the CDLL-redirect hook is the correct fix.
- **`E0702 … code_object.cpp:1038 register fat binary failed` is not caused by this PR:** it's emitted by the HIP/clr C++ runtime, appears ambiently (~4,774×/run across rocm-preview gfx942 jobs incl. the distributed shards above), and is non-fatal — a pre-existing TheRock rocm-preview build/toolchain matter, orthogonal to these two Python-only changes.
- **Fix-plan pointer (fat-binary):** prove pre-existing on a PR-free `main` rocm-preview baseline → localize via `AMD_LOG_LEVEL=3/4` → scoped clr-log suppress/demote (escalate to clr/comgr pin or `PYTORCH_ROCM_ARCH` only on a real running-arch failure) → validate via `ciflow/rocm-preview`. Belongs in the build/CI layer, not torch source. Tracked in ROCm/frameworks-internal pytorch#17160.

## Test plan

- [x] Validate on the TheRock wheel path via `ciflow/rocm-preview` (see **Validation** above).
- [x] `ast.parse` both changed files (`torch/__init__.py`, `torch/cuda/__init__.py`).
- [x] Confirm CUDA and CPU builds are unaffected (both fixes no-op when `torch.version.hip is None` / `_rocm_sdk_core` absent).

Fixes pytorch#188561

Made with Cursor

Pull Request resolved: pytorch#188454
Approved by: https://github.com/jeffdaily
@ScottTodd

Copy link
Copy Markdown
Contributor

This PR continues to cause issues in ROCm, for the reasons I stated: ROCm/TheRock#6965. Specifically:

jithunnair-amd added a commit to ethanwee1/pytorch that referenced this pull request Jul 29, 2026
Drop the TheRock ROCm runtime preloading added in pytorch#188454 from
torch/__init__.py while keeping the amdsmi / libamd_smi.so discovery
changes in torch/cuda/__init__.py from that PR.

Test Plan:
- Verified diff only touches torch/__init__.py (torch/cuda/__init__.py unchanged)

Authored with assistance from Cursor

Co-authored-by: Cursor <[email protected]>
ethanwee1 pushed a commit to ethanwee1/pytorch that referenced this pull request Jul 31, 2026
Drop the TheRock ROCm runtime preloading added in pytorch#188454 from
torch/__init__.py while keeping the amdsmi / libamd_smi.so discovery
changes in torch/cuda/__init__.py from that PR.

Test Plan:
- Verified diff only touches torch/__init__.py (torch/cuda/__init__.py unchanged)

Authored with assistance from Cursor

Co-authored-by: Cursor <[email protected]>
pytorchmergebot pushed a commit that referenced this pull request Aug 4, 2026
…RPATH (#190276)

## Summary

Adds the ROCm 7.14 nightly binary-wheel build, installing ROCm from the multi-arch TheRock wheel index (`https://repo.amd.com/rocm/whl-multi-arch/`). Matrix: `ROCM_ARCHES = ["7.2", "7.14"]`.

Re-combined into one PR (docker image + wheels) now that #190749 (content-addressed builder images) and #190985 (ROCm `manywheel-build` consumes the ECR image via `get-docker-tag`) let a single PR build its own `rocm7.14` `.ci/docker` image (pushed to ECR on `ciflow/docker`) and build/consume the wheel in the same `ciflow/binaries` run.

## Changes

- `.ci/docker/common/install_rocm.sh`: `install_almalinux()` (mirrors `install_ubuntu()`) installs ROCm from the wheel index (`rocm[libraries,devel,device-all]==${ROCM_VERSION}.*`), discovers the root via `rocm-sdk path`, writes `/etc/rocm_env.sh` (build-time env; no `/opt/rocm` symlink); dispatched on `ID=almalinux`.
- `.ci/docker/manywheel/Dockerfile_2_28`: OS-package stage renamed to `rocm_final_legacy`; new wheel-based `rocm_final` stage. `.ci/docker/manywheel/build.sh`: folded rocm7.14 into the generic `rocm*` case (7.14 -> `rocm_final` + almalinux base via `ROCM_VERSION`; earlier -> `rocm_final_legacy` + `rocm/dev-almalinux-8`). `build-manywheel-images.yml`: add the `rocm7.14` tag.
- **`.ci/manywheel/repair_wheel.py`: RPATH method.** Instead of hand-maintaining `ROCM_SO_FILES` and bundling, add `rocm_rpaths()` (`$ORIGIN/../../_rocm_sdk_core/lib` + `rocm_sysdeps/lib`, mirroring `cuda_rpaths()`). For the TheRock wheel layout (`ROCM_HOME` under `_rocm_sdk*`) set RPATH and skip bundling; keep `rocm_bundle`/`ROCM_SO_FILES` only for the legacy OS layout (`/opt/rocm`, rocm7.2). This gets us out of maintaining a fragile list of ROCm libraries.
- `.github/scripts/generate_binary_build_matrix.py`: `ROCM_ARCHES=["7.2","7.14"]` + regenerated workflow. `.ci/manywheel/build_env_setup.py`: `discover_rocm_home()`.

## Notes

- RPATH is currently used only for the wheel-based rocm7.14 layout; rocm7.2 (OS `/opt/rocm`) keeps the self-contained bundle. The RPATH resolves the ROCm libs from the `rocm` pip package (`_rocm_sdk_core`, sibling of torch), the same way CUDA/XPU resolve from their pip packages, combined with `_preload_rocm_deps` (#188454).
- RPATH-only for now: relies on `_rocm_sdk_core` being co-installed with torch in the CI build/test image; declaring `rocm` as an end-user `PYTORCH_EXTRA_INSTALL_REQUIREMENTS` is a follow-up.
- Per #190749, the ROCm/XPU GPU **test** path stays on the Docker Hub image.

## Validation

Built `manylinux2_28-builder:rocm7.14` locally: `install_almalinux` installs 7.14 from `repo.amd.com`; `hipcc --version` reports HIP 7.14.60850; `$ROCM_HOME/lib` has runtime `.so`s + `rocm_sysdeps/lib`. ruff/bash/py checks pass.

Pull Request resolved: #190276
Approved by: https://github.com/jithunnair-amd, https://github.com/atalman

Co-authored-by: Jithun Nair <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-td Do not run TD on this PR ciflow/docker ciflow/periodic-rocm-mi300 Trigger "distributed" config CI on ROCm MI300/MI325 ciflow/rocm-nightly Trigger "default" config CI on a nightly build of ROCm from theRock on MI300 ciflow/rocm-preview Trigger unit tests CI on a preview build of ROCm from theRock on MI300 keep-going Don't stop on first failure, keep running tests until the end Merged module: rocm AMD GPU support for Pytorch open source topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

import torch fails in clean environment on ROCm nightly (ROCm 7.14) — vendored rocm_sysdeps libs resolvable only via LD_LIBRARY_PATH (no RPATH)

8 participants