Distributed ANN#

The SNMG (single-node multi-GPUs) ANN API provides a set of functions to deploy ANN indexes on multiple GPUs.

#include <cuvs/neighbors/common.hpp>

namespace cuvs::neighbors

Index build parameters#

enum distribution_mode#

Distribution mode

Values:

enumerator REPLICATED#

Index is replicated on each device, favors throughput

enumerator SHARDED#

Index is split on several devices, favors scaling

template<typename Upstream>
struct mg_index_params : public Upstream#
#include <common.hpp>

Build parameters

Public Members

cuvs::neighbors::distribution_mode mode = SHARDED#

Distribution mode

Search parameters#

enum replicated_search_mode#

Search mode when using a replicated index

Values:

enumerator LOAD_BALANCER#

Search queries are splited to maintain equal load on GPUs

enumerator ROUND_ROBIN#

Each search query is processed by a single GPU in a round-robin fashion

enum sharded_merge_mode#

Merge mode when using a sharded index

Values:

enumerator MERGE_ON_ROOT_RANK#

Search batches are merged on the root rank

enumerator TREE_MERGE#

Search batches are merged in a tree reduction fashion

template<typename Upstream>
struct mg_search_params : public Upstream#
#include <common.hpp>

Search parameters

Public Members

cuvs::neighbors::replicated_search_mode search_mode = LOAD_BALANCER#

Replicated search mode

cuvs::neighbors::sharded_merge_mode merge_mode = TREE_MERGE#

Sharded merge mode

int64_t n_rows_per_batch = 1 << 20#

Number of rows per batch

Index build#

cuvs::neighbors::mg_index<cagra::index<float, uint32_t>, float, uint32_t> build(
const raft::resources &clique,
const cuvs::neighbors::mg_index_params<cagra::index_params> &index_params,
raft::host_matrix_view<const float, int64_t, row_major> index_dataset
)#

Builds a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<cagra::index_params> index_params;
auto index = cuvs::neighbors::cagra::build(clique, index_params, index_dataset);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index_params – configure the index building

  • index_dataset[in] a row-major matrix on host [n_rows, dim]

Returns:

the constructed CAGRA MG index

cuvs::neighbors::mg_index<cagra::index<half, uint32_t>, half, uint32_t> build(
const raft::resources &clique,
const cuvs::neighbors::mg_index_params<cagra::index_params> &index_params,
raft::host_matrix_view<const half, int64_t, row_major> index_dataset
)#

Builds a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<cagra::index_params> index_params;
auto index = cuvs::neighbors::cagra::build(clique, index_params, index_dataset);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index_params – configure the index building

  • index_dataset[in] a row-major matrix on host [n_rows, dim]

Returns:

the constructed CAGRA MG index

cuvs::neighbors::mg_index<cagra::index<int8_t, uint32_t>, int8_t, uint32_t> build(
const raft::resources &clique,
const cuvs::neighbors::mg_index_params<cagra::index_params> &index_params,
raft::host_matrix_view<const int8_t, int64_t, row_major> index_dataset
)#

Builds a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<cagra::index_params> index_params;
auto index = cuvs::neighbors::cagra::build(clique, index_params, index_dataset);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index_params – configure the index building

  • index_dataset[in] a row-major matrix on host [n_rows, dim]

Returns:

the constructed CAGRA MG index

cuvs::neighbors::mg_index<cagra::index<uint8_t, uint32_t>, uint8_t, uint32_t> build(
const raft::resources &clique,
const cuvs::neighbors::mg_index_params<cagra::index_params> &index_params,
raft::host_matrix_view<const uint8_t, int64_t, row_major> index_dataset
)#

Builds a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<cagra::index_params> index_params;
auto index = cuvs::neighbors::cagra::build(clique, index_params, index_dataset);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index_params – configure the index building

  • index_dataset[in] a row-major matrix on host [n_rows, dim]

Returns:

the constructed CAGRA MG index

cuvs::neighbors::mg_index<ivf_flat::index<float, int64_t>, float, int64_t> build(
const raft::resources &clique,
const cuvs::neighbors::mg_index_params<ivf_flat::index_params> &index_params,
raft::host_matrix_view<const float, int64_t, row_major> index_dataset
)#

