From 03dc52b7fe42a866f1b43a7ceeec6890aa94ed8c Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 4 Dec 2024 23:35:08 +0000 Subject: [PATCH 1/4] Update cuvs to match raft's cutlass changes --- cpp/cmake/patches/cutlass/build-export.patch | 27 ++++++++++++ cpp/cmake/patches/cutlass_override.json | 16 ++++++++ cpp/cmake/thirdparty/get_cutlass.cmake | 43 ++++++++++---------- 3 files changed, 65 insertions(+), 21 deletions(-) create mode 100644 cpp/cmake/patches/cutlass/build-export.patch create mode 100644 cpp/cmake/patches/cutlass_override.json diff --git a/cpp/cmake/patches/cutlass/build-export.patch b/cpp/cmake/patches/cutlass/build-export.patch new file mode 100644 index 000000000..a6423e9c0 --- /dev/null +++ b/cpp/cmake/patches/cutlass/build-export.patch @@ -0,0 +1,27 @@ +From e0a9597946257a01ae8444200f836ee51d5597ba Mon Sep 17 00:00:00 2001 +From: Kyle Edwards +Date: Wed, 20 Nov 2024 16:37:38 -0500 +Subject: [PATCH] Remove erroneous include directories + +These directories are left over from when CuTe was a separate +CMake project. Remove them. +--- + CMakeLists.txt | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7419bdf5e..545384d82 100755 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -665,8 +665,6 @@ target_include_directories( + $ + $ + $ +- $ +- $ + ) + + # Mark CTK headers as system to supress warnings from them +-- +2.34.1 + diff --git a/cpp/cmake/patches/cutlass_override.json b/cpp/cmake/patches/cutlass_override.json new file mode 100644 index 000000000..7bf818987 --- /dev/null +++ b/cpp/cmake/patches/cutlass_override.json @@ -0,0 +1,16 @@ +{ + "packages" : { + "cutlass" : { + "version": "3.5.1", + "git_url": "https://github.com/NVIDIA/cutlass.git", + "git_tag": "v${version}", + "patches" : [ + { + "file" : "${current_json_dir}/cutlass/build-export.patch", + "issue" : "Fix build directory export", + "fixed_in" : "" + } + ] + } + } +} diff --git a/cpp/cmake/thirdparty/get_cutlass.cmake b/cpp/cmake/thirdparty/get_cutlass.cmake index 61065318b..d5bdd4632 100644 --- a/cpp/cmake/thirdparty/get_cutlass.cmake +++ b/cpp/cmake/thirdparty/get_cutlass.cmake @@ -13,7 +13,9 @@ # ============================================================================= function(find_and_configure_cutlass) - set(oneValueArgs VERSION REPOSITORY PINNED_TAG) + set(options) + set(oneValueArgs) + set(multiValueArgs) cmake_parse_arguments(PKG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) # if(RAFT_ENABLE_DIST_DEPENDENCIES OR RAFT_COMPILE_LIBRARIES) @@ -22,7 +24,7 @@ function(find_and_configure_cutlass) CACHE BOOL "Enable only the header library" ) set(CUTLASS_NAMESPACE - "cuvs_cutlass" + "raft_cutlass" CACHE STRING "Top level namespace of CUTLASS" ) set(CUTLASS_ENABLE_CUBLAS @@ -34,13 +36,22 @@ function(find_and_configure_cutlass) set(CUDART_LIBRARY "${CUDA_cudart_static_LIBRARY}" CACHE FILEPATH "fixing cutlass cmake code" FORCE) endif() + include("${rapids-cmake-dir}/cpm/package_override.cmake") + rapids_cpm_package_override("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../patches/cutlass_override.json") + + include("${rapids-cmake-dir}/cpm/detail/package_details.cmake") + rapids_cpm_package_details(cutlass version repository tag shallow exclude) + + include("${rapids-cmake-dir}/cpm/detail/generate_patch_command.cmake") + rapids_cpm_generate_patch_command(cutlass ${version} patch_command) + rapids_cpm_find( - NvidiaCutlass ${PKG_VERSION} + NvidiaCutlass ${version} GLOBAL_TARGETS nvidia::cutlass::cutlass CPM_ARGS - GIT_REPOSITORY ${PKG_REPOSITORY} - GIT_TAG ${PKG_PINNED_TAG} - GIT_SHALLOW TRUE + GIT_REPOSITORY ${repository} + GIT_TAG ${tag} + GIT_SHALLOW ${shallow} ${patch_command} OPTIONS "CUDAToolkit_ROOT ${CUDAToolkit_LIBRARY_DIR}" ) @@ -61,32 +72,22 @@ function(find_and_configure_cutlass) # We generate the cutlass-config files when we built cutlass locally, so always do # `find_dependency` rapids_export_package( - BUILD NvidiaCutlass cuvs-exports GLOBAL_TARGETS nvidia::cutlass::cutlass + BUILD NvidiaCutlass raft-exports GLOBAL_TARGETS nvidia::cutlass::cutlass ) rapids_export_package( - INSTALL NvidiaCutlass cuvs-exports GLOBAL_TARGETS nvidia::cutlass::cutlass + INSTALL NvidiaCutlass raft-exports GLOBAL_TARGETS nvidia::cutlass::cutlass ) # Tell cmake where it can find the generated NvidiaCutlass-config.cmake we wrote. include("${rapids-cmake-dir}/export/find_package_root.cmake") rapids_export_find_package_root( INSTALL NvidiaCutlass [=[${CMAKE_CURRENT_LIST_DIR}/../]=] - EXPORT_SET cuvs-exports + EXPORT_SET raft-exports ) rapids_export_find_package_root( BUILD NvidiaCutlass [=[${CMAKE_CURRENT_LIST_DIR}]=] - EXPORT_SET cuvs-exports + EXPORT_SET raft-exports ) endfunction() -if(NOT RAFT_CUTLASS_GIT_TAG) - set(RAFT_CUTLASS_GIT_TAG v2.10.0) -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.10.0 REPOSITORY ${RAFT_CUTLASS_GIT_REPOSITORY} PINNED_TAG ${RAFT_CUTLASS_GIT_TAG} -) +find_and_configure_cutlass() From 59f16b0d8e92508f30edd553b0ba52bb2a9f72a8 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 4 Dec 2024 23:41:23 +0000 Subject: [PATCH 2/4] raft->cuvs and some cleanup --- cpp/cmake/thirdparty/get_cutlass.cmake | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cpp/cmake/thirdparty/get_cutlass.cmake b/cpp/cmake/thirdparty/get_cutlass.cmake index d5bdd4632..71bd2d26c 100644 --- a/cpp/cmake/thirdparty/get_cutlass.cmake +++ b/cpp/cmake/thirdparty/get_cutlass.cmake @@ -18,13 +18,12 @@ function(find_and_configure_cutlass) set(multiValueArgs) cmake_parse_arguments(PKG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - # if(RAFT_ENABLE_DIST_DEPENDENCIES OR RAFT_COMPILE_LIBRARIES) set(CUTLASS_ENABLE_HEADERS_ONLY ON CACHE BOOL "Enable only the header library" ) set(CUTLASS_NAMESPACE - "raft_cutlass" + "cuvs_cutlass" CACHE STRING "Top level namespace of CUTLASS" ) set(CUTLASS_ENABLE_CUBLAS @@ -67,26 +66,25 @@ function(find_and_configure_cutlass) NAMESPACE nvidia::cutlass:: ) endif() - # endif() # We generate the cutlass-config files when we built cutlass locally, so always do # `find_dependency` rapids_export_package( - BUILD NvidiaCutlass raft-exports GLOBAL_TARGETS nvidia::cutlass::cutlass + BUILD NvidiaCutlass cuvs-exports GLOBAL_TARGETS nvidia::cutlass::cutlass ) rapids_export_package( - INSTALL NvidiaCutlass raft-exports GLOBAL_TARGETS nvidia::cutlass::cutlass + INSTALL NvidiaCutlass cuvs-exports GLOBAL_TARGETS nvidia::cutlass::cutlass ) # Tell cmake where it can find the generated NvidiaCutlass-config.cmake we wrote. include("${rapids-cmake-dir}/export/find_package_root.cmake") rapids_export_find_package_root( INSTALL NvidiaCutlass [=[${CMAKE_CURRENT_LIST_DIR}/../]=] - EXPORT_SET raft-exports + EXPORT_SET cuvs-exports ) rapids_export_find_package_root( BUILD NvidiaCutlass [=[${CMAKE_CURRENT_LIST_DIR}]=] - EXPORT_SET raft-exports + EXPORT_SET cuvs-exports ) endfunction() From 6e1ce1602f23cdc97bc66e564557cc5521d5c734 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 4 Dec 2024 23:49:07 +0000 Subject: [PATCH 3/4] Add in pre-commit changes so that spelling isn't checked --- .pre-commit-config.yaml | 5 ++++- .../cuvs_bench/cuvs_bench/generate_groundtruth/__main__.py | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f4fdf202e..5e53abd92 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -91,7 +91,10 @@ repos: - id: codespell additional_dependencies: [tomli] args: ["--toml", "pyproject.toml"] - exclude: (?x)^(^CHANGELOG.md$) + exclude: | + (?x) + ^CHANGELOG[.]md$| + ^cpp/cmake/patches/cutlass/build-export[.]patch$ - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: diff --git a/python/cuvs_bench/cuvs_bench/generate_groundtruth/__main__.py b/python/cuvs_bench/cuvs_bench/generate_groundtruth/__main__.py index dbee6cd36..b89b6305b 100644 --- a/python/cuvs_bench/cuvs_bench/generate_groundtruth/__main__.py +++ b/python/cuvs_bench/cuvs_bench/generate_groundtruth/__main__.py @@ -21,11 +21,10 @@ import cupy as cp import numpy as np import rmm +from cuvs.neighbors.brute_force import build, search from pylibraft.common import DeviceResources from rmm.allocators.cupy import rmm_cupy_allocator -from cuvs.neighbors.brute_force import build, search - from .utils import memmap_bin_file, suffix_from_dtype, write_bin From 1a5dd9581657f312dc1248dbdebd10aa67d81e5d Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 4 Dec 2024 23:58:49 +0000 Subject: [PATCH 4/4] Revert undesired change --- python/cuvs_bench/cuvs_bench/generate_groundtruth/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/cuvs_bench/cuvs_bench/generate_groundtruth/__main__.py b/python/cuvs_bench/cuvs_bench/generate_groundtruth/__main__.py index b89b6305b..dbee6cd36 100644 --- a/python/cuvs_bench/cuvs_bench/generate_groundtruth/__main__.py +++ b/python/cuvs_bench/cuvs_bench/generate_groundtruth/__main__.py @@ -21,10 +21,11 @@ import cupy as cp import numpy as np import rmm -from cuvs.neighbors.brute_force import build, search from pylibraft.common import DeviceResources from rmm.allocators.cupy import rmm_cupy_allocator +from cuvs.neighbors.brute_force import build, search + from .utils import memmap_bin_file, suffix_from_dtype, write_bin