Skip to content

Load ROCm from the SDK wheels the torch wheel was built against - #4

Merged
cyyever merged 1 commit into
trimfrom
rocm-wheel-runtime
Oct 23, 2026
Merged

cyyever merged 1 commit into
trimfrom
rocm-wheel-runtime

Conversation

@cyyever

@cyyever cyyever commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Draft until reviewed.

Agent details (AI-generated)

Problem. ROCm wheels built with PYTORCH_ROCM_EXTERNAL_SDK=1 declare no ROCm dependency and ship no torch/_rocm_init.py. import torch therefore finds ROCm only through LD_LIBRARY_PATH or the host's ld.so.conf. On a Breadboard guest that means the accelerator pack's ROCm 10.0 rather than our patched 10.1 SDK. Without LD_LIBRARY_PATH the import fails on librocm-openblas.so.0.

Change.

  • The build reads the SDK wheels' version from PYTORCH_ROCM_SDK_VERSION.
  • tools/metadata/dependencies.py pins rocm[libraries] to that version.
  • torch/CMakeLists.txt writes the _rocm_init.py that the existing install rule and torch/__init__.py already expect, so import torch preloads the SDK libraries through rocm_sdk.initialize_process and checks the version. The preload list is TheRock's build_prod_wheels.py list without hipdnn, which this SDK does not build.
  • PYTORCH_ROCM_EXTERNAL_SDK is removed.

Needs a breadkernel change. accelerator-wheels-rocm.toml must set PYTORCH_ROCM_SDK_VERSION to the SDK wheel version and drop PYTORCH_ROCM_EXTERNAL_SDK. Without it, the fallback pins whatever rocm is installed in the build venv, which is 10.0.0 today.

Tested. The CMake block was run with and without the variable; the dependency provider was exercised. On a gfx1201 sandbox, with the generated file added to the published gdb71170c wheel, import torch works without LD_LIBRARY_PATH and all ROCm libraries load from the rocm_sdk wheels. A full wheel build with the change has not been run.

🤖 Generated with Claude Code

ROCm wheels built against an unpacked TheRock SDK (PYTORCH_ROCM_EXTERNAL_SDK)
declared no ROCm dependency and shipped no torch/_rocm_init.py, so
`import torch` resolved librocm-openblas and the HIP libraries only through
LD_LIBRARY_PATH or whatever ROCm the host's ld.so.conf exposed. On a
Breadboard guest that is the accelerator pack's ROCm 10.0, not the 10.1 SDK
the wheel was built and patched against; without LD_LIBRARY_PATH the import
fails on librocm-openblas.so.0.

The build now takes the SDK wheels' version from PYTORCH_ROCM_SDK_VERSION.
tools/metadata/dependencies.py pins rocm[libraries] to it, and
torch/CMakeLists.txt writes the _rocm_init.py that the existing install rule
and torch/__init__.py already expect, so `import torch` preloads the SDK
libraries from those wheels through rocm_sdk.initialize_process and checks
the version. The preload list is TheRock's build_prod_wheels.py list minus
hipdnn, which this SDK does not build. PYTORCH_ROCM_EXTERNAL_SDK is gone;
the alternative of keeping it and fixing the guest's ld.so.conf would leave
torch tied to whatever ROCm the host provides.

Test Plan:

```
cmake -P test.cmake   # the new block, with and without PYTORCH_ROCM_SDK_VERSION
python -c 'import dependencies; ...'   # rocm[libraries]==<version>
env -u LD_LIBRARY_PATH python -c 'import torch; ...'
```

With the generated _rocm_init.py added to the published gdb71170c wheel on
a gfx1201 sandbox, `import torch` succeeds without LD_LIBRARY_PATH and
/proc/self/maps shows libamdhip64, libhsa-runtime64, librocblas, libMIOpen
and librocm-openblas loaded from the rocm_sdk wheels. A full wheel build
with the change was not run.