Builds a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_flat::index_params> index_params;
auto index = cuvs::neighbors::ivf_flat::build(clique, index_params, index_dataset);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index_params – configure the index building

  • index_dataset[in] a row-major matrix on host [n_rows, dim]

Returns:

the constructed IVF-Flat MG index

cuvs::neighbors::mg_index<ivf_flat::index<int8_t, int64_t>, int8_t, int64_t> build(
const raft::resources &clique,
const cuvs::neighbors::mg_index_params<ivf_flat::index_params> &index_params,
raft::host_matrix_view<const int8_t, int64_t, row_major> index_dataset
)#

Builds a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_flat::index_params> index_params;
auto index = cuvs::neighbors::ivf_flat::build(clique, index_params, index_dataset);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index_params – configure the index building

  • index_dataset[in] a row-major matrix on host [n_rows, dim]

Returns:

the constructed IVF-Flat MG index

cuvs::neighbors::mg_index<ivf_flat::index<uint8_t, int64_t>, uint8_t, int64_t> build(
const raft::resources &clique,
const cuvs::neighbors::mg_index_params<ivf_flat::index_params> &index_params,
raft::host_matrix_view<const uint8_t, int64_t, row_major> index_dataset
)#

Builds a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_flat::index_params> index_params;
auto index = cuvs::neighbors::ivf_flat::build(clique, index_params, index_dataset);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index_params – configure the index building

  • index_dataset[in] a row-major matrix on host [n_rows, dim]

Returns:

the constructed IVF-Flat MG index

cuvs::neighbors::mg_index<ivf_pq::index<int64_t>, float, int64_t> build(
const raft::resources &clique,
const cuvs::neighbors::mg_index_params<ivf_pq::index_params> &index_params,
raft::host_matrix_view<const float, int64_t, row_major> index_dataset
)#

Builds a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_pq::index_params> index_params;
auto index = cuvs::neighbors::ivf_pq::build(clique, index_params, index_dataset);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index_params – configure the index building

  • index_dataset[in] a row-major matrix on host [n_rows, dim]

Returns:

the constructed IVF-PQ MG index

cuvs::neighbors::mg_index<ivf_pq::index<int64_t>, half, int64_t> build(
const raft::resources &clique,
const cuvs::neighbors::mg_index_params<ivf_pq::index_params> &index_params,
raft::host_matrix_view<const half, int64_t, row_major> index_dataset
)#

Builds a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_pq::index_params> index_params;
auto index = cuvs::neighbors::ivf_pq::build(clique, index_params, index_dataset);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index_params – configure the index building

  • index_dataset[in] a row-major matrix on host [n_rows, dim]

Returns:

the constructed IVF-PQ MG index

cuvs::neighbors::mg_index<ivf_pq::index<int64_t>, int8_t, int64_t> build(
const raft::resources &clique,
const cuvs::neighbors::mg_index_params<ivf_pq::index_params> &index_params,
raft::host_matrix_view<const int8_t, int64_t, row_major> index_dataset
)#

Builds a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_pq::index_params> index_params;
auto index = cuvs::neighbors::ivf_pq::build(clique, index_params, index_dataset);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index_params – configure the index building

  • index_dataset[in] a row-major matrix on host [n_rows, dim]

Returns:

the constructed IVF-PQ MG index

cuvs::neighbors::mg_index<ivf_pq::index<int64_t>, uint8_t, int64_t> build(
const raft::resources &clique,
const cuvs::neighbors::mg_index_params<ivf_pq::index_params> &index_params,
raft::host_matrix_view<const uint8_t, int64_t, row_major> index_dataset
)#

Builds a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_pq::index_params> index_params;
auto index = cuvs::neighbors::ivf_pq::build(clique, index_params, index_dataset);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index_params – configure the index building

  • index_dataset[in] a row-major matrix on host [n_rows, dim]

Returns:

the constructed IVF-PQ MG index

Index extend#

void extend(
const raft::resources &clique,
cuvs::neighbors::mg_index<cagra::index<float, uint32_t>, float, uint32_t> &index,
raft::host_matrix_view<const float, int64_t, row_major> new_vectors,
std::optional<raft::host_vector_view<const uint32_t, int64_t>> new_indices
)#

