Skip to content

Commit

Permalink
fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
mfoerste4 committed May 22, 2024
2 parents 4d5ff0c + b757c19 commit 545032b
Show file tree
Hide file tree
Showing 91 changed files with 1,489 additions and 1,012 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ dask-worker-space/
*.bin
bench/ann/data
temporary_*.json
rust/target/
rust/Cargo.lock

## scikit-build
_skbuild
Expand Down
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ repos:
setup[.]cfg$
exclude: |
(?x)
cpp/include/cuvs/neighbors/detail/faiss_select/|
docs/source/sphinxext/github_link\.py|
cpp/cmake/modules/FindAVX\.cmake|
Expand Down
12 changes: 4 additions & 8 deletions ci/release/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function sed_runner() {
sed -i.bak ''"$1"'' $2 && rm -f ${2}.bak
}

sed_runner "s/set(RAPIDS_VERSION .*)/set(RAPIDS_VERSION \"${NEXT_SHORT_TAG}\")/g" cpp/examples/cmake/thirdparty/fetch_rapids.cmake
sed_runner "s/set(RAPIDS_VERSION .*)/set(RAPIDS_VERSION \"${NEXT_SHORT_TAG}\")/g" examples/cmake/thirdparty/fetch_rapids.cmake

# Centralized version file update
echo "${NEXT_FULL_TAG}" > VERSION
Expand All @@ -47,6 +47,7 @@ DEPENDENCIES=(
cuvs
cuvs-cu11
cuvs-cu12
pylibraft
pylibraft-cu11
pylibraft-cu12
rmm
Expand All @@ -68,19 +69,13 @@ for FILE in python/*/pyproject.toml; do
sed_runner "/\"ucx-py==/ s/==.*\"/==${NEXT_UCX_PY_SHORT_TAG_PEP440}.*\"/g" ${FILE}
done

sed_runner "/^ucx_py_version:$/ {n;s/.*/ - \"${NEXT_UCX_PY_VERSION}\"/}" conda/recipes/raft-dask/conda_build_config.yaml

for FILE in .github/workflows/*.yaml; do
sed_runner "/shared-workflows/ s/@.*/@branch-${NEXT_SHORT_TAG}/g" "${FILE}"
done

sed_runner "/^set(CUVS_VERSION/ s|\".*\"|\"${NEXT_SHORT_TAG}\"|g" docs/source/build.md
sed_runner "s|branch-[0-9][0-9].[0-9][0-9]|branch-${NEXT_SHORT_TAG}|g" docs/source/build.md
sed_runner "/rapidsai\/raft/ s|branch-[0-9][0-9].[0-9][0-9]|branch-${NEXT_SHORT_TAG}|g" docs/source/developer_guide.md

sed_runner "s|:[0-9][0-9].[0-9][0-9]|:${NEXT_SHORT_TAG}|g" docs/source/raft_ann_benchmarks.md

sed_runner "s|branch-[0-9][0-9].[0-9][0-9]|branch-${NEXT_SHORT_TAG}|g" README.md
sed_runner "s|=[0-9][0-9].[0-9][0-9]|=${NEXT_SHORT_TAG}|g" README.md

# rust can't handle leading 0's in the major/minor/patch version - remove
NEXT_FULL_RUST_TAG=$(printf "%d.%d.%d" $((10#$NEXT_MAJOR)) $((10#$NEXT_MINOR)) $((10#$NEXT_PATCH)))
Expand All @@ -90,6 +85,7 @@ sed_runner "s/version = \".*\"/version = \"${NEXT_FULL_RUST_TAG}\"/g" rust/Cargo
find .devcontainer/ -type f -name devcontainer.json -print0 | while IFS= read -r -d '' filename; do
sed_runner "s@rapidsai/devcontainers:[0-9.]*@rapidsai/devcontainers:${NEXT_SHORT_TAG}@g" "${filename}"
sed_runner "s@rapidsai/devcontainers/features/ucx:[0-9.]*@rapidsai/devcontainers/features/ucx:${NEXT_SHORT_TAG_PEP440}@" "${filename}"
sed_runner "s@rapidsai/devcontainers/features/cuda:[0-9.]*@rapidsai/devcontainers/features/cuda:${NEXT_SHORT_TAG_PEP440}@" "${filename}"
sed_runner "s@rapidsai/devcontainers/features/rapids-build-utils:[0-9.]*@rapidsai/devcontainers/features/rapids-build-utils:${NEXT_SHORT_TAG_PEP440}@" "${filename}"
sed_runner "s@rapids-\${localWorkspaceFolderBasename}-${CURRENT_SHORT_TAG}@rapids-\${localWorkspaceFolderBasename}-${NEXT_SHORT_TAG}@g" "${filename}"
done
25 changes: 20 additions & 5 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -447,14 +447,29 @@ target_include_directories(
"$<INSTALL_INTERFACE:include>"
)

rapids_find_package(
OpenMP REQUIRED
BUILD_EXPORT_SET cuvs-exports
INSTALL_EXPORT_SET cuvs-exports
)

if(NOT BUILD_CPU_ONLY)

set(CUVS_CUSOLVER_DEPENDENCY CUDA::cusolver${_ctk_static_suffix})
set(CUVS_CUBLAS_DEPENDENCY CUDA::cublas${_ctk_static_suffix})
set(CUVS_CURAND_DEPENDENCY CUDA::curand${_ctk_static_suffix})
set(CUVS_CUSPARSE_DEPENDENCY CUDA::cusparse${_ctk_static_suffix})

set(CUVS_CTK_MATH_DEPENDENCIES ${CUVS_CUBLAS_DEPENDENCY} ${CUVS_CUSOLVER_DEPENDENCY}
${CUVS_CUSPARSE_DEPENDENCY} ${CUVS_CURAND_DEPENDENCY}
)

# 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
PUBLIC rmm::rmm raft::raft
PRIVATE nvidia::cutlass::cutlass ${CUVS_CTK_MATH_DEPENDENCIES}
$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>
)
endif()

Expand Down Expand Up @@ -559,7 +574,7 @@ if(BUILD_C_LIBRARY)
target_link_libraries(
cuvs_c
PUBLIC cuvs::cuvs
PRIVATE $<$<BOOL:${CUDA_STATIC_RUNTIME}>:raft::raft>
PRIVATE raft::raft ${CUVS_CTK_MATH_DEPENDENCIES}
)

# ensure CUDA symbols aren't relocated to the middle of the debug build binaries
Expand Down
15 changes: 2 additions & 13 deletions cpp/cmake/thirdparty/get_raft.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set(RAFT_FORK "rapidsai")
set(RAFT_PINNED_TAG "branch-${RAPIDS_VERSION_MAJOR_MINOR}")

function(find_and_configure_raft)
set(oneValueArgs VERSION FORK PINNED_TAG COMPILE_LIBRARY USE_RAFT_STATIC ENABLE_NVTX ENABLE_MNMG_DEPENDENCIES)
set(oneValueArgs VERSION FORK PINNED_TAG USE_RAFT_STATIC ENABLE_NVTX ENABLE_MNMG_DEPENDENCIES)
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )

Expand All @@ -31,16 +31,6 @@ function(find_and_configure_raft)

set(RAFT_COMPONENTS "")

if(PKG_COMPILE_LIBRARY)
if(NOT PKG_USE_RAFT_STATIC)
string(APPEND RAFT_COMPONENTS " compiled")
set(RAFT_COMPILED_LIB raft::compiled PARENT_SCOPE)
else()
string(APPEND RAFT_COMPONENTS " compiled_static")
set(RAFT_COMPILED_LIB raft::compiled_static PARENT_SCOPE)
endif()
endif()

if(PKG_ENABLE_MNMG_DEPENDENCIES)
string(APPEND RAFT_COMPONENTS " distributed")
endif()
Expand All @@ -62,7 +52,7 @@ function(find_and_configure_raft)
"BUILD_PRIMS_BENCH OFF"
"BUILD_ANN_BENCH OFF"
"RAFT_NVTX ${PKG_ENABLE_NVTX}"
"RAFT_COMPILE_LIBRARY ${PKG_COMPILE_LIBRARY}"
"RAFT_COMPILE_LIBRARY OFF"
)
endfunction()

Expand All @@ -72,7 +62,6 @@ endfunction()
find_and_configure_raft(VERSION ${RAFT_VERSION}.00
FORK ${RAFT_FORK}
PINNED_TAG ${RAFT_PINNED_TAG}
COMPILE_LIBRARY ON
ENABLE_MNMG_DEPENDENCIES OFF
ENABLE_NVTX OFF
USE_RAFT_STATIC ${CUVS_USE_RAFT_STATIC}
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/cuvs/cluster/agglomerative.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#pragma once

#include <cuvs/distance/distance_types.hpp>
#include <cuvs/distance/distance.hpp>
#include <optional>
#include <raft/core/device_mdspan.hpp>
#include <raft/core/resources.hpp>
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/cuvs/cluster/kmeans.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/
#pragma once
#include <cuvs/distance/distance_types.hpp>
#include <cuvs/distance/distance.hpp>
#include <raft/core/device_mdspan.hpp>
#include <raft/core/host_mdspan.hpp>
#include <raft/core/resources.hpp>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, NVIDIA CORPORATION.
* Copyright (c) 2021-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,13 +16,54 @@

#pragma once

#include "distance.h"

#include <cstdint>
#include <cuvs/distance/distance_types.hpp>
#include <raft/core/device_mdspan.hpp>
#include <raft/core/resources.hpp>

namespace cuvs::distance {

using DistanceType = cuvsDistanceType;

/**
* Whether minimal distance corresponds to similar elements (using the given metric).
*/
inline bool is_min_close(DistanceType metric)
{
bool select_min;
switch (metric) {
case DistanceType::InnerProduct:
// Similarity metrics have the opposite meaning, i.e. nearest neighbors are those with larger
// similarity (See the same logic at cpp/include/raft/sparse/spatial/detail/knn.cuh:362
// {perform_k_selection})
select_min = false;
break;
default: select_min = true;
}
return select_min;
}

namespace kernels {
enum KernelType { LINEAR, POLYNOMIAL, RBF, TANH };

/**
* Parameters for kernel matrices.
* The following kernels are implemented:
* - LINEAR \f[ K(x_1,x_2) = <x_1,x_2>, \f] where \f$< , >\f$ is the dot product
* - POLYNOMIAL \f[ K(x_1, x_2) = (\gamma <x_1,x_2> + \mathrm{coef0})^\mathrm{degree} \f]
* - RBF \f[ K(x_1, x_2) = \exp(- \gamma |x_1-x_2|^2) \f]
* - TANH \f[ K(x_1, x_2) = \tanh(\gamma <x_1,x_2> + \mathrm{coef0}) \f]
*/
struct KernelParams {
// Kernel function parameters
KernelType kernel; //!< Type of the kernel function
int degree; //!< Degree of polynomial kernel (ignored by others)
double gamma; //!< multiplier in the
double coef0; //!< additive constant in poly and tanh kernels
};
} // end namespace kernels

/**
* @defgroup pairwise_distance Pairwise Distances API
* @{
Expand All @@ -37,7 +78,7 @@ namespace cuvs::distance {
* @code{.cpp}
* #include <raft/core/resources.hpp>
* #include <raft/core/device_mdarray.hpp>
* #include <cuvs/distance/pairwise_distance.hpp>
* #include <cuvs/distance/distance.hpp>
*
* raft::resources handle;
* int n_samples = 5000;
Expand Down Expand Up @@ -81,7 +122,7 @@ void pairwise_distance(
* @code{.cpp}
* #include <raft/core/resources.hpp>
* #include <raft/core/device_mdarray.hpp>
* #include <cuvs/distance/pairwise_distance.hpp>
* #include <cuvs/distance/distance.hpp>
*
* raft::resources handle;
* int n_samples = 5000;
Expand Down Expand Up @@ -125,7 +166,7 @@ void pairwise_distance(
* @code{.cpp}
* #include <raft/core/resources.hpp>
* #include <raft/core/device_mdarray.hpp>
* #include <cuvs/distance/pairwise_distance.hpp>
* #include <cuvs/distance/distance.hpp>
*
* raft::resources handle;
* int n_samples = 5000;
Expand Down Expand Up @@ -168,7 +209,7 @@ void pairwise_distance(
* @code{.cpp}
* #include <raft/core/resources.hpp>
* #include <raft/core/device_mdarray.hpp>
* #include <cuvs/distance/pairwise_distance.hpp>
* #include <cuvs/distance/distance.hpp>
*
* raft::resources handle;
* int n_samples = 5000;
Expand Down Expand Up @@ -205,4 +246,4 @@ void pairwise_distance(

/** @} */ // end group pairwise_distance_runtime

} // namespace cuvs::distance
}; // namespace cuvs::distance
63 changes: 0 additions & 63 deletions cpp/include/cuvs/distance/distance_types.hpp

This file was deleted.

Loading

0 comments on commit 545032b

Please sign in to comment.