Repository navigation
[ROCm] Retry VecISA dlopen probe with import torch on cold load failure - #193601
Conversation
…re (#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)
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/193601
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New FailuresAs of commit 6dd19bf with merge base 73db3ed ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@claude review these changes |
|
Claude finished @jansel's task in 9m 19s —— View job Review: looks correct and appropriately scoped for a 2.14 cherry-pick — one diagnostics gap and two test-robustness nits.
Full reviewCherry-pick fidelityBoth changed files are byte-identical to So this is a clean pick with no drift. The fix itself —
|
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 torchthis 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 fromimport torch+ dlopen to a cold dlopen withLD_LIBRARY_PATH=<torch>/lib, so on such a machine everycheck_buildfails 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 torchif 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-cacheto emulate a machine with no system ROCm: the pre-fix probe script fails withOSError: libamd_comgr.so.3: cannot open shared object fileand the fixed script succeeds. The new regression test simulates the layout without needing a ROCm wheel:This PR was authored with Claude (AI assistant).
cc @jeffdaily @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