-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(python): Enable collection with gpu engine
Introduce option to collect a query using the cudf_polars gpu engine. By default this falls back transparently to the default cpu engine if the query cannot be executed. Configuration of specifics of the GPU engine can be controlled by passing a GPUEngine object to the new `engine` argument to `collect`. The import of cudf_polars is currently quite expensive (will improve in the coming months), so since we lazy-load the gpu engine, the first query executed on gpu will pay this (one-time) cost.
- Loading branch information
Showing
6 changed files
with
105 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
from polars.lazyframe.engine_config import GPUEngine | ||
from polars.lazyframe.frame import LazyFrame | ||
|
||
__all__ = [ | ||
"GPUEngine", | ||
"LazyFrame", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING, Any | ||
|
||
if TYPE_CHECKING: | ||
from collections.abc import Mapping | ||
|
||
from rmm.mr import DeviceMemoryResource | ||
|
||
|
||
class GPUEngine: | ||
""" | ||
Configuration options for the GPU execution engine. | ||
Use this if you want control over details of the execution. | ||
Supported options | ||
- `device`: Select the device to run the query on. | ||
- `memory_resource`: Set an RMM memory resource for | ||
device-side allocations. | ||
""" | ||
|
||
device: int | None | ||
"""Device on which to run query.""" | ||
memory_resource: DeviceMemoryResource | None | ||
"""Memory resource to use for device allocations.""" | ||
config: Mapping[str, Any] | ||
"""Additional configuration options for the engine.""" | ||
|
||
def __init__( | ||
self, | ||
*, | ||
device: int | None = None, | ||
memory_resource: Any | None = None, | ||
**kwargs: Any, | ||
) -> None: | ||
super().__init__(**kwargs) | ||
self.device = device | ||
self.memory_resource = memory_resource | ||
self.config = kwargs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters