Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROCm Support : HIP kernel Generator #1201

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

petrex
Copy link
Collaborator

@petrex petrex commented Oct 30, 2024

This pull request introduces support for ROCm (Radeon Open Compute) in addition to CUDA for GPU acceleration. The changes primarily focus on enabling the build and execution of ROCm-specific code paths alongside existing CUDA paths.

In this PR, I use tensor_core_tiled_layout as proof of concept, but it generalizes to other kernels (for example, fp6_llm or sparse_marlin) with minimum effort. Feedback are welcome

co-author : @lcskrishna

Features:

ROCm Support Integration:

  • setup.py: Added detection for ROCm and adjusted the logic for compiling GPU extensions based on the availability of CUDA or ROCm.

Conditional Compilation for ROCm:

These changes ensure that the codebase can compile and run efficiently on both CUDA and ROCm platforms, leveraging the best available GPU acceleration technology.

Usage

With ROCm pytorch nightly docker , simply run PYTORCH_ROCM_ARCH=gfx942 python setup.py install

Next

  • AMD specific unit tests (tensor_core_tiled_layout)
  • workload and platform specific optimization (tensor_core_tiled_layout)

Copy link

pytorch-bot bot commented Oct 30, 2024

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 10 New Failures, 2 Unrelated Failures

As of commit 612ad14 with merge base 6234116 (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 30, 2024
@petrex petrex mentioned this pull request Oct 31, 2024
1 task
@msaroufim msaroufim self-requested a review November 2, 2024 22:50
Copy link
Member

@msaroufim msaroufim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Left some prelim feedback more of a n00b question but is this the main way you've seen ROCm supported in new codebases? The other approach would be to have some code duplication and avoid a boolean flag like USE_ROCM in the .cu file

setup.py Show resolved Hide resolved
setup.py Show resolved Hide resolved
@@ -57,11 +59,11 @@ def get_extensions():

if not torch.cuda.is_available():
print("PyTorch GPU support is not available. Skipping compilation of CUDA extensions")
if CUDA_HOME is None and torch.cuda.is_available():
print("CUDA toolkit is not available. Skipping compilation of CUDA extensions")
if CUDA_HOME is None or not IS_ROCM and torch.cuda.is_available():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some of these if conditions might cause our binary builds to break - check CI, since we run binary builds when people modify setup.py

Until you get your first PR merged I'll have to manually approve every CI run so might be easiest if you wanna make some simple doc level PR and I can merge that fast

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for approving the CI flow, we will look into this

@jcaip jcaip mentioned this pull request Nov 11, 2024
1 task
@petrex
Copy link
Collaborator Author

petrex commented Nov 13, 2024

@msaroufim can we have the CI flow to test the change? thanks

@petrex petrex changed the title ROCm Support Integration ROCm Support : HIP kernel Generator Nov 13, 2024
@msaroufim
Copy link
Member

I gave you triage access @petrex - what might help is also merging some simple PR since after that you shouldn't need me to trigger CI for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: rocm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants