-
Notifications
You must be signed in to change notification settings - Fork 23
Update build system for AOTriton 0.11b and upgrade FWD call to V3 API
#360
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
Open
Micky774
wants to merge
14
commits into
dev
Choose a base branch
from
zain/aotriton
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+205
−81
Open
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d10fa92
Initial commit
Micky774 eef7dc0
Updated to build from source by default
Micky774 cc68ab7
Updated for V3 API
Micky774 4455361
Fixed build, reverted AOTriton bwd changes (now V2)
Micky774 2586b18
Removed alterations
Micky774 aa80f81
Removed lazy tensor wrapper
Micky774 9a91b9e
Streamlined cmakelist, other PR review feedback adressed
Micky774 023deb4
Removed `pad_between_seqs`
Micky774 6b8dbe5
Updated typing to be more explicit
Micky774 68303d0
Minor streamlining and formatting
Micky774 6788a16
Simplified window size func for current non-SWA support
Micky774 182101a
Removed accidental include
Micky774 917e3c3
Updated window values for causal
Micky774 d6e46c1
Update AOTriton to 0.11.1b
Micky774 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -278,67 +278,116 @@ else() | |
| set(GPU_TARGETS ${CMAKE_HIP_ARCHITECTURES}) | ||
|
|
||
| if(USE_FUSED_ATTN_AOTRITON) | ||
| # This is for GPU kernel downloading | ||
| # The AOTriton C++ runtime will be built from ../../3rdparty/aotriton | ||
| # Hence there is no need to add multiple ROCM version here | ||
|
|
||
| set(__AOTRITON_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/aotriton") | ||
| set(__AOTRITON_SUFFIX "_TEprivate") | ||
|
|
||
| if(NOT DEFINED AOTRITON_PATH) | ||
| # Install aotriton fused attn | ||
| # If AOTRITON_PATH is not provided, we proceed to build the runtime | ||
| # ourselves and either build or download the GPU kernels | ||
| if(USE_FUSED_ATTN_AOTRITON_BUILD_GPU_KERNELS) | ||
| set(AOTRITON_NOIMAGE_MODE OFF) | ||
| else() | ||
| set(AOTRITON_NOIMAGE_MODE ON) | ||
| endif() | ||
|
|
||
| string(REPLACE ";" "," ARCH_LIST_COMMA_STR "${CMAKE_HIP_ARCHITECTURES}") | ||
| set(__AOTRITON_VER "0.11b") | ||
| set(__AOTRITON_IMAGE_LIST | ||
| "amd-gfx942" | ||
| "amd-gfx950" | ||
| ) | ||
| set(__AOTRITON_IMAGE_SHA256_LIST | ||
| "3a06a99971dddb7703a30378f1c5d6b41468d926ea51821156d1b6857b985bc4" # amd-gfx942 | ||
| "27fc21f6761d57987a700436de8cf29cbdd9eeee91318dfed596eeb147d219ad" # amd-gfx950 | ||
|
||
| ) | ||
| set(__AOTRITON_BASE_URL "https://github.com/ROCm/aotriton/releases/download/") # @lint-ignore | ||
| include(ExternalProject) | ||
| ExternalProject_Add(aotriton_external | ||
| LIST_SEPARATOR "," | ||
| SOURCE_DIR ${TE}/3rdparty/aotriton | ||
| CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${__AOTRITON_INSTALL_DIR} | ||
| -DAOTRITON_TARGET_ARCH=${ARCH_LIST_COMMA_STR} | ||
| -DGPU_TARGETS=${ARCH_LIST_COMMA_STR} | ||
| -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} | ||
| -DAOTRITON_NO_PYTHON=ON | ||
| -DAOTRITON_NAME_SUFFIX=${__AOTRITON_SUFFIX} | ||
| -DAOTRITON_NOIMAGE_MODE=${AOTRITON_NOIMAGE_MODE} | ||
| BUILD_BYPRODUCTS "${__AOTRITON_INSTALL_DIR}/lib/libaotriton${__AOTRITON_SUFFIX}_v2.so" | ||
|
|
||
| # Download GPU kernels for a specific target | ||
| function(aotriton_download_image image project) | ||
| list(FIND __AOTRITON_IMAGE_LIST ${image} index) | ||
| list(GET __AOTRITON_IMAGE_SHA256_LIST ${index} __AOTRITON_IMAGE_SHA256) | ||
|
|
||
| string(CONCAT __AOTRITON_FILE | ||
| "aotriton-${__AOTRITON_VER}-images-" | ||
| "${image}.tar.gz") | ||
| string(CONCAT __AOTRITON_URL | ||
| "${__AOTRITON_BASE_URL}" | ||
| "${__AOTRITON_VER}/${__AOTRITON_FILE}") | ||
|
|
||
| # Set up directories | ||
| set(__AOTRITON_DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/aotriton/download/${image}) | ||
| set(__AOTRITON_EXTRACT_DIR ${CMAKE_CURRENT_BINARY_DIR}/aotriton/image/${image}) | ||
|
|
||
| ExternalProject_Add(${project} | ||
| URL "${__AOTRITON_URL}" | ||
| URL_HASH SHA256=${__AOTRITON_IMAGE_SHA256} | ||
| DOWNLOAD_DIR ${__AOTRITON_DOWNLOAD_DIR} | ||
| SOURCE_DIR ${__AOTRITON_EXTRACT_DIR} | ||
| CONFIGURE_COMMAND "" | ||
| BUILD_COMMAND "" | ||
| INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory | ||
| "${__AOTRITON_EXTRACT_DIR}" | ||
| "${__AOTRITON_INSTALL_DIR}" | ||
| BUILD_BYPRODUCTS | ||
| "${__AOTRITON_INSTALL_DIR}/lib/aotriton.images/${image}/__signature__" | ||
ipanfilo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
| message(STATUS "Download AOTriton pre-compiled GPU images from ${__AOTRITON_URL}.") | ||
| endfunction() | ||
|
|
||
| # Build the AOTriton runtime from source with custom suffix to avoid | ||
| # potential conflict with libaotriton as provided by PyTorch | ||
| function(aotriton_build_from_source noimage) | ||
| message(STATUS "No-image mode: ${noimage}.") | ||
| ExternalProject_Add(aotriton_external | ||
| LIST_SEPARATOR "," | ||
| SOURCE_DIR ${TE}/3rdparty/aotriton | ||
| CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${__AOTRITON_INSTALL_DIR} | ||
| -DAOTRITON_TARGET_ARCH=${ARCH_LIST_COMMA_STR} | ||
| -DGPU_TARGETS=${ARCH_LIST_COMMA_STR} | ||
| -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} | ||
| -DAOTRITON_NO_PYTHON=ON | ||
| -DAOTRITON_NAME_SUFFIX=${__AOTRITON_SUFFIX} | ||
| -DAOTRITON_NOIMAGE_MODE=${noimage} | ||
| BUILD_BYPRODUCTS "${__AOTRITON_INSTALL_DIR}/lib/libaotriton${__AOTRITON_SUFFIX}_v2.so" | ||
| ) | ||
| message(STATUS "Adding AOTriton library.") | ||
| add_dependencies(aotriton aotriton_external) | ||
| target_link_libraries(aotriton INTERFACE ${__AOTRITON_INSTALL_DIR}/lib/libaotriton${__AOTRITON_SUFFIX}_v2.so) | ||
| target_include_directories(aotriton INTERFACE ${__AOTRITON_INSTALL_DIR}/include) | ||
| install(DIRECTORY | ||
| ${__AOTRITON_INSTALL_DIR}/lib | ||
| DESTINATION ${CMAKE_INSTALL_PREFIX}/transformer_engine | ||
| PATTERN "cmake" EXCLUDE | ||
| ) | ||
| endfunction() | ||
|
|
||
| add_library(aotriton INTERFACE) | ||
| add_dependencies(aotriton aotriton_external) | ||
| target_link_libraries(aotriton INTERFACE ${__AOTRITON_INSTALL_DIR}/lib/libaotriton${__AOTRITON_SUFFIX}_v2.so) | ||
| target_include_directories(aotriton INTERFACE ${__AOTRITON_INSTALL_DIR}/include) | ||
| message(STATUS "Building AOTriton from source.") | ||
| string(REPLACE ";" "," ARCH_LIST_COMMA_STR "${CMAKE_HIP_ARCHITECTURES}") | ||
| aotriton_build_from_source(${AOTRITON_NOIMAGE_MODE}) | ||
|
|
||
| # Download GPU kernels if needed | ||
| if(NOT USE_FUSED_ATTN_AOTRITON_BUILD_GPU_KERNELS) | ||
| set(__AOTRITON_VER "0.10b") | ||
| set(__AOTRITON_SHA256 "1e9b3dddf0c7fc07131c6f0f5266129e83ce2331f459fa2be8c63f4ae91b0f5b") | ||
| string(CONCAT __AOTRITON_URL "https://github.com/ROCm/aotriton/releases/download/" | ||
| "${__AOTRITON_VER}/aotriton-" | ||
| "${__AOTRITON_VER}-manylinux_2_28" | ||
| "_x86_64-rocm7.0" | ||
| "-shared.tar.gz") | ||
| set(aotriton_image_dirs) | ||
| foreach(X IN LISTS CMAKE_HIP_ARCHITECTURES) | ||
| list(APPEND aotriton_image_dirs "${CMAKE_CURRENT_BINARY_DIR}/aotriton_tarball/lib/aotriton.images/amd-${X}") | ||
| message(STATUS "Downloading AOTriton GPU Kernels.") | ||
| foreach(image ${__AOTRITON_IMAGE_LIST}) | ||
| string(SUBSTRING ${image} 7 -1 gfx_pattern) | ||
| string(REPLACE "x" "." gfx_regex ${gfx_pattern}) | ||
ipanfilo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| foreach(target ${ARCH_LIST_COMMA_STR}) | ||
| if(target MATCHES ${gfx_regex}) | ||
| message(STATUS "Downloading AOTriton image ${image}.") | ||
| set(__AOTRITON_DOWNLOAD_TARGET aotriton_image_${gfx_pattern}) | ||
| aotriton_download_image(${image} ${__AOTRITON_DOWNLOAD_TARGET}) | ||
| add_dependencies(aotriton_external ${__AOTRITON_DOWNLOAD_TARGET}) | ||
| break() | ||
| endif() | ||
| endforeach() | ||
| endforeach() | ||
| set(aotriton_lib_install_dir "${__AOTRITON_INSTALL_DIR}/lib/aotriton.images") | ||
| file(REMOVE_RECURSE ${aotriton_lib_install_dir}) | ||
| file(MAKE_DIRECTORY ${aotriton_lib_install_dir}) | ||
| ExternalProject_Add(aotriton_images | ||
| URL "${__AOTRITON_URL}" | ||
| URL_HASH SHA256=${__AOTRITON_SHA256} | ||
| SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/aotriton_tarball | ||
| CONFIGURE_COMMAND "" | ||
| BUILD_COMMAND "" | ||
| BUILD_ALWAYS TRUE | ||
| INSTALL_COMMAND cp -Ra ${aotriton_image_dirs} ${aotriton_lib_install_dir}) | ||
| add_dependencies(aotriton aotriton_images) | ||
| else() | ||
| endif() | ||
| install(DIRECTORY | ||
| ${__AOTRITON_INSTALL_DIR}/lib | ||
| DESTINATION ${CMAKE_INSTALL_PREFIX}/transformer_engine | ||
| PATTERN "cmake" EXCLUDE | ||
| PATTERN "libaotriton${__AOTRITON_SUFFIX}_v2.so" EXCLUDE) | ||
|
|
||
| else() | ||
| # Use aotriton built during initial TE building/installation | ||
| # When only need rebuild TE library itself | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.