-
Notifications
You must be signed in to change notification settings - Fork 34
Update QoLA/AITER #599
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
base: dev
Are you sure you want to change the base?
Update QoLA/AITER #599
Changes from 14 commits
d89f90f
312212f
89f6983
c417e40
90e3a5a
c7ecaf7
da6e9a6
e7ed124
6241f99
82ebdb6
68a2eaf
f9ab59c
fec80b8
6eb3b23
8fd79f9
ab68ca9
f521ef0
e5ebe9c
c08548e
292870e
3476f53
79c400d
3a98eda
bb0797a
bf2ae3c
8a91a58
679283a
948c077
eaa860d
48e73b2
9172b4b
485ba06
fe94903
eaf3cce
2411723
9860a92
6a23ce3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| +1 −0 | .github/CODEOWNERS | |
| +11 −0 | .gitignore | |
| +0 −3 | .gitmodules | |
| +0 −1 | 3rdparty/aiter | |
| +27 −6 | CLAUDE.md | |
| +196 −0 | LICENSE | |
| +56 −8 | README.md | |
| +6 −1 | example/te-manifest.toml | |
| +41 −0 | patches/aiter/0001-jit-gpu-targets.patch | |
| +101 −0 | patches/aiter/0002-hsa-only-aiter-hip-common.patch | |
| +114 −0 | patches/aiter/0003-ck-te-receipt-700.patch | |
| +42 −0 | patches/aiter/README.md | |
| +2 −1 | qola/build_tools/__init__.py | |
| +29 −3 | qola/build_tools/builder.py | |
| +60 −3 | qola/build_tools/config.py | |
| +244 −0 | qola/build_tools/submodule.py | |
| +70 −2 | qola/cli.py | |
| +28 −4 | qola/cpp_itfs/registry.toml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,34 +22,56 @@ if(NOT _gfx1250_idx EQUAL -1) | |
| endif() | ||
| set(GPU_TARGETS ${CMAKE_HIP_ARCHITECTURES}) | ||
| endif() | ||
| set(__AITER_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../3rdparty/QoLA/3rdparty/aiter") | ||
| set(__QOLA_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../3rdparty/QoLA") | ||
| set(__AITER_SOURCE_DIR "${__QOLA_DIR}/build/third_party/aiter") | ||
| set(__CK_SOURCE_DIR "${__AITER_SOURCE_DIR}/3rdparty/composable_kernel") | ||
|
|
||
| set(CK_INCLUDE_DIR "${__CK_SOURCE_DIR}/include") | ||
| message(STATUS "ck_include_dir: ${CK_INCLUDE_DIR}") | ||
| if(NOT EXISTS "${CK_INCLUDE_DIR}") | ||
| message(FATAL_ERROR | ||
| "Could not find CK API. " | ||
| "Try running 'git submodule update --init --recursive' " | ||
| "within the Transformer Engine source.") | ||
| endif() | ||
|
|
||
| set(AITER_INCLUDE_DIR "${__AITER_SOURCE_DIR}/csrc/include") | ||
| message(STATUS "aiter_include_dir: ${AITER_INCLUDE_DIR}") | ||
| if(NOT EXISTS "${AITER_INCLUDE_DIR}") | ||
| message(FATAL_ERROR | ||
| "Could not find AITER API. " | ||
| "Try running 'git submodule update --init --recursive' " | ||
| "within the Transformer Engine source.") | ||
| endif() | ||
|
|
||
| if(NOT Python_EXECUTABLE) | ||
| find_package(Python COMPONENTS Interpreter QUIET) | ||
| endif() | ||
|
|
||
| # Resolve the manifest-pinned AITER commit (defines AITER_SHA) and bring the | ||
| # QoLA-managed AITER source tree to that commit before any consumer reads it | ||
| # (header validation below, header includes for the .cpp build later, and | ||
| # QoLA's own kernel build if the prebuilt cache misses). | ||
| include("${CMAKE_CURRENT_LIST_DIR}/aiter_prebuilt.cmake") | ||
|
|
||
| if(Python_EXECUTABLE) | ||
| set(__QOLA_MANIFEST "${CMAKE_CURRENT_LIST_DIR}/qola_manifest.toml") | ||
| # Redirect GIT_CONFIG_GLOBAL to a tempfile carrying `safe.directory = *` so | ||
| # git operations inside the QoLA-managed AITER tree (and its recursive | ||
| # submodules) work in containerized builds where the bind-mounted .git is | ||
| # owned by a different UID than the build process. Mirrors the pattern in | ||
| # transformer_engine/common/CMakeLists.txt:get_git_commit(). | ||
| execute_process( | ||
| COMMAND sh -c | ||
| "tmp=$(mktemp /tmp/gitconfig.XXXXXX) || exit 1; \ | ||
| GIT_CONFIG_GLOBAL=$tmp git config --global --add safe.directory '*' >/dev/null 2>&1; \ | ||
| GIT_CONFIG_GLOBAL=$tmp PYTHONPATH=\"${__QOLA_DIR}:$PYTHONPATH\" '${Python_EXECUTABLE}' -m qola.cli checkout \ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it make sense to integrate safe.directory overriding to qola? The pattern with dubious ownership is probably not TE specific
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I worry that such behavior is a bit too authoritative for qola if that makes sense? My reasoning is that the permission scope here seems to be outside of qola and hence qola should not be the one in charge of it. I'm open to reconsidering that, but it's just my initial position.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is valid concern bearing in mind QoLA is intended to be reused by different components. May be make this behavior controllable then. It is OK to keep the things in TE, it will just require doing things this overriding twice - here and when build is called - BTW, there are comments there but not actual code change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good, but can we do that in a separate PR to QoLA first?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now, with qola expected to create aiter dir runtime (it is not a part of repository tree), is there a reason to modify git config safe.directory? It was added for specific case: repository tree is checked out by a user and then shared with a container run with another user credentials. |
||
| --manifest '${__QOLA_MANIFEST}' \ | ||
| --aiter-root '${__AITER_SOURCE_DIR}'; \ | ||
| rc=$?; rm -f \"$tmp\"; exit $rc" | ||
| RESULT_VARIABLE AITER_CHECKOUT_RESULT | ||
| OUTPUT_VARIABLE AITER_CHECKOUT_OUTPUT | ||
| ERROR_VARIABLE AITER_CHECKOUT_ERROR | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| ERROR_STRIP_TRAILING_WHITESPACE | ||
| ) | ||
| if(NOT AITER_CHECKOUT_RESULT EQUAL 0) | ||
| message(FATAL_ERROR | ||
| "Failed to sync AITER source tree at ${__AITER_SOURCE_DIR} to " | ||
| "manifest-pinned commit ${AITER_SHA}.\n" | ||
|
ipanfilo marked this conversation as resolved.
|
||
| "${AITER_CHECKOUT_OUTPUT}\n${AITER_CHECKOUT_ERROR}") | ||
| endif() | ||
| message(STATUS "[AITER] Synced ${__AITER_SOURCE_DIR} to ${AITER_SHA}") | ||
|
|
||
| execute_process( | ||
| COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/check_aiter_mha_args.py --mode both --te-dir "${CMAKE_CURRENT_LIST_DIR}/../../.." | ||
| COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/check_aiter_mha_args.py | ||
| --mode both | ||
| --te-dir "${CMAKE_CURRENT_LIST_DIR}/../../.." | ||
| --aiter-root "${__AITER_SOURCE_DIR}" | ||
| RESULT_VARIABLE AITER_ARG_CHECK_RESULT | ||
| OUTPUT_VARIABLE AITER_ARG_CHECK_OUTPUT | ||
| ERROR_VARIABLE AITER_ARG_CHECK_ERROR | ||
|
|
@@ -64,7 +86,24 @@ if(Python_EXECUTABLE) | |
| endif() | ||
| message(STATUS "AITER API validation passed via check_aiter_mha_args.py") | ||
| else() | ||
| message(WARNING "Python interpreter not found; skipping AITER API validation.") | ||
| message(WARNING "Python interpreter not found; skipping AITER source-tree sync and API validation.") | ||
|
ipanfilo marked this conversation as resolved.
Outdated
|
||
| endif() | ||
|
|
||
| # Sanity-check the resolved include directories now that `qola checkout` has | ||
| # materialized the AITER tree. | ||
| message(STATUS "ck_include_dir: ${CK_INCLUDE_DIR}") | ||
| if(NOT EXISTS "${CK_INCLUDE_DIR}") | ||
| message(FATAL_ERROR | ||
| "Could not find CK API at ${CK_INCLUDE_DIR}. " | ||
| "Re-run the build to let `qola checkout` clone AITER and its " | ||
| "composable_kernel submodule.") | ||
| endif() | ||
|
|
||
| message(STATUS "aiter_include_dir: ${AITER_INCLUDE_DIR}") | ||
| if(NOT EXISTS "${AITER_INCLUDE_DIR}") | ||
| message(FATAL_ERROR | ||
| "Could not find AITER API at ${AITER_INCLUDE_DIR}. " | ||
| "Re-run the build to let `qola checkout` clone AITER.") | ||
| endif() | ||
|
|
||
| if(DEFINED AITER_MHA_PATH) | ||
|
|
@@ -73,16 +112,16 @@ if(DEFINED AITER_MHA_PATH) | |
| set(__AITER_MHA_PATH ${AITER_MHA_PATH}) | ||
| else() | ||
| set(__AITER_MHA_PATH "") | ||
| include("${CMAKE_CURRENT_LIST_DIR}/aiter_prebuilt.cmake") | ||
| get_prebuilt_aiter(__AITER_MHA_PATH) | ||
|
|
||
| if(__AITER_MHA_PATH STREQUAL "") | ||
| # If not available, fallback: Build from source via QoLA | ||
| list(JOIN CMAKE_HIP_ARCHITECTURES ";" GPU_ARCHS_STR) | ||
| message(STATUS "[AITER-BUILD] Building AITER kernels for ${GPU_ARCHS_STR} via QoLA.") | ||
| set(__QOLA_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../3rdparty/QoLA") | ||
| set(__QOLA_BUILD_DIR "${__QOLA_DIR}/build") | ||
| set(__QOLA_MANIFEST "${CMAKE_CURRENT_LIST_DIR}/qola_manifest.toml") | ||
| # Same GIT_CONFIG_GLOBAL trick as the earlier `qola.cli checkout` call: | ||
| # `qola.cli build` re-invokes ensure_aiter_commit internally and will hit | ||
| # the same dubious-ownership trap without it. | ||
| execute_process( | ||
| COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${__QOLA_DIR}:$ENV{PYTHONPATH}" | ||
| ${Python_EXECUTABLE} -m qola.cli build | ||
|
|
@@ -124,7 +163,8 @@ endforeach() | |
| add_library(ck_fused_attn SHARED ${ck_fused_attn_SOURCES}) | ||
| set(CK_FUSED_ATTN_COMPILE_OPTIONS) | ||
| list(APPEND CK_FUSED_ATTN_COMPILE_OPTIONS | ||
| -DCK_TILE_FLOAT_TO_BFLOAT16_DEFAULT=${CK_FUSED_ATTN_FLOAT_TO_BFLOAT16_DEFAULT}) | ||
| -DCK_TILE_FLOAT_TO_BFLOAT16_DEFAULT=${CK_FUSED_ATTN_FLOAT_TO_BFLOAT16_DEFAULT} | ||
| -DENABLE_CK=1) | ||
|
|
||
| # Public QoLA headers ship alongside the .so libs in ${__AITER_MHA_PATH}/../include | ||
| # (emitted by qola.cli build, or copied from the QoLA build dir above for the | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,8 +18,22 @@ string(STRIP "${ROCM_VER_CONTENT}" ROCM_VER_CONTENT) | |
| string(REGEX MATCH "^[0-9]+\\.[0-9]+" ROCM_VER "${ROCM_VER_CONTENT}") | ||
| string(REGEX MATCH "^[0-9]+" ROCM_VER_MAJOR "${ROCM_VER}") | ||
|
|
||
| # AITER commit | ||
| get_git_commit("${__AITER_SOURCE_DIR}" AITER_SHA) | ||
| # AITER commit — read from the QoLA manifest so the cache key tracks the | ||
| # commit QoLA will actually check out and build, not whatever happens to be | ||
| # the submodule's current HEAD at configure time. | ||
| set(__QOLA_MANIFEST "${CMAKE_CURRENT_LIST_DIR}/qola_manifest.toml") | ||
| set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${__QOLA_MANIFEST}") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AITER_SHA is not cached variable. Why is CMAKE_CONFIGURE_DEPENDS needed?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mainly have it so that direct
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will it also trigger re-executing of QoLA cli in the parent (ck_used_attn/ ) CMAkeLists.txt? |
||
| file(STRINGS "${__QOLA_MANIFEST}" __AITER_COMMIT_LINES | ||
| REGEX "^[ \t]*aiter_commit[ \t]*=[ \t]*\"[^\"]+\"") | ||
| list(LENGTH __AITER_COMMIT_LINES __AITER_COMMIT_COUNT) | ||
| if(NOT __AITER_COMMIT_COUNT EQUAL 1) | ||
| message(FATAL_ERROR | ||
| "Expected exactly one 'aiter_commit = \"...\"' line in " | ||
| "${__QOLA_MANIFEST}, found ${__AITER_COMMIT_COUNT}.") | ||
| endif() | ||
| list(GET __AITER_COMMIT_LINES 0 __AITER_COMMIT_LINE) | ||
| string(REGEX MATCH "\"([^\"]+)\"" _UNUSED "${__AITER_COMMIT_LINE}") | ||
| set(AITER_SHA "${CMAKE_MATCH_1}") | ||
|
|
||
| # Cache key & local paths | ||
| set(AITER_CACHE_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../../build/aiter-prebuilts") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not needed here - AITER_SHA is determined above, cache directory is only needed if neither AITER_MHA_PATH is set nor CK-JIT is enabled, so it is included at line 158