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

Customize index type in index creation benchmark #886

Merged
merged 1 commit into from
May 19, 2023
Merged
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
29 changes: 26 additions & 3 deletions benchmarks/sift/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
# limitations under the License.

import argparse
import struct
import platform
import time
from subprocess import check_output

import lance
import numpy as np
Expand All @@ -27,10 +29,13 @@ def main():
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument("uri", help="lance path", metavar="FILE")
parser.add_argument("-t", "--index-type", choices=["ivf_pq", "diskann"], default="ivf_pq")
parser.add_argument("-m", "--metric", choices=["l2", "cosine"], default="l2")
parser.add_argument(
"-c",
"--column-name",
type=str,
metavar="NAME",
default="vector",
help="Name of the vector column",
)
Expand All @@ -53,13 +58,31 @@ def main():
args = parser.parse_args()

dataset = lance.dataset(args.uri)
start = time.time()
dataset = dataset.create_index(
args.column_name,
index_type="IVF_PQ",
# metric="cosine",
index_type=args.index_type,
metric=args.metric,
num_partitions=args.ivf_partitions, # IVF
num_sub_vectors=args.pq_subvectors,
) # PQ
end = time.time()

GIT_COMMIT = (
check_output(["git", "rev-parse", "--short", "HEAD"]).strip().decode("utf-8")
)
bench_results = {
"commit": GIT_COMMIT,
"name": "index_creation",
"platform": platform.platform(),
"arch": platform.machine(),
"params": {
"type": args.index_type,
},
"duration": end - start,
}
print(bench_results)

return dataset


Expand Down