Skip to content

Commit

Permalink
Merge branch 'develop' into add_pd_op
Browse files Browse the repository at this point in the history
  • Loading branch information
PolaKuma authored Dec 11, 2024
2 parents 95d254c + 461fbd1 commit 9a82b0e
Show file tree
Hide file tree
Showing 1,549 changed files with 24,037 additions and 13,373 deletions.
84 changes: 6 additions & 78 deletions _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ extend-exclude = [
anc = 'anc'
arange = "arange"
astroid = 'astroid'
ba = 'ba'
cacl = 'cacl'
CANN = 'CANN'
Clas = 'Clas'
clen = 'clen'
cll = 'cll'
dout = "dout"
eles = 'eles'
grad = "grad"
Expand All @@ -24,84 +30,17 @@ UE = "UE"
unpacket = "unpacket"

# These words need to be fixed
Acceses = 'Acceses'
accessable = 'accessable'
accesss = 'accesss'
accoding = 'accoding'
accurary = 'accurary'
Accuarcy = 'Accuarcy'
actived = 'actived'
acitve = 'acitve'
actualy = 'actualy'
actural = 'actural'
Actural = 'Actural'
assigend = 'assigend'
assined = 'assined'
assgin = 'assgin'
axises = 'axises'
Axises = 'Axises'
aixs = 'aixs'
beacuse = 'beacuse'
becasue = 'becasue'
Becasue = 'Becasue'
becuase = 'becuase'
blokc = 'blokc'
blcok = 'blcok'
bootom = 'bootom'
bondary = 'bondary'
branchs = 'branchs'
Broardcast = 'Broardcast'
Bradcast = 'Bradcast'
Boardcast = 'Boardcast'
Buitin = 'Buitin'
buitlin = 'buitlin'
buitin = 'buitin'
builded = 'builded'
ba = 'ba'
cahe = 'cahe'
Caculate = 'Caculate'
caculate = 'caculate'
calcualtion = 'calcualtion'
cacl = 'cacl'
cll = 'cll'
candiate = 'candiate'
cadidate = 'cadidate'
connot = 'connot'
CANN = 'CANN'
Cann = 'Cann'
cann = 'cann'
vart = 'vart'
checkings = 'checkings'
childs = 'childs'
Chunck = 'Chunck'
clen = 'clen'
Clas = 'Clas'
clas = 'clas'
compability = 'compability'
compatiblity = 'compatiblity'
Compitable = 'Compitable'
compatable = 'compatable'
compitable = 'compitable'
compling = 'compling'
comple = 'comple'
complition = 'complition'
complext = 'complext'
compsite = 'compsite'
configurated = 'configurated'
configed = 'configed'
confict = 'confict'
conjuction = 'conjuction'
conect = 'conect'
consequtive = 'consequtive'
consistant = 'consistant'
contraints = 'contraints'
contruction = 'contruction'
consructor = 'consructor'
comsume = 'comsume'
Continer = 'Continer'
contenst = 'contenst'
conter = 'conter'
ontext = 'ontext'
Continous = 'Continous'
contibute = 'contibute'
controled = 'controled'
Expand Down Expand Up @@ -149,13 +88,6 @@ defind = 'defind'
defeine = 'defeine'
defition = 'defition'
defination = 'defination'
delet = 'delet'
dependecies = 'dependecies'
dependecy = 'dependecy'
decprecated = 'decprecated'
derivated = 'derivated'
descripor = 'descripor'
deserailize = 'deserailize'
Destory = 'Destory'
DEIVCE = 'DEIVCE'
dictionnary = 'dictionnary'
Expand Down Expand Up @@ -426,7 +358,6 @@ Normlized = 'Normlized'
normlize = 'normlize'
noraml = 'noraml'
numer = 'numer'
Numberic = 'Numberic'
occured = 'occured'
Ocurred = 'Ocurred'
occures = 'occures'
Expand All @@ -435,7 +366,6 @@ fo = 'fo'
offets = 'offets'
offseted = 'offseted'
OLT = 'OLT'
olny = 'olny'
pn = 'pn'
Operants = 'Operants'
operants = 'operants'
Expand All @@ -454,13 +384,11 @@ orginal = 'orginal'
onces = 'onces'
outter = 'outter'
outpus = 'outpus'
outputing = 'outputing'
outout = 'outout'
ouput = 'ouput'
outpout = 'outpout'
ouptut = 'ouptut'
Ouput = 'Ouput'
ouside = 'ouside'
overriden = 'overriden'
Overide = 'Overide'
overide = 'overide'
Expand Down
1 change: 1 addition & 0 deletions cmake/cinn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ cinn_cc_library(
${cinnapi_src}
DEPS
glog
python
${llvm_libs}
param_proto
auto_schedule_proto
Expand Down
4 changes: 0 additions & 4 deletions cmake/cinn/core.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ function(cinn_cc_library TARGET_NAME)
endif()

if(cinn_cc_library_DEPS)
if("${cinn_cc_library_DEPS};" MATCHES "python;")
list(REMOVE_ITEM cinn_cc_library_DEPS python)
add_dependencies(${TARGET_NAME} python)
endif()
target_link_libraries(${TARGET_NAME} ${cinn_cc_library_DEPS})
add_dependencies(${TARGET_NAME} ${cinn_cc_library_DEPS})
endif()
Expand Down
10 changes: 10 additions & 0 deletions cmake/external/brpc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,23 @@ set(prefix_path
"${THIRD_PARTY_PATH}/install/gflags|${THIRD_PARTY_PATH}/install/leveldb|${THIRD_PARTY_PATH}/install/snappy|${THIRD_PARTY_PATH}/install/gtest|${THIRD_PARTY_PATH}/install/protobuf|${THIRD_PARTY_PATH}/install/zlib|${THIRD_PARTY_PATH}/install/glog"
)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND ${CMAKE_CXX_COMPILER_VERSION}
VERSION_GREATER_EQUAL 13.0)
file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/brpc/http2.h.patch
http2_h_patch)
set(BRPC_PATCH_COMMAND_GCC13 git apply ${http2_h_patch})
endif()

# If minimal .a is need, you can set WITH_DEBUG_SYMBOLS=OFF
ExternalProject_Add(
extern_brpc
${EXTERNAL_PROJECT_LOG_ARGS}
SOURCE_DIR ${BRPC_SOURCE_DIR}
PREFIX ${BRPC_PREFIX_DIR}
UPDATE_COMMAND ""
PATCH_COMMAND
COMMAND git checkout -- . && git checkout ${BRPC_TAG}
COMMAND ${BRPC_PATCH_COMMAND_GCC13}
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
Expand Down
105 changes: 103 additions & 2 deletions cmake/external/flashattn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,20 @@ if(WITH_ROCM)
else()

add_definitions(-DPADDLE_WITH_FLASHATTN)
option(FA_BUILD_WITH_CACHE "Download cache so files from bos" ON)

set(FLASHATTN_PREFIX_DIR ${THIRD_PARTY_PATH}/flashattn)
set(FLASHATTN_SOURCE_SUBDIR csrc)
set(FLASHATTN_INSTALL_DIR ${THIRD_PARTY_PATH}/install/flashattn)
set(SOURCE_DIR ${PADDLE_SOURCE_DIR}/third_party/flashattn)
set(FLASHATTN_TAG 5fc132ac11e78d26471ca09e5ba0cd817c3424d8)

# get FA git commit
execute_process(
COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_VARIABLE FLASHATTN_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "flashattn git commit: ${FLASHATTN_TAG}")

set(FLASHATTN_INCLUDE_DIR
"${FLASHATTN_INSTALL_DIR}/include"
Expand Down Expand Up @@ -166,6 +174,99 @@ else()
endif()
endforeach()

set(BASE_URL
"https://xly-devops.bj.bcebos.com/gpups/flash-attention/cu${FA_NVCC_ARCH_BIN}"
)
set(TAR_FILE_NAME "flashattn_libs_${FLASHATTN_TAG}.tar")
set(TAR_FILE_URL "${BASE_URL}/${TAR_FILE_NAME}")
set(FA_BUILD_DIR "${FLASHATTN_PREFIX_DIR}/src/extern_flashattn-build/")
set(CACHE_TAR_PATH "${FA_BUILD_DIR}/${TAR_FILE_NAME}")
set(CACHE_TAR_DIR "${FA_BUILD_DIR}/flashattn_libs_${FLASHATTN_TAG}")

set(SKIP_BUILD_FA OFF)
if(FA_BUILD_WITH_CACHE)

message(STATUS "Downloading ${TAR_FILE_URL} to ${CACHE_TAR_PATH}")
file(
DOWNLOAD "${TAR_FILE_URL}" "${CACHE_TAR_PATH}"
STATUS DOWNLOAD_STATUS
LOG DOWNLOAD_LOG)
list(GET DOWNLOAD_STATUS 0 DOWNLOAD_RESULT)

if(DOWNLOAD_RESULT EQUAL 0)
message(STATUS "Download Successful")

file(MAKE_DIRECTORY ${FA_BUILD_DIR})

execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xf ${CACHE_TAR_PATH}
WORKING_DIRECTORY ${FA_BUILD_DIR}
RESULT_VARIABLE TAR_RESULT)

if(NOT TAR_RESULT EQUAL 0)
message(FATAL_ERROR "Failed to extract ${CACHE_TAR_PATH}")
endif()

file(STRINGS ${CACHE_TAR_DIR}/MD5.txt FILE_MD5)

# Strip any leading or trailing whitespace
string(STRIP ${FILE_MD5} FILE_MD5)

file(MD5 ${CACHE_TAR_DIR}/fa_libs.tar FILE_MD5_ACTUAL)

message(STATUS "Expected MD5: ${FILE_MD5}")
message(STATUS "Actual MD5: ${FILE_MD5_ACTUAL}")

if(NOT "${FILE_MD5}" STREQUAL "${FILE_MD5_ACTUAL}")
message(
FATAL_ERROR "MD5 checksum mismatch! The download may be corrupted.")
else()
message(STATUS "MD5 checksum verified successfully.")
endif()

execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xf ${CACHE_TAR_DIR}/fa_libs.tar
WORKING_DIRECTORY ${CACHE_TAR_DIR}
RESULT_VARIABLE TAR_RESULT)

if(NOT TAR_RESULT EQUAL 0)
message(FATAL_ERROR "Failed to extract ${CACHE_TAR_PATH}/fa_libs.tar")
endif()

file(GLOB_RECURSE SO_FILES "${CACHE_TAR_DIR}/fa_libs/*.so")
foreach(so_file ${SO_FILES})
message(STATUS "Copy ${so_file} to ${FA_BUILD_DIR}")
message(STATUS "Copy ${so_file} to ${FLASHATTN_LIB_DIR}")
file(COPY "${so_file}" DESTINATION "${FA_BUILD_DIR}")
file(COPY "${so_file}" DESTINATION "${FLASHATTN_LIB_DIR}")
endforeach()

file(REMOVE_RECURSE ${CACHE_TAR_DIR})
message(STATUS "Extraction completed in ${FA_BUILD_DIR}")

set(SKIP_BUILD_FA ON)

elseif(DOWNLOAD_RESULT EQUAL 6)
message(
STATUS
"Could not resolve host. The given remote host was not resolvable.")
elseif(DOWNLOAD_RESULT EQUAL 7)
message(STATUS "Failed to connect to host.")
elseif(DOWNLOAD_RESULT EQUAL 22)
message(
STATUS
"HTTP page not retrieved. The requested URL was not found or a server returned a 4xx (client error) or 5xx (server error) response."
)
elseif(DOWNLOAD_RESULT EQUAL 28)
message(
STATUS
"Operation timeout. The specified time-out period was reached according to the conditions."
)
else()
message(STATUS "An error occurred. Error code: ${DOWNLOAD_RESULT}")
endif()
endif()

ExternalProject_Add(
extern_flashattn
${EXTERNAL_PROJECT_LOG_ARGS}
Expand Down Expand Up @@ -196,13 +297,13 @@ else()
-DCMAKE_JOB_POOLS:STRING=compile=${FA_JOB_POOLS_COMPILE}
-DNVCC_ARCH_BIN=${FA_NVCC_ARCH_BIN}
-DWITH_FLASHATTN_V3=${WITH_FLASHATTN_V3}
-DSKIP_BUILD_FA=${SKIP_BUILD_FA}
${EXTERNAL_OPTIONAL_ARGS}
CMAKE_CACHE_ARGS
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
-DCMAKE_INSTALL_PREFIX:PATH=${FLASHATTN_INSTALL_DIR}
BUILD_BYPRODUCTS ${BUILD_BYPRODUCTS_LIST})

endif()

message(STATUS "flash-attn library: ${FLASHATTN_LIBRARIES}")
Expand Down
13 changes: 4 additions & 9 deletions cmake/external/openblas.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,11 @@ set(CBLAS_INSTALL_DIR ${THIRD_PARTY_PATH}/install/openblas)
set(CBLAS_SOURCE_DIR ${PADDLE_SOURCE_DIR}/third_party/openblas)
set(CBLAS_TAG v0.3.7)

# Why use v0.3.18? The IDG business line encountered a random openblas error,
# which can be resolved after upgrading openblas.
# And why compile when gcc>8.2? Please refer to
# https://github.com/spack/spack/issues/19932#issuecomment-733452619
# v0.3.18 only support gcc>=8.3 or gcc>=7.4
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.2
if(UNIX
AND NOT APPLE
AND NOT WITH_ROCM
AND NOT WITH_XPU)
# We only compile with openblas 0.3.18 when gcc >= 8.3
set(CBLAS_TAG v0.3.18)
set(CBLAS_TAG v0.3.28)
endif()

if(APPLE AND WITH_ARM)
Expand Down
Loading

0 comments on commit 9a82b0e

Please sign in to comment.