Skip to content
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

[Paddle Inference]cutlass kernel compile optimization #64641

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions paddle/phi/kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ if(DEFINED REDUCE_INFERENCE_LIB_SIZE)
endif()

if(WITH_CUTLASS)
add_custom_target(
gemm_epilogue_compile_script ALL
COMMAND bash compile.sh "${PYTHON_EXECUTABLE}" "${CUDA_TOOLKIT_ROOT_DIR}"
\"${NVCC_ARCH_BIN}\" "${CMAKE_COMMAND}"
WORKING_DIRECTORY
${PADDLE_SOURCE_DIR}/paddle/phi/kernels/fusion/cutlass/gemm_epilogue
COMMENT "GemmEpilogue compile script")
add_custom_target(
fused_conv2d_add_act_compile_script ALL
COMMAND bash compile.sh "${PYTHON_EXECUTABLE}" "${CUDA_TOOLKIT_ROOT_DIR}"
\"${NVCC_ARCH_BIN}\" "${CMAKE_COMMAND}"
WORKING_DIRECTORY
${PADDLE_SOURCE_DIR}/paddle/phi/kernels/fusion/cutlass/conv2d
COMMENT "FusedConv2dAddAct compile script")

execute_process(
COMMAND
${PYTHON_EXECUTABLE}
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/fusion/cutlass/conv2d/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.23)
cmake_minimum_required(VERSION 3.18)

if(NOT DEFINED PYTHON_EXECUTABLE)
message(
Expand Down
37 changes: 27 additions & 10 deletions paddle/phi/kernels/fusion/cutlass/conv2d/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,38 @@
# limitations under the License.
set -e

cutlass_repo_directory="cutlass"
if [ ! -d "$cutlass_repo_directory" ]; then
git clone --branch v3.0.0 https://github.com/NVIDIA/cutlass
fi

build_directory="build"
if [ ! -d "$build_directory" ]; then
mkdir $build_directory
fi

python_exe_path="python"
cuda_root_path="/usr/local/cuda"
gpu_cc="80"
libname="$build_directory/libCutlassConv2d.so"
if [ -e "$libname" ]; then
exit 0
fi

default_python_exe_path="/usr/bin/python"
default_cuda_root_path="/usr/local/cuda"
default_gpu_cc="80"
default_cmake_command="cmake"

python_exe_path="${1:-$default_python_exe_path}"
cuda_root_path="${2:-$default_cuda_root_path}"
gpu_cc="${3:-$default_gpu_cc}"
cmake_command="${4:-$default_cmake_command}"

case "$gpu_cc" in
75|80|86|89) ;;
*) exit 0 ;;
esac

cutlass_repo_directory="cutlass"
if [ ! -d "$cutlass_repo_directory" ]; then
git clone --branch v3.0.0 https://github.com/NVIDIA/cutlass
fi


cd $build_directory
cmake .. -DPYTHON_EXECUTABLE=$python_exe_path -DCUDA_TOOLKIT_ROOT_DIR=$cuda_root_path -DCOMPUTE_CAPABILITY=$gpu_cc
make -j
$cmake_command .. -DPYTHON_EXECUTABLE=$python_exe_path -DCUDA_TOOLKIT_ROOT_DIR=$cuda_root_path -DCOMPUTE_CAPABILITY=$gpu_cc
make -j8
cd -
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.23)
cmake_minimum_required(VERSION 3.18)

if(NOT DEFINED PYTHON_EXECUTABLE)
message(
Expand Down
37 changes: 27 additions & 10 deletions paddle/phi/kernels/fusion/cutlass/gemm_epilogue/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,38 @@
# limitations under the License.
set -e

cutlass_repo_directory="cutlass"
if [ ! -d "$cutlass_repo_directory" ]; then
git clone --branch v2.11.0 https://github.com/NVIDIA/cutlass
fi

build_directory="build"
if [ ! -d "$build_directory" ]; then
mkdir $build_directory
fi

python_exe_path="/usr/bin/python"
cuda_root_path="/usr/local/cuda"
gpu_cc="80"
libname="$build_directory/libCutlassGemmEpilogue.so"
if [ -e "$libname" ]; then
exit 0
fi

default_python_exe_path="/usr/bin/python"
default_cuda_root_path="/usr/local/cuda"
default_gpu_cc="80"
default_cmake_command="cmake"

python_exe_path="${1:-$default_python_exe_path}"
cuda_root_path="${2:-$default_cuda_root_path}"
gpu_cc="${3:-$default_gpu_cc}"
cmake_command="${4:-$default_cmake_command}"

case "$gpu_cc" in
80|86|89) ;;
*) exit 0 ;;
esac

cutlass_repo_directory="cutlass"
if [ ! -d "$cutlass_repo_directory" ]; then
git clone --branch v2.11.0 https://github.com/NVIDIA/cutlass
fi


cd $build_directory
cmake .. -DPYTHON_EXECUTABLE=$python_exe_path -DCUDA_TOOLKIT_ROOT_DIR=$cuda_root_path -DCOMPUTE_CAPABILITY=$gpu_cc
make -j
$cmake_command .. -DPYTHON_EXECUTABLE=$python_exe_path -DCUDA_TOOLKIT_ROOT_DIR=$cuda_root_path -DCOMPUTE_CAPABILITY=$gpu_cc
make -j8
cd -
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// limitations under the License.

#pragma once
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <vector>

#include "paddle/phi/kernels/fusion/cutlass/gemm_epilogue/gemm_epilogue_decl.h"
Expand Down