Authored with an AI assistant (Claude Code).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cyyever
cyyever marked this pull request as ready for review October 23, 2026 05:12
@cyyever
cyyever merged commit 6ff2913 into trim Oct 23, 2026
17 checks passed
@cyyever
cyyever deleted the rocm-wheel-runtime branch October 23, 2026 05:12
cyyever added a commit that referenced this pull request Oct 27, 2026
ROCm wheels built against an unpacked TheRock SDK (PYTORCH_ROCM_EXTERNAL_SDK)
declared no ROCm dependency and shipped no torch/_rocm_init.py, so
`import torch` resolved librocm-openblas and the HIP libraries only through
LD_LIBRARY_PATH or whatever ROCm the host's ld.so.conf exposed. On a
Breadboard guest that is the accelerator pack's ROCm 10.0, not the 10.1 SDK
the wheel was built and patched against; without LD_LIBRARY_PATH the import
fails on librocm-openblas.so.0.

The build now takes the SDK wheels' version from PYTORCH_ROCM_SDK_VERSION.
tools/metadata/dependencies.py pins rocm[libraries] to it, and
torch/CMakeLists.txt writes the _rocm_init.py that the existing install rule
and torch/__init__.py already expect, so `import torch` preloads the SDK
libraries from those wheels through rocm_sdk.initialize_process and checks
the version. The preload list is TheRock's build_prod_wheels.py list minus
hipdnn, which this SDK does not build. PYTORCH_ROCM_EXTERNAL_SDK is gone;
the alternative of keeping it and fixing the guest's ld.so.conf would leave
torch tied to whatever ROCm the host provides.

Test Plan:

```
cmake -P test.cmake   # the new block, with and without PYTORCH_ROCM_SDK_VERSION
python -c 'import dependencies; ...'   # rocm[libraries]==<version>
env -u LD_LIBRARY_PATH python -c 'import torch; ...'
```

With the generated _rocm_init.py added to the published gdb71170c wheel on
a gfx1201 sandbox, `import torch` succeeds without LD_LIBRARY_PATH and
/proc/self/maps shows libamdhip64, libhsa-runtime64, librocblas, libMIOpen
and librocm-openblas loaded from the rocm_sdk wheels. A full wheel build
with the change was not run.

Authored with an AI assistant (Claude Code).

Co-authored-by: Claude Opus 5.5 <[email protected]>
cyyever added a commit that referenced this pull request Oct 31, 2026
ROCm wheels built against an unpacked TheRock SDK (PYTORCH_ROCM_EXTERNAL_SDK)
declared no ROCm dependency and shipped no torch/_rocm_init.py, so
`import torch` resolved librocm-openblas and the HIP libraries only through
LD_LIBRARY_PATH or whatever ROCm the host's ld.so.conf exposed. On a
Breadboard guest that is the accelerator pack's ROCm 10.0, not the 10.1 SDK
the wheel was built and patched against; without LD_LIBRARY_PATH the import
fails on librocm-openblas.so.0.

The build now takes the SDK wheels' version from PYTORCH_ROCM_SDK_VERSION.
tools/metadata/dependencies.py pins rocm[libraries] to it, and
torch/CMakeLists.txt writes the _rocm_init.py that the existing install rule
and torch/__init__.py already expect, so `import torch` preloads the SDK
libraries from those wheels through rocm_sdk.initialize_process and checks
the version. The preload list is TheRock's build_prod_wheels.py list minus
hipdnn, which this SDK does not build. PYTORCH_ROCM_EXTERNAL_SDK is gone;
the alternative of keeping it and fixing the guest's ld.so.conf would leave
torch tied to whatever ROCm the host provides.

Test Plan:

```
cmake -P test.cmake   # the new block, with and without PYTORCH_ROCM_SDK_VERSION
python -c 'import dependencies; ...'   # rocm[libraries]==<version>
env -u LD_LIBRARY_PATH python -c 'import torch; ...'
```

With the generated _rocm_init.py added to the published gdb71170c wheel on
a gfx1201 sandbox, `import torch` succeeds without LD_LIBRARY_PATH and
/proc/self/maps shows libamdhip64, libhsa-runtime64, librocblas, libMIOpen
and librocm-openblas loaded from the rocm_sdk wheels. A full wheel build
with the change was not run.

Authored with an AI assistant (Claude Code).

Co-authored-by: Claude Opus 5.5 <[email protected]>
cyyever added a commit that referenced this pull request Oct 31, 2026
Load ROCm from the SDK wheels the torch wheel was built against (#4)

ROCm wheels built against an unpacked TheRock SDK (PYTORCH_ROCM_EXTERNAL_SDK)
declared no ROCm dependency and shipped no torch/_rocm_init.py, so
`import torch` resolved librocm-openblas and the HIP libraries only through
LD_LIBRARY_PATH or whatever ROCm the host's ld.so.conf exposed. On a
Breadboard guest that is the accelerator pack's ROCm 10.0, not the 10.1 SDK
the wheel was built and patched against; without LD_LIBRARY_PATH the import
fails on librocm-openblas.so.0.

The build now takes the SDK wheels' version from PYTORCH_ROCM_SDK_VERSION.
tools/metadata/dependencies.py pins rocm[libraries] to it, and
torch/CMakeLists.txt writes the _rocm_init.py that the existing install rule
and torch/__init__.py already expect, so `import torch` preloads the SDK
libraries from those wheels through rocm_sdk.initialize_process and checks
the version. The preload list is TheRock's build_prod_wheels.py list minus
hipdnn, which this SDK does not build. PYTORCH_ROCM_EXTERNAL_SDK is gone;
the alternative of keeping it and fixing the guest's ld.so.conf would leave
torch tied to whatever ROCm the host provides.

Test Plan:

```
cmake -P test.cmake   # the new block, with and without PYTORCH_ROCM_SDK_VERSION
python -c 'import dependencies; ...'   # rocm[libraries]==<version>
env -u LD_LIBRARY_PATH python -c 'import torch; ...'
```

With the generated _rocm_init.py added to the published gdb71170c wheel on
a gfx1201 sandbox, `import torch` succeeds without LD_LIBRARY_PATH and
/proc/self/maps shows libamdhip64, libhsa-runtime64, librocblas, libMIOpen
and librocm-openblas loaded from the rocm_sdk wheels. A full wheel build
with the change was not run.

Authored with an AI assistant (Claude Code).

Co-authored-by: Claude Opus 5.5 <[email protected]>

Take the ROCm SDK version for _rocm_init.py from the build environment (#5)

* Take the ROCm SDK version for _rocm_init.py from the build environment

tools/metadata/dependencies.py pins rocm[libraries] to PYTORCH_ROCM_SDK_VERSION,
or to the rocm package installed in the build environment when the variable
is unset, but torch/CMakeLists.txt only generated _rocm_init.py from the
variable. A build that installs the SDK's rocm package instead of exporting
the version got the dependency but no preload. Fall back to the installed
rocm package in CMake too, so both read the same version.

Test Plan:

```
cmake -P t.cmake                            # check_version='<installed rocm>'
PYTORCH_ROCM_SDK_VERSION=9.9.9 cmake -P t.cmake   # check_version='9.9.9'
```

Authored with an AI assistant (Claude Code).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Depend on the ROCm SDK device wheel too

rocm[libraries] leaves out rocm-sdk-device-gfx1201, which carries the GPU
code objects for rocBLAS, MIOpen and the other kpack-split libraries;
without it their kernels fail with hipErrorInvalidKernelFile.

Authored with an AI assistant (Claude Code).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
cyyever added a commit that referenced this pull request Oct 31, 2026
Use external ROCm SDK libraries without pip runtime dependencies

Use rocBLAS, hipBLASLt and MIOpen from the ROCm SDK

The ROCm build downloaded a separate rocm-libraries revision (271344a4),
built rocBLAS, hipBLASLt and MIOpen through ExternalProject and shipped
them in torch/lib (~250 MB), and installed Caffe2 configs re-entered that
logic so downstream builds such as vLLM fetched the 10 GB source again.
That existed to get gfx1201-only kernels; the TheRock SDK now builds these
libraries for gfx1201 itself, with our patches applied, so the bundled
copies were a second, divergent build of the same libraries, and which one
a process loaded depended on LD_LIBRARY_PATH.

Find them from ROCM_PATH like the other ROCm components and drop
cmake/External/rocm_bundled.cmake with its install rule, Caffe2Config
plumbing and summary line. The mslk symbol hiding that landed with the
bundling stays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Avoid pip ROCm dependency for external SDK wheels

Load the ROCm SDK version selected at wheel build time

Load ROCm from the SDK wheels the torch wheel was built against (#4)

ROCm wheels built against an unpacked TheRock SDK (PYTORCH_ROCM_EXTERNAL_SDK)
declared no ROCm dependency and shipped no torch/_rocm_init.py, so
`import torch` resolved librocm-openblas and the HIP libraries only through
LD_LIBRARY_PATH or whatever ROCm the host's ld.so.conf exposed. On a
Breadboard guest that is the accelerator pack's ROCm 10.0, not the 10.1 SDK
the wheel was built and patched against; without LD_LIBRARY_PATH the import
fails on librocm-openblas.so.0.

The build now takes the SDK wheels' version from PYTORCH_ROCM_SDK_VERSION.
tools/metadata/dependencies.py pins rocm[libraries] to it, and
torch/CMakeLists.txt writes the _rocm_init.py that the existing install rule
and torch/__init__.py already expect, so `import torch` preloads the SDK
libraries from those wheels through rocm_sdk.initialize_process and checks
the version. The preload list is TheRock's build_prod_wheels.py list minus
hipdnn, which this SDK does not build. PYTORCH_ROCM_EXTERNAL_SDK is gone;
the alternative of keeping it and fixing the guest's ld.so.conf would leave
torch tied to whatever ROCm the host provides.

Test Plan:

```
cmake -P test.cmake   # the new block, with and without PYTORCH_ROCM_SDK_VERSION
python -c 'import dependencies; ...'   # rocm[libraries]==<version>
env -u LD_LIBRARY_PATH python -c 'import torch; ...'
```

With the generated _rocm_init.py added to the published gdb71170c wheel on
a gfx1201 sandbox, `import torch` succeeds without LD_LIBRARY_PATH and
/proc/self/maps shows libamdhip64, libhsa-runtime64, librocblas, libMIOpen
and librocm-openblas loaded from the rocm_sdk wheels. A full wheel build
with the change was not run.

Authored with an AI assistant (Claude Code).

Co-authored-by: Claude Opus 5.5 <[email protected]>

Take the ROCm SDK version for _rocm_init.py from the build environment (#5)

* Take the ROCm SDK version for _rocm_init.py from the build environment

tools/metadata/dependencies.py pins rocm[libraries] to PYTORCH_ROCM_SDK_VERSION,
or to the rocm package installed in the build environment when the variable
is unset, but torch/CMakeLists.txt only generated _rocm_init.py from the
variable. A build that installs the SDK's rocm package instead of exporting
the version got the dependency but no preload. Fall back to the installed
rocm package in CMake too, so both read the same version.

Test Plan:

```
cmake -P t.cmake                            # check_version='<installed rocm>'
PYTORCH_ROCM_SDK_VERSION=9.9.9 cmake -P t.cmake   # check_version='9.9.9'
```

Authored with an AI assistant (Claude Code).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Depend on the ROCm SDK device wheel too

rocm[libraries] leaves out rocm-sdk-device-gfx1201, which carries the GPU
code objects for rocBLAS, MIOpen and the other kpack-split libraries;
without it their kernels fail with hipErrorInvalidKernelFile.

Authored with an AI assistant (Claude Code).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
cyyever added a commit that referenced this pull request Oct 31, 2026
Build and package trimmed ROCm SDK dependencies

Fix ROCm wheel build blockers

Fix ROCm 10.1 PyTorch HIP build blockers

Build and package trimmed ROCm SDK dependencies

Use external ROCm SDK libraries without pip runtime dependencies

Use rocBLAS, hipBLASLt and MIOpen from the ROCm SDK

The ROCm build downloaded a separate rocm-libraries revision (271344a4),
built rocBLAS, hipBLASLt and MIOpen through ExternalProject and shipped
them in torch/lib (~250 MB), and installed Caffe2 configs re-entered that
logic so downstream builds such as vLLM fetched the 10 GB source again.
That existed to get gfx1201-only kernels; the TheRock SDK now builds these
libraries for gfx1201 itself, with our patches applied, so the bundled
copies were a second, divergent build of the same libraries, and which one
a process loaded depended on LD_LIBRARY_PATH.

Find them from ROCM_PATH like the other ROCm components and drop
cmake/External/rocm_bundled.cmake with its install rule, Caffe2Config
plumbing and summary line. The mslk symbol hiding that landed with the
bundling stays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Avoid pip ROCm dependency for external SDK wheels

Load the ROCm SDK version selected at wheel build time

Load ROCm from the SDK wheels the torch wheel was built against (#4)

ROCm wheels built against an unpacked TheRock SDK (PYTORCH_ROCM_EXTERNAL_SDK)
declared no ROCm dependency and shipped no torch/_rocm_init.py, so
`import torch` resolved librocm-openblas and the HIP libraries only through
LD_LIBRARY_PATH or whatever ROCm the host's ld.so.conf exposed. On a
Breadboard guest that is the accelerator pack's ROCm 10.0, not the 10.1 SDK
the wheel was built and patched against; without LD_LIBRARY_PATH the import
fails on librocm-openblas.so.0.

The build now takes the SDK wheels' version from PYTORCH_ROCM_SDK_VERSION.
tools/metadata/dependencies.py pins rocm[libraries] to it, and
torch/CMakeLists.txt writes the _rocm_init.py that the existing install rule
and torch/__init__.py already expect, so `import torch` preloads the SDK
libraries from those wheels through rocm_sdk.initialize_process and checks
the version. The preload list is TheRock's build_prod_wheels.py list minus
hipdnn, which this SDK does not build. PYTORCH_ROCM_EXTERNAL_SDK is gone;
the alternative of keeping it and fixing the guest's ld.so.conf would leave
torch tied to whatever ROCm the host provides.

Test Plan:

```
cmake -P test.cmake   # the new block, with and without PYTORCH_ROCM_SDK_VERSION
python -c 'import dependencies; ...'   # rocm[libraries]==<version>
env -u LD_LIBRARY_PATH python -c 'import torch; ...'
```

With the generated _rocm_init.py added to the published gdb71170c wheel on
a gfx1201 sandbox, `import torch` succeeds without LD_LIBRARY_PATH and
/proc/self/maps shows libamdhip64, libhsa-runtime64, librocblas, libMIOpen
and librocm-openblas loaded from the rocm_sdk wheels. A full wheel build
with the change was not run.

Authored with an AI assistant (Claude Code).

Co-authored-by: Claude Opus 5.5 <[email protected]>

Take the ROCm SDK version for _rocm_init.py from the build environment (#5)

* Take the ROCm SDK version for _rocm_init.py from the build environment

tools/metadata/dependencies.py pins rocm[libraries] to PYTORCH_ROCM_SDK_VERSION,
or to the rocm package installed in the build environment when the variable
is unset, but torch/CMakeLists.txt only generated _rocm_init.py from the
variable. A build that installs the SDK's rocm package instead of exporting
the version got the dependency but no preload. Fall back to the installed
rocm package in CMake too, so both read the same version.

Test Plan:

```
cmake -P t.cmake                            # check_version='<installed rocm>'
PYTORCH_ROCM_SDK_VERSION=9.9.9 cmake -P t.cmake   # check_version='9.9.9'
```

Authored with an AI assistant (Claude Code).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Depend on the ROCm SDK device wheel too

rocm[libraries] leaves out rocm-sdk-device-gfx1201, which carries the GPU
code objects for rocBLAS, MIOpen and the other kpack-split libraries;
without it their kernels fail with hipErrorInvalidKernelFile.

Authored with an AI assistant (Claude Code).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

Test Plan

History-only consolidation; all original patches replayed and the final tree compared exactly.

```
python3 agent_space/fold-v3/fold.py
git diff --exit-code 320a29e HEAD
```

Prepared with an AI assistant.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant