Skip to content

[ROCm] [CK] Composable Kernel integration for inductor backend - #158747

Closed
iupaikov-amd wants to merge 54 commits into
pytorch:mainfrom
ROCm:iupaikov_ck_integration_upstream2
Closed

iupaikov-amd wants to merge 54 commits into
pytorch:mainfrom
ROCm:iupaikov_ck_integration_upstream2

Conversation

@iupaikov-amd

@iupaikov-amd iupaikov-amd commented Jul 21, 2025 •

Copy link
Copy Markdown
Contributor

This is a part of our effort for integrating Composable Kernel library for Inductor backend. Currently we have a submodule, but would prefer to have commit pin control over the library as with Triton. We intentionally avoid putting all installation logic in CI scripts to allow locally built versions to have this functionality.

The idea is to have CK as a pytorch dependency in pytorch 2.9 release to allow people to use it with inductor and AOT inductor and then gradually step away from submodule usage. Right now CK usage in SDPA/Gemm is tied to submodule files.

This PR is a remake of due to branch error: #156192

cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @dllehr-amd @jataylo @hongxiayang @naromero77amd @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @chenyang78 @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben

@pytorch-bot

pytorch-bot Bot commented Jul 21, 2025 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/158747

Note: Links to docs will display an error until the docs builds have been completed.

⏳ No Failures, 72 Pending

As of commit fdd5126 with merge base 789d494 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot Bot added module: inductor module: rocm AMD GPU support for Pytorch release notes: releng release notes category labels Jul 21, 2025
@iupaikov-amd

Copy link
Copy Markdown
Contributor Author

@pytorchbot rebase

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Rebase failed due to Command git -C /home/runner/work/pytorch/pytorch rebase refs/remotes/origin/viable/strict pull/158747/head returned non-zero exit code 1

Rebasing (1/6)
Auto-merging setup.py
CONFLICT (content): Merge conflict in setup.py
error: could not apply f61030db195... Implemented CK installation for ROCm builds
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Could not apply f61030db195... # Implemented CK installation for ROCm builds

Raised by https://github.com/pytorch/pytorch/actions/runs/16421942414

@iupaikov-amd
iupaikov-amd force-pushed the iupaikov_ck_integration_upstream2 branch from 36cb691 to 41deb6e Compare July 21, 2025 16:13
@iupaikov-amd iupaikov-amd added ciflow/trunk Trigger trunk jobs on your pull request ciflow/inductor keep-going Don't stop on first failure, keep running tests until the end ciflow/rocm ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 labels Jul 21, 2025
@iupaikov-amd

Copy link
Copy Markdown
Contributor Author

@pytorchbot rebase

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Successfully rebased iupaikov_ck_integration_upstream2 onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout iupaikov_ck_integration_upstream2 && git pull --rebase)

@pytorchmergebot
pytorchmergebot force-pushed the iupaikov_ck_integration_upstream2 branch from 41deb6e to 784166a Compare July 22, 2025 10:10
@pytorch-bot pytorch-bot Bot removed ciflow/trunk Trigger trunk jobs on your pull request ciflow/inductor ciflow/rocm ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 labels Jul 22, 2025
@iupaikov-amd iupaikov-amd added ciflow/trunk Trigger trunk jobs on your pull request ciflow/inductor ciflow/rocm ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 ciflow/periodic-rocm-mi300 Trigger "distributed" config CI on ROCm MI300/MI325 labels Jul 22, 2025
Comment thread test/inductor/test_ck_backend.py Resolved
@pytorch-bot pytorch-bot Bot removed ciflow/trunk Trigger trunk jobs on your pull request ciflow/inductor labels Jul 22, 2025
jithunnair-amd and others added 2 commits August 29, 2025 15:37
This is currently the most-common installation path for Linux. Windows case has too many options, so just choosing /opt/rocm as a sensible default.
@tenpercent

tenpercent commented Sep 2, 2025 •

Copy link
Copy Markdown
Collaborator

@pytorchbot label "ciflow/rocm" "ciflow/rocm-mi300"

@pytorch-bot

pytorch-bot Bot commented Sep 2, 2025

Copy link
Copy Markdown

To add the ciflow label ciflow/rocm please first approve the workflows that are awaiting approval (scroll to the bottom of this page).

This helps ensure we don't trigger CI on this PR until it is actually authorized to do so. Please ping one of the reviewers if you do not have access to approve and run workflows.

@pytorch-bot

pytorch-bot Bot commented Sep 2, 2025

Copy link
Copy Markdown

To add the ciflow label ciflow/rocm-mi300 please first approve the workflows that are awaiting approval (scroll to the bottom of this page).

This helps ensure we don't trigger CI on this PR until it is actually authorized to do so. Please ping one of the reviewers if you do not have access to approve and run workflows.

@jithunnair-amd

jithunnair-amd commented Sep 3, 2025 •

Copy link
Copy Markdown
Collaborator

@malfet @atalman Can you please review the changes in this PR vis-a-vis the dependencies introduced on the ROCm pytorch builds to let us know if you have any concerns?

@jithunnair-amd

Copy link
Copy Markdown
Collaborator

