[AMD] Improve ld.lld detection for ROCm SDK / ROCM_PATH installs#950
Open
adityas-amd wants to merge 1 commit into
Open
Conversation
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.
7 tasks
Member
Author
|
Landing on ROCm/triton:release/internal/3.3.x per review - see triton-lang#10387. Approval carried over |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backports a small
path_to_rocm_lld()change torelease/internal/3.3.x. Onmainandrelease/3.5.xthis 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 viapytorch-triton-rocmfixes: ROCm/TheRock#2006 .
What changes
HIPBackend.path_to_rocm_lld()now also probes:$ROCM_PATH/llvm/bin/ld.lldwhenROCM_PATHis set,$(rocm-sdk path --root)/llvm/bin/ld.lldwhenrocm-sdkis 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 unlessTRITON_HIP_LLD_PATHis exported manually. The failure fires fromHIPBackend.hash()viatorch.utils._triton.triton_hash_with_backend(), which Inductor calls whenever it codegens a Triton kernel — sotorch.compileandaoti_compile_and_packageare unusable without the workaround.Reproduced locally with
torch==2.7.1+pytorch-triton-rocm==3.3.1on a TheRock-only host (no/opt/rocm;ld.lldonly 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.
/testforlittests/unittestfor C++ tests/python/testfor end-to-end testsrocm-sdk path --rootresolves to a real directory containingllvm/bin/ld.lld) orROCM_PATHpointing 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.
littests.littests 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.)