Skip to content

[ROCm] Retry VecISA dlopen probe with import torch on cold load failure - #189900

Closed
jeffdaily wants to merge 1 commit into
mainfrom
jeffdaily/vec-isa-probe-import-torch-fallback
Closed

jeffdaily wants to merge 1 commit into
mainfrom
jeffdaily/vec-isa-probe-import-torch-fallback

Conversation

@jeffdaily

@jeffdaily jeffdaily commented Jul 14, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #189194

The ROCm manywheel build bundles the ROCm runtime into torch/lib under unversioned filenames (libamd_comgr.so, libamdhip64.so, ...) and rewrites consumers' DT_NEEDED entries to match, but some entries are missed: in the 2.13.0+rocm7.2 wheel, libhiprtc.so, librocprofiler-sdk.so, and librocroller.so still reference libamd_comgr.so.3, a filename that does not exist in the wheel. After import torch this is harmless: the bundled libamd_comgr.so is already loaded and registered under its unchanged SONAME libamd_comgr.so.3, so those references resolve against the in-process copy. A cold dlopen has no such copy, so on a machine without a system ROCm install the load fails (a ROCm docker image masks the bug because /opt/rocm provides libamd_comgr.so.3 via ldconfig). #183515 changed the VecISA dlopen probe child from import torch + dlopen to a cold dlopen with LD_LIBRARY_PATH=<torch>/lib, so on such a machine every check_build fails and inductor reports "Can't detect vectorized ISA for CPU". Thanks to @karthickai and @atalman for bisecting to #183515 on the issue.

The fix keeps the fast no-import path but retries after import torch if the cold dlopen raises OSError, so whatever loading semantics the wheel relies on are in effect before the second attempt. This also covers the same class of failure for TheRock-based ROCm wheels (ROCm libs preloaded from separate rocm-sdk packages with no rpath) and the latent CUDA case where torch and the nvidia wheels land in different site-packages roots and the $ORIGIN-relative rpaths dangle. The 60s probe timeout from #183515 still bounds the child either way, so the CI hang that change addressed stays fixed. The missed DT_NEEDED rewrites are arguably a wheel packaging bug worth fixing at the source, but the probe fallback repairs wheels already shipped and does not hardcode packaging layout into inductor.

Reproduced and validated with the actual 2.13.0+rocm7.2 test wheel in a venv, using the glibc loader's --inhibit-cache to emulate a machine with no system ROCm: the pre-fix probe script fails with OSError: libamd_comgr.so.3: cannot open shared object file and the fixed script succeeds. The new regression test simulates the layout without needing a ROCm wheel:

python test/inductor/test_codecache.py TestVecISACheckBuild

This PR was authored with Claude (AI assistant).

cc @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben

@pytorch-bot

pytorch-bot Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ You can merge normally! (1 Unrelated Failure)

As of commit 4eb9fe3 with merge base 5a7eae4 (image):

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

@atalman atalman added ciflow/binaries Trigger all binary build and upload jobs on the PR ciflow/binaries_wheel Trigger binary build and upload jobs for wheel on the PR labels Jul 14, 2026
chinmaydk99 added a commit to ROCm/TheRock that referenced this pull request Jul 27, 2026
The ldconfig loader-path wiring, TORCH_SERIALIZATION_DEBUG, and
ROCPROFILER_LOG_LEVEL workarounds in run_pytorch_tests_full.py belong
in pytorch upstream (pytorch/pytorch#189900 / _preload_rocm_deps),
not in the TheRock test harness. Reverts b7ec75f.

Restores the 10 skips that were removed in 72630b5 on the basis of
those harness fixes: multiprocessing/test_fs x5, utils/test_load_standalone,
inductor/tmp_not_defined + vec_isa, serialization/test_debug_set_in_ci,
dynamo/test_logs_out.

Co-Authored-By: Claude <[email protected]>
@jeffdaily jeffdaily removed ciflow/binaries Trigger all binary build and upload jobs on the PR ciflow/binaries_wheel Trigger binary build and upload jobs for wheel on the PR ciflow/torchtitan Run TorchTitan integration tests labels Aug 13, 2026
@jeffdaily

Copy link
Copy Markdown
Collaborator Author

@pytorchbot rebase

pytorchmergebot pushed a commit that referenced this pull request Aug 13, 2026
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).
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

The ROCm manywheel build bundles the ROCm runtime into torch/lib under unversioned filenames (libamd_comgr.so, libamdhip64.so, ...) and rewrites consumers' DT_NEEDED entries to match, but some entries are missed: in the 2.13.0+rocm7.2 wheel, libhiprtc.so, librocprofiler-sdk.so, and librocroller.so still reference libamd_comgr.so.3, a filename that does not exist in the wheel. After `import torch` this is harmless: the bundled libamd_comgr.so is already loaded and registered under its unchanged SONAME libamd_comgr.so.3, so those references resolve against the in-process copy. A cold dlopen has no such copy, so on a machine without a system ROCm install the load fails (a ROCm docker image masks the bug because /opt/rocm provides libamd_comgr.so.3 via ldconfig). #183515 changed the VecISA dlopen probe child from `import torch` + dlopen to a cold dlopen with `LD_LIBRARY_PATH=<torch>/lib`, so on such a machine every `check_build` fails and inductor reports "Can't detect vectorized ISA for CPU".

