Skip to content

Conversation

@xinyazhang
Copy link
Collaborator

@xinyazhang xinyazhang commented Oct 7, 2024

We do not need install_aotriton.sh and aotriton_version.txt any more since aotriton.cmake now installs the best binary release package as the default option when building pytorch.

This should resolve the issue of needing a pre-installed aotriton package when building PyTorch for ROCm from source, which is not feasible if building PyTorch outside a CI docker image. With this change, a user can have a pre-installed AOTriton in their environment, if desired, and have the build pick it up by specifying the AOTRITON_INSTALLED_PREFIX env var, or have the build automatically detect and install the compatible version. As a third option, the user can also force AOTriton to build from source instead, using the AOTRITON_INSTALL_FROM_SOURCE env var.

Also, with the changes in this PR, the cmake build process handles the tasks of copying aotriton .so and images directory from torch/lib to the installation path.

cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @dllehr-amd @jataylo @hongxiayang @naromero77amd

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 7, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit 79ad25f with merge base ebeb433 (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 the release notes: releng release notes category label Oct 7, 2024
@xinyazhang
Copy link
Collaborator Author

@jithunnair-amd shall we use this PR to bump to 0.7.1b as well?

Copy link
Collaborator

@jithunnair-amd jithunnair-amd left a comment

Choose a reason for hiding this comment

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

LGTM, let's make sure various CI workflows run successfully

@jithunnair-amd jithunnair-amd added ciflow/binaries Trigger all binary build and upload jobs on the PR ciflow/rocm Trigger "default" config CI on ROCm labels Oct 7, 2024
@jithunnair-amd
Copy link
Collaborator

@jithunnair-amd shall we use this PR to bump to 0.7.1b as well?

No, I'd prefer we do that in a different PR

jithunnair-amd added a commit to ROCm/pytorch that referenced this pull request Oct 8, 2024
    Fix tarball's suffix

    Read rocm version from variables set by LoadHIP.cmake

    Copy AOTRITON_INSTALLED_PREFIX/* to torch/

    Otherwise bdist_wheel will miss libaotriton_v2.so

    Fix problems in aotriton.cmake

    Guard against new ROCM environment

    This also updates aotriton_version.txt's format

    Supply ROCM versions and SHA256 checksums as lists.

    Let install_aotriton.sh parse the new format of aotriton_version.txt

    Do not hardcode __AOTRITON_ARCH

    Updates to aotriton build steps and Dockerfiles (#1599)

Changes cherry-picked from pytorch#137443
jithunnair-amd added a commit to ROCm/pytorch that referenced this pull request Oct 9, 2024
    Fix tarball's suffix

    Read rocm version from variables set by LoadHIP.cmake

    Copy AOTRITON_INSTALLED_PREFIX/* to torch/

    Otherwise bdist_wheel will miss libaotriton_v2.so

    Fix problems in aotriton.cmake

    Guard against new ROCM environment

    This also updates aotriton_version.txt's format

    Supply ROCM versions and SHA256 checksums as lists.

    Let install_aotriton.sh parse the new format of aotriton_version.txt

    Do not hardcode __AOTRITON_ARCH

    Updates to aotriton build steps and Dockerfiles (#1599)

Changes cherry-picked from pytorch#137443
@xinyazhang
Copy link
Collaborator Author

Confirmed the new algorithm's correctness with

set(__AOTRITON_ROCM_LIST
    "rocm6.1"
    "rocm6.2"
    "rocm6.4"
)

set(detection_lists
    "6.0"
    "6.1"
    "6.2"
    "6.3"
    "6.4"
)
foreach(__AOTRITON_SYSTEM_ROCM IN LISTS detection_lists)
    list(GET __AOTRITON_ROCM_LIST 0 __AOTRITON_ROCM_DEFAULT_STR)
    # Initialize __AOTRITON_ROCM to lowest version, in case all builds > system's ROCM
    string(SUBSTRING ${__AOTRITON_ROCM_DEFAULT_STR} 4 -1 __AOTRITON_ROCM)
    foreach(AOTRITON_ROCM_BUILD_STR IN LISTS __AOTRITON_ROCM_LIST)
      # len("rocm") == 4
      string(SUBSTRING ${AOTRITON_ROCM_BUILD_STR} 4 -1 AOTRITON_ROCM_BUILD)
      # Find the last build that <= system's ROCM
      # Assume the list is from lower to higher
      if(AOTRITON_ROCM_BUILD VERSION_GREATER __AOTRITON_SYSTEM_ROCM)
        break()
      endif()
      set(__AOTRITON_ROCM ${AOTRITON_ROCM_BUILD})
    endforeach()
    message(STATUS "System ROCM ${__AOTRITON_SYSTEM_ROCM}, Selected Package ${__AOTRITON_ROCM}")
endforeach()

Output

-- System ROCM 6.0, Selected Package 6.1
-- System ROCM 6.1, Selected Package 6.1
-- System ROCM 6.2, Selected Package 6.2
-- System ROCM 6.3, Selected Package 6.2
-- System ROCM 6.4, Selected Package 6.4

ethanwee1 pushed a commit to ROCm/pytorch that referenced this pull request Oct 29, 2024
ethanwee1 pushed a commit to ROCm/pytorch that referenced this pull request Oct 29, 2024
ethanwee1 pushed a commit to ROCm/pytorch that referenced this pull request Oct 29, 2024
ethanwee1 pushed a commit to ROCm/builder that referenced this pull request Oct 29, 2024
ethanwee1 pushed a commit to ROCm/builder that referenced this pull request Oct 29, 2024
@xinyazhang
Copy link
Collaborator Author

Current plan: let's send varlen/nestedtensor support, which requires some fixes in AOTriton 0.7.2b, and then update this PR.

@xinyazhang xinyazhang force-pushed the xinyazhang/aotriton-multiple_binary_packages branch from a112857 to 9ce8535 Compare November 9, 2024 00:09
@huydhn
Copy link
Contributor

huydhn commented Nov 11, 2024

@pytorchbot rebase

@pytorchmergebot
Copy link
Collaborator

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

@pytorchmergebot
Copy link
Collaborator

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

@pytorchmergebot pytorchmergebot force-pushed the xinyazhang/aotriton-multiple_binary_packages branch from 9ce8535 to ecbdf92 Compare November 11, 2024 19:51
@jithunnair-amd
Copy link
Collaborator

@jeffdaily Please review and approve if it looks good.

@pruthvistony pruthvistony added module: rocm AMD GPU support for Pytorch rocm This tag is for PRs from ROCm team labels Jan 8, 2025
@jithunnair-amd
Copy link
Collaborator

@pytorchbot merge -f "Rocm CI jobs passed. Wheel build jobs also passed, installing all aotriton files during Pytorch build as expected"

@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

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]>
xinyazhang added a commit to ROCm/pytorch that referenced this pull request Jan 14, 2025
The previous port of upstream PR pytorch#137443 is incomplete
xinyazhang added a commit to ROCm/pytorch that referenced this pull request Jan 14, 2025
The previous port of upstream PR pytorch#137443 is incomplete

Fixes #SWDEV-509002
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]>
xinyazhang added a commit to ROCm/pytorch that referenced this pull request Jan 20, 2025
…te aotriton_version.txt (pytorch#137443)

We do not need `install_aotriton.sh` and `aotriton_version.txt` any more since `aotriton.cmake` now installs the best binary release package as the default option when building pytorch.

This should resolve the issue of needing a pre-installed aotriton package when building PyTorch for ROCm from source, which is not feasible if building PyTorch *outside* a CI docker image. With this change, a user can have a pre-installed AOTriton in their environment, if desired, and have the build pick it up by specifying the `AOTRITON_INSTALLED_PREFIX` env var, or have the build automatically detect and install the compatible version. As a third option, the user can also force AOTriton to build from source instead, using the `AOTRITON_INSTALL_FROM_SOURCE` env var.

Also, with the changes in this PR, the cmake build process handles the tasks of copying aotriton .so and images directory from `torch/lib` to the installation path.

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

Co-authored-by: Jithun Nair <[email protected]>
jithunnair-amd pushed a commit to ROCm/pytorch that referenced this pull request Feb 19, 2025
…pport

==========================================================================

Let aotriton.cmake detect the best binary package to use, and deprecate aotriton_version.txt (pytorch#137443)

We do not need `install_aotriton.sh` and `aotriton_version.txt` any more since `aotriton.cmake` now installs the best binary release package as the default option when building pytorch.

This should resolve the issue of needing a pre-installed aotriton package when building PyTorch for ROCm from source, which is not feasible if building PyTorch *outside* a CI docker image. With this change, a user can have a pre-installed AOTriton in their environment, if desired, and have the build pick it up by specifying the `AOTRITON_INSTALLED_PREFIX` env var, or have the build automatically detect and install the compatible version. As a third option, the user can also force AOTriton to build from source instead, using the `AOTRITON_INSTALL_FROM_SOURCE` env var.

Also, with the changes in this PR, the cmake build process handles the tasks of copying aotriton .so and images directory from `torch/lib` to the installation path.

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

Co-authored-by: Jithun Nair <[email protected]>
(cherry picked from commit bc57635)

Bump AOTriton to 0.8.2b (#1853)

Fixes SWDEV-508774

(cherry picked from commit 4bed249)

Enable head_dim == 512 with AOTriton 0.8.1

(cherry picked from commit 6edd36f)

Add unit tests for head dimension 512

(cherry picked from commit 85290fa)
jithunnair-amd pushed a commit to ROCm/pytorch that referenced this pull request Feb 20, 2025
…pport

==========================================================================

Let aotriton.cmake detect the best binary package to use, and deprecate aotriton_version.txt (pytorch#137443)

We do not need `install_aotriton.sh` and `aotriton_version.txt` any more since `aotriton.cmake` now installs the best binary release package as the default option when building pytorch.

This should resolve the issue of needing a pre-installed aotriton package when building PyTorch for ROCm from source, which is not feasible if building PyTorch *outside* a CI docker image. With this change, a user can have a pre-installed AOTriton in their environment, if desired, and have the build pick it up by specifying the `AOTRITON_INSTALLED_PREFIX` env var, or have the build automatically detect and install the compatible version. As a third option, the user can also force AOTriton to build from source instead, using the `AOTRITON_INSTALL_FROM_SOURCE` env var.

Also, with the changes in this PR, the cmake build process handles the tasks of copying aotriton .so and images directory from `torch/lib` to the installation path.

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

Co-authored-by: Jithun Nair <[email protected]>
(cherry picked from commit bc57635)

Bump AOTriton to 0.8.2b (#1853)

Fixes SWDEV-508774

(cherry picked from commit 4bed249)

Enable head_dim == 512 with AOTriton 0.8.1

(cherry picked from commit 6edd36f)

Add unit tests for head dimension 512

(cherry picked from commit 85290fa)
xinyazhang added a commit to ROCm/pytorch that referenced this pull request Jul 16, 2025
…te aotriton_version.txt (pytorch#137443)

We do not need `install_aotriton.sh` and `aotriton_version.txt` any more since `aotriton.cmake` now installs the best binary release package as the default option when building pytorch.

This should resolve the issue of needing a pre-installed aotriton package when building PyTorch for ROCm from source, which is not feasible if building PyTorch *outside* a CI docker image. With this change, a user can have a pre-installed AOTriton in their environment, if desired, and have the build pick it up by specifying the `AOTRITON_INSTALLED_PREFIX` env var, or have the build automatically detect and install the compatible version. As a third option, the user can also force AOTriton to build from source instead, using the `AOTRITON_INSTALL_FROM_SOURCE` env var.

Also, with the changes in this PR, the cmake build process handles the tasks of copying aotriton .so and images directory from `torch/lib` to the installation path.

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

Co-authored-by: Jithun Nair <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/binaries Trigger all binary build and upload jobs on the PR ciflow/rocm Trigger "default" config CI on ROCm Merged module: rocm AMD GPU support for Pytorch open source release notes: releng release notes category rocm This tag is for PRs from ROCm team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants