Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
Browse files Browse the repository at this point in the history
… remove_api_with_data_parallel
  • Loading branch information
kangguangli committed Mar 13, 2023
2 parents af9e125 + 5dfbb22 commit af47580
Show file tree
Hide file tree
Showing 2,081 changed files with 70,534 additions and 36,328 deletions.
30 changes: 20 additions & 10 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,26 @@ exclude =
./python/paddle/fluid/tests/unittests/npu/**,
./python/paddle/fluid/tests/unittests/mlu/**
ignore =
E203, # Whitespace before ‘,’, ‘;’, or ‘:’, it is not compatible with black
E402, # Module level import not at top of file
E501, # Line too long (82 > 79 characters)
E721, # Do not compare types, use `isinstance()`
E722, # Do not use bare except, specify exception instead
E731, # Do not assign a lambda expression, use a def
E741, # Do not use variables named ‘l’, ‘O’, or ‘I’
F405, # `name` may be undefined, or defined from star imports: `module`
F841, # Local variable name is assigned to but never used
W503 # Line break before binary operator, it is not compatible with black
# Whitespace before ‘,’, ‘;’, or ‘:’, it is not compatible with black
E203,
# Module level import not at top of file
E402,
# Line too long (82 > 79 characters)
E501,
# Do not compare types, use `isinstance()`
E721,
# Do not use bare except, specify exception instead
E722,
# Do not assign a lambda expression, use a def
E731,
# Do not use variables named ‘l’, ‘O’, or ‘I’
E741,
# `name` may be undefined, or defined from star imports: `module`
F405,
# Local variable name is assigned to but never used
F841,
# Line break before binary operator, it is not compatible with black
W503
per-file-ignores =
# These files need tabs for testing.
python/paddle/fluid/tests/unittests/dygraph_to_static/test_error.py:E101,W191
Expand Down
16 changes: 14 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,25 @@ paddle/fluid/operators/ops_extra_info.cc
paddle/phi/api/backward/backward_api.h
paddle/phi/api/backward/sparse_bw_api.h
paddle/phi/api/include/api.h
paddle/phi/api/include/operants_base.h
paddle/phi/api/include/operants_manager.h
paddle/phi/api/include/sparse_api.h
paddle/phi/api/include/strings_api.h
paddle/phi/api/include/tensor_operants.h
paddle/phi/api/lib/api.cc
paddle/phi/api/lib/dygraph_api.*
paddle/phi/api/lib/backward_api.cc
paddle/phi/api/lib/operants_manager.cc
paddle/phi/api/lib/sparse_api.cc
paddle/phi/api/lib/strings_api.cc
paddle/phi/api/lib/sparse_bw_api.cc
paddle/phi/api/lib/tensor_api.cc
paddle/phi/api/lib/tensor_operants.cc
paddle/phi/extension.h
paddle/phi/include/*
paddle/phi/infermeta/generated.*

paddle/fluid/prim/api/generated_prim/*.cc
paddle/fluid/prim/api/generated_prim/*.h
*.DS_Store
*.vs
build/
Expand Down Expand Up @@ -74,7 +81,7 @@ paddle/fluid/pybind/eager_op_function.cc
tools/nvcc_lazy

# these files (directories) are generated before build system generation
paddle/fluid/operators/generated_op.cc
paddle/fluid/operators/generated_op*.cc
paddle/fluid/operators/generated_sparse_op.cc
paddle/fluid/operators/generated_static_op.cc
paddle/phi/ops/compat/generated_*.cc
Expand All @@ -86,3 +93,8 @@ paddle/fluid/pybind/eager_op_function_impl.h
paddle/fluid/pybind/op_function_impl.h
paddle/fluid/pybind/*final_state_op_function_impl.h
paddle/fluid/prim/api/generated/prim_api/*
paddle/fluid/framework/__init__.py
paddle/phi/api/profiler/__init__.py
python/paddle/incubate/fleet/parameter_server/pslib/ps_pb2.py
paddle/phi/kernels/fusion/cutlass/conv2d/generated/*
python/paddle/fluid/incubate/fleet/parameter_server/pslib/ps_pb2.py
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ repos:
hooks:
- id: isort
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 5.0.4
hooks:
- id: flake8
args: ["--config=.flake8"]
- repo: https://github.com/PyCQA/autoflake
rev: v1.7.7
hooks:
Expand Down
2 changes: 2 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ This is an incomplete list of authors of [Paddle](https://github.com/PaddlePaddl
| Haichao-Zhang | Hai-Chao Zhang |
| hedaoyuan | Dao-Yuan He |
| helinwang | He-Lin Wang |
| heliqi | Li-Qi He |
| houj04 | HOU Jue |
| HulekJakub | Jakub Hulek |
| jacquesqiao | Long-Fei Qiao |
| [jakpiase](https://raw.githubusercontent.com/jakpiase/Paddle/new_paddle_intel_authors/img/img.jpg) | Jakub Piasecki |
| [jczaja](https://raw.githubusercontent.com/jakpiase/Paddle/new_paddle_intel_authors/img/img.jpg) | Jacek Czaja |
Expand Down
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ option(WITH_MPI "Compile PaddlePaddle with MPI" OFF)
option(WITH_TENSORRT "Compile PaddlePaddle with NVIDIA TensorRT" OFF)
option(WITH_XPU "Compile PaddlePaddle with BAIDU KUNLUN XPU" OFF)
option(WITH_XPU_KP "Compile PaddlePaddle with BAIDU XPU compiler " OFF)
option(WITH_XPU_XFT "Compile PaddlePaddle with BAIDU XPU-XFT" OFF)
option(WITH_MLU "Compile PaddlePaddle with CAMBRICON MLU" OFF)
option(WITH_WIN_DUMP_DBG "Compile with windows core dump debug mode" OFF)
option(WITH_ASCEND "Compile PaddlePaddle with ASCEND" OFF)
Expand All @@ -74,6 +75,9 @@ endif()
if(WITH_GPU AND WITH_XPU_KP)
message(FATAL_ERROR "Error when compile GPU and XPU2 at the same time")
endif()
if(WITH_GPU AND WITH_XPU_XFT)
message(FATAL_ERROR "Error when compile GPU and XPU-XFT at the same time")
endif()
if(WITH_GPU AND WITH_ASCEND)
message(FATAL_ERROR "Error when compile GPU and ASCEND at the same time")
endif()
Expand Down Expand Up @@ -419,6 +423,15 @@ if(WITH_XPU_KP AND NOT WITH_XPU)
CACHE STRING "Enable WITH_XPU when compiling with WITH_XPU_KP" FORCE)
endif()

if(NOT WITH_XPU AND WITH_XPU_XFT)
message(
WARNING
"Enable WITH_XPU when compiling with WITH_XPU_XFT. Force WITH_XPU=ON.")
set(WITH_XPU
ON
CACHE STRING "Enable WITH_XPU when compiling with WITH_XPU_XFT" FORCE)
endif()

if(NOT WITH_XPU AND WITH_XPU_BKCL)
message(
WARNING "Disable BKCL when compiling without XPU. Force WITH_XPU_BKCL=OFF.")
Expand Down
4 changes: 2 additions & 2 deletions cmake/cuda.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ elseif(NEW_RELEASE_PYPI)
add_definitions(-DNEW_RELEASE_PYPI)
set(paddle_known_gpu_archs "35 50 52 60 61 70 75 80 86")
set(paddle_known_gpu_archs10 "")
set(paddle_known_gpu_archs11 "60 61 70 75 80")
set(paddle_known_gpu_archs11 "61 70 75 80")
elseif(NEW_RELEASE_JIT)
message("Using New Release Strategy - JIT Packge")
add_definitions(-DNEW_RELEASE_JIT)
Expand All @@ -27,7 +27,7 @@ elseif(NEW_RELEASE_JIT)
set(paddle_known_gpu_archs11 "35 50 60 70 75 80")
else()
set(paddle_known_gpu_archs "35 50 52 60 61 70 75 80")
set(paddle_known_gpu_archs10 "35 50 52 60 61 70 75")
set(paddle_known_gpu_archs10 "50 52 60 61 70 75")
set(paddle_known_gpu_archs11 "52 60 61 70 75 80")
endif()

Expand Down
6 changes: 3 additions & 3 deletions cmake/experiments/cuda_module_loading_lazy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ if(LINUX)
CACHE BOOL "" FORCE)
set(CMAKE_CUDA_FLAGS "--cudart shared")
enable_language(CUDA)
set(CMAKE_CUDA_COMPILER
"${CMAKE_SOURCE_DIR}/tools/nvcc_lazy"
CACHE FILEPATH "" FORCE)
execute_process(
COMMAND "rm" "-rf" "${CMAKE_SOURCE_DIR}/tools/nvcc_lazy"
COMMAND "chmod" "755" "${CMAKE_SOURCE_DIR}/tools/nvcc_lazy.sh"
Expand All @@ -54,7 +57,4 @@ if(LINUX)
set(CUDA_NVCC_EXECUTABLE
"${CMAKE_SOURCE_DIR}/tools/nvcc_lazy"
CACHE FILEPATH "" FORCE)
set(CMAKE_CUDA_COMPILER
"${CMAKE_SOURCE_DIR}/tools/nvcc_lazy"
CACHE FILEPATH "" FORCE)
endif()
3 changes: 2 additions & 1 deletion cmake/external/brpc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ find_package(OpenSSL REQUIRED)

message(STATUS "ssl:" ${OPENSSL_SSL_LIBRARY})
message(STATUS "crypto:" ${OPENSSL_CRYPTO_LIBRARY})
message(STATUS "WITH_SNAPPY:" ${WITH_SNAPPRY})

add_library(ssl SHARED IMPORTED GLOBAL)
set_property(TARGET ssl PROPERTY IMPORTED_LOCATION ${OPENSSL_SSL_LIBRARY})
Expand Down Expand Up @@ -46,7 +47,7 @@ ExternalProject_Add(
extern_brpc
${EXTERNAL_PROJECT_LOG_ARGS}
GIT_REPOSITORY "https://github.com/apache/incubator-brpc"
GIT_TAG 1.2.0
GIT_TAG 1.4.0
PREFIX ${BRPC_PREFIX_DIR}
UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
Expand Down
3 changes: 1 addition & 2 deletions cmake/external/cinn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ if(NOT WITH_CINN)
endif()

if(NOT CINN_GIT_TAG)
# 2023.02.09 commit
set(CINN_GIT_TAG 63cf4267a0f8756df61b0dca5fb30bf3748ba2f4)
set(CINN_GIT_TAG develop)
endif()

message(STATUS "CINN version: " ${CINN_GIT_TAG})
Expand Down
13 changes: 12 additions & 1 deletion cmake/external/cutlass.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ include_directories(

add_definitions("-DPADDLE_WITH_CUTLASS")

if(NOT PYTHON_EXECUTABLE)
find_package(PythonInterp REQUIRED)
endif()

ExternalProject_Add(
extern_cutlass
${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE}
Expand All @@ -34,7 +38,14 @@ ExternalProject_Add(
PREFIX ${CUTLASS_PREFIX_DIR}
UPDATE_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
BUILD_COMMAND
mkdir -p
${CMAKE_SOURCE_DIR}/paddle/phi/kernels/sparse/gpu/cutlass/build/generated/gemm
&& ${PYTHON_EXECUTABLE} -B
${CMAKE_SOURCE_DIR}/paddle/phi/kernels/sparse/gpu/cutlass/gather_gemm_scatter_generator.py
"${THIRD_PARTY_PATH}/cutlass/src/extern_cutlass/tools/library/scripts/"
"${CMAKE_SOURCE_DIR}/paddle/phi/kernels/sparse/gpu/cutlass/build"
"${CMAKE_CUDA_COMPILER_VERSION}"
INSTALL_COMMAND ""
TEST_COMMAND "")

Expand Down
108 changes: 108 additions & 0 deletions cmake/external/flashattn.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

include(ExternalProject)

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(FLASHATTN_TAG f0edf243a813a65d05c75fcb331b2a95faf96bbc)

set(FLASHATTN_INCLUDE_DIR
"${FLASHATTN_INSTALL_DIR}/include"
CACHE PATH "flash-attn Directory" FORCE)
set(FLASHATTN_LIB_DIR
"${FLASHATTN_INSTALL_DIR}/lib"
CACHE PATH "flash-attn Library Directory" FORCE)

if(WIN32)
set(FLASHATTN_LIBRARIES
"${FLASHATTN_INSTALL_DIR}/bin/flashattn${CMAKE_SHARED_LIBRARY_SUFFIX}"
CACHE FILEPATH "flash-attn Library" FORCE)
else()
set(FLASHATTN_LIBRARIES
"${FLASHATTN_INSTALL_DIR}/lib/libflashattn${CMAKE_SHARED_LIBRARY_SUFFIX}"
CACHE FILEPATH "flash-attn Library" FORCE)
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"
OR WIN32)
set(USE_OMP OFF)
else()
set(USE_OMP ON)
endif()

if(WIN32)
set(FLASHATTN_C_FLAGS $<FILTER:${CMAKE_C_FLAGS},EXCLUDE,/Zc:inline>)
set(FLASHATTN_C_FLAGS_DEBUG
$<FILTER:${CMAKE_C_FLAGS_DEBUG},EXCLUDE,/Zc:inline>)
set(FLASHATTN_C_FLAGS_RELEASE
$<FILTER:${CMAKE_C_FLAGS_RELEASE},EXCLUDE,/Zc:inline>)
set(FLASHATTN_CXX_FLAGS $<FILTER:${CMAKE_CXX_FLAGS},EXCLUDE,/Zc:inline>)
set(FLASHATTN_CXX_FLAGS_RELEASE
$<FILTER:${CMAKE_CXX_FLAGS_RELEASE},EXCLUDE,/Zc:inline>)
set(FLASHATTN_CXX_FLAGS_DEBUG
$<FILTER:${CMAKE_CXX_FLAGS_DEBUG},EXCLUDE,/Zc:inline>)
else()
set(FLASHATTN_C_FLAGS ${CMAKE_C_FLAGS})
set(FLASHATTN_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
set(FLASHATTN_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
set(FLASHATTN_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(FLASHATTN_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
set(FLASHATTN_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
endif()

ExternalProject_Add(
extern_flashattn
${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE}
GIT_REPOSITORY ${FLASHATTN_REPOSITORY}
GIT_TAG ${FLASHATTN_TAG}
PREFIX ${FLASHATTN_PREFIX_DIR}
SOURCE_SUBDIR ${FLASHATTN_SOURCE_SUBDIR}
UPDATE_COMMAND ""
PATCH_COMMAND ""
#BUILD_ALWAYS 1
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${FLASHATTN_C_FLAGS}
-DCMAKE_C_FLAGS_DEBUG=${FLASHATTN_C_FLAGS_DEBUG}
-DCMAKE_C_FLAGS_RELEASE=${FLASHATTN_C_FLAGS_RELEASE}
-DCMAKE_CXX_FLAGS=${FLASHATTN_CXX_FLAGS}
-DCMAKE_CXX_FLAGS_RELEASE=${FLASHATTN_CXX_FLAGS_RELEASE}
-DCMAKE_CXX_FLAGS_DEBUG=${FLASHATTN_CXX_FLAGS_DEBUG}
-DCMAKE_INSTALL_PREFIX=${FLASHATTN_INSTALL_DIR}
-DWITH_GPU=${WITH_GPU}
-DWITH_ROCM=${WITH_ROCM}
-DWITH_OMP=${USE_OMP}
-DBUILD_SHARED=ON
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
${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 ${FLASHATTN_LIBRARIES})

message(STATUS "flash-attn library: ${FLASHATTN_LIBRARIES}")
get_filename_component(FLASHATTN_LIBRARY_PATH ${FLASHATTN_LIBRARIES} DIRECTORY)
include_directories(${FLASHATTN_INCLUDE_DIR})

add_library(flashattn INTERFACE)
#set_property(TARGET flashattn PROPERTY IMPORTED_LOCATION ${FLASHATTN_LIBRARIES})
add_dependencies(flashattn extern_flashattn)
17 changes: 17 additions & 0 deletions cmake/external/gloo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ if(WITH_GPU)
endif()
endif()

if(CMAKE_COMPILER_IS_GNUCC)
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpfullversion -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION})
list(GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR)
list(GET GCC_VERSION_COMPONENTS 1 GCC_MINOR)
set(GCC_VERSION "${GCC_MAJOR}.${GCC_MINOR}")
if(GCC_VERSION GREATER_EQUAL "12.0")
file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/gloo/device.cc.patch
native_dst)
file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/gloo/types.h.patch
types_header)
set(GLOO_PATCH_COMMAND
patch -d ${GLOO_SOURCE_DIR}/gloo/transport/tcp < ${native_dst} && patch
-d ${GLOO_SOURCE_DIR}/gloo/ < ${types_header})
endif()
endif()
include_directories(${GLOO_INCLUDE_DIR})

if(WITH_ASCEND OR WITH_ASCEND_CL)
Expand Down
2 changes: 1 addition & 1 deletion cmake/external/mkldnn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ set(MKLDNN_INC_DIR
"${MKLDNN_INSTALL_DIR}/include"
CACHE PATH "mkldnn include directory." FORCE)
set(MKLDNN_REPOSITORY ${GIT_URL}/oneapi-src/oneDNN.git)
set(MKLDNN_TAG 9b186765dded79066e0cd9c17eb70b680b76fb8e)
set(MKLDNN_TAG 2089770c4818be8933c5e9d1dd3cbaeba1457667)

# Introduce variables:
# * CMAKE_INSTALL_LIBDIR
Expand Down
12 changes: 10 additions & 2 deletions cmake/external/protobuf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,13 @@ function(build_protobuf TARGET_NAME BUILD_FOR_HOST)
# Change the tag to support building with vs2019
set(PROTOBUF_TAG 01a05a53f40ca2ac5f0af10c6cc0810bee39b792)
else()
set(PROTOBUF_REPOSITORY ${GIT_URL}/protocolbuffers/protobuf.git)
set(PROTOBUF_TAG v21.12)
if(WITH_PSLIB)
set(PROTOBUF_REPOSITORY "https://github.com/google/protobuf.git")
set(PROTOBUF_TAG "9f75c5aa851cd877fb0d93ccc31b8567a6706546")
else()
set(PROTOBUF_REPOSITORY ${GIT_URL}/protocolbuffers/protobuf.git)
set(PROTOBUF_TAG v21.12)
endif()
if(WITH_GPU)
if(${CMAKE_CUDA_COMPILER_VERSION} LESS 12.0
AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 12.0)
Expand Down Expand Up @@ -326,6 +331,9 @@ elseif(WITH_IPU)
set(PROTOBUF_VERSION 21.12)
elseif(WITH_ARM_BRPC)
set(PROTOBUF_VERSION 21.12-baidu-ee-common)
elseif(WIN32)
#Lower version prootbuf is used for widows
set(PROTOBUF_VERSION 3.2)
else()
set(PROTOBUF_VERSION 21.12)
if(WITH_GPU)
Expand Down
Loading

0 comments on commit af47580

Please sign in to comment.