set -e # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # @nolint # This script launches the experiments on a cluster # It assumes two shell functions are defined: # # run_on_1machine: runs a command on one (full) machine on a cluster # # run_on_8gpu: runs a command on one machine with 8 GPUs # # the two functions are called as: # # run_on_1machine # # the stdout of the command should be stored in $logdir/.stdout function run_on () { sys="$1" shift name="$1" shift script="$logdir/$name.sh" if [ -e "$script" ]; then echo script "$script" exists return fi # srun handles special characters fine, but the shell interpreter # does not escaped_cmd=$( printf "%q " "$@" ) cat > $script < (1 << (2 * ls)); ls++)); do echo -n done sncent=$(( 1 << ls )) indexkeys=" IVF$((sncent/2)),PQ48x4fs,RFlat IVF$((sncent*2)),PQ48x4fs,RFlat HNSW32 PQ48x4fs PQ48x4fs,RFlat IVF$sncent,PQ48x4fs,RFlat " for indexkey in $indexkeys; do key="cent_index.db$db.k$k.$indexkey" run_on_1machine_1h "$key.b" \ python -u bench_all_ivf.py \ --db $db \ --indexkey "$indexkey" \ --maxtrain 0 \ --inter \ --searchthreads 32 \ --k $k done done done ############################### 10M experiments for db in deep10M bigann10M; do coarses=" IVF65536(IVF256,PQHDx4fs,RFlat) IVF16384_HNSW32 IVF65536_HNSW32 IVF262144_HNSW32 IVF262144(IVF512,PQHDx4fs,RFlat) " dim=$( get_db_dim $db ) for coarse in $coarses do replace_coarse_PQHD "$coarse" $dim indexkeys=" $coarseD,PQ$((dim/2))x4fs OPQ8_64,$coarse64,PQ8 PCAR16,$coarse16,SQ4 OPQ16_64,$coarse64,PQ16x4fs OPQ16_64,$coarse64,PQ16x4fsr OPQ16_64,$coarse64,PQ16 PCAR16,$coarse16,SQ8 PCAR32,$coarse32,SQ4 OPQ32_64,$coarse64,PQ32x4fs OPQ32_64,$coarse64,PQ32x4fsr OPQ32_128,$coarse128,PQ32 PCAR32,$coarse32,SQ8 PCAR64,$coarse64,SQ4 PCAR16,$coarse16,SQfp16 OPQ64_128,$coarse128,PQ64x4fs OPQ64_128,$coarse128,PQ64x4fsr OPQ64_128,$coarse128,PQ64 PCAR64,$coarse64,SQ8 PCAR32,$coarse32,SQfp16 PCAR128,$coarse128,SQ4 OPQ128_256,$coarse256,PQ128x4fs OPQ128_256,$coarse256,PQ128x4fsr OPQ56_112,$coarse112,PQ7+56 OPQ16_64,$coarse64,PQ16x4fs,Refine(OPQ56_112,PQ56) OPQ16_64,$coarse64,PQ16x4fs,Refine(PCAR72,SQ6) OPQ32_64,$coarse64,PQ16x4fs,Refine(PCAR64,SQ6) OPQ32_64,$coarse64,PQ32x4fs,Refine(OPQ48_96,PQ48) " indexkeys=" OPQ16_64,$coarse64,PQ16x4fsr OPQ32_64,$coarse64,PQ32x4fsr OPQ64_128,$coarse128,PQ64x4fsr OPQ128_256,$coarse256,PQ128x4fsr " for indexkey in $indexkeys do key=autotune.db$db.${indexkey//,/_} key="${key//(/_}" key="${key//)/_}" run_on_1machine_3h $key.l \ python -u bench_all_ivf.py \ --db $db \ --indexkey "$indexkey" \ --maxtrain 0 \ --indexfile "$indexdir/$key.faissindex" \ $( add_precomputed_quantizer $db $coarse ) \ --searchthreads 32 \ --min_test_duration 3 \ --autotune_max nprobe:2000 done done done ############################### 100M experiments for db in deep100M bigann100M; do coarses=" IVF65536_HNSW32 IVF262144_HNSW32 IVF262144(IVF512,PQHDx4fs,RFlat) IVF1048576_HNSW32 IVF1048576(IVF1024,PQHDx4fs,RFlat) " dim=$( get_db_dim $db ) for coarse in $coarses do replace_coarse_PQHD "$coarse" $dim indexkeys=" OPQ8_64,$coarse64,PQ8 OPQ16_64,$coarse64,PQ16x4fs PCAR32,$coarse32,SQ4 OPQ16_64,$coarse64,PQ16 OPQ32_64,$coarse64,PQ32x4fs OPQ32_128,$coarse128,PQ32 PCAR64,$coarse64,SQ4 PCAR32,$coarse32,SQ8 OPQ64_128,$coarse128,PQ64x4fs PCAR128,$coarse128,SQ4 OPQ64_128,$coarse128,PQ64 PCAR32,$coarse32,SQfp16 PCAR64,$coarse64,SQ8 OPQ128_256,$coarse256,PQ128x4fs OPQ56_112,$coarse112,PQ7+56 OPQ16_64,$coarse64,PQ16x4fs,Refine(OPQ56_112,PQ56) $coarseD,PQ$((dim/2))x4fs " indexkeys=" OPQ128_256,$coarse256,PQ128x4fsr OPQ64_128,$coarse128,PQ64x4fsr OPQ32_64,$coarse64,PQ32x4fsr OPQ16_64,$coarse64,PQ16x4fsr OPQ16_64,$coarse64,PQ16x4fsr,Refine(OPQ56_112,PQ56) " for indexkey in $indexkeys do key=autotune.db$db.${indexkey//,/_} key="${key//(/_}" key="${key//)/_}" run_on_1machine $key.e \ python -u bench_all_ivf.py \ --db $db \ --indexkey "$indexkey" \ --maxtrain 0 \ --indexfile $indexdir/$key.faissindex \ --searchthreads 32 \ --min_test_duration 3 \ $( add_precomputed_quantizer $db $coarse ) \ --add_bs 1000000 \ --autotune_max nprobe:2000 done done done ################################# # 1B-scale experiment for db in deep1B bigann1B; do coarses=" IVF1048576_HNSW32 IVF4194304_HNSW32 IVF4194304(IVF1024,PQHDx4fs,RFlat) " dim=$( get_db_dim $db ) for coarse in $coarses; do replace_coarse_PQHD "$coarse" $dim indexkeys=" OPQ8_64,$coarse64,PQ8 OPQ16_64,$coarse64,PQ16x4fsr OPQ16_64,$coarse64,PQ16 OPQ32_64,$coarse64,PQ32x4fsr OPQ32_128,$coarse128,PQ32 OPQ64_128,$coarse128,PQ64x4fsr OPQ64_128,$coarse128,PQ64 OPQ128_256,$coarse256,PQ128x4fsr OPQ56_112,$coarse112,PQ7+56 OPQ16_64,$coarse64,PQ16x4fs,Refine(OPQ56_112,PQ56) $coarseD,PQ$((dim/2))x4fs " for indexkey in $indexkeys do key=autotune.db$db.${indexkey//,/_} key="${key//(/_}" key="${key//)/_}" run_on_1machine $key.d \ python -u bench_all_ivf.py \ --db $db \ --indexkey "$indexkey" \ --maxtrain 0 \ --indexfile $indexdir/$key.faissindex \ --searchthreads 32 \ --min_test_duration 3 \ $( add_precomputed_quantizer $db $coarse ) \ --add_bs 1000000 \ --autotune_max nprobe:3000 done done done fi