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
merge branch-22.12
  • Loading branch information
mdoijade committed Nov 10, 2022
commit a05e1e2af8de1de6ef9fa2594be61487f0257f97
43 changes: 25 additions & 18 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,16 @@ option(DISABLE_OPENMP "Disable OpenMP" OFF)
option(RAFT_NVTX "Enable nvtx markers" OFF)

option(RAFT_COMPILE_LIBRARIES "Enable building raft shared library instantiations" ${BUILD_TESTS})
option(RAFT_COMPILE_NN_LIBRARY "Enable building raft nearest neighbors shared library instantiations" ${RAFT_COMPILE_LIBRARIES})
option(RAFT_COMPILE_DIST_LIBRARY "Enable building raft distant shared library instantiations" ${RAFT_COMPILE_LIBRARIES})
option(RAFT_ENABLE_DIST_DEPENDENCIES "Search for raft::distance dependencies like cutlass" ${RAFT_COMPILE_LIBRARIES})
option(RAFT_ENABLE_NN_DEPENDENCIES "Search for raft::nn dependencies like faiss" ${RAFT_COMPILE_LIBRARIES})
option(
RAFT_COMPILE_NN_LIBRARY "Enable building raft nearest neighbors shared library instantiations"
${RAFT_COMPILE_LIBRARIES}
)
option(RAFT_COMPILE_DIST_LIBRARY "Enable building raft distant shared library instantiations"
${RAFT_COMPILE_LIBRARIES}
)
option(RAFT_ENABLE_NN_DEPENDENCIES "Search for raft::nn dependencies like faiss"
${RAFT_COMPILE_LIBRARIES}
)

option(RAFT_ENABLE_thrust_DEPENDENCY "Enable Thrust dependency" ON)

Expand Down Expand Up @@ -203,17 +209,16 @@ target_include_directories(
raft INTERFACE "$<BUILD_INTERFACE:${RAFT_SOURCE_DIR}/include>" "$<INSTALL_INTERFACE:include>"
)

# Keep RAFT as lightweight as possible.
# Only CUDA libs and rmm should
# be used in global target.
target_link_libraries(raft INTERFACE
rmm::rmm
CUDA::cublas${_ctk_static_suffix}
CUDA::curand${_ctk_static_suffix}
CUDA::cusolver${_ctk_static_suffix}
CUDA::cusparse${_ctk_static_suffix}
$<$<BOOL:${RAFT_ENABLE_thrust_DEPENDENCY}>:raft::Thrust>
nvidia::cutlass::cutlass
# Keep RAFT as lightweight as possible. Only CUDA libs and rmm should be used in global target.
target_link_libraries(
raft
INTERFACE rmm::rmm
CUDA::cublas${_ctk_static_suffix}
CUDA::curand${_ctk_static_suffix}
CUDA::cusolver${_ctk_static_suffix}
CUDA::cusparse${_ctk_static_suffix}
$<$<BOOL:${RAFT_ENABLE_thrust_DEPENDENCY}>:raft::Thrust>
nvidia::cutlass::cutlass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dependency needs to be on the raft-distance target and not the raft target

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robertmaynard I see that several tests and core algorithms depend on cosine/euclidean distance headers where we are using cutlass, hence I think it needs to be dependency on raft target. without it I am seeing several build failures when those sources are built.
I've modified get_cutlass.cmake from raft-distance-exports to raft-exports. Can this resolve the build issue in pylibraft?
I've submitted this change and waiting to see if CI passes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cjnolet Are you okay with cutlass being a hard requirement for raft?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if we could make CUTLASS a dependency only of raft::distance (which pylibraft uses).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdoijade any tests/benchmarks and downstream projects which depend on distances also specify and use the raft::distance target.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I've tried to add dependency on raft_distance wherever required and got the build working locally, please review if it looks good now.
also I've enabled the cutlass path only till cuda 11.x.

)

target_compile_features(raft INTERFACE cxx_std_17 $<BUILD_INTERFACE:cuda_std_17>)
Expand Down Expand Up @@ -486,9 +491,11 @@ if(TARGET raft_nn_lib)
)
endif()

install(DIRECTORY include/raft
COMPONENT raft
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(
DIRECTORY include/raft
COMPONENT raft
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

# Temporary install of raft.hpp while the file is removed
install(
Expand Down
45 changes: 24 additions & 21 deletions cpp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,27 +97,30 @@ if(BUILD_TESTS)
test/test.cpp
)

ConfigureTest(NAME DISTANCE_TEST
PATH
test/distance/dist_adj.cu
test/distance/dist_canberra.cu
test/distance/dist_chebyshev.cu
test/distance/dist_correlation.cu
test/distance/dist_cos.cu
test/distance/dist_euc_exp.cu
test/distance/dist_euc_unexp.cu
test/distance/dist_eucsqrt_exp.cu
test/distance/dist_hamming.cu
test/distance/dist_hellinger.cu
test/distance/dist_jensen_shannon.cu
test/distance/dist_kl_divergence.cu
test/distance/dist_l1.cu
test/distance/dist_minkowski.cu
test/distance/dist_russell_rao.cu
test/distance/fused_l2_nn.cu
test/distance/gram.cu
OPTIONAL DIST
)
ConfigureTest(
NAME
DISTANCE_TEST
PATH
test/distance/dist_adj.cu
test/distance/dist_canberra.cu
test/distance/dist_chebyshev.cu
test/distance/dist_correlation.cu
test/distance/dist_cos.cu
test/distance/dist_euc_exp.cu
test/distance/dist_euc_unexp.cu
test/distance/dist_eucsqrt_exp.cu
test/distance/dist_hamming.cu
test/distance/dist_hellinger.cu
test/distance/dist_jensen_shannon.cu
test/distance/dist_kl_divergence.cu
test/distance/dist_l1.cu
test/distance/dist_minkowski.cu
test/distance/dist_russell_rao.cu
test/distance/fused_l2_nn.cu
test/distance/gram.cu
OPTIONAL
DIST
)

ConfigureTest(NAME LABEL_TEST PATH test/label/label.cu test/label/merge_labels.cu)

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.