Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ if(FAISS_ENABLE_CUVS AND NOT TARGET cuvs::cuvs)
find_package(cuvs)
endif()

if(FAISS_ENABLE_CUVS AND NOT TARGET rmm::rmm)
find_package(rmm REQUIRED)
endif()

add_subdirectory(faiss)

if(FAISS_ENABLE_GPU)
Expand Down
16 changes: 6 additions & 10 deletions faiss/IndexHNSW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <limits>
#include <memory>
#include <queue>
#include <random>

#include <cstdint>
#include "faiss/Index.h"
Expand Down Expand Up @@ -1433,13 +1432,11 @@ void IndexHNSWCagra::search(
// first real candidate will always be strictly better.
nearest_d[i] = C::neutral();

std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<idx_t> distrib(
0, this->ntotal - 1);
// Seeded per query so entrypoints are reproducible.
SplitMix64RandomGenerator gen(i);

for (idx_t j = 0; j < num_base_level_search_entrypoints; j++) {
auto idx = distrib(gen);
idx_t idx = gen.rand_int64() % this->ntotal;
auto distance = (*dis)(idx);
if (C::cmp(nearest_d[i], distance)) {
nearest[i] = static_cast<storage_idx_t>(idx);
Expand Down Expand Up @@ -1498,12 +1495,11 @@ void IndexHNSWCagra::range_search(
// real candidate will always be strictly better.
float nearest_d = C::neutral();

std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<idx_t> distrib(0, ntotal - 1);
// For reproducible entrypoint.
SplitMix64RandomGenerator gen(i);

for (idx_t j = 0; j < num_base_level_search_entrypoints; j++) {
auto idx = distrib(gen);
idx_t idx = gen.rand_int64() % ntotal;
auto distance = (*dis)(idx);
// C::cmp(nearest_d, distance) is true iff distance is
// strictly better than the current nearest_d.
Expand Down
2 changes: 1 addition & 1 deletion faiss/IndexHNSW.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ struct IndexHNSWCagra : IndexHNSW {
/// searches only the base level knn graph of the HNSW index.
/// This parameter selects the entry point by randomly selecting
/// some points and using the best one.
int num_base_level_search_entrypoints = 32;
int num_base_level_search_entrypoints = 256;

void add(idx_t n, const float* x) override;

Expand Down
2 changes: 1 addition & 1 deletion faiss/gpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ else()


find_package(CUDAToolkit REQUIRED)
target_link_libraries(faiss_gpu_objs PRIVATE ${CUDA_LIBS} $<$<BOOL:${FAISS_ENABLE_CUVS}>:cuvs::cuvs> $<$<BOOL:${FAISS_ENABLE_CUVS}>:OpenMP::OpenMP_CXX>)
target_link_libraries(faiss_gpu_objs PRIVATE ${CUDA_LIBS} $<$<BOOL:${FAISS_ENABLE_CUVS}>:cuvs::cuvs> $<$<BOOL:${FAISS_ENABLE_CUVS}>:rmm::rmm> $<$<BOOL:${FAISS_ENABLE_CUVS}>:OpenMP::OpenMP_CXX>)
target_compile_options(faiss_gpu_objs PRIVATE
$<$<COMPILE_LANGUAGE:CUDA>:-Xfatbin=-compress-all
--expt-extended-lambda --expt-relaxed-constexpr
Expand Down
7 changes: 7 additions & 0 deletions faiss/gpu/GpuIndexBinaryCagra.cu
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ std::shared_ptr<GpuResources> GpuIndexBinaryCagra::getResources() {
}

void GpuIndexBinaryCagra::train(idx_t n, const uint8_t* x) {
// The config is shared with the float index; there is no binary
// multi-GPU build, so reject rather than silently ignoring the request.
FAISS_THROW_IF_MSG(
cagraConfig_.devices.size() > 1,
"binary CAGRA has no multi-GPU build; "
"GpuIndexCagraConfig::devices must name at most one device");

DeviceScope scope(cagraConfig_.device);
if (this->is_trained) {
FAISS_ASSERT(index_);
Expand Down
Loading
Loading