Skip to content

Commit

Permalink
AOTriton: download binary from github, NO BUILD FROM SOURCE option
Browse files Browse the repository at this point in the history
    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
  • Loading branch information
jithunnair-amd committed Oct 8, 2024
1 parent dba6ce9 commit 94e2aab
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 59 deletions.
5 changes: 0 additions & 5 deletions .ci/docker/aotriton_version.txt

This file was deleted.

6 changes: 0 additions & 6 deletions .ci/docker/centos-rocm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,6 @@ COPY triton_version.txt triton_version.txt
RUN if [ -n "${TRITON}" ]; then bash ./install_triton.sh; fi
RUN rm install_triton.sh common_utils.sh triton-rocm.txt triton_version.txt

COPY ./aotriton_version.txt aotriton_version.txt
COPY ./common/common_utils.sh common_utils.sh
COPY ./common/install_aotriton.sh install_aotriton.sh
RUN ["/bin/bash", "-c", "./install_aotriton.sh /opt/rocm && rm -rf install_aotriton.sh aotriton_version.txt common_utils.sh"]
ENV AOTRITON_INSTALLED_PREFIX /opt/rocm/aotriton

# Install ccache/sccache (do this last, so we get priority in PATH)
COPY ./common/install_cache.sh install_cache.sh
ENV PATH /opt/cache/bin:$PATH
Expand Down
23 changes: 0 additions & 23 deletions .ci/docker/common/install_aotriton.sh

This file was deleted.

6 changes: 0 additions & 6 deletions .ci/docker/ubuntu-rocm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,6 @@ COPY triton_version.txt triton_version.txt
RUN if [ -n "${TRITON}" ]; then bash ./install_triton.sh; fi
RUN rm install_triton.sh common_utils.sh triton-rocm.txt triton_version.txt

COPY ./aotriton_version.txt aotriton_version.txt
COPY ./common/common_utils.sh common_utils.sh
COPY ./common/install_aotriton.sh install_aotriton.sh
RUN ["/bin/bash", "-c", "./install_aotriton.sh /opt/rocm && rm -rf install_aotriton.sh aotriton_version.txt common_utils.sh"]
ENV AOTRITON_INSTALLED_PREFIX /opt/rocm/aotriton

# Install ccache/sccache (do this last, so we get priority in PATH)
COPY ./common/install_cache.sh install_cache.sh
ENV PATH /opt/cache/bin:$PATH
Expand Down
76 changes: 57 additions & 19 deletions cmake/External/aotriton.cmake
Original file line number Diff line number Diff line change
@@ -1,35 +1,73 @@
if(NOT __AOTRITON_INCLUDED)
set(__AOTRITON_INCLUDED TRUE)

