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

Exp: Basic setup and DiskANN experiments #27

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode
build
67 changes: 17 additions & 50 deletions algorithms/utils/check_nn_recall.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ nn_result checkRecall(const Graph<indexType> &G,
return N;
}

void write_to_csv(std::string csv_filename, parlay::sequence<float> buckets,
void write_to_csv(std::string csv_filename,
parlay::sequence<nn_result> results, Graph_ G) {
csvfile csv(csv_filename);
csv << "GRAPH"
Expand All @@ -140,7 +140,6 @@ void write_to_csv(std::string csv_filename, parlay::sequence<float> buckets,
<< endrow;
csv << endrow;
csv << "Num queries"
<< "Target recall"
<< "Actual recall"
<< "QPS"
<< "Average Cmps"
Expand All @@ -152,7 +151,7 @@ void write_to_csv(std::string csv_filename, parlay::sequence<float> buckets,
<< "cut" << endrow;
for (int i = 0; i < results.size(); i++) {
nn_result N = results[i];
csv << N.num_queries << buckets[i] << N.recall << N.QPS << N.avg_cmps
csv << N.num_queries << N.recall << N.QPS << N.avg_cmps
<< N.tail_cmps << N.avg_visited << N.tail_visited << N.k << N.beamQ
<< N.cut << endrow;
}
Expand Down Expand Up @@ -214,59 +213,27 @@ void search_and_parse(Graph_ G_,
QP.limit = (long) G.size();
QP.rerank_factor = rerank_factor;
QP.degree_limit = (long) G.max_degree();
beams = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 24, 26, 28, 30, 32,
34, 36, 38, 40, 45, 50, 55, 60, 65, 70, 80, 90, 100, 120, 140, 160,
180, 200, 225, 250, 275, 300, 375, 500, 750, 1000};
beams = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 125, 150, 200, 250, 275, 300, 375, 500, 750, 1000};
if(k==0) allr = {10};
else allr = {k};
cuts = {1.35};

if (fixed_beam_width != 0) {
QP.k = allr[0];
QP.cut = cuts[0];
QP.beamSize = fixed_beam_width;
for (int i = 0; i < 5; i++)
check(QP.k, QP);
} else {
for (long r : allr) {
results.clear();
QP.k = r;
for (float cut : cuts){
QP.cut = cut;
for (float Q : beams){
QP.beamSize = Q;
if (Q >= r){
results.push_back(check(r, QP));
}

std::cout<<"Fixed beam width: "<<fixed_beam_width<<std::endl;
for (long r : allr) {
results.clear();
QP.k = r;
for (float cut : cuts){
QP.cut = cut;
for (float Q : beams){
QP.beamSize = Q;
if (Q >= r){
results.push_back(check(r, QP));
}
}

// check "limited accuracy"
// {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 30, 35}; //
parlay::sequence<long> limits = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 30, 35};
//calculate_limits(results[0].avg_visited);
//parlay::sequence<long> degree_limits = calculate_limits(G.max_degree());
//degree_limits.push_back(G.max_degree());
QP = QueryParams(r, r, 1.35, (long) G.size(), (long) G.max_degree());
for(long l : limits){
QP.limit = l;
QP.beamSize = std::max<long>(l, r);
//for(long dl : degree_limits){
QP.degree_limit = std::min<int>(G.max_degree(), 5 * l);
results.push_back(check(r, QP));
}
// check "best accuracy"
QP = QueryParams((long) 100, (long) 1000, (double) 10.0, (long) G.size(), (long) G.max_degree());
results.push_back(check(r, QP));

parlay::sequence<float> buckets = {.1, .2, .3, .4, .5, .6, .7, .75, .8, .85,
.9, .93, .95, .97, .98, .99, .995, .999, .9995,
.9999, .99995, .99999};
auto [res, ret_buckets] = parse_result(results, buckets);
std::cout << std::endl;
if (res_file != NULL)
write_to_csv(std::string(res_file), ret_buckets, res, G_);
}
std::cout << std::endl;
if (res_file != NULL)
write_to_csv(std::string(res_file), results, G_);
}
}

Expand Down
140 changes: 140 additions & 0 deletions algorithms/vamana/parlay_vamana_results.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
"GRAPH","Parameters","Size","Build time","Avg degree","Max degree"
"Vamana","R = 64, L = 100",1010812,306.005,47.5557,64

"Num queries","Target recall","Actual recall","QPS","Average Cmps","Tail Cmps","Average Visited","Tail Visited","k","Q","cut"
13265,0.1,0.144109,107123,469,490,10,10,10,10,1.35
13265,0.2,0.236932,72406,670,703,12,12,10,12,1.35
13265,0.3,0.305435,57168.8,828,871,14,14,10,14,1.35
13265,0.4,0.414489,41645.3,1110,1175,19,19,10,19,1.35
13265,0.5,0.509242,33372,1376,2327,23,40,10,14,1.35
13265,0.6,0.602314,23899,1882,3145,32,54,10,22,1.35
13265,0.7,0.703777,15759.5,2823,4520,49,78,10,38,1.35
13265,0.75,0.760671,11730.2,3784,5660,66,98,10,55,1.35
13265,0.8,0.812439,8598.29,5064,7278,92,129,10,80,1.35
13265,0.85,0.858093,6123.03,6994,9707,133,174,10,120,1.35
13265,0.9,0.902676,3913.39,10516,14071,218,261,10,200,1.35
13265,0.93,0.930418,2714.22,14857,19754,324,372,10,300,1.35
13265,0.95,0.95663,1717.45,23216,30743,537,596,10,500,1.35
13265,0.97,0.971964,1182.04,32974,43910,816,899,10,750,1.35


"GRAPH","Parameters","Size","Build time","Avg degree","Max degree"
"Vamana","R = 32, L = 50",1010812,70.5576,22.9389,32

"Num queries","Target recall","Actual recall","QPS","Average Cmps","Tail Cmps","Average Visited","Tail Visited","k","Q","cut"
13265,0.1,0.103468,114707,397,427,14,14,10,14,1.35
13265,0.2,0.224109,80493.9,588,1039,20,37,10,10,1.35
13265,0.3,0.301357,59723.5,784,1373,28,50,10,15,1.35
13265,0.4,0.406672,33859.8,1150,2002,42,73,10,24,1.35
13265,0.5,0.50634,23632.8,1666,2867,61,104,10,40,1.35
13265,0.6,0.602133,15665,2474,4190,95,159,10,70,1.35
13265,0.7,0.701153,8997.7,4163,6616,174,265,10,140,1.35
13265,0.75,0.755665,6040.98,6092,8989,267,372,10,225,1.35
13265,0.8,0.806385,3849.66,9292,13149,437,548,10,375,1.35
13265,0.85,0.861772,2048.92,16941,23427,861,999,10,750,1.35


"GRAPH","Parameters","Size","Build time","Avg degree","Max degree"
"Vamana","R = 32, L = 50",1010812,0,22.9389,32

"Num queries","Target recall","Actual recall","QPS","Average Cmps","Tail Cmps","Average Visited","Tail Visited","k","Q","cut"
13265,0.1,0.103468,114800,397,427,14,14,10,14,1.35
13265,0.2,0.208194,68717.4,615,661,22,22,10,22,1.35
13265,0.3,0.339299,42290.3,961,1038,35,35,10,35,1.35
13265,0.4,0.406672,31805.1,1150,2002,42,73,10,24,1.35
13265,0.5,0.50634,17573.4,1666,2867,61,104,10,40,1.35
13265,0.6,0.602133,12943.3,2474,4190,95,159,10,70,1.35
13265,0.7,0.701153,7510.01,4163,6616,174,265,10,140,1.35
13265,0.75,0.766174,5438.07,6659,9652,294,396,10,250,1.35
13265,0.8,0.806385,3811.94,9292,13149,437,548,10,375,1.35
13265,0.85,0.861772,2021.44,16941,23427,861,999,10,750,1.35


"GRAPH","Parameters","Size","Build time","Avg degree","Max degree"
"Vamana","R = 32, L = 50",1010812,0,22.9389,32

"Num queries","Target recall","Actual recall","QPS","Average Cmps","Tail Cmps","Average Visited","Tail Visited","k","Q","cut"
13265,0.1,0.103468,124846,397,427,14,14,10,14,1.35
13265,0.2,0.208194,74976.1,615,661,22,22,10,22,1.35
13265,0.3,0.339299,46272.7,961,1038,35,35,10,35,1.35
13265,0.4,0.406672,30427.5,1150,2002,42,73,10,24,1.35
13265,0.5,0.50634,21626.9,1666,2867,61,104,10,40,1.35
13265,0.6,0.602133,14680.3,2474,4190,95,159,10,70,1.35
13265,0.7,0.701153,8501.88,4163,6616,174,265,10,140,1.35
13265,0.75,0.755665,5717.47,6092,8989,267,372,10,225,1.35
13265,0.8,0.806385,3848.63,9292,13149,437,548,10,375,1.35
13265,0.85,0.861772,2068.67,16941,23427,861,999,10,750,1.35


"GRAPH","Parameters","Size","Build time","Avg degree","Max degree"
"Vamana","R = 32, L = 50",1010812,0,22.9389,32

"Num queries","Target recall","Actual recall","QPS","Average Cmps","Tail Cmps","Average Visited","Tail Visited","k","Q","cut"
13265,0.1,0.103468,127823,397,427,14,14,10,14,1.35
13265,0.2,0.208194,76946.7,615,661,22,22,10,22,1.35
13265,0.3,0.339299,48126.8,961,1038,35,35,10,35,1.35
13265,0.4,0.406672,29702.7,1150,2002,42,73,10,24,1.35
13265,0.5,0.50634,21150.6,1666,2867,61,104,10,40,1.35
13265,0.6,0.602133,15453.9,2474,4190,95,159,10,70,1.35
13265,0.7,0.701153,9316.64,4163,6616,174,265,10,140,1.35
13265,0.75,0.755665,6396.81,6092,8989,267,372,10,225,1.35
13265,0.8,0.806385,4473.85,9292,13149,437,548,10,375,1.35
13265,0.85,0.861772,2390.13,16941,23427,861,999,10,750,1.35


"GRAPH","Parameters","Size","Build time","Avg degree","Max degree"
"Vamana","R = 32, L = 50",1010812,0,22.9389,32

"Num queries","Target recall","Actual recall","QPS","Average Cmps","Tail Cmps","Average Visited","Tail Visited","k","Q","cut"
13265,0.1,0.110939,100768,452,486,16,16,25,25,1.35
13265,0.2,0.200127,64993.9,669,720,24,24,25,25,1.35
13265,0.3,0.373823,32257,1211,2104,44,77,25,26,1.35
13265,0.4,0.414583,22561.9,1417,2463,52,90,25,32,1.35
13265,0.5,0.508722,17233.9,2084,3506,77,130,25,55,1.35
13265,0.6,0.607846,11025,3228,5351,129,209,25,100,1.35
13265,0.7,0.701066,6274.72,5530,8388,241,345,25,200,1.35
13265,0.75,0.770651,3945.84,9296,13163,437,550,25,375,1.35
13265,0.8,0.834961,2099.69,16991,23380,864,1000,25,750,1.35
13265,0.85,0.857399,1699.7,21957,30131,1145,1296,25,1000,10


"GRAPH","Parameters","Size","Build time","Avg degree","Max degree"
"Vamana","R = 32, L = 50",1010812,0,22.9389,32

"Num queries","Actual recall","QPS","Average Cmps","Tail Cmps","Average Visited","Tail Visited","k","Q","cut"
13265,0.367098,31378.3,1181,2051,43,74,25,25,1.35
13265,0.399421,28504.7,1326,2288,48,83,25,30,1.35
13265,0.45543,24822.8,1666,2867,61,104,25,40,1.35
13265,0.493859,21947,1955,3318,73,122,25,50,1.35
13265,0.561873,16572.1,2617,4448,101,168,25,75,1.35
13265,0.607846,13324.7,3228,5351,129,209,25,100,1.35
13265,0.638568,11353.4,3841,6162,156,244,25,125,1.35
13265,0.663786,9875.83,4392,6908,184,278,25,150,1.35
13265,0.701066,7719.68,5530,8388,241,345,25,200,1.35
13265,0.725877,6385.63,6659,9652,294,396,25,250,1.35
13265,0.746491,5468.08,7724,11043,352,456,25,300,1.35
13265,0.777294,4250.6,9841,13975,465,580,25,400,1.35
13265,0.798254,3486.96,11936,16702,575,692,25,500,1.35
13265,0.0436457,192979,285,308,10,10,25,25,1.35
13265,0.0538832,170661,313,338,11,11,25,25,1.35
13265,0.0649167,154255,341,368,12,12,25,25,1.35
13265,0.0760588,139679,369,398,13,13,25,25,1.35
13265,0.087611,129670,397,427,14,14,25,25,1.35
13265,0.0992145,121226,425,456,15,15,25,25,1.35
13265,0.110939,111702,452,486,16,16,25,25,1.35
13265,0.122934,104539,479,515,17,17,25,25,1.35
13265,0.134423,99122.7,507,545,18,18,25,25,1.35
13265,0.145833,92399.7,534,574,19,19,25,25,1.35
13265,0.157141,87719.9,561,603,20,20,25,25,1.35
13265,0.168271,82704.7,588,632,21,21,25,25,1.35
13265,0.179175,79105.7,615,661,22,22,25,25,1.35
13265,0.189735,74748,642,690,23,23,25,25,1.35
13265,0.200127,72427,669,720,24,24,25,25,1.35
13265,0.21034,67823.6,696,749,25,25,25,25,1.35
13265,0.21989,66788.8,722,778,26,26,25,26,1.35
13265,0.238779,61644.1,776,835,28,28,25,28,1.35
13265,0.256733,56312.1,829,893,30,30,25,30,1.35
13265,0.297538,48058.5,961,1038,35,35,25,35,1.35
13265,0.857399,1816.09,21957,30131,1145,1296,25,1000,10


24 changes: 24 additions & 0 deletions algorithms/vamana/results.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"GRAPH","Parameters","Size","Build time","Avg degree","Max degree"
"Vamana","R = 32, L = 50",1010812,0,22.9389,32

"Num queries","Actual recall","QPS","Average Cmps","Tail Cmps","Average Visited","Tail Visited","k","Q","cut"
13265,0.399421,28989.3,1326,2288,48,83,25,30,1.35
13265,0.45543,24088.3,1666,2867,61,104,25,40,1.35
13265,0.493859,21535,1955,3318,73,122,25,50,1.35
13265,0.524381,19881.5,2240,3807,83,140,25,60,1.35
13265,0.551089,18115,2474,4190,95,159,25,70,1.35
13265,0.573012,16326.2,2761,4644,107,175,25,80,1.35
13265,0.590266,14933.4,3018,5017,117,192,25,90,1.35
13265,0.607846,13831.8,3228,5351,129,209,25,100,1.35
13265,0.638568,11610.9,3841,6162,156,244,25,125,1.35
13265,0.663786,9950.91,4392,6908,184,278,25,150,1.35
13265,0.701066,7042.62,5530,8388,241,345,25,200,1.35
13265,0.725877,6171.78,6659,9652,294,396,25,250,1.35
13265,0.737336,5694.58,7184,10438,325,431,25,275,1.35
13265,0.746491,5303.66,7724,11043,352,456,25,300,1.35
13265,0.770651,4327.17,9296,13163,437,550,25,375,1.35
13265,0.798254,3454.53,11936,16702,575,692,25,500,1.35
13265,0.834961,2360.3,16991,23380,864,1000,25,750,1.35
13265,0.857487,1824.55,21959,30128,1145,1295,25,1000,1.35


11 changes: 5 additions & 6 deletions build/_deps/parlaylib-subbuild/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.

cmake_minimum_required(VERSION 3.25.1)
cmake_minimum_required(VERSION 3.22.1)

# We name the project and the target for the ExternalProject_Add() call
# to something that will highlight to the user what we are working on if
Expand All @@ -13,24 +13,23 @@ project(parlaylib-populate NONE)
# Pass through things we've already detected in the main project to avoid
# paying the cost of redetecting them again in ExternalProject_Add()
set(GIT_EXECUTABLE [==[/usr/bin/git]==])
set(GIT_VERSION_STRING [==[2.39.2]==])
set(GIT_VERSION_STRING [==[2.34.1]==])
set_property(GLOBAL PROPERTY _CMAKE_FindGit_GIT_EXECUTABLE_VERSION
[==[/usr/bin/git;2.39.2]==]
[==[/usr/bin/git;2.34.1]==]
)


include(ExternalProject)
ExternalProject_Add(parlaylib-populate
"UPDATE_DISCONNECTED" "False" "GIT_REPOSITORY" "https://github.com/cmuparlay/parlaylib.git" "GIT_TAG" "master"
SOURCE_DIR "/home/laxmand_google_com/ParlayANN/build/_deps/parlaylib-src"
BINARY_DIR "/home/laxmand_google_com/ParlayANN/build/_deps/parlaylib-build"
SOURCE_DIR "/home/rakri/avarhade/ParlayANN/build/_deps/parlaylib-src"
BINARY_DIR "/home/rakri/avarhade/ParlayANN/build/_deps/parlaylib-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
USES_TERMINAL_DOWNLOAD YES
USES_TERMINAL_UPDATE YES
USES_TERMINAL_PATCH YES
)


9 changes: 9 additions & 0 deletions hybrid-ann.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# cd algorithms/vamana
# make
# ./neighbors -R 32 -L 50 -alpha 1.2 -graph_outfile /nvmessd1/fbv4/avarhade/parlay_prec1M_32_50 -query_path /nvmessd1/fbv4/queries.fbin -gt_path /nvmessd1/fbv4/prec1M_gt100.bin -res_path parlay_vamana_res.csv -data_type float -dist_func Euclidian -base_path /nvmessd1/fbv4/prec1M.fbin
# ./neighbors -R 32 -L 50 -k 25 -alpha 1.2 -graph_path /nvmessd1/fbv4/avarhade/parlay_prec1M_32_50 -query_path /nvmessd1/fbv4/queries.fbin -gt_path /nvmessd1/fbv4/prec1M_gt100.bin -res_path results.csv -data_type float -dist_func Euclidian -base_path /nvmessd1/fbv4/prec1M.fbin

cd algorithms/HNSW
make

./neighbors -m 32 -efc 50 -alpha 1.2 -ml 0.0 -graph_outfile /nvmessd1/fbv4/avarhade/parlay_hnsw_prec1M_32_50 -query_path /nvmessd1/fbv4/queries.fbin -gt_path /nvmessd1/fbv4/prec1M_gt100.bin -res_path hnsw_results.csv -data_type float -dist_func Euclidian -base_path /nvmessd1/fbv4/prec1M.fbin