-
Notifications
You must be signed in to change notification settings - Fork 7
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
Changes from 5 commits
9ee3272
8650768
11f12ca
581cefa
1e3936b
3f11501
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
def submit_local(d, func, *args, **kwargs): | ||
# Drop kwarg | ||
kwargs.pop("image_name", None) | ||
kwargs.pop("resource_class", None) | ||
kwargs.pop("resources", None) | ||
return d.submit_local(func, *args, **kwargs) | ||
|
||
|
@@ -133,6 +134,8 @@ def query_internal( | |
nthreads: int = -1, | ||
use_nuv_implementation: bool = False, | ||
mode: Mode = None, | ||
resource_class: Optional[str] = None, | ||
resources: Optional[Mapping[str, Any]] = None, | ||
num_partitions: int = -1, | ||
num_workers: int = -1, | ||
): | ||
|
@@ -153,7 +156,21 @@ def query_internal( | |
wether to use the nuv query implementation. Default: False | ||
mode: Mode | ||
If provided the query will be executed using TileDB cloud taskgraphs. | ||
For distributed execution you can use REALTIME or BATCH mode | ||
For distributed execution you can use REALTIME or BATCH mode. | ||
For local execution you can use LOCAL mode. | ||
resource_class: | ||
The name of the resource class to use ("standard" or "large"). Resource classes define maximum | ||
limits for cpu and memory usage. Can only be used in REALTIME or BATCH mode. | ||
Cannot be used alongside resources. | ||
In REALTIME or BATCH mode if neither resource_class nor resources are provided, | ||
we default to the "large" resource class. | ||
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. | ||
num_partitions: int | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate documentation for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, good catch, removed. |
||
Only relevant for taskgraph based execution. | ||
If provided, we split the query execution in that many partitions. | ||
num_partitions: int | ||
Only relevant for taskgraph based execution. | ||
If provided, we split the query execution in that many partitions. | ||
|
@@ -167,6 +184,9 @@ def query_internal( | |
(queries.shape[0], k), index.MAX_UINT64 | ||
) | ||
|
||
if not (mode == Mode.REALTIME or mode == Mode.BATCH) and (resource_class or resources): | ||
raise TypeError("Can only pass resource_class or resources in REALTIME or BATCH mode") | ||
|
||
assert queries.dtype == np.float32 | ||
|
||
if queries.ndim == 1: | ||
|
@@ -217,6 +237,8 @@ def query_internal( | |
nthreads=nthreads, | ||
nprobe=nprobe, | ||
mode=mode, | ||
resource_class=resource_class, | ||
resources=resources, | ||
num_partitions=num_partitions, | ||
num_workers=num_workers, | ||
config=self.config, | ||
|
@@ -229,6 +251,8 @@ def taskgraph_query( | |
nprobe: int = 10, | ||
nthreads: int = -1, | ||
mode: Mode = None, | ||
resource_class: Optional[str] = None, | ||
resources: Optional[Mapping[str, Any]] = None, | ||
num_partitions: int = -1, | ||
num_workers: int = -1, | ||
config: Optional[Mapping[str, Any]] = None, | ||
|
@@ -248,7 +272,18 @@ def taskgraph_query( | |
Number of threads to use for query | ||
mode: Mode | ||
If provided the query will be executed using TileDB cloud taskgraphs. | ||
For distributed execution you can use REALTIME or BATCH mode | ||
For distributed execution you can use REALTIME or BATCH mode. | ||
For local execution you can use LOCAL mode. | ||
resource_class: | ||
The name of the resource class to use ("standard" or "large"). Resource classes define maximum | ||
limits for cpu and memory usage. Can only be used in REALTIME or BATCH mode. | ||
Cannot be used alongside resources. | ||
In REALTIME or BATCH mode if neither resource_class nor resources are provided, | ||
we default to the "large" resource class. | ||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above, only BATCH mode There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, done. |
||
num_partitions: int | ||
Only relevant for taskgraph based execution. | ||
If provided, we split the query execution in that many partitions. | ||
|
@@ -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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a check to make sure that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, done. Originally I just let |
||
raise TypeError("Cannot provide both resource_class and resources") | ||
|
||
def dist_qv_udf( | ||
dtype: np.dtype, | ||
parts_uri: str, | ||
|
@@ -373,7 +411,8 @@ def dist_qv_udf( | |
k_nn=k, | ||
config=config, | ||
timestamp=self.base_array_timestamp, | ||
resource_class="large" if mode == Mode.REALTIME else None, | ||
resource_class="large" if (not resources and not resource_class) else resource_class, | ||
resources=resources, | ||
image_name="3.9-vectorsearch", | ||
) | ||
) | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.