@pytorchbot rebase

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Rebase failed due to Command git -C /home/runner/work/pytorch/pytorch rebase refs/remotes/origin/viable/strict pull/158747/head returned non-zero exit code 1

Rebasing (1/46)
Auto-merging setup.py
CONFLICT (content): Merge conflict in setup.py
error: could not apply 10b7cb2b92e... Implemented CK installation for ROCm builds
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Could not apply 10b7cb2b92e... # Implemented CK installation for ROCm builds

Raised by https://github.com/pytorch/pytorch/actions/runs/17435650711

@jithunnair-amd

Copy link
Copy Markdown
Collaborator

MI200 CI successfully ran test_ck_backend.py as part of https://hud.pytorch.org/pytorch/pytorch/pull/158747?sha=9794e74014d28d685a0b30760e630d79af8ad2fe#rocm:

https://github.com/pytorch/pytorch/actions/runs/17417340421/job/49450261028
2025-09-03T07:24:28.2219881Z inductor/test_ck_backend 1/1 was successful, full logs can be found in artifacts with path test/test-reports/inductor.test_ck_backend_1.1_7a0cb909fcf40c75_.log

MI300 CI successfully ran test_ck_backend.py as part of https://hud.pytorch.org/pytorch/pytorch/pull/158747?sha=b7af5c9e63fe21cfba81d594ec728943f8347fde#rocm-mi300

Latest MI200 failures are due to outage as per #161784, so we can ignore it.

@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -f "force merging on request from jithunnair-amd based on evidence of prior clean CI signals"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: Commit b7af5c9 was HEAD when comment 3254576258 was posted but now the latest commit on the PR is fdd5126. Please re-issue the merge command to merge the latest commit.

Details for Dev Infra team Raised by workflow job

@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -f "force merging on request from jithunnair-amd based on evidence of prior clean CI signals"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

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.

Pull Request Overview

This PR integrates the Composable Kernel (CK) library as a proper PyTorch dependency for ROCm builds, moving away from the submodule-based approach to enable better version control and commit pinning similar to Triton.

  • Adds CK as a dependency in setup.py for ROCm builds with commit pinning support
  • Simplifies CK path detection by removing manual directory configuration requirements
  • Updates test infrastructure to use the new CK import mechanism

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
torch/_inductor/utils.py Simplifies CK directory validation by automatically setting config.rocm.ck_dir from imported package
torch/_inductor/codegen/rocm/compile_command.py Updates CK path resolution to use try_import_ck_lib when config is not set
tools/setup_helpers/rocm_env.py Adds utilities for CK dependency management including commit pin reading and PEP 508 URL generation
test/inductor/test_ck_backend.py Refactors test setup to use try_import_ck_lib instead of manual package import
setup.py Integrates CK dependency for ROCm Linux builds using the new dependency string helper
.ci/docker/ci_commit_pins/rocm-composable-kernel.txt Pins CK to specific commit hash for reproducible builds
Comments suppressed due to low confidence (1)

.ci/docker/ci_commit_pins/rocm-composable-kernel.txt:1

  • [nitpick] The file contains an unnecessary trailing newline after the commit hash. Consider removing the empty line to keep the file clean and consistent with other commit pin files.
7fe50dc3da2069d6645d9deb8c017a876472a977

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@tenpercent

Copy link
Copy Markdown
Collaborator
  • this PR reconsiders how TORCHINDUCTOR_CK_DIR env variable is used; previously, this var was used to point to rocm-composable-kernel package installation path on the filesystem; now, the path is inferred by trying to import ck4inductor
  • the tests are updated to reflect this change
  • since in CI clang points to a bash script which invokes sccache, we cannot patch PATH to not contain sccache, this logic is removed from the testing code
  • scaled_mm test crashes during the benchmarking when the benchmarking happens in the main process, and times out benchmarking when it happens in a subprocess, on gfx942, so it is disabled

@jithunnair-amd

Copy link
Copy Markdown
Collaborator

@pytorch-bot

pytorch-bot Bot commented Sep 5, 2025

Copy link
Copy Markdown

❌ 🤖 pytorchbot command failed:

@pytorchbot revert: error: the following arguments are required: -c/--classification

usage: @pytorchbot revert -m MESSAGE -c
                          {nosignal,ignoredsignal,landrace,weird,ghfirst}

Try @pytorchbot --help for more info.

@jithunnair-amd

Copy link
Copy Markdown
Collaborator

@pytorchbot revert -m "Broke linux-binary-manywheel-rocm / manywheel-py3_9-rocm6_4-test: https://hud.pytorch.org/hud/pytorch/pytorch/019fed39aa6b2dd8c69347378d53423e5efae8d4/1?per_page=50&name_filter=manywheel&mergeEphemeralLF=true ... PR didn't have this job run successfully due to CI outage" -c nosignal

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot successfully started a revert job. Check the current status here.
Questions? Feedback? Please reach out to the PyTorch DevX Team

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@iupaikov-amd your PR has been successfully reverted.

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

Labels

ci-no-td Do not run TD on this PR keep-going Don't stop on first failure, keep running tests until the end Merged module: inductor module: rocm AMD GPU support for Pytorch open source release notes: releng release notes category release notes: rocm mandatorylabel Reverted triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.