Extends a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<cagra::index_params> index_params;
auto index = cuvs::neighbors::cagra::build(clique, index_params, index_dataset);
cuvs::neighbors::cagra::extend(clique, index, new_vectors, std::nullopt);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • new_vectors[in] a row-major matrix on host [n_rows, dim]

  • new_indices[in] optional vector on host [n_rows], std::nullopt means default continuous range [0...n_rows)

void extend(
const raft::resources &clique,
cuvs::neighbors::mg_index<cagra::index<half, uint32_t>, half, uint32_t> &index,
raft::host_matrix_view<const half, int64_t, row_major> new_vectors,
std::optional<raft::host_vector_view<const uint32_t, int64_t>> new_indices
)#

Extends a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<cagra::index_params> index_params;
auto index = cuvs::neighbors::cagra::build(clique, index_params, index_dataset);
cuvs::neighbors::cagra::extend(clique, index, new_vectors, std::nullopt);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • new_vectors[in] a row-major matrix on host [n_rows, dim]

  • new_indices[in] optional vector on host [n_rows], std::nullopt means default continuous range [0...n_rows)

void extend(
const raft::resources &clique,
cuvs::neighbors::mg_index<cagra::index<int8_t, uint32_t>, int8_t, uint32_t> &index,
raft::host_matrix_view<const int8_t, int64_t, row_major> new_vectors,
std::optional<raft::host_vector_view<const uint32_t, int64_t>> new_indices
)#

Extends a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<cagra::index_params> index_params;
auto index = cuvs::neighbors::cagra::build(clique, index_params, index_dataset);
cuvs::neighbors::cagra::extend(clique, index, new_vectors, std::nullopt);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • new_vectors[in] a row-major matrix on host [n_rows, dim]

  • new_indices[in] optional vector on host [n_rows], std::nullopt means default continuous range [0...n_rows)

void extend(
const raft::resources &clique,
cuvs::neighbors::mg_index<cagra::index<uint8_t, uint32_t>, uint8_t, uint32_t> &index,
raft::host_matrix_view<const uint8_t, int64_t, row_major> new_vectors,
std::optional<raft::host_vector_view<const uint32_t, int64_t>> new_indices
)#

Extends a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<cagra::index_params> index_params;
auto index = cuvs::neighbors::cagra::build(clique, index_params, index_dataset);
cuvs::neighbors::cagra::extend(clique, index, new_vectors, std::nullopt);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • new_vectors[in] a row-major matrix on host [n_rows, dim]

  • new_indices[in] optional vector on host [n_rows], std::nullopt means default continuous range [0...n_rows)

void extend(
const raft::resources &clique,
cuvs::neighbors::mg_index<ivf_flat::index<float, int64_t>, float, int64_t> &index,
raft::host_matrix_view<const float, int64_t, row_major> new_vectors,
std::optional<raft::host_vector_view<const int64_t, int64_t>> new_indices
)#

Extends a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_flat::index_params> index_params;
auto index = cuvs::neighbors::ivf_flat::build(clique, index_params, index_dataset);
cuvs::neighbors::ivf_flat::extend(clique, index, new_vectors, std::nullopt);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • new_vectors[in] a row-major matrix on host [n_rows, dim]

  • new_indices[in] optional vector on host [n_rows], std::nullopt means default continuous range [0...n_rows)

void extend(
const raft::resources &clique,
cuvs::neighbors::mg_index<ivf_flat::index<int8_t, int64_t>, int8_t, int64_t> &index,
raft::host_matrix_view<const int8_t, int64_t, row_major> new_vectors,
std::optional<raft::host_vector_view<const int64_t, int64_t>> new_indices
)#

Extends a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_flat::index_params> index_params;
auto index = cuvs::neighbors::ivf_flat::build(clique, index_params, index_dataset);
cuvs::neighbors::ivf_flat::extend(clique, index, new_vectors, std::nullopt);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • new_vectors[in] a row-major matrix on host [n_rows, dim]

  • new_indices[in] optional vector on host [n_rows], std::nullopt means default continuous range [0...n_rows)

void extend(
const raft::resources &clique,
cuvs::neighbors::mg_index<ivf_flat::index<uint8_t, int64_t>, uint8_t, int64_t> &index,
raft::host_matrix_view<const uint8_t, int64_t, row_major> new_vectors,
std::optional<raft::host_vector_view<const int64_t, int64_t>> new_indices
)#

Extends a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_flat::index_params> index_params;
auto index = cuvs::neighbors::ivf_flat::build(clique, index_params, index_dataset);
cuvs::neighbors::ivf_flat::extend(clique, index, new_vectors, std::nullopt);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • new_vectors[in] a row-major matrix on host [n_rows, dim]

  • new_indices[in] optional vector on host [n_rows], std::nullopt means default continuous range [0...n_rows)

void extend(
const raft::resources &clique,
cuvs::neighbors::mg_index<ivf_pq::index<int64_t>, float, int64_t> &index,
raft::host_matrix_view<const float, int64_t, row_major> new_vectors,
std::optional<raft::host_vector_view<const int64_t, int64_t>> new_indices
)#

Extends a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_pq::index_params> index_params;
auto index = cuvs::neighbors::ivf_pq::build(clique, index_params, index_dataset);
cuvs::neighbors::ivf_pq::extend(clique, index, new_vectors, std::nullopt);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • new_vectors[in] a row-major matrix on host [n_rows, dim]

  • new_indices[in] optional vector on host [n_rows], std::nullopt means default continuous range [0...n_rows)

void extend(
const raft::resources &clique,
cuvs::neighbors::mg_index<ivf_pq::index<int64_t>, half, int64_t> &index,
raft::host_matrix_view<const half, int64_t, row_major> new_vectors,
std::optional<raft::host_vector_view<const int64_t, int64_t>> new_indices
)#

Extends a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_pq::index_params> index_params;
auto index = cuvs::neighbors::ivf_pq::build(clique, index_params, index_dataset);
cuvs::neighbors::ivf_pq::extend(clique, index, new_vectors, std::nullopt);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • new_vectors[in] a row-major matrix on host [n_rows, dim]

  • new_indices[in] optional vector on host [n_rows], std::nullopt means default continuous range [0...n_rows)

void extend(
const raft::resources &clique,
cuvs::neighbors::mg_index<ivf_pq::index<int64_t>, int8_t, int64_t> &index,
raft::host_matrix_view<const int8_t, int64_t, row_major> new_vectors,
std::optional<raft::host_vector_view<const int64_t, int64_t>> new_indices
)#

Extends a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_pq::index_params> index_params;
auto index = cuvs::neighbors::ivf_pq::build(clique, index_params, index_dataset);
cuvs::neighbors::ivf_pq::extend(clique, index, new_vectors, std::nullopt);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • new_vectors[in] a row-major matrix on host [n_rows, dim]

  • new_indices[in] optional vector on host [n_rows], std::nullopt means default continuous range [0...n_rows)

void extend(
const raft::resources &clique,
cuvs::neighbors::mg_index<ivf_pq::index<int64_t>, uint8_t, int64_t> &index,
raft::host_matrix_view<const uint8_t, int64_t, row_major> new_vectors,
std::optional<raft::host_vector_view<const int64_t, int64_t>> new_indices
)#

Extends a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_pq::index_params> index_params;
auto index = cuvs::neighbors::ivf_pq::build(clique, index_params, index_dataset);
cuvs::neighbors::ivf_pq::extend(clique, index, new_vectors, std::nullopt);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • new_vectors[in] a row-major matrix on host [n_rows, dim]

  • new_indices[in] optional vector on host [n_rows], std::nullopt means default continuous range [0...n_rows)

Index serialize#

void serialize(
const raft::resources &clique,
const cuvs::neighbors::mg_index<cagra::index<float, uint32_t>, float, uint32_t> &index,
const std::string &filename
)#

Serializes a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<cagra::index_params> index_params;
auto index = cuvs::neighbors::cagra::build(clique, index_params, index_dataset);
const std::string filename = "mg_index.cuvs";
cuvs::neighbors::cagra::serialize(clique, index, filename);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • filename[in] path to the file to be serialized

void serialize(
const raft::resources &clique,
const cuvs::neighbors::mg_index<cagra::index<half, uint32_t>, half, uint32_t> &index,
const std::string &filename
)#

Serializes a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<cagra::index_params> index_params;
auto index = cuvs::neighbors::cagra::build(clique, index_params, index_dataset);
const std::string filename = "mg_index.cuvs";
cuvs::neighbors::cagra::serialize(clique, index, filename);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • filename[in] path to the file to be serialized

void serialize(
const raft::resources &clique,
const cuvs::neighbors::mg_index<cagra::index<int8_t, uint32_t>, int8_t, uint32_t> &index,
const std::string &filename
)#

Serializes a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<cagra::index_params> index_params;
auto index = cuvs::neighbors::cagra::build(clique, index_params, index_dataset);
const std::string filename = "mg_index.cuvs";
cuvs::neighbors::cagra::serialize(clique, index, filename);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • filename[in] path to the file to be serialized

void serialize(
const raft::resources &clique,
const cuvs::neighbors::mg_index<cagra::index<uint8_t, uint32_t>, uint8_t, uint32_t> &index,
const std::string &filename
)#

Serializes a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<cagra::index_params> index_params;
auto index = cuvs::neighbors::cagra::build(clique, index_params, index_dataset);
const std::string filename = "mg_index.cuvs";
cuvs::neighbors::cagra::serialize(clique, index, filename);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • filename[in] path to the file to be serialized

void serialize(
const raft::resources &clique,
const cuvs::neighbors::mg_index<ivf_flat::index<float, int64_t>, float, int64_t> &index,
const std::string &filename
)#

Serializes a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_flat::index_params> index_params;
auto index = cuvs::neighbors::ivf_flat::build(clique, index_params, index_dataset);
const std::string filename = "mg_index.cuvs";
cuvs::neighbors::ivf_flat::serialize(clique, index, filename);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • filename[in] path to the file to be serialized

void serialize(
const raft::resources &clique,
const cuvs::neighbors::mg_index<ivf_flat::index<int8_t, int64_t>, int8_t, int64_t> &index,
const std::string &filename
)#

Serializes a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_flat::index_params> index_params;
auto index = cuvs::neighbors::ivf_flat::build(clique, index_params, index_dataset);
const std::string filename = "mg_index.cuvs";
cuvs::neighbors::ivf_flat::serialize(clique, index, filename);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • filename[in] path to the file to be serialized

void serialize(
const raft::resources &clique,
const cuvs::neighbors::mg_index<ivf_flat::index<uint8_t, int64_t>, uint8_t, int64_t> &index,
const std::string &filename
)#

Serializes a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_flat::index_params> index_params;
auto index = cuvs::neighbors::ivf_flat::build(clique, index_params, index_dataset);
const std::string filename = "mg_index.cuvs";
cuvs::neighbors::ivf_flat::serialize(clique, index, filename);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • filename[in] path to the file to be serialized

void serialize(
const raft::resources &clique,
const cuvs::neighbors::mg_index<ivf_pq::index<int64_t>, float, int64_t> &index,
const std::string &filename
)#

Serializes a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_pq::index_params> index_params;
auto index = cuvs::neighbors::ivf_pq::build(clique, index_params, index_dataset);
const std::string filename = "mg_index.cuvs";
cuvs::neighbors::ivf_pq::serialize(clique, index, filename);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • filename[in] path to the file to be serialized

void serialize(
const raft::resources &clique,
const cuvs::neighbors::mg_index<ivf_pq::index<int64_t>, half, int64_t> &index,
const std::string &filename
)#

Serializes a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_pq::index_params> index_params;
auto index = cuvs::neighbors::ivf_pq::build(clique, index_params, index_dataset);
const std::string filename = "mg_index.cuvs";
cuvs::neighbors::ivf_pq::serialize(clique, index, filename);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • filename[in] path to the file to be serialized

void serialize(
const raft::resources &clique,
const cuvs::neighbors::mg_index<ivf_pq::index<int64_t>, int8_t, int64_t> &index,
const std::string &filename
)#

Serializes a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_pq::index_params> index_params;
auto index = cuvs::neighbors::ivf_pq::build(clique, index_params, index_dataset);
const std::string filename = "mg_index.cuvs";
cuvs::neighbors::ivf_pq::serialize(clique, index, filename);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • filename[in] path to the file to be serialized

void serialize(
const raft::resources &clique,
const cuvs::neighbors::mg_index<ivf_pq::index<int64_t>, uint8_t, int64_t> &index,
const std::string &filename
)#

Serializes a multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_pq::index_params> index_params;
auto index = cuvs::neighbors::ivf_pq::build(clique, index_params, index_dataset);
const std::string filename = "mg_index.cuvs";
cuvs::neighbors::ivf_pq::serialize(clique, index, filename);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • index[in] the pre-built index

  • filename[in] path to the file to be serialized

Index deserialize#

template<typename T, typename IdxT>
cuvs::neighbors::mg_index<cagra::index<T, IdxT>, T, IdxT> deserialize(
const raft::resources &clique,
const std::string &filename
)#

Deserializes a CAGRA multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<cagra::index_params> index_params;
auto index = cuvs::neighbors::cagra::build(clique, index_params, index_dataset);
const std::string filename = "mg_index.cuvs";
cuvs::neighbors::cagra::serialize(clique, index, filename);
auto new_index = cuvs::neighbors::cagra::deserialize<float, uint32_t>(clique, filename);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • filename[in] path to the file to be deserialized

template<typename T, typename IdxT>
cuvs::neighbors::mg_index<ivf_flat::index<T, IdxT>, T, IdxT> deserialize(
const raft::resources &clique,
const std::string &filename
)#

Deserializes an IVF-Flat multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_flat::index_params> index_params;
auto index = cuvs::neighbors::ivf_flat::build(clique, index_params, index_dataset);
const std::string filename = "mg_index.cuvs";
cuvs::neighbors::ivf_flat::serialize(clique, index, filename);
auto new_index = cuvs::neighbors::ivf_flat::deserialize<float, int64_t>(clique, filename);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • filename[in] path to the file to be deserialized

template<typename T, typename IdxT>
cuvs::neighbors::mg_index<ivf_pq::index<IdxT>, T, IdxT> deserialize(
const raft::resources &clique,
const std::string &filename
)#

Deserializes an IVF-PQ multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::mg_index_params<ivf_pq::index_params> index_params;
auto index = cuvs::neighbors::ivf_pq::build(clique, index_params, index_dataset);
const std::string filename = "mg_index.cuvs";
cuvs::neighbors::ivf_pq::serialize(clique, index, filename);
auto new_index = cuvs::neighbors::ivf_pq::deserialize<float, int64_t>(clique, filename);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • filename[in] path to the file to be deserialized

Distribute pre-built local index#

template<typename T, typename IdxT>
cuvs::neighbors::mg_index<cagra::index<T, IdxT>, T, IdxT> distribute(
const raft::resources &clique,
const std::string &filename
)#

Replicates a locally built and serialized CAGRA index to all GPUs to form a distributed multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::cagra::index_params index_params;
auto index = cuvs::neighbors::cagra::build(clique, index_params, index_dataset);
const std::string filename = "local_index.cuvs";
cuvs::neighbors::cagra::serialize(clique, filename, index);
auto new_index = cuvs::neighbors::cagra::distribute<float, uint32_t>(clique, filename);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • filename[in] path to the file to be deserialized : a local index

template<typename T, typename IdxT>
cuvs::neighbors::mg_index<ivf_flat::index<T, IdxT>, T, IdxT> distribute(
const raft::resources &clique,
const std::string &filename
)#

Replicates a locally built and serialized IVF-Flat index to all GPUs to form a distributed multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::ivf_flat::index_params index_params;
auto index = cuvs::neighbors::ivf_flat::build(clique, index_params, index_dataset);
const std::string filename = "local_index.cuvs";
cuvs::neighbors::ivf_flat::serialize(clique, filename, index);
auto new_index = cuvs::neighbors::ivf_flat::distribute<float, int64_t>(clique, filename);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • filename[in] path to the file to be deserialized : a local index

template<typename T, typename IdxT>
cuvs::neighbors::mg_index<ivf_pq::index<IdxT>, T, IdxT> distribute(
const raft::resources &clique,
const std::string &filename
)#

Replicates a locally built and serialized IVF-PQ index to all GPUs to form a distributed multi-GPU index.

Usage example:

raft::device_resources_snmg clique;
cuvs::neighbors::ivf_pq::index_params index_params;
auto index = cuvs::neighbors::ivf_pq::build(clique, index_params, index_dataset);
const std::string filename = "local_index.cuvs";
cuvs::neighbors::ivf_pq::serialize(clique, filename, index);
auto new_index = cuvs::neighbors::ivf_pq::distribute<float, int64_t>(clique, filename);

Parameters:
  • clique[in] a raft::resources object specifying the NCCL clique configuration

  • filename[in] path to the file to be deserialized : a local index