Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ann-bench Documentation #1754

Merged
merged 8 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
10 changes: 8 additions & 2 deletions bench/ann/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,14 @@ def main():
conf_file = json.load(f)

# Replace base, query to dataset-path
conf_file["dataset"]["base_file"] = os.path.join(dataset_path, "base.fbin")
conf_file["dataset"]["query_file"] = os.path.join(dataset_path, "query.fbin")
replacement_base_filepath = \
os.path.normpath(conf_file["dataset"]["base_file"]).split(os.path.sep)[-1]
conf_file["dataset"]["base_file"] = \
os.path.join(dataset_path, replacement_base_filepath)
replacement_query_filepath = \
os.path.normpath(conf_file["dataset"]["query_file"]).split(os.path.sep)[-1]
conf_file["dataset"]["query_file"] = \
os.path.join(dataset_path, replacement_query_filepath)
# Ensure base and query files exist for dataset
if not os.path.exists(conf_file["dataset"]["base_file"]):
raise FileNotFoundError(conf_file["dataset"]["base_file"])
Expand Down
43 changes: 22 additions & 21 deletions docs/source/raft_ann_benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ This project provides a benchmark program for various ANN search implementations

The easiest way to install these benchmarks is through conda. We suggest using mamba as it generally leads to a faster install time::
```bash
git clone https://github.com/rapidsai/raft.git && cd raft
export RAFT_HOME=$(pwd)

mamba env create --name raft_ann_benchmarks -f conda/environments/bench_ann_cuda-118_arch-x86_64.yaml
conda activate raft_ann_benchmarks

mamba install -c rapidsai -c conda-forge -c nvidia libraft libraft-ann-bench cudatoolkit=11.8*

git clone https://github.com/rapidsai/raft.git && cd raft
export RAFT_HOME=$(pwd)
```
The channel `rapidsai` can easily be substituted `rapidsai-nightly` if nightly benchmarks are desired.

Expand All @@ -35,50 +35,50 @@ expected to be defined to run these scripts; this variable holds the directory w
### End-to-end example: Million-scale
```bash
export RAFT_HOME=$(pwd)
# All scripts are present in directory raft/scripts/ann-benchmarks
# All scripts are present in directory raft/bench/ann

# (1) prepare dataset
python scripts/ann-benchmarks/get_dataset.py --dataset glove-100-angular --normalize
python bench/ann/get_dataset.py --dataset glove-100-angular --normalize

# (2) build and search index
python scripts/ann-benchmarks/run.py --configuration bench/ann/conf/glove-100-inner.json
python bench/ann/run.py --dataset glove-100-inner

# (3) evaluate results
python scripts/ann-benchmarks/data_export.py --output out.csv --dataset glove-100-inner result/glove-100-inner/
python bench/ann/data_export.py --output out.csv --dataset glove-100-inner result/glove-100-inner/
divyegala marked this conversation as resolved.
Show resolved Hide resolved

# (4) plot results
python scripts/ann-benchmarks/plot.py --result-csv out.csv
python bench/ann/plot.py --result-csv out.csv
```

### End-to-end example: Billion-scale
`scripts/get_dataset.py` cannot be used to download the [billion-scale datasets](ann_benchmarks_dataset.md#billion-scale)
`bench/ann/get_dataset.py` cannot be used to download the [billion-scale datasets](ann_benchmarks_dataset.md#billion-scale)
because they are so large. You should instead use our billion-scale datasets guide to download and prepare them.
All other python scripts mentioned below work as intended once the
All other python mentioned below work as intended once the
billion-scale dataset has been downloaded.
To download Billion-scale datasets, visit [big-ann-benchmarks](http://big-ann-benchmarks.com/neurips21.html)

```bash
export RAFT_HOME=$(pwd)
# All scripts are present in directory raft/scripts/ann-benchmarks
# All scripts are present in directory raft/bench/ann

mkdir -p data/deep-1B
# (1) prepare dataset
# download manually "Ground Truth" file of "Yandex DEEP"
# suppose the file name is deep_new_groundtruth.public.10K.bin
python scripts/ann-benchmarks/split_groundtruth.py --groundtruth data/deep-1B/deep_new_groundtruth.public.10K.bin
python bench/ann/split_groundtruth.py --groundtruth data/deep-1B/deep_new_groundtruth.public.10K.bin
# two files 'groundtruth.neighbors.ibin' and 'groundtruth.distances.fbin' should be produced

# (2) build and search index
python scripts/ann-benchmarks/run.py --configuration bench/ann/conf/deep-1B.json
python bench/ann/run.py --dataset deep-1B

# (3) evaluate results
python scripts/ann-benchmarks/data_export.py --output out.csv --dataset deep-1B result/deep-1B/
python bench/ann/data_export.py --output out.csv --dataset deep-1B result/deep-1B/

# (4) plot results
python scripts/ann-benchmarks/plot.py --result-csv out.csv
python bench/ann/plot.py --result-csv out.csv
```

The usage of `scripts/ann-benchmarks/split-groundtruth.py` is:
The usage of `bench/ann/split-groundtruth.py` is:
```bash
usage: split_groundtruth.py [-h] --groundtruth GROUNDTRUTH

Expand All @@ -89,7 +89,7 @@ options:
```

##### Step 1: Prepare Dataset<a id='prep-dataset'></a>
The script `scripts/ann-benchmarks/get_dataset.py` will download and unpack the dataset in directory
The script `bench/ann/get_dataset.py` will download and unpack the dataset in directory
that the user provides. As of now, only million-scale datasets are supported by this
script. For more information on [datasets and formats](ann_benchmarks_dataset.md).

Expand All @@ -107,9 +107,10 @@ options:
When option `normalize` is provided to the script, any dataset that has cosine distances
will be normalized to inner product. So, for example, the dataset `glove-100-angular`
will be written at location `${RAFT_HOME}/bench/ann/data/glove-100-inner/`.
```

#### Step 2: Build and Search Index
The script `scripts/ann-benchmarks/run.py` will build and search indices for a given dataset and its
The script `bench/ann/run.py` will build and search indices for a given dataset and its
specified configuration.
To confirgure which algorithms are available, we use `algos.yaml`.
To configure building/searching indices for a dataset, look at [index configuration](#json-index-config).
Expand All @@ -123,7 +124,7 @@ raft_ivf_pq:
available in `raft/cpp/build/`.
`disabled` : denotes whether an algorithm should be excluded from benchmark runs.

The usage of the script `scripts/run.py` is:
The usage of the script `bench/ann/run.py` is:
```bash
usage: run.py [-h] [--configuration CONFIGURATION] [--dataset DATASET] [--build] [--search] [--algorithms ALGORITHMS] [--indices INDICES] [-f]

Expand Down Expand Up @@ -161,7 +162,7 @@ it is assumed both are `True`.
is available in `algos.yaml` and not disabled, as well as having an associated executable.

#### Step 3: Evaluating Results
The script `scripts/ann-benchmarks/data_export.py` will evaluate results for a dataset whose index has been built
The script `bench/ann/data_export.py` will evaluate results for a dataset whose index has been built
and search with at least one algorithm. For every result file that is supplied to the script, the output
will be combined and written to a CSV file.

Expand All @@ -181,7 +182,7 @@ options:
`result-filepaths` : whitespace delimited list of result files/directories that can be captured via pattern match. For more [information and examples](ann_benchmarks_low_level.html#result-filepath-example)

#### Step 4: Plot Results
The script `scripts/ann-benchmarks/plot.py` will plot all results evaluated to a CSV file for a given dataset.
The script `bench/ann/plot.py` will plot all results evaluated to a CSV file for a given dataset.
divyegala marked this conversation as resolved.
Show resolved Hide resolved

The usage of this script is:
```bash
Expand Down