From 20a9d2fde0d39595a65e4f8be0d30acf898ed03c Mon Sep 17 00:00:00 2001 From: Wang Xin Date: Mon, 5 Jun 2023 17:46:27 +0800 Subject: [PATCH] third-party lib offline compilation support for mkldnn flashattn gtest (#54319) * third-party lib offline compilation support for mkldnn flashattn and gtest * fix bug * ignore dirty --- .gitmodules | 12 ++++++++++++ cmake/external/flashattn.cmake | 7 +++---- cmake/external/gtest.cmake | 14 ++++++-------- cmake/external/mkldnn.cmake | 7 +++---- third_party/flashattn | 1 + third_party/gtest | 1 + third_party/mkldnn | 1 + 7 files changed, 27 insertions(+), 16 deletions(-) create mode 160000 third_party/flashattn create mode 160000 third_party/gtest create mode 160000 third_party/mkldnn diff --git a/.gitmodules b/.gitmodules index 8c294e25bd6..67437e82e8e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -50,3 +50,15 @@ path = third_party/eigen3 url = https://gitlab.com/libeigen/eigen.git ignore = dirty +[submodule "third_party/mkldnn"] + path = third_party/mkldnn + url = https://github.com/oneapi-src/oneDNN.git + ignore = dirty +[submodule "third_party/flashattn"] + path = third_party/flashattn + url = https://github.com/PaddlePaddle/flash-attention.git + ignore = dirty +[submodule "third_party/gtest"] + path = third_party/gtest + url = https://github.com/google/googletest.git + ignore = dirty diff --git a/cmake/external/flashattn.cmake b/cmake/external/flashattn.cmake index 68957406756..b071f25dd4d 100644 --- a/cmake/external/flashattn.cmake +++ b/cmake/external/flashattn.cmake @@ -19,7 +19,7 @@ add_definitions(-DPADDLE_WITH_FLASHATTN) set(FLASHATTN_PREFIX_DIR ${THIRD_PARTY_PATH}/flashattn) set(FLASHATTN_SOURCE_SUBDIR csrc/flash_attn) set(FLASHATTN_INSTALL_DIR ${THIRD_PARTY_PATH}/install/flashattn) -set(FLASHATTN_REPOSITORY ${GIT_URL}/PaddlePaddle/flash-attention.git) +set(SOURCE_DIR ${PADDLE_SOURCE_DIR}/third_party/flashattn) set(FLASHATTN_TAG 18106c1ba0ccee81b97ca947397c08a141815a47) set(FLASHATTN_INCLUDE_DIR @@ -69,9 +69,8 @@ endif() ExternalProject_Add( extern_flashattn - ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE} - GIT_REPOSITORY ${FLASHATTN_REPOSITORY} - GIT_TAG ${FLASHATTN_TAG} + ${EXTERNAL_PROJECT_LOG_ARGS} + SOURCE_DIR ${SOURCE_DIR} PREFIX ${FLASHATTN_PREFIX_DIR} SOURCE_SUBDIR ${FLASHATTN_SOURCE_SUBDIR} UPDATE_COMMAND "" diff --git a/cmake/external/gtest.cmake b/cmake/external/gtest.cmake index 777d37a023f..f71e6e09b07 100644 --- a/cmake/external/gtest.cmake +++ b/cmake/external/gtest.cmake @@ -26,7 +26,7 @@ set(GTEST_INSTALL_DIR ${THIRD_PARTY_PATH}/install/gtest) set(GTEST_INCLUDE_DIR "${GTEST_INSTALL_DIR}/include" CACHE PATH "gtest include directory." FORCE) -set(GTEST_REPOSITORY ${GIT_URL}/google/googletest.git) +set(SOURCE_DIR ${PADDLE_SOURCE_DIR}/third_party/gtest) set(GTEST_TAG release-1.8.1) set(GTEST_SOURCE_DIR ${THIRD_PARTY_PATH}/gtest/src/extern_gtest) include_directories(${GTEST_INCLUDE_DIR}) @@ -69,14 +69,13 @@ if(NOT WIN32 AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 12.0) # See: [Why calling some `git` commands before `patch`?] set(GTEST_PATCH_COMMAND git checkout -- . && git checkout ${GTEST_TAG} && patch -Nd - ${GTEST_SOURCE_DIR}/googletest/src < ${native_src}) + ${SOURCE_DIR}/googletest/src < ${native_src}) endif() if(WIN32) ExternalProject_Add( extern_gtest - ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE} - GIT_REPOSITORY ${GTEST_REPOSITORY} - GIT_TAG ${GTEST_TAG} + ${EXTERNAL_PROJECT_LOG_ARGS} + SOURCE_DIR ${SOURCE_DIR} DEPENDS ${GTEST_DEPENDS} PREFIX ${GTEST_PREFIX_DIR} UPDATE_COMMAND "" @@ -106,9 +105,8 @@ if(WIN32) else() ExternalProject_Add( extern_gtest - ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE} - GIT_REPOSITORY ${GTEST_REPOSITORY} - GIT_TAG ${GTEST_TAG} + ${EXTERNAL_PROJECT_LOG_ARGS} + SOURCE_DIR ${SOURCE_DIR} DEPENDS ${GTEST_DEPENDS} PREFIX ${GTEST_PREFIX_DIR} UPDATE_COMMAND "" diff --git a/cmake/external/mkldnn.cmake b/cmake/external/mkldnn.cmake index 00a83a37893..03e66635f4c 100644 --- a/cmake/external/mkldnn.cmake +++ b/cmake/external/mkldnn.cmake @@ -20,7 +20,7 @@ set(MKLDNN_INSTALL_DIR ${THIRD_PARTY_PATH}/install/mkldnn) set(MKLDNN_INC_DIR "${MKLDNN_INSTALL_DIR}/include" CACHE PATH "mkldnn include directory." FORCE) -set(MKLDNN_REPOSITORY ${GIT_URL}/oneapi-src/oneDNN.git) +set(SOURCE_DIR ${PADDLE_SOURCE_DIR}/third_party/mkldnn) set(MKLDNN_TAG 2089770c4818be8933c5e9d1dd3cbaeba1457667) # Introduce variables: @@ -69,9 +69,8 @@ endif() ExternalProject_Add( ${MKLDNN_PROJECT} - ${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE} - GIT_REPOSITORY ${MKLDNN_REPOSITORY} - GIT_TAG ${MKLDNN_TAG} + ${EXTERNAL_PROJECT_LOG_ARGS} + SOURCE_DIR ${SOURCE_DIR} DEPENDS ${MKLDNN_DEPENDS} PREFIX ${MKLDNN_PREFIX_DIR} UPDATE_COMMAND "" diff --git a/third_party/flashattn b/third_party/flashattn new file mode 160000 index 00000000000..18106c1ba0c --- /dev/null +++ b/third_party/flashattn @@ -0,0 +1 @@ +Subproject commit 18106c1ba0ccee81b97ca947397c08a141815a47 diff --git a/third_party/gtest b/third_party/gtest new file mode 160000 index 00000000000..2fe3bd994b3 --- /dev/null +++ b/third_party/gtest @@ -0,0 +1 @@ +Subproject commit 2fe3bd994b3189899d93f1d5a881e725e046fdc2 diff --git a/third_party/mkldnn b/third_party/mkldnn new file mode 160000 index 00000000000..2089770c481 --- /dev/null +++ b/third_party/mkldnn @@ -0,0 +1 @@ +Subproject commit 2089770c4818be8933c5e9d1dd3cbaeba1457667 -- GitLab