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

Moving and renaming distance namespaces from raft -> cuvs #85

Merged
merged 22 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f07d571
Moving and renaming distance namespaces from raft -> cuvs
cjnolet Apr 18, 2024
d2f8bae
Moving over the raft public APIs (into cuVS source directory).
cjnolet Apr 18, 2024
f2401f5
Adding instantion files for pairwise
cjnolet Apr 18, 2024
2ea074d
It seems to build!
cjnolet Apr 18, 2024
58b3ebd
And it builds!o
cjnolet Apr 18, 2024
8df5ae5
Adding mdspan-based public API for pairwise distances
cjnolet Apr 19, 2024
1221bc4
Merge branch 'branch-24.06' into fea-2406-move_raft_distance
cjnolet Apr 19, 2024
68c901d
Adding pairwise distance tests
cjnolet Apr 23, 2024
4aaac50
Merge branch 'fea-2406-move_raft_distance' of github.com:cjnolet/cuvs…
cjnolet Apr 23, 2024
9e02d67
Removing files that don't need to be moved over yet.
cjnolet Apr 23, 2024
59fe3fd
Adding docs for pairwise_distance
cjnolet Apr 23, 2024
28b115c
Updating APIs to account for const types
cjnolet Apr 23, 2024
07614b2
Removing duplication from the distance types
cjnolet Apr 23, 2024
1129366
Updating the indexing type to match other APIs
cjnolet Apr 23, 2024
def9bd1
Merge branch 'branch-24.06' into fea-2406-move_raft_distance
cjnolet Apr 23, 2024
d678008
Merge branch 'branch-24.06' into fea-2406-move_raft_distance
cjnolet Apr 25, 2024
7a927c3
Using cuvsDistanceType
cjnolet Apr 25, 2024
19b90cf
Merge branch 'fea-2406-move_raft_distance' of github.com:cjnolet/cuvs…
cjnolet Apr 25, 2024
e398b1b
Distance type
cjnolet Apr 25, 2024
4134810
Changing rust to expose proper cuvs distance type
cjnolet Apr 26, 2024
080bf3a
Adding nvjitlink to dependencies (not sure why this is needed)
cjnolet Apr 26, 2024
53b4c2b
Find libnvjitlink
cjnolet Apr 26, 2024
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
1 change: 1 addition & 0 deletions conda/environments/all_cuda-122_arch-aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies:
- libcurand-dev
- libcusolver-dev
- libcusparse-dev
- libnvjitlink
- make
- nccl>=2.9.9
- ninja
Expand Down
1 change: 1 addition & 0 deletions conda/environments/all_cuda-122_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies:
- libcurand-dev
- libcusolver-dev
- libcusparse-dev
- libnvjitlink
- make
- nccl>=2.9.9
- ninja
Expand Down
91 changes: 56 additions & 35 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,35 @@ include(cmake/thirdparty/get_cutlass.cmake)

