diff --git a/.ci/docker/aotriton_version.txt b/.ci/docker/aotriton_version.txt deleted file mode 100644 index c26513b4301e5..0000000000000 --- a/.ci/docker/aotriton_version.txt +++ /dev/null @@ -1,5 +0,0 @@ -0.4.2b -manylinux_2_28 -rocm6.2 -99f540a954e80f446ec6980f108e8c25408f1823 -50f7d307356bca70928c4b4ac16ad94b0ae130478de51123f018f3588cd0b1f4 diff --git a/.ci/docker/centos-rocm/Dockerfile b/.ci/docker/centos-rocm/Dockerfile index 8e329985616d6..32ee138f4637d 100644 --- a/.ci/docker/centos-rocm/Dockerfile +++ b/.ci/docker/centos-rocm/Dockerfile @@ -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 diff --git a/.ci/docker/common/install_aotriton.sh b/.ci/docker/common/install_aotriton.sh deleted file mode 100755 index 8b340ee219de2..0000000000000 --- a/.ci/docker/common/install_aotriton.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -set -ex - -source "$(dirname "${BASH_SOURCE[0]}")/common_utils.sh" - -TARBALL='aotriton.tar.bz2' -# This read command alwasy returns with exit code 1 -read -d "\n" VER MANYLINUX ROCMBASE PINNED_COMMIT SHA256 < aotriton_version.txt || true -ARCH=$(uname -m) -AOTRITON_INSTALL_PREFIX="$1" -AOTRITON_URL="https://github.com/ROCm/aotriton/releases/download/${VER}/aotriton-${VER}-${MANYLINUX}_${ARCH}-${ROCMBASE}-shared.tar.bz2" - -cd "${AOTRITON_INSTALL_PREFIX}" -# Must use -L to follow redirects -curl -L --retry 3 -o "${TARBALL}" "${AOTRITON_URL}" -ACTUAL_SHA256=$(sha256sum "${TARBALL}" | cut -d " " -f 1) -if [ "${SHA256}" != "${ACTUAL_SHA256}" ]; then - echo -n "Error: The SHA256 of downloaded tarball is ${ACTUAL_SHA256}," - echo " which does not match the expected value ${SHA256}." - exit -fi -tar xf "${TARBALL}" && rm -rf "${TARBALL}" diff --git a/.ci/docker/ubuntu-rocm/Dockerfile b/.ci/docker/ubuntu-rocm/Dockerfile index 3c5e42199cd41..aefa3a5b7501f 100644 --- a/.ci/docker/ubuntu-rocm/Dockerfile +++ b/.ci/docker/ubuntu-rocm/Dockerfile @@ -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 diff --git a/cmake/External/aotriton.cmake b/cmake/External/aotriton.cmake index 18615b2c6aea0..d26dcc9103805 100644 --- a/cmake/External/aotriton.cmake +++ b/cmake/External/aotriton.cmake @@ -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)