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

Add cutlass 3xTF32,DMMA based L2/cosine distance kernels for SM 8.0 or higher #939

Merged
merged 28 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
20648c5
cutlass based euclidean expanded, cosine kernels
mdoijade Oct 20, 2022
a9dabc8
add prior ampere pairwisedistmat kernel to prevent redundant kernel c…
mdoijade Oct 21, 2022
1a45bfa
add noexcept to the functor methods
mdoijade Oct 21, 2022
c6f091b
merge branch 22.12 and resolve conflicts
mdoijade Oct 21, 2022
7786fcb
fix comments, remove redundant code and fix formatting issues
mdoijade Oct 27, 2022
181fc40
add cutlass cmake support for raft with custom namespace, fix formati…
mdoijade Oct 28, 2022
3d34545
fix formatting issues
mdoijade Oct 28, 2022
02c23ed
fix the cutlass_include_dir path in cmake
mdoijade Nov 3, 2022
7933436
fix bugs in get_cutlass cmake to use cutlass provided properties corr…
mdoijade Nov 4, 2022
d4bdec5
remove the cutlass namespace setting in test cmakefiles as it is not …
mdoijade Nov 4, 2022
d26bcef
temp remove dist dependency from cutlass to check if it works in ci/cd
mdoijade Nov 4, 2022
4df4185
merge branch-22.12 latest changes
mdoijade Nov 7, 2022
451c3c0
fix get_cutlass.cmake to work with pylibraft by using NvidiaCutlass i…
mdoijade Nov 10, 2022
7b512f9
fix get_cutlass install path, make changes as per review comments
mdoijade Nov 10, 2022
a05e1e2
merge branch-22.12
mdoijade Nov 10, 2022
d32b4c0
fix clang format issues
mdoijade Nov 10, 2022
f7c440a
temp fix to check if python build works
mdoijade Nov 11, 2022
b1a1fd7
add raft-exports instead of raft-distance-exports as other raft compo…
mdoijade Nov 15, 2022
4ef44e7
make cutlass to depend only on raft_distance and add raft_distance de…
mdoijade Nov 16, 2022
186fcc7
fix cmake formatting issues
mdoijade Nov 16, 2022
8aa8909
prevent cutlass based pairwise dist kernels to be disabled on cuda 12…
mdoijade Nov 16, 2022
abfd493
Moving cutlass dependency to distance and nn to keep them separate.
cjnolet Nov 16, 2022
f1b1239
Adding CUTLASS to build docs as dependency
cjnolet Nov 16, 2022
32e6052
Updating to export to both distance and nn
cjnolet Nov 16, 2022
f6de9ee
Adding cutlass as private dependency
cjnolet Nov 16, 2022
9bf0647
Making cutlass INTERFACE in raft::nn and raft::distance
cjnolet Nov 16, 2022
8f0119a
Using proper exports per Robert Maynard's suggestion.
cjnolet Nov 16, 2022
6ad4fd1
Adding cutlass as private dependency of lib targets
cjnolet Nov 16, 2022
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
Prev Previous commit
Next Next commit
fix bugs in get_cutlass cmake to use cutlass provided properties corr…
…ectly
  • Loading branch information
mdoijade committed Nov 4, 2022
commit 79334361caae2279e8a30315c018be96fb87859b
6 changes: 2 additions & 4 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ add_library(raft::raft ALIAS raft)

target_include_directories(raft INTERFACE
"$<BUILD_INTERFACE:${RAFT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
"$<BUILD_INTERFACE:${CUTLASS_INCLUDE_DIR}>")
"$<INSTALL_INTERFACE:include>")

# Keep RAFT as lightweight as possible.
# Only CUDA libs and rmm should
Expand All @@ -192,6 +191,7 @@ target_link_libraries(raft INTERFACE
CUDA::cusolver${_ctk_static_suffix}
CUDA::cusparse${_ctk_static_suffix}
$<$<BOOL:${RAFT_ENABLE_thrust_DEPENDENCY}>:raft::Thrust>
nvidia::cutlass::cutlass
)

target_compile_features(raft INTERFACE cxx_std_17 $<BUILD_INTERFACE:cuda_std_17>)
Expand Down Expand Up @@ -322,8 +322,6 @@ if(RAFT_COMPILE_DIST_LIBRARY)
)
target_compile_definitions(raft_distance_lib
INTERFACE "RAFT_DISTANCE_COMPILED")
target_compile_definitions(raft_distance_lib
INTERFACE "CUTLASS_NAMESPACE=${RAFT_CUTLASS_NAMESPACE}")

# ensure CUDA symbols aren't relocated to the middle of the debug build binaries
target_link_options(raft_distance_lib PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/fatbin.ld")
Expand Down
45 changes: 17 additions & 28 deletions cpp/cmake/thirdparty/get_cutlass.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,58 +20,47 @@ function(find_and_configure_cutlass)
"${multiValueArgs}" ${ARGN} )

if(RAFT_ENABLE_DIST_DEPENDENCIES OR RAFT_COMPILE_LIBRARIES)
rapids_find_generate_module(cutlass
HEADER_NAMES cutlass/include/*
INCLUDE_SUFFIXES cutlass
)
set(CUTLASS_ENABLE_HEADERS_ONLY ON)
set(RAFT_CUTLASS_NAMESPACE "raft_cutlass" CACHE STRING "Top level namespace of CUTLASS")
# set(BUILD_SHARED_LIBS OFF)
# if (PKG_BUILD_STATIC_LIBS)
# set(BUILD_SHARED_LIBS OFF)
# set(CPM_DOWNLOAD_cutlass ON)
# endif()
set(CUTLASS_ENABLE_HEADERS_ONLY ON CACHE BOOL "Enable only the header library")
set(CUTLASS_NAMESPACE "raft_cutlass" CACHE STRING "Top level namespace of CUTLASS")

rapids_cpm_find(cutlass ${PKG_VERSION}
robertmaynard marked this conversation as resolved.
Show resolved Hide resolved
GLOBAL_TARGETS cutlass::cutlass
GLOBAL_TARGETS nvidia::cutlass::CUTLASS
CPM_ARGS
GIT_REPOSITORY ${PKG_REPOSITORY}
GIT_TAG ${PKG_PINNED_TAG}
mdoijade marked this conversation as resolved.
Show resolved Hide resolved
EXCLUDE_FROM_ALL ${PKG_EXCLUDE_FROM_ALL}
OPTIONS
"CMAKE_INSTALL_INCLUDEDIR include"
"CUDAToolkit_ROOT ${CUDAToolkit_LIBRARY_DIR}"
)

if(TARGET cutlass AND NOT TARGET cutlass::cutlass)
add_library(cutlass::cutlass ALIAS cutlass)
if(TARGET cutlass AND NOT TARGET nvidia::cutlass::cutlass)
robertmaynard marked this conversation as resolved.
Show resolved Hide resolved
add_library(nvidia::cutlass::cutlass ALIAS CUTLASS)
endif()

# if(cutlass_ADDED)
# rapids_export(BUILD cutlass
# EXPORT_SET cutlass-targets
# GLOBAL_TARGETS cutlass
# NAMESPACE cutlass::)
# endif()
if(cutlass_ADDED)
rapids_export(BUILD cutlass
robertmaynard marked this conversation as resolved.
Show resolved Hide resolved
EXPORT_SET NvidiaCutlass
GLOBAL_TARGETS nvidia::cutlass::CUTLASS
NAMESPACE nvidia::cutlass::)
endif()
endif()

# We generate the faiss-config files when we built faiss locally, so always do `find_dependency`
rapids_export_package(BUILD cutlass raft-distance-lib-exports GLOBAL_TARGETS cutlass::cutlass cutlass)
rapids_export_package(INSTALL cutlass raft-distance-lib-exports GLOBAL_TARGETS cutlass::cutlass cutlass)
# We generate the cutlass-config files when we built cutlass locally, so always do `find_dependency`
rapids_export_package(BUILD cutlass raft-distance-exports GLOBAL_TARGETS nvidia::cutlass::CUTLASS)
robertmaynard marked this conversation as resolved.
Show resolved Hide resolved
rapids_export_package(INSTALL cutlass raft-distance-exports GLOBAL_TARGETS nvidia::cutlass::CUTLASS)
robertmaynard marked this conversation as resolved.
Show resolved Hide resolved

# Tell cmake where it can find the generated cutlass-config.cmake we wrote.
include("${rapids-cmake-dir}/export/find_package_root.cmake")
rapids_export_find_package_root(INSTALL cutlass [=[${CMAKE_CURRENT_LIST_DIR}]=] raft-distance-lib-exports)
rapids_export_find_package_root(INSTALL cutlass [=[${CMAKE_CURRENT_LIST_DIR}]=] raft-distance-exports)
robertmaynard marked this conversation as resolved.
Show resolved Hide resolved
endfunction()

if(NOT RAFT_CUTLASS_GIT_TAG)
set(RAFT_CUTLASS_GIT_TAG v2.9.0)
set(RAFT_CUTLASS_GIT_TAG v2.9.1)
endif()

if(NOT RAFT_CUTLASS_GIT_REPOSITORY)
set(RAFT_CUTLASS_GIT_REPOSITORY https://github.com/NVIDIA/cutlass.git)
endif()

find_and_configure_cutlass(VERSION 2.9.0
find_and_configure_cutlass(VERSION 2.9.1
REPOSITORY ${RAFT_CUTLASS_GIT_REPOSITORY}
PINNED_TAG ${RAFT_CUTLASS_GIT_TAG})