The fix keeps the fast no-import path but retries after `import torch` if the cold dlopen raises OSError, so whatever loading semantics the wheel relies on are in effect before the second attempt. This also covers the same class of failure for TheRock-based ROCm wheels (ROCm libs preloaded from separate rocm-sdk packages with no rpath) and the latent CUDA case where torch and the nvidia wheels are installed into different site-packages roots and the `$ORIGIN`-relative rpaths dangle (the case `_preload_cuda_deps` exists for). The 60s probe timeout from #183515 still bounds the child either way, so the CI hang that change addressed stays fixed. The missed DT_NEEDED rewrites are arguably a wheel packaging bug worth fixing at the source, but the probe fallback repairs wheels already shipped and does not hardcode any packaging layout into inductor.

Fixes #189194

Test Plan:

Reproduced the failure with the actual 2.13.0+rocm7.2 test wheel in a venv on a ROCm host, using the glibc loader's --inhibit-cache to get the loader semantics of a machine with no system ROCm:

```
pip install torch==2.13.0 --index-url https://download.pytorch.org/whl/test/rocm7.2
# build the real VecISA probe .so via CppBuilder, then:
env -u LD_LIBRARY_PATH /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 --inhibit-cache --library-path <venv>/torch/lib python -c "<probe script>"
```

The pre-fix probe script fails with "OSError: libamd_comgr.so.3: cannot open shared object file" (the exact #189194 failure); the fixed script succeeds via the import torch fallback.

New regression test simulates the layout without needing a ROCm wheel: a probe .so that DT_NEEDEDs libc10.so with no rpath fails to cold-load when LD_LIBRARY_PATH is stripped, and the probe script must recover by importing torch:

```
python test/inductor/test_codecache.py TestVecISACheckBuild
```

All four tests in the class pass on a Linux x86_64 ROCm build, and the fast path still detects VecAVX2 end to end through `valid_vec_isa_list()` without importing torch in the child.

Authored with Claude (AI assistant).
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Successfully rebased jeffdaily/vec-isa-probe-import-torch-fallback onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout jeffdaily/vec-isa-probe-import-torch-fallback && git pull --rebase)

@pytorchmergebot
pytorchmergebot force-pushed the jeffdaily/vec-isa-probe-import-torch-fallback branch from 04bfaea to 4eb9fe3 Compare August 13, 2026 19:48
@pytorch-bot pytorch-bot Bot added the ciflow/torchtitan Run TorchTitan integration tests label Aug 13, 2026
@jeffdaily

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Aug 13, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: This PR needs a release notes: label
If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Details for Dev Infra team Raised by workflow job

@jeffdaily jeffdaily added the release notes: rocm mandatorylabel label Aug 13, 2026
@jeffdaily

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

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

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

The merge job was canceled or timed out. This most often happen if two merge requests were issued for the same PR, or if merge job was waiting for more than 6 hours for tests to finish. In later case, please do not hesitate to reissue the merge command
For more information see pytorch-bot wiki.

@jeffdaily

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

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

pytorchmergebot pushed a commit that referenced this pull request Aug 14, 2026
#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
@jeffdaily

Copy link
Copy Markdown
Collaborator Author

@pytorchbot cherry-pick --onto release/2.14 -c critical

@pytorchbot

Copy link
Copy Markdown
Collaborator

Cherry picking #189900

The cherry pick PR is at #193601 and it is recommended to link a critical cherry pick PR with an issue. The following tracker issues are updated:

Details for Dev Infra team Raised by workflow job

