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

Enable setting resource_class or resources when calling query() on IVFFlatIndex #165

Merged
merged 6 commits into from
Dec 14, 2023

Conversation

jparismorgan
Copy link
Contributor

What

Adds resource_class and resources to query(). These are only valid for Mode.REALTIME and Mode.BATCH. If not provided, the default is large. You cannot pass both resource_class and resources.

Testing

  • Adds unit tests checking that we throw exceptions when we should and succeed otherwise.
  • I manually looked at what machine we ran on for each scenario and things look okay, but I didn't see a nice path to testing this programmatically, though please do let me know if I just missed it :
index.query(query_vectors, k=k, nprobe=nprobe, mode=Mode.REALTIME, resource_class="standard")
Screenshot 2023-12-13 at 3 15 36 PM
index.query(query_vectors, k=k, nprobe=nprobe, mode=Mode.REALTIME)
Screenshot 2023-12-13 at 3 17 21 PM
index.query(query_vectors, k=k, nprobe=nprobe, mode=Mode.BATCH, resource_class="standard")
Screenshot 2023-12-13 at 3 22 22 PM
index.query(query_vectors, k=k, nprobe=nprobe, mode=Mode.BATCH)
Screenshot 2023-12-13 at 3 28 15 PM
resources = {"cpu": "9", "memory": "12Gi", "gpu": 0}
index.query(query_vectors, k=k, nprobe=nprobe, mode=Mode.BATCH, resources=resources)
Screenshot 2023-12-13 at 3 30 26 PM

resources:
A specification for the amount of resources to use when executing using TileDB cloud
taskgraphs, of the form: {"cpu": "6", "memory": "12Gi", "gpu": 1}. Can only be used
in REALTIME or BATCH mode. Cannot be used alongside resource_class.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can only be used in BATCH mode

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops thanks, good catch, updated.

A specification for the amount of resources to use when executing using TileDB cloud
taskgraphs, of the form: {"cpu": "6", "memory": "12Gi", "gpu": 1}. Can only be used
in REALTIME or BATCH mode. Cannot be used alongside resource_class.
num_partitions: int
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate documentation for num_partitions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good catch, removed.

resources:
A specification for the amount of resources to use when executing using TileDB cloud
taskgraphs, of the form: {"cpu": "6", "memory": "12Gi", "gpu": 1}. Can only be used
in REALTIME or BATCH mode. Cannot be used alongside resource_class.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, only BATCH mode

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

@@ -268,6 +303,9 @@ def taskgraph_query(
from tiledb.vector_search.module import (array_to_matrix, dist_qv,
partition_ivf_index)

if resource_class and resources:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a check to make sure that resources is not defined for REALTIME

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, done. Originally I just let tiledb.cloud throw this error, but you're right, that's inconsistent with how I'm handling other errors, so updated.

@jparismorgan jparismorgan marked this pull request as ready for review December 14, 2023 10:12
@jparismorgan
Copy link
Contributor Author

@lums658 / @ihnorton going to merge this, but adding you as reviewers so you can take a look after the fact. Please let me know any suggestions and I'll address them in a follow-up.

@jparismorgan jparismorgan merged commit 3e3e7f8 into main Dec 14, 2023
4 checks passed
@jparismorgan jparismorgan deleted the jparismorgan/query-resources branch December 14, 2023 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants