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

added diskANN testing back to test_query_vector_similarity #39654

Merged
Merged
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
44 changes: 22 additions & 22 deletions sdk/cosmos/azure-cosmos/test/test_query_vector_similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ def setUpClass(cls):
vector_embedding_policy=test_config.get_vector_embedding_policy(data_type="float32",
distance_function="euclidean",
dimensions=128))
# cls.created_diskANN_dotproduct_container = cls.test_db.create_container(
# id="diskANN" + cls.TEST_CONTAINER_ID,
# partition_key=PartitionKey(path="/pk"),
# offer_throughput=test_config.TestConfig.THROUGHPUT_FOR_5_PARTITIONS,
# indexing_policy=test_config.get_vector_indexing_policy(embedding_type="diskANN"),
# vector_embedding_policy=test_config.get_vector_embedding_policy(data_type="float32",
# distance_function="dotproduct",
# dimensions=128))
cls.created_diskANN_dotproduct_container = cls.test_db.create_container(
id="diskANN" + cls.TEST_CONTAINER_ID,
partition_key=PartitionKey(path="/pk"),
offer_throughput=test_config.TestConfig.THROUGHPUT_FOR_5_PARTITIONS,
indexing_policy=test_config.get_vector_indexing_policy(embedding_type="diskANN"),
vector_embedding_policy=test_config.get_vector_embedding_policy(data_type="float32",
distance_function="dotproduct",
dimensions=128))
cls.created_large_container = cls.test_db.create_container(
id="large_container" + cls.TEST_CONTAINER_ID,
partition_key=PartitionKey(path="/pk"),
Expand All @@ -82,14 +82,14 @@ def setUpClass(cls):
for item in vector_test_data.get_vector_items():
cls.created_quantized_cosine_container.create_item(item)
cls.created_flat_euclidean_container.create_item(item)
# cls.created_diskANN_dotproduct_container.create_item(item)
cls.created_diskANN_dotproduct_container.create_item(item)

@classmethod
def tearDownClass(cls):
try:
cls.test_db.delete_container("quantized" + cls.TEST_CONTAINER_ID)
cls.test_db.delete_container("flat" + cls.TEST_CONTAINER_ID)
# cls.test_db.delete_container("diskANN" + cls.TEST_CONTAINER_ID)
cls.test_db.delete_container("diskANN" + cls.TEST_CONTAINER_ID)
cls.test_db.delete_container("large_container" + cls.TEST_CONTAINER_ID)
cls.client.delete_database(cls.test_db.id)
except exceptions.CosmosHttpResponseError:
Expand Down Expand Up @@ -145,10 +145,10 @@ def test_ordering_distances(self):
enable_cross_partition_query=True))
verify_ordering(quantized_list, "euclidean")

# disk_ann_list = list(
# self.created_diskANN_dotproduct_container.query_items(query=specs_query,
# enable_cross_partition_query=True))
# verify_ordering(disk_ann_list, "euclidean")
disk_ann_list = list(
self.created_diskANN_dotproduct_container.query_items(query=specs_query,
enable_cross_partition_query=True))
verify_ordering(disk_ann_list, "euclidean")
# test cosine distance
for i in range(1, 11):
vanilla_query = "SELECT TOP {} c.text, VectorDistance(c.embedding, [{}]) AS " \
Expand All @@ -168,10 +168,10 @@ def test_ordering_distances(self):
enable_cross_partition_query=True))
verify_ordering(quantized_list, "cosine")

# disk_ann_list = list(
# self.created_diskANN_dotproduct_container.query_items(query=specs_query,
# enable_cross_partition_query=True))
# verify_ordering(disk_ann_list, "cosine")
disk_ann_list = list(
self.created_diskANN_dotproduct_container.query_items(query=specs_query,
enable_cross_partition_query=True))
verify_ordering(disk_ann_list, "cosine")
# test dot product distance
for i in range(1, 11):
vanilla_query = "SELECT TOP {} c.text, VectorDistance(c.embedding, [{}]) AS " \
Expand All @@ -191,10 +191,10 @@ def test_ordering_distances(self):
enable_cross_partition_query=True))
verify_ordering(quantized_list, "dotproduct")

# disk_ann_list = list(
# self.created_diskANN_dotproduct_container.query_items(query=vanilla_query,
# enable_cross_partition_query=True))
# verify_ordering(disk_ann_list, "dotproduct")
disk_ann_list = list(
self.created_diskANN_dotproduct_container.query_items(query=vanilla_query,
enable_cross_partition_query=True))
verify_ordering(disk_ann_list, "dotproduct")

def test_vector_query_pagination(self):
# load up previously calculated embedding for the given string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ def setUpClass(cls):
vector_embedding_policy=test_config.get_vector_embedding_policy(data_type="float32",
distance_function="euclidean",
dimensions=128))
# cls.created_diskANN_dotproduct_container = cls.test_db.create_container(
# id="diskANN" + cls.TEST_CONTAINER_ID,
# partition_key=PartitionKey(path="/pk"),
# offer_throughput=test_config.TestConfig.THROUGHPUT_FOR_5_PARTITIONS,
# indexing_policy=test_config.get_vector_indexing_policy(embedding_type="diskANN"),
# vector_embedding_policy=test_config.get_vector_embedding_policy(data_type="float32",
# distance_function="dotproduct",
# dimensions=128))
cls.created_diskANN_dotproduct_container = cls.test_db.create_container(
id="diskANN" + cls.TEST_CONTAINER_ID,
partition_key=PartitionKey(path="/pk"),
offer_throughput=test_config.TestConfig.THROUGHPUT_FOR_5_PARTITIONS,
indexing_policy=test_config.get_vector_indexing_policy(embedding_type="diskANN"),
vector_embedding_policy=test_config.get_vector_embedding_policy(data_type="float32",
distance_function="dotproduct",
dimensions=128))
cls.created_large_container = cls.test_db.create_container(
id="large_container" + cls.TEST_CONTAINER_ID,
partition_key=PartitionKey(path="/pk"),
Expand All @@ -82,7 +82,7 @@ def setUpClass(cls):
for item in vector_test_data.get_vector_items():
cls.created_quantized_cosine_container.create_item(item)
cls.created_flat_euclidean_container.create_item(item)
# await cls.created_diskANN_dotproduct_container.create_item(item)
cls.created_diskANN_dotproduct_container.create_item(item)

@classmethod
def tearDownClass(cls):
Expand All @@ -96,6 +96,7 @@ async def asyncSetUp(self):
self.test_db = self.client.get_database_client(self.test_db.id)
self.created_flat_euclidean_container = self.test_db.get_container_client(self.created_flat_euclidean_container.id)
self.created_quantized_cosine_container = self.test_db.get_container_client(self.created_quantized_cosine_container.id)
self.created_diskANN_dotproduct_container = self.test_db.get_container_client(self.created_diskANN_dotproduct_container.id)
self.created_large_container = self.test_db.get_container_client(self.created_large_container.id)

async def asyncTearDown(self):
Expand Down Expand Up @@ -148,8 +149,8 @@ async def test_ordering_distances_async(self):
quantized_list = [item async for item in self.created_quantized_cosine_container.query_items(query=specs_query)]
verify_ordering(quantized_list, "euclidean")

# disk_ann_list = [item async for item in self.created_diskANN_dotproduct_container.query_items(query=specs_query)]
# verify_ordering(disk_ann_list, "euclidean")
disk_ann_list = [item async for item in self.created_diskANN_dotproduct_container.query_items(query=specs_query)]
verify_ordering(disk_ann_list, "euclidean")
# test cosine distance
for i in range(1, 11):
vanilla_query = "SELECT TOP {} c.text, VectorDistance(c.embedding, [{}]) AS " \
Expand All @@ -166,8 +167,8 @@ async def test_ordering_distances_async(self):
quantized_list = [item async for item in self.created_quantized_cosine_container.query_items(query=vanilla_query)]
verify_ordering(quantized_list, "cosine")

# disk_ann_list = [item async for item in self.created_diskANN_dotproduct_container.query_items(query=specs_query)]
# verify_ordering(disk_ann_list, "cosine")
disk_ann_list = [item async for item in self.created_diskANN_dotproduct_container.query_items(query=specs_query)]
verify_ordering(disk_ann_list, "cosine")
# test dot product distance
for i in range(1, 11):
vanilla_query = "SELECT TOP {} c.text, VectorDistance(c.embedding, [{}]) AS " \
Expand All @@ -184,8 +185,8 @@ async def test_ordering_distances_async(self):
quantized_list = [item async for item in self.created_quantized_cosine_container.query_items(query=specs_query)]
verify_ordering(quantized_list, "dotproduct")

# disk_ann_list = [item async for item in self.created_diskANN_dotproduct_container.query_items(query=vanilla_query)]
# verify_ordering(disk_ann_list, "dotproduct")
disk_ann_list = [item async for item in self.created_diskANN_dotproduct_container.query_items(query=vanilla_query)]
verify_ordering(disk_ann_list, "dotproduct")

async def test_vector_query_pagination_async(self):
# load up previously calculated embedding for the given string
Expand Down