-
Notifications
You must be signed in to change notification settings - Fork 4
/
run.sh
76 lines (63 loc) · 2.68 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
set -xe
# Simple wrapper script that will give opportunity to run tests with
# different memory limits for one run versus another.
#
# Usage:
# **Note - this needs to be run from the root of the project for now...**
#
# bash experiments/exp-low-mem-knn/run.sh <method> <rescore context> <compression level>
#
#
# Params:
# method: hnsw, ivf, hnswpq, ivfpq
# rescore context: 0r, 2r, 10r
# compression level: 1x, 8x, 16x, 32x
METHOD=$1
RESCORE_CONTEXT=$2
COMPRESSION_LEVEL=$3
# Constants
EXPERIMENT_PATH="experiments/low-mem-knn-exp/exp-1"
BASE_ENV_PATH="${EXPERIMENT_PATH}/env/${COMPRESSION_LEVEL}"
INDEX_ENV_PATH="${BASE_ENV_PATH}/index-build.env"
SEARCH_ENV_PATH="${BASE_ENV_PATH}/search.env"
OSB_PARAMS_PATH="osb/custom/params"
PARAMS_PATH="${EXPERIMENT_PATH}/osb-params/${COMPRESSION_LEVEL}"
TMP_ENV_DIR="${EXPERIMENT_PATH}/tmp"
TMP_ENV_NAME="test.env"
TMP_ENV_PATH="${EXPERIMENT_PATH}/${TMP_ENV_NAME}"
source ${EXPERIMENT_PATH}/functions.sh
# Derive procedure for indexing and rescoring information
if [[ "$METHOD" == "hnsw" ]]; then
RESCORE_SUFFIX=""
OSB_INDEX_PROCEDURE="no-train-test-index-with-merge"
elif [[ "$METHOD" == "ivf" ]]; then
RESCORE_SUFFIX=""
OSB_INDEX_PROCEDURE="train-test-index-with-merge"
else
RESCORE_SUFFIX="-${RESCORE_CONTEXT}"
OSB_INDEX_PROCEDURE="train-test-index-with-merge"
fi
# Copy params to OSB folder
cp ${PARAMS_PATH}/${METHOD}-1c${RESCORE_SUFFIX}.json ${OSB_PARAMS_PATH}/
cp ${PARAMS_PATH}/${METHOD}-4c${RESCORE_SUFFIX}.json ${OSB_PARAMS_PATH}/
cp ${PARAMS_PATH}/${METHOD}-16c${RESCORE_SUFFIX}.json ${OSB_PARAMS_PATH}/
# Initialize shared data folder for containers
mkdir -m 777 /tmp/share-data
setup_environment ${TMP_ENV_DIR} ${TMP_ENV_NAME} "index-build" ${METHOD}-1c${RESCORE_SUFFIX}.json ${OSB_INDEX_PROCEDURE} false
docker compose --env-file ${INDEX_ENV_PATH} --env-file ${TMP_ENV_PATH} -f compose.yaml up -d
wait_for_container_stop osb
setup_environment ${TMP_ENV_DIR} ${TMP_ENV_NAME} "search-1c" ${METHOD}-1c${RESCORE_SUFFIX}.json "search-only" true
docker compose --env-file ${SEARCH_ENV_PATH} --env-file ${TMP_ENV_PATH} -f compose.yaml up -d
clear_cache
wait_for_container_stop osb
setup_environment ${TMP_ENV_DIR} ${TMP_ENV_NAME} "search-4c" ${METHOD}-4c${RESCORE_SUFFIX}.json "search-only" true
docker compose --env-file ${SEARCH_ENV_PATH} --env-file ${TMP_ENV_PATH} -f compose.yaml up -d
clear_cache
wait_for_container_stop osb
setup_environment ${TMP_ENV_DIR} ${TMP_ENV_NAME} "search-16c" ${METHOD}-16c${RESCORE_SUFFIX}.json "search-only" true
docker compose --env-file ${SEARCH_ENV_PATH} --env-file ${TMP_ENV_PATH} -f compose.yaml up -d
clear_cache
# Add at the end to ensure container finishes
wait_for_container_stop osb
echo "Finished all runs"