Skip to content

[AMD] Improve ld.lld detection for ROCm SDK / ROCM_PATH installs#950

Open
adityas-amd wants to merge 1 commit into
ROCm:release/internal/3.3.xfrom
adityas-amd:aditya/fix-lld-detection-internal-3.3.x
Open

[AMD] Improve ld.lld detection for ROCm SDK / ROCM_PATH installs#950
adityas-amd wants to merge 1 commit into
ROCm:release/internal/3.3.xfrom
adityas-amd:aditya/fix-lld-detection-internal-3.3.x

Conversation

@adityas-amd

Copy link
Copy Markdown
Member

Backports a small path_to_rocm_lld() change to release/internal/3.3.x. On main and release/3.5.x this code path was already removed by triton-lang#7548 ([AMD] Use lld library API for linking), so this PR is targeted only at the still-shipping branches that PyTorch 2.7.x consumes via pytorch-triton-rocm
fixes: ROCm/TheRock#2006 .

What changes

HIPBackend.path_to_rocm_lld() now also probes:

  • $ROCM_PATH/llvm/bin/ld.lld when ROCM_PATH is set,
  • $(rocm-sdk path --root)/llvm/bin/ld.lld when rocm-sdk is on PATH (TheRock SDK case),
  • shutil.which("ld.lld") as a final fallback.

The error message now lists every probed location.

Why

Landing here on release/internal/3.3.x (where pytorch-triton-rocm is built) per @antiagainst's review on triton-lang#10387. Upstream main already drops this
path via triton-lang#7548.

On TheRock SDK installs (Python wheel layout, no /opt/rocm), Triton fails to compile any kernel unless TRITON_HIP_LLD_PATH is exported manually. The failure fires from HIPBackend.hash() via torch.utils._triton.triton_hash_with_backend(), which Inductor calls whenever it codegens a Triton kernel — so torch.compile and aoti_compile_and_package are unusable without the workaround.

Reproduced locally with torch==2.7.1 + pytorch-triton-rocm==3.3.1 on a TheRock-only host (no /opt/rocm; ld.lld only present under $(rocm-sdk path --root)/llvm/bin/ld.lld). Original ROCm/triton draft was #908 (will close in favor of this one).

See ROCm/TheRock#2006 for the full traceback.

New contributor declaration

  • I am not making a trivial change, such as fixing a typo in a comment.

  • I have written a PR description following these
    rules.

  • I have run pre-commit run --from-ref origin/main --to-ref HEAD.

  • Select one of the following.

    • I have added tests.
      • /test for lit tests
      • /unittest for C++ tests
      • /python/test for end-to-end tests
    • This PR does not need a test because the change is environment-dependent filesystem probing of the ROCm linker path. Exercising the new branches requires either a TheRock SDK install (so rocm-sdk path --root resolves to a real directory containing llvm/bin/ld.lld) or ROCM_PATH pointing at a populated ROCm install, neither of which is available in the upstream CI environment. The pre-existing fallbacks (TRITON_HIP_LLD_PATH, bundled <triton>/llvm/bin/ld.lld, /opt/rocm/llvm/bin/ld.lld, /usr/bin/ld.lld) are unchanged and remain exercised by existing builds.
  • Select one of the following.

    • I have not added any lit tests.
    • The lit tests I have added follow these best practices,
      including the "tests should be minimal" section. (Usually running Python code
      and using the instructions it generates is not minimal.)

Extend HIPBackend.path_to_rocm_lld() so PyTorch + Triton works out of the
box on TheRock SDK installs (ROCm under $(rocm-sdk path --root), no /opt/rocm):
  - $ROCM_PATH/llvm/bin/ld.lld when ROCM_PATH is set
  - $(rocm-sdk path --root)/llvm/bin/ld.lld when rocm-sdk is on PATH
  - shutil.which('ld.lld') as a final PATH fallback
The error message now lists every probed path.

Landing on release/internal/3.3.x (the branch pytorch-triton-rocm is built
from) per review on triton-lang#10387. Upstream main already drops
this code path via triton-lang#7548.

Fixes ROCm/TheRock#2006.
@adityas-amd

Copy link
Copy Markdown
Member Author

Landing on ROCm/triton:release/internal/3.3.x per review - see triton-lang#10387. Approval carried over

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