atalman pushed a commit that referenced this pull request Aug 17, 2026
#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]>
atalman pushed a commit that referenced this pull request Aug 17, 2026
…re (#193601)

[ROCm] Retry VecISA dlopen probe with import torch on cold load failure (#189900)

Fixes #189194

The ROCm manywheel build bundles the ROCm runtime into torch/lib under unversioned filenames (libamd_comgr.so, libamdhip64.so, ...) and rewrites consumers' DT_NEEDED entries to match, but some entries are missed: in the 2.13.0+rocm7.2 wheel, libhiprtc.so, librocprofiler-sdk.so, and librocroller.so still reference libamd_comgr.so.3, a filename that does not exist in the wheel. After `import torch` this is harmless: the bundled libamd_comgr.so is already loaded and registered under its unchanged SONAME libamd_comgr.so.3, so those references resolve against the in-process copy. A cold dlopen has no such copy, so on a machine without a system ROCm install the load fails (a ROCm docker image masks the bug because /opt/rocm provides libamd_comgr.so.3 via ldconfig). #183515 changed the VecISA dlopen probe child from `import torch` + dlopen to a cold dlopen with `LD_LIBRARY_PATH=<torch>/lib`, so on such a machine every `check_build` fails and inductor reports "Can't detect vectorized ISA for CPU". Thanks to @karthickai and @atalman for bisecting to #183515 on the issue.

The fix keeps the fast no-import path but retries after `import torch` if the cold dlopen raises OSError, so whatever loading semantics the wheel relies on are in effect before the second attempt. This also covers the same class of failure for TheRock-based ROCm wheels (ROCm libs preloaded from separate rocm-sdk packages with no rpath) and the latent CUDA case where torch and the nvidia wheels land in different site-packages roots and the `$ORIGIN`-relative rpaths dangle. The 60s probe timeout from #183515 still bounds the child either way, so the CI hang that change addressed stays fixed. The missed DT_NEEDED rewrites are arguably a wheel packaging bug worth fixing at the source, but the probe fallback repairs wheels already shipped and does not hardcode packaging layout into inductor.

Reproduced and validated with the actual 2.13.0+rocm7.2 test wheel in a venv, using the glibc loader's `--inhibit-cache` to emulate a machine with no system ROCm: the pre-fix probe script fails with `OSError: libamd_comgr.so.3: cannot open shared object file` and the fixed script succeeds. The new regression test simulates the layout without needing a ROCm wheel:

```
python test/inductor/test_codecache.py TestVecISACheckBuild
```

This PR was authored with Claude (AI assistant).

Pull Request resolved: #189900
Approved by: https://github.com/atalman

(cherry picked from commit 74e49c1)

Co-authored-by: Jeff Daily <[email protected]>
orrangetabby17 pushed a commit to orrangetabby17/pytorch that referenced this pull request Sep 2, 2026
…re (pytorch#189900)

Fixes pytorch#189194

The ROCm manywheel build bundles the ROCm runtime into torch/lib under unversioned filenames (libamd_comgr.so, libamdhip64.so, ...) and rewrites consumers' DT_NEEDED entries to match, but some entries are missed: in the 2.13.0+rocm7.2 wheel, libhiprtc.so, librocprofiler-sdk.so, and librocroller.so still reference libamd_comgr.so.3, a filename that does not exist in the wheel. After `import torch` this is harmless: the bundled libamd_comgr.so is already loaded and registered under its unchanged SONAME libamd_comgr.so.3, so those references resolve against the in-process copy. A cold dlopen has no such copy, so on a machine without a system ROCm install the load fails (a ROCm docker image masks the bug because /opt/rocm provides libamd_comgr.so.3 via ldconfig). pytorch#183515 changed the VecISA dlopen probe child from `import torch` + dlopen to a cold dlopen with `LD_LIBRARY_PATH=<torch>/lib`, so on such a machine every `check_build` fails and inductor reports "Can't detect vectorized ISA for CPU". Thanks to @karthickai and @atalman for bisecting to pytorch#183515 on the issue.

The fix keeps the fast no-import path but retries after `import torch` if the cold dlopen raises OSError, so whatever loading semantics the wheel relies on are in effect before the second attempt. This also covers the same class of failure for TheRock-based ROCm wheels (ROCm libs preloaded from separate rocm-sdk packages with no rpath) and the latent CUDA case where torch and the nvidia wheels land in different site-packages roots and the `$ORIGIN`-relative rpaths dangle. The 60s probe timeout from pytorch#183515 still bounds the child either way, so the CI hang that change addressed stays fixed. The missed DT_NEEDED rewrites are arguably a wheel packaging bug worth fixing at the source, but the probe fallback repairs wheels already shipped and does not hardcode packaging layout into inductor.

Reproduced and validated with the actual 2.13.0+rocm7.2 test wheel in a venv, using the glibc loader's `--inhibit-cache` to emulate a machine with no system ROCm: the pre-fix probe script fails with `OSError: libamd_comgr.so.3: cannot open shared object file` and the fixed script succeeds. The new regression test simulates the layout without needing a ROCm wheel:

```
python test/inductor/test_codecache.py TestVecISACheckBuild
```

This PR was authored with Claude (AI assistant).

Pull Request resolved: pytorch#189900
Approved by: https://github.com/atalman
orrangetabby17 pushed a commit to orrangetabby17/pytorch that referenced this pull request Sep 2, 2026
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
@github-actions
github-actions Bot deleted the jeffdaily/vec-isa-probe-import-torch-fallback branch November 4, 2026 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/inductor ciflow/torchtitan Run TorchTitan integration tests ciflow/trunk Trigger trunk jobs on your pull request Merged module: inductor module: rocm AMD GPU support for Pytorch open source release notes: rocm mandatorylabel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ROCm] torch 2.13 wheel: "Can't detect vectorized ISA for CPU" in torch.compile smoke test on non-ROCm image (regression vs 2.12.1)

4 participants