Skip to content

Conversation

@xinyazhang
Copy link
Collaborator

@xinyazhang xinyazhang commented Nov 8, 2024

Notable new features for SDPA operators on AMD systems from AOTriton 0.8b:

  1. Nestedtensor support;
  2. MQA/GQA support;
  3. Restore Efficient attention support for causal=True and seqlen_q != seqlen_k cases;
    • The kernel should use top-left alignment, bottom right alignment will be added later
  4. Move gfx1100 (RX7900/W7800/W7900) out of experimental support status.
    However, users are strongly recommended to update to ROCM 6.2.4, notably for
    its firmware updates.

Related unit tests are enabled as well.

Notable related changes from AOTriton 0.8b:

  1. AOTriton 0.8b moves the GPU kernel out of libaotriton.so to a separate directory aotriton.images;
  2. LZMA replaces ZSTD as GPU kernel compression algorithm for better compression ratio: aotriton0.8b (.so + aotriton.images take 350MB) compared to aotriton0.7b .so: 800MB
  3. The compression cannot be disabled now, and liblzma is hard run-time dependency.
    • Should not be a problem, since lzma is part of Python Standard Library

This PR also updates the wheel building logic to include the aotriton.images directory and files: fea8b5a

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 @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire @chauhang @aakhundov

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 8, 2024

🔗 Helpful Links

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

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

❌ 7 New Failures, 9 Unrelated Failures

As of commit 4b2c0e6 with merge base 920e436 (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

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

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

UNSTABLE - The following jobs failed but were likely due to flakiness present on trunk and has been marked as unstable:

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

@pytorch-bot pytorch-bot bot added module: rocm AMD GPU support for Pytorch release notes: releng release notes category labels Nov 8, 2024
@xinyazhang
Copy link
Collaborator Author

@pytorchbot label "ciflow/rocm" "keep-going" "rocm" "topic: not user facing"

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 8, 2024

Can't add following labels to PR: ciflow/rocm. Please ping one of the reviewers for help.

@xinyazhang
Copy link
Collaborator Author

@jithunnair-amd @jataylo can you approve the ROCM CI tag?

@jithunnair-amd jithunnair-amd added ciflow/rocm Trigger "default" config CI on ROCm release notes: rocm mandatorylabel labels Nov 11, 2024
@xinyazhang xinyazhang force-pushed the xinyazhang/sdpa-nestedtensor branch from 04a6184 to eac8c49 Compare November 16, 2024 06:02
@xinyazhang xinyazhang force-pushed the xinyazhang/sdpa-nestedtensor branch from eac8c49 to 2e44237 Compare November 25, 2024 22:41
@xinyazhang xinyazhang changed the title [ROCm] Support Nestedtensor in SDPA operators [ROCm] Bump to AOTriton 0.8b Nov 26, 2024
@xinyazhang xinyazhang changed the title [ROCm] Bump to AOTriton 0.8b [ROCm] Update to AOTriton 0.8b Nov 26, 2024
@xinyazhang xinyazhang force-pushed the xinyazhang/sdpa-nestedtensor branch from 74e349e to 8e72a1f Compare November 26, 2024 20:46
@xinyazhang
Copy link
Collaborator Author

@jithunnair-amd @jeffdaily @pruthvistony
We can move gfx1100 out of experimental status since our experiments have shown its performance advantage on ROCM 6.2.4
image

@xinyazhang xinyazhang force-pushed the xinyazhang/sdpa-nestedtensor branch from c997bfb to 9abbe31 Compare November 26, 2024 21:11
"lib/*.lib",
]
)
aotriton_image_path = os.path.join(lib_path, "aotriton.images")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In 0.8 we moved GPU kernels in to separate files to counter the bloating size of share object file
This is the subdirectory that AOTriton puts all GPU kernels, it must be on the same directory of libaotriton.so

Copy link
Collaborator

Choose a reason for hiding this comment

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

@malfet to take a look at this change especially. We have additional files in aotriton that would need to be packaged with the pytorch installation

@xinyazhang xinyazhang force-pushed the xinyazhang/sdpa-nestedtensor branch from f6b7c1a to e0b9459 Compare November 27, 2024 09:00
@xinyazhang
Copy link
Collaborator Author

@jithunnair-amd I changed the runner to 12xlarge temporarily to make sure the docker image build can complete within 100 minutes.

@xinyazhang
Copy link
Collaborator Author

@pytorchbot label "ciflow/inductor-rocm"

@pytorch-bot pytorch-bot bot added the ciflow/inductor-rocm Trigger "inductor" config CI on ROCm label Dec 3, 2024
@xinyazhang xinyazhang force-pushed the xinyazhang/sdpa-nestedtensor branch from 361f296 to f67538e Compare December 3, 2024 18:34
@xinyazhang xinyazhang marked this pull request as ready for review December 3, 2024 22:40
@xinyazhang
Copy link
Collaborator Author

xinyazhang commented Dec 3, 2024

https://hud.pytorch.org/pytorch/pytorch/pull/140172?sha=f67538eda2ff51ded484df1e08b3c17df3224a9d

All CUDA+ROCM tests passed, move out of draft status.

Note the ROCm inductor tests hit Secret source: None randomly and thus not very reliable.

@jithunnair-amd jithunnair-amd requested a review from malfet December 3, 2024 23:26
// On ROCM, ME and FA share the backend, and hence they share the checking
// function for fundamental limitations by the GPU kernel
// caller_is_meff is added to make the TORCH_WARN message showing the correct result
template<bool caller_is_meff = false>
Copy link
Collaborator

Choose a reason for hiding this comment

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

@malfet to look at this change especially, since this is a function commonly used by CUDA and ROCm, but the changes here maintains the same functionality for CUDA.

@xinyazhang xinyazhang marked this pull request as ready for review December 6, 2024 05:35
@jithunnair-amd
Copy link
Collaborator

@xinyazhang This CI failure seems related to your PR: https://github.com/pytorch/pytorch/actions/runs/12189422770/job/34006369193
Looking at the history of failures of this build, all the failures are only from CI runs on this PR.

@xinyazhang
Copy link
Collaborator Author

xinyazhang commented Dec 6, 2024

@netlify
Copy link

netlify bot commented Dec 6, 2024

Deploy Preview for chimerical-cranachan-793287 ready!

Name Link
🔨 Latest commit 4b2c0e6
🔍 Latest deploy log https://app.netlify.com/sites/chimerical-cranachan-793287/deploys/6752b01f4f67a30008f3d1e5
😎 Deploy Preview https://deploy-preview-140172--chimerical-cranachan-793287.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@jithunnair-amd
Copy link
Collaborator

@pytorchbot merge -f "Unrelated CI failures"

@pytorchmergebot
Copy link
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

pytorch-bot bot pushed a commit that referenced this pull request Dec 9, 2024
Notable new features for SDPA operators on AMD systems from AOTriton 0.8b:

1. Nestedtensor support;
2. MQA/GQA support;
3. Restore Efficient attention support for causal=True and seqlen_q != seqlen_k cases;
    + The kernel should use top-left alignment, bottom right alignment will be added later
4. Move gfx1100 (RX7900/W7800/W7900) out of experimental support status.
   However, users are strongly recommended to update to ROCM 6.2.4, notably for
   its firmware updates.

Related unit tests are enabled as well.

Notable related changes from AOTriton 0.8b:

1. AOTriton 0.8b moves the GPU kernel out of libaotriton.so to a separate directory `aotriton.images`;
2. LZMA replaces ZSTD as GPU kernel compression algorithm for better compression ratio: aotriton0.8b (.so + aotriton.images take 350MB) compared to aotriton0.7b .so: 800MB
3. The compression cannot be disabled now, and `liblzma` is hard run-time dependency.
    + Should not be a problem, since `lzma` is part of Python Standard Library

Pull Request resolved: #140172
Approved by: https://github.com/jithunnair-amd, https://github.com/jeffdaily

Co-authored-by: Jithun Nair <[email protected]>
@austin362667
Copy link

Hi @xinyazhang Thanks for the great works!
Could I kindly ask which PyTorch version this fix is expected to be released in? Will it be 2.6.0 or a later version? cc @jataylo

@xinyazhang
Copy link
Collaborator Author

Could I kindly ask which PyTorch version this fix is expected to be released in? Will it be 2.6.0 or a later version? cc @jataylo

It should be part of PyTorch 2.6

@jithunnair-amd jithunnair-amd deleted the xinyazhang/sdpa-nestedtensor branch January 1, 2025 01:20
xinyazhang added a commit to ROCm/pytorch that referenced this pull request Jan 13, 2025
This is backported from upstream PR pytorch#140172, pytorch#137443 and pytorch#139432.

Original commit message of pytorch#140172:

Notable new features for SDPA operators on AMD systems from AOTriton 0.8b:

1. Nestedtensor support;
2. MQA/GQA support;
3. Restore Efficient attention support for causal=True and seqlen_q != seqlen_k cases;
    + The kernel should use top-left alignment, bottom right alignment will be added later
4. Move gfx1100 (RX7900/W7800/W7900) out of experimental support status.
   However, users are strongly recommended to update to ROCM 6.2.4, notably for
   its firmware updates.

Related unit tests are enabled as well.

Notable related changes from AOTriton 0.8b:

1. AOTriton 0.8b moves the GPU kernel out of libaotriton.so to a separate directory `aotriton.images`;
2. LZMA replaces ZSTD as GPU kernel compression algorithm for better compression ratio: aotriton0.8b (.so + aotriton.images take 350MB) compared to aotriton0.7b .so: 800MB
3. The compression cannot be disabled now, and `liblzma` is hard run-time dependency.
    + Should not be a problem, since `lzma` is part of Python Standard Library

Pull Request resolved: pytorch#140172
Approved by: https://github.com/jithunnair-amd, https://github.com/jeffdaily

Co-authored-by: Jithun Nair <[email protected]>
pruthvistony pushed a commit to ROCm/pytorch that referenced this pull request Jan 16, 2025
This is backported from upstream PR pytorch#140172, pytorch#137443 and pytorch#139432.

Original commit message of pytorch#140172:

Notable new features for SDPA operators on AMD systems from AOTriton
0.8b:

1. Nestedtensor support;
2. MQA/GQA support;
3. Restore Efficient attention support for causal=True and seqlen_q !=
seqlen_k cases;
+ The kernel should use top-left alignment, bottom right alignment will
be added later
4. Move gfx1100 (RX7900/W7800/W7900) out of experimental support status.
However, users are strongly recommended to update to ROCM 6.2.4, notably
for its firmware updates.

Related unit tests are enabled as well.

Notable related changes from AOTriton 0.8b:

1. AOTriton 0.8b moves the GPU kernel out of libaotriton.so to a
separate directory `aotriton.images`;
2. LZMA replaces ZSTD as GPU kernel compression algorithm for better
compression ratio: aotriton0.8b (.so + aotriton.images take 350MB)
compared to aotriton0.7b .so: 800MB
3. The compression cannot be disabled now, and `liblzma` is hard
run-time dependency.
+ Should not be a problem, since `lzma` is part of Python Standard
Library

Pull Request resolved: pytorch#140172
Approved by: https://github.com/jithunnair-amd,
https://github.com/jeffdaily

Fixes #ISSUE_NUMBER

---------

Co-authored-by: Jithun Nair <[email protected]>
@jithunnair-amd jithunnair-amd restored the xinyazhang/sdpa-nestedtensor branch February 21, 2025 15:43
@jithunnair-amd jithunnair-amd deleted the xinyazhang/sdpa-nestedtensor branch February 21, 2025 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/binaries_wheel Trigger binary build and upload jobs for wheel on the PR ciflow/inductor ciflow/inductor-rocm Trigger "inductor" config CI on ROCm ciflow/rocm Trigger "default" config CI on ROCm Merged module: inductor module: rocm AMD GPU support for Pytorch open source release notes: releng release notes category release notes: rocm mandatorylabel 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.

7 participants