set(__AOTRITON_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/aotriton/src")
set(__AOTRITON_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/aotriton/build")
set(__AOTRITON_EXTERN_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/aotriton")
set(__AOTRITON_INSTALL_DIR "${PROJECT_SOURCE_DIR}/torch")
add_library(__caffe2_aotriton INTERFACE)

# AOTriton package information from GitHub Release Pages
# Replaces .ci/docker/aotriton_version.txt
set(__AOTRITON_VER "0.4.2b")
list(JOIN
"manylinux_2_28" # rocm6.2
";"
__AOTRITON_MANYLINUX_LIST)
list(JOIN
"rocm6.2"
";"
__AOTRITON_ROCM_LIST)
set(__AOTRITON_CI_COMMIT "99f540a954e80f446ec6980f108e8c25408f1823")
list(JOIN
"50f7d307356bca70928c4b4ac16ad94b0ae130478de51123f018f3588cd0b1f4" # rocm6.2
";"
__AOTRITON_SHA256_LIST)
set(__AOTRITON_Z "bz2")

# Note it is INSTALL"ED"
if(DEFINED ENV{AOTRITON_INSTALLED_PREFIX})
install(DIRECTORY
$ENV{AOTRITON_INSTALLED_PREFIX}/lib
$ENV{AOTRITON_INSTALLED_PREFIX}/include
DESTINATION ${__AOTRITON_INSTALL_DIR})
set(__AOTRITON_INSTALL_DIR "$ENV{AOTRITON_INSTALLED_PREFIX}")
message(STATUS "Using Preinstalled AOTriton at ${__AOTRITON_INSTALL_DIR}")
else()
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/.ci/docker/aotriton_version.txt" __AOTRITON_CI_INFO)
list(GET __AOTRITON_CI_INFO 3 __AOTRITON_CI_COMMIT)
list(GET __AOTRITON_ROCM_LIST 0 __AOTRITON_ROCM_LOW_STR)
list(GET __AOTRITON_ROCM_LIST -1 __AOTRITON_ROCM_HIGH_STR)
# len("rocm") == 4
string(SUBSTRING ${__AOTRITON_ROCM_LOW_STR} 4 -1 __AOTRITON_ROCM_LOW)
string(SUBSTRING ${__AOTRITON_ROCM_HIGH_STR} 4 -1 __AOTRITON_ROCM_HIGH)
set(__AOTRITON_SYSTEM_ROCM "${ROCM_VERSION_DEV_MAJOR}.${ROCM_VERSION_DEV_MINOR}")
if(__AOTRITON_SYSTEM_ROCM VERSION_LESS __AOTRITON_ROCM_LOW)
set(__AOTRITON_ROCM ${__AOTRITON_ROCM_LOW})
elseif(__AOTRITON_SYSTEM_ROCM VERSION_GREATER __AOTRITON_ROCM_HIGH)
set(__AOTRITON_ROCM ${__AOTRITON_ROCM_HIGH})
else()
set(__AOTRITON_ROCM ${__AOTRITON_SYSTEM_ROCM})
endif()
list(FIND __AOTRITON_ROCM_LIST "rocm${__AOTRITON_ROCM}" __AOTRITON_ROCM_INDEX)
list(GET __AOTRITON_SHA256_LIST ${__AOTRITON_ROCM_INDEX} __AOTRITON_SHA256)
list(GET __AOTRITON_MANYLINUX_LIST ${__AOTRITON_ROCM_INDEX} __AOTRITON_MANYLINUX)
set(__AOTRITON_ARCH ${CMAKE_HOST_SYSTEM_PROCESSOR})
string(CONCAT __AOTRITON_FILE "aotriton-"
"${__AOTRITON_VER}-${__AOTRITON_MANYLINUX}"
"_${__AOTRITON_ARCH}-rocm${__AOTRITON_ROCM}"
"-shared.tar.${__AOTRITON_Z}")
string(CONCAT __AOTRITON_URL "https://github.com/ROCm/aotriton/releases/download/"
"${__AOTRITON_VER}/${__AOTRITON_FILE}")
ExternalProject_Add(aotriton_external
GIT_REPOSITORY https://github.com/ROCm/aotriton.git
GIT_TAG ${__AOTRITON_CI_COMMIT}
SOURCE_DIR ${__AOTRITON_SOURCE_DIR}
BINARY_DIR ${__AOTRITON_BUILD_DIR}
PREFIX ${__AOTRITON_INSTALL_DIR}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${__AOTRITON_INSTALL_DIR}
-DAOTRITON_COMPRESS_KERNEL=OFF
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DAOTRITON_NO_PYTHON=ON
-DAOTRITON_NO_SHARED=OFF
# CONFIGURE_COMMAND ""
# BUILD_COMMAND ${MAKE_COMMAND}
URL "${__AOTRITON_URL}"
URL_HASH SHA256=${__AOTRITON_SHA256}
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/aotriton_tarball
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory
"${CMAKE_CURRENT_BINARY_DIR}/aotriton_tarball"
"${__AOTRITON_INSTALL_DIR}"
BUILD_BYPRODUCTS "${__AOTRITON_INSTALL_DIR}/lib/libaotriton_v2.so"
# INSTALL_COMMAND ${MAKE_COMMAND} install
)
)
add_dependencies(__caffe2_aotriton aotriton_external)
message(STATUS "Using AOTriton compiled from source directory ${__AOTRITON_SOURCE_DIR}")
message(STATUS "Using AOTriton from pre-compiled binary ${__AOTRITON_URL}")
endif()
target_link_libraries(__caffe2_aotriton INTERFACE ${__AOTRITON_INSTALL_DIR}/lib/libaotriton_v2.so)
target_include_directories(__caffe2_aotriton INTERFACE ${__AOTRITON_INSTALL_DIR}/include)
Expand Down

0 comments on commit 94e2aab

Please sign in to comment.