add_library(
cuvs SHARED
src/distance/detail/pairwise_matrix/dispatch_canberra_double_double_double_int.cu
src/distance/detail/pairwise_matrix/dispatch_canberra_float_float_float_int.cu
src/distance/detail/pairwise_matrix/dispatch_correlation_double_double_double_int.cu
src/distance/detail/pairwise_matrix/dispatch_correlation_float_float_float_int.cu
src/distance/detail/pairwise_matrix/dispatch_cosine_double_double_double_int.cu
src/distance/detail/pairwise_matrix/dispatch_cosine_float_float_float_int.cu
src/distance/detail/pairwise_matrix/dispatch_hamming_unexpanded_double_double_double_int.cu
src/distance/detail/pairwise_matrix/dispatch_hamming_unexpanded_float_float_float_int.cu
src/distance/detail/pairwise_matrix/dispatch_hellinger_expanded_double_double_double_int.cu
src/distance/detail/pairwise_matrix/dispatch_hellinger_expanded_float_float_float_int.cu
src/distance/detail/pairwise_matrix/dispatch_jensen_shannon_double_double_double_int.cu
src/distance/detail/pairwise_matrix/dispatch_jensen_shannon_float_float_float_int.cu
src/distance/detail/pairwise_matrix/dispatch_kl_divergence_double_double_double_int.cu
src/distance/detail/pairwise_matrix/dispatch_kl_divergence_float_float_float_int.cu
src/distance/detail/pairwise_matrix/dispatch_l1_double_double_double_int.cu
src/distance/detail/pairwise_matrix/dispatch_l1_float_float_float_int.cu
src/distance/detail/pairwise_matrix/dispatch_l2_expanded_double_double_double_int.cu
src/distance/detail/pairwise_matrix/dispatch_l2_expanded_float_float_float_int.cu
src/distance/detail/pairwise_matrix/dispatch_l2_unexpanded_double_double_double_int.cu
src/distance/detail/pairwise_matrix/dispatch_l2_unexpanded_float_float_float_int.cu
src/distance/detail/pairwise_matrix/dispatch_l_inf_double_double_double_int.cu
src/distance/detail/pairwise_matrix/dispatch_l_inf_float_float_float_int.cu
src/distance/detail/pairwise_matrix/dispatch_lp_unexpanded_double_double_double_int.cu
src/distance/detail/pairwise_matrix/dispatch_lp_unexpanded_float_float_float_int.cu
src/distance/detail/pairwise_matrix/dispatch_rbf.cu
src/distance/detail/pairwise_matrix/dispatch_russel_rao_double_double_double_int.cu
src/distance/detail/pairwise_matrix/dispatch_russel_rao_float_float_float_int.cu
src/distance/distance.cu
src/distance/pairwise_distance.cu
src/neighbors/brute_force_index.cu
src/neighbors/brute_force.cu
src/neighbors/cagra_build_float.cpp
Expand Down Expand Up @@ -240,16 +269,13 @@ target_include_directories(

if(NOT BUILD_CPU_ONLY)
# Keep cuVS as lightweight as possible. Only CUDA libs and rmm should be used in global target.
target_link_libraries(cuvs
PUBLIC
rmm::rmm
$<$<NOT:$<BOOL:${CUDA_STATIC_RUNTIME}>>:raft::raft>
$<$<NOT:$<BOOL:${CUDA_STATIC_RUNTIME}>>:raft::compiled>
PRIVATE
$<$<BOOL:${CUDA_STATIC_RUNTIME}>:raft::raft>
$<$<BOOL:${CUDA_STATIC_RUNTIME}>:raft::compiled_static>
nvidia::cutlass::cutlass
)
target_link_libraries(
cuvs
PUBLIC rmm::rmm $<$<NOT:$<BOOL:${CUDA_STATIC_RUNTIME}>>:raft::raft>
$<$<NOT:$<BOOL:${CUDA_STATIC_RUNTIME}>>:raft::compiled>
PRIVATE $<$<BOOL:${CUDA_STATIC_RUNTIME}>:raft::raft>
$<$<BOOL:${CUDA_STATIC_RUNTIME}>:raft::compiled_static> nvidia::cutlass::cutlass
)
endif()

# Endian detection
Expand Down Expand Up @@ -304,14 +330,14 @@ endif()

set_target_properties(
cuvs
PROPERTIES BUILD_RPATH "\$ORIGIN"
INSTALL_RPATH "\$ORIGIN"
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED ON
PROPERTIES BUILD_RPATH "\$ORIGIN"
INSTALL_RPATH "\$ORIGIN"
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED ON
INTERFACE_POSITION_INDEPENDENT_CODE ON
POSITION_INDEPENDENT_CODE ON
POSITION_INDEPENDENT_CODE ON
)

target_compile_options(
Expand All @@ -325,25 +351,21 @@ target_link_options(cuvs PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/fatbin.ld")
# * cuvs_c -------------------------------------------------------------------------------
if(BUILD_C_LIBRARY)
add_library(
cuvs_c SHARED
src/core/c_api.cpp
src/neighbors/brute_force_c.cpp
src/neighbors/ivf_flat_c.cpp
src/neighbors/ivf_pq_c.cpp
src/neighbors/cagra_c.cpp
cuvs_c SHARED src/core/c_api.cpp src/neighbors/brute_force_c.cpp src/neighbors/ivf_flat_c.cpp
src/neighbors/ivf_pq_c.cpp src/neighbors/cagra_c.cpp
)

add_library(cuvs::c_api ALIAS cuvs_c)

set_target_properties(
cuvs_c
PROPERTIES BUILD_RPATH "\$ORIGIN"
INSTALL_RPATH "\$ORIGIN"
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
POSITION_INDEPENDENT_CODE ON
PROPERTIES BUILD_RPATH "\$ORIGIN"
INSTALL_RPATH "\$ORIGIN"
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
POSITION_INDEPENDENT_CODE ON
INTERFACE_POSITION_INDEPENDENT_CODE ON
EXPORT_NAME c_api
EXPORT_NAME c_api
)

target_compile_options(cuvs_c PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${CUVS_CXX_FLAGS}>")
Expand All @@ -354,12 +376,11 @@ if(BUILD_C_LIBRARY)
INTERFACE "$<INSTALL_INTERFACE:include>"
)

target_link_libraries(cuvs_c
PUBLIC
cuvs::cuvs
PRIVATE
$<$<BOOL:${CUDA_STATIC_RUNTIME}>:raft::raft>
)
target_link_libraries(
cuvs_c
PUBLIC cuvs::cuvs
PRIVATE $<$<BOOL:${CUDA_STATIC_RUNTIME}>:raft::raft>
)

# ensure CUDA symbols aren't relocated to the middle of the debug build binaries
target_link_options(cuvs_c PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/fatbin.ld")
Expand Down
4 changes: 2 additions & 2 deletions cpp/include/cuvs/distance/distance_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern "C" {
#endif

/** enum to tell how to compute distance */
enum DistanceType {
typedef enum {

/** evaluate as dist_ij = sum(x_ik^2) + sum(y_ij)^2 - 2*sum(x_ik * y_jk) */
L2Expanded = 0,
Expand Down Expand Up @@ -64,7 +64,7 @@ enum DistanceType {
DiceExpanded = 19,
/** Precomputed (special value) **/
Precomputed = 100
};
} cuvsDistanceType;

#ifdef __cplusplus
}
Expand Down
48 changes: 2 additions & 46 deletions cpp/include/cuvs/distance/distance_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,56 +14,12 @@
* limitations under the License.
*/

#include "distance_types.h"
#pragma once

namespace cuvs::distance {

/** enum to tell how to compute distance */
enum DistanceType : unsigned short {

/** evaluate as dist_ij = sum(x_ik^2) + sum(y_ij)^2 - 2*sum(x_ik * y_jk) */
L2Expanded = 0,
/** same as above, but inside the epilogue, perform square root operation */
L2SqrtExpanded = 1,
/** cosine distance */
CosineExpanded = 2,
/** L1 distance */
L1 = 3,
/** evaluate as dist_ij += (x_ik - y-jk)^2 */
L2Unexpanded = 4,
/** same as above, but inside the epilogue, perform square root operation */
L2SqrtUnexpanded = 5,
/** basic inner product **/
InnerProduct = 6,
/** Chebyshev (Linf) distance **/
Linf = 7,
/** Canberra distance **/
Canberra = 8,
/** Generalized Minkowski distance **/
LpUnexpanded = 9,
/** Correlation distance **/
CorrelationExpanded = 10,
/** Jaccard distance **/
JaccardExpanded = 11,
/** Hellinger distance **/
HellingerExpanded = 12,
/** Haversine distance **/
Haversine = 13,
/** Bray-Curtis distance **/
BrayCurtis = 14,
/** Jensen-Shannon distance**/
JensenShannon = 15,
/** Hamming distance **/
HammingUnexpanded = 16,
/** KLDivergence **/
KLDivergence = 17,
/** RusselRao **/
RusselRaoExpanded = 18,
/** Dice-Sorensen distance **/
DiceExpanded = 19,
/** Precomputed (special value) **/
Precomputed = 100
};
using DistanceType = cuvsDistanceType;

/**
* Whether minimal distance corresponds to similar elements (using the given metric).
Expand Down
Loading
Loading