Skip to content

Commit

Permalink
More docs updates for 24.04 (#54)
Browse files Browse the repository at this point in the history
Authors:
  - Corey J. Nolet (https://github.com/cjnolet)

Approvers:
  - Divye Gala (https://github.com/divyegala)

URL: #54
  • Loading branch information
cjnolet authored Mar 14, 2024
1 parent 6eb9bdb commit 5b8393f
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 104 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# <div align="left"><img src="https://rapids.ai/assets/images/rapids_logo.png" width="90px"/>&nbsp;cuVS: Vector Search and Clustering on the GPU</div>

> [!note]
> cuVS is a new library mostly derived from the approximate nearest neighbors and clustering algorithms in the [RAPIDS RAFT](https://github.com/rapidsai) library of data mining primitives. RAPIDS RAFT currently contains the most fully-featured versions of the approximate nearest neighbors and clustering algorithms in cuVS. We are in the process of migrating the algorithms from RAFT to cuVS, but if you are unsure of which to use, please consider the following:
> 1. RAFT contains C++ and Python APIs for all of the approximate nearest neighbors and clustering algorithms.
> 2. cuVS contains a growing support for different languages, including C, C++, Python, and Rust. We will be adding more language support to cuVS in the future but will not be improving the language support for RAFT.
> 3. Once all of RAFT's approximate nearest neighbors and clustering algorithms are moved to cuVS, the RAFT APIs will be deprecated and eventually removed altogether. Once removed, RAFT will become a lightweight header-only library. In the meantime, there's no harm in using RAFT if support for additional languages is not needed.

## Contents

1. [Useful Resources](#useful-resources)
Expand All @@ -23,11 +30,6 @@

cuVS contains state-of-the-art implementations of several algorithms for running approximate nearest neighbors and clustering on the GPU. It can be used directly or through the various databases and other libraries that have integrated it. The primary goal of cuVS is to simplify the use of GPUs for vector similarity search and clustering.

**Please note** that cuVS is a new library mostly derived from the approximate nearest neighbors and clustering algorithms in the [RAPIDS RAFT](https://github.com/rapidsai) library of data mining primitives. RAPIDS RAFT currently contains the most fully-featured versions of the approximate nearest neighbors and clustering algorithms in cuVS. We are in the process of migrating the algorithms from RAFT to cuVS, but if you are unsure of which to use, please consider the following:
1. RAFT contains C++ and Python APIs for all of the approximate nearest neighbors and clustering algorithms.
2. cuVS contains a growing support for different languages, including C, C++, Python, and Rust. We will be adding more language support to cuVS in the future but will not be improving the language support for RAFT.
3. Once all of RAFT's approximate nearest neighbors and clustering algorithms are moved to cuVS, the RAFT APIs will be deprecated and eventually removed altogether. Once removed, RAFT will become a lightweight header-only library. In the meantime, there's no harm in using RAFT if support for additional languages is not needed.

## Installing cuVS

cuVS comes with pre-built packages that can be installed through [conda](https://conda.io/projects/conda/en/latest/user-guide/getting-started.html#managing-python). Different packages are available for the different languages supported by cuVS:
Expand Down
107 changes: 8 additions & 99 deletions docs/source/working_with_ann_indexes.rst
Original file line number Diff line number Diff line change
@@ -1,102 +1,11 @@
Working with ANN Indexes
========================

- `Building an index`_
- `Searching an index`_
- `CPU/GPU Interoperability`_
- `Serializing an index`_

Building an index
-----------------

C
^

.. code-block:: c
#include <cuvs/neighbors/cagra.h>
cuvsResources_t res;
cuvsCagraIndexParams_t index_params;
cuvsCagraIndex_t index;
DLManagedTensor *dataset;
load_dataset(dataset);
cuvsResourcesCreate(&res);
cuvsCagraIndexParamsCreate(&index_params);
cuvsCagraIndexCreate(&index);
cuvsCagraBuild(res, index_params, dataset, index);
cuvsCagraIndexDestroy(index);
cuvsCagraIndexParamsDestroy(index_params);
cuvsResourcesDestroy(res);
C++
^^^

.. code-block:: c++

#include <cuvs/neighbors/cagra.hpp>

using namespace cuvs::neighbors;

raft::device_matrix_view<float> dataset = load_dataset();
raft::device_resources res;

cagra::index_params index_params;

auto index = cagra::build(res, index_params, dataset);


Python
^^^^^^

.. code-block:: python
from cuvs.neighbors import cagra
dataset = load_data()
index_params = cagra.IndexParams()
index = cagra.build_index(build_params, dataset)
Rust
^^^^

.. code-block:: rust
use cuvs::cagra::{Index, IndexParams};
use cuvs::{Resources, Result};
use ndarray_rand::rand_distr::Uniform;
use ndarray_rand::RandomExt;
/// Example showing how to index and search data with CAGRA
fn cagra_example() -> Result<()> {
let res = Resources::new()?;
// Create a new random dataset to index
let n_datapoints = 65536;
let n_features = 512;
let dataset =
ndarray::Array::<f32, _>::random((n_datapoints, n_features), Uniform::new(0., 1.0));
// build the cagra index
let build_params = IndexParams::new()?;
let index = Index::build(&res, &build_params, &dataset)?;
Ok(())
}
Searching an index
------------------


CPU/GPU interoperability
------------------------

Serializing an index
--------------------
.. toctree::
:maxdepth: 1
:caption: Contents:

working_with_ann_indexes_c.rst
working_with_ann_indexes_cpp.rst
working_with_ann_indexes_python.rst
working_with_ann_indexes_rust.rst
39 changes: 39 additions & 0 deletions docs/source/working_with_ann_indexes_c.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Working with ANN Indexes in C
=============================

- `Building an index`_
- `Searching an index`_
- `CPU/GPU Interoperability`_
- `Serializing an index`_

Building an index
-----------------

.. code-block:: c
#include <cuvs/neighbors/cagra.h>
cuvsResources_t res;
cuvsCagraIndexParams_t index_params;
cuvsCagraIndex_t index;
DLManagedTensor *dataset;
load_dataset(dataset);
cuvsResourcesCreate(&res);
cuvsCagraIndexParamsCreate(&index_params);
cuvsCagraIndexCreate(&index);
cuvsCagraBuild(res, index_params, dataset, index);
cuvsCagraIndexDestroy(index);
cuvsCagraIndexParamsDestroy(index_params);
cuvsResourcesDestroy(res);
Searching an index
------------------


Serializing an index
--------------------
35 changes: 35 additions & 0 deletions docs/source/working_with_ann_indexes_cpp.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Working with ANN Indexes in C++
===============================

- `Building an index`_
- `Searching an index`_
- `CPU/GPU Interoperability`_
- `Serializing an index`_

Building an index
-----------------

.. code-block:: c++

#include <cuvs/neighbors/cagra.hpp>

using namespace cuvs::neighbors;

raft::device_matrix_view<float> dataset = load_dataset();
raft::device_resources res;

cagra::index_params index_params;

auto index = cagra::build(res, index_params, dataset);



Searching an index
------------------


CPU/GPU interoperability
------------------------

Serializing an index
--------------------
30 changes: 30 additions & 0 deletions docs/source/working_with_ann_indexes_python.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Working with ANN Indexes in Python
==================================

- `Building an index`_
- `Searching an index`_
- `CPU/GPU Interoperability`_
- `Serializing an index`_

Building an index
-----------------

.. code-block:: python
from cuvs.neighbors import cagra
dataset = load_data()
index_params = cagra.IndexParams()
index = cagra.build_index(build_params, dataset)
Searching an index
------------------


CPU/GPU interoperability
------------------------

Serializing an index
--------------------
43 changes: 43 additions & 0 deletions docs/source/working_with_ann_indexes_rust.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Working with ANN Indexes in Rust
================================

- `Building an index`_
- `Searching an index`_
- `CPU/GPU Interoperability`_
- `Serializing an index`_

Building an index
-----------------

.. code-block:: rust
use cuvs::cagra::{Index, IndexParams};
use cuvs::{Resources, Result};
use ndarray_rand::rand_distr::Uniform;
use ndarray_rand::RandomExt;
/// Example showing how to index and search data with CAGRA
fn cagra_example() -> Result<()> {
let res = Resources::new()?;
// Create a new random dataset to index
let n_datapoints = 65536;
let n_features = 512;
let dataset =
ndarray::Array::<f32, _>::random((n_datapoints, n_features), Uniform::new(0., 1.0));
// build the cagra index
let build_params = IndexParams::new()?;
let index = Index::build(&res, &build_params, &dataset)?;
Ok(())
}
Searching an index
------------------


Serializing an index
--------------------

0 comments on commit 5b8393f

Please sign in to comment.