Skip to content

[Build][JIT] Support core-only ROCm SDK environments - #1222

Open
apinge wants to merge 10 commits into
ROCm:mainfrom
apinge:fix_cmake_rocm7.14
Open

apinge wants to merge 10 commits into
ROCm:mainfrom
apinge:fix_cmake_rocm7.14

Conversation

@apinge

@apinge apinge commented Oct 1, 2026 •

Copy link
Copy Markdown

Motivation

Since ROCm 7.14, ROCm can be installed via python packages and is no longer necessarily located under /opt/rocm. While rocm-sdk-core already provides the hip headers, runtime libraries, lld, and device bitcode, it does not ship hip-config.cmake, and its resource layout differs from the traditional /opt/rocm structure.

This creates two issues:

  1. CMake cannot locate hip via find_package(hip). Although [Build] Find ROCm through rocm-sdk before falling back to /opt/rocm* #1142 added support for discovering a pip-installed ROCm sdk via rocm-sdk path --root, that mechanism depends on rocm[devel], which is not present in some images such as rocm/pytorch:rocm7.14.1_ubuntu24.04_py3.13_pytorch_release_2.12.0.

  2. GPU JIT still searches for lld and device bitcode under /opt/rocm, which can lead to lld invocation failed in environments that only provide the core wheel.

This PR only covers source builds and GPU JIT in core-only ROCm environments. The default external linking flow for AOT artifacts remains affected by the missing development linker name for libamdhip64.so (see ROCm/TheRock#1205) and is left for future work.

Technical Details

  1. This PR preserves the existing lookup priority for the standard hip cmake package discovery mechanisms: hip_DIR, ROCM_PATH, rocm-sdk path --root, and /opt/rocm. Only if hip-config.cmake cannot be found in any of those locations will it fall back to reading the hip headers and runtime library from the _rocm_sdk_core package in the Python environment used for the build, while also providing the hip::host and hip::amdhip64 targets required by the FlyDSL runtime.
  2. This PR introduces FlyRocmModuleToBinaryPass as a replacement for upstream llvm's GpuModuleToBinaryPass, and FlyRocmSerializer as a derived replacement for upstream llvm's AMDGPUSerializer. By overriding compileToBinary in the derived serializer, it avoids the hardcoded linker path used upstream. It solves the same problem as Auto-discover MLIR ROCm toolkit from rocm-sdk Python wheels #568 , but without requiring extra symbolic links, which makes the user environment easier to maintain. This makes it possible to resolve both the traditional installation path
toolkit = /opt/rocm
linker  = /opt/rocm/llvm/bin/ld.lld
bitcode = /opt/rocm/amdgcn/bitcode

and the new rocm-sdk-core path

toolkit = <core>/lib/llvm
linker  = <core>/lib/llvm/bin/ld.lld
bitcode = <core>/lib/llvm/amdgcn/bitcode

Test Plan

  • Verified in a ROCm 7.14 core-only python environment that bash scripts/build.sh -j64 .
  • Passed all tests in scripts/run_benchmark.sh.
  • Passed all tests in scripts/run_tests.sh except tests/unit/test_aot_export.py.

Test Result

Submission Checklist

@apinge
apinge marked this pull request as ready for review October 1, 2026 11:32
Copilot AI balanced review requested due to automatic review settings October 1, 2026 11:32

Copilot AI 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.

Copilot review overview

🟢 Approval recommended

The fallback preserves existing discovery priority and has focused automated coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Adds HIP discovery fallback for minimal rocm-sdk-core Python installations.

Changes:

  • Creates compatible hip::host and hip::amdhip64 CMake targets from core-wheel assets.
  • Adds a focused configuration test for fallback discovery.
File Description
lib/​Runtime/​ROCm/​CMakeLists.txt Implements core-wheel HIP fallback.
tests/​unit/​test_backend_cmake_defaults.py Verifies fallback target paths.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@apinge
apinge marked this pull request as draft October 1, 2026 11:40
@apinge apinge changed the title [Build] Fall back to HIP runtime from rocm-sdk core wheels [Build][JIT] Support core-only ROCm SDK environments Oct 5, 2026
@apinge
apinge marked this pull request as ready for review October 5, 2026 13:59
@sammysun0711
sammysun0711 requested a review from coderfeli October 8, 2026 05:15

This branch has not been deployed

No deployments
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.

2 participants