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

Single-partition Dask executor for cuDF-Polars #17262

Merged
merged 67 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
a590076
cleanup
rjzamora Nov 6, 2024
7f1bec7
rename to parallel
rjzamora Nov 7, 2024
023e085
Merge branch 'branch-24.12' into cudf-polars-dask-simple
rjzamora Nov 7, 2024
e7a2fce
Merge branch 'branch-24.12' into cudf-polars-dask-simple
rjzamora Nov 7, 2024
69a3374
simplify solution
rjzamora Nov 7, 2024
6aa3694
Merge branch 'cudf-polars-dask-simple' of github.com:rjzamora/cudf in…
rjzamora Nov 7, 2024
ea22a9a
Merge branch 'branch-24.12' into cudf-polars-dask-simple
rjzamora Nov 7, 2024
915a779
deeper dive
rjzamora Nov 8, 2024
bd9d783
improve simple agg reduction
rjzamora Nov 8, 2024
7363d91
cleanup fundamental bugs
rjzamora Nov 10, 2024
58ee5f4
move PartitionInfo
rjzamora Nov 10, 2024
ecc51ef
add Literal
rjzamora Nov 10, 2024
75eae0c
Merge branch 'branch-24.12' into cudf-polars-dask-simple
rjzamora Nov 12, 2024
fb2d6bf
add lower_ir_graph
rjzamora Nov 12, 2024
c17564c
Merge remote-tracking branch 'upstream/branch-24.12' into cudf-polars…
rjzamora Nov 12, 2024
6e66998
strip out most exploratory logic
rjzamora Nov 12, 2024
c41723d
Merge branch 'branch-24.12' into cudf-polars-dask-simple
rjzamora Nov 12, 2024
d774f38
Merge branch 'branch-24.12' into cudf-polars-dask-simple
rjzamora Nov 13, 2024
6886f8d
Add basic Dask evaluate test
pentschev Nov 13, 2024
29b2d7b
Replace environment variable with new `"executor"` config
pentschev Nov 13, 2024
3a68a6d
Add kwarg to specify executor in `assert_gpu_result_equal`
pentschev Nov 13, 2024
8079ac0
Add couple of Dask executor tests
pentschev Nov 13, 2024
6f7ccee
Merge remote-tracking branch 'upstream/branch-24.12' into cudf-polars…
pentschev Nov 13, 2024
af4c5f5
Merge remote-tracking branch 'rjzamora/cudf-polars-dask-simple' into …
pentschev Nov 13, 2024
8aed94f
Improve `count` code
pentschev Nov 13, 2024
aadaf10
Pass `executor` to `GPUEngine` in `assert_gpu_result_equal`
pentschev Nov 13, 2024
c3a6907
Merge remote-tracking branch 'upstream/branch-24.12' into cudf-polars…
pentschev Nov 14, 2024
4f67819
Merge branch 'branch-24.12' into cudf-polars-dask-simple
rjzamora Nov 14, 2024
c8ca09e
Clarify intent renaming executor to "dask-experimental"
pentschev Nov 14, 2024
3fd51bb
move PartitionInfo out of ir module
rjzamora Nov 14, 2024
bf182e4
Merge remote-tracking branch 'rjzamora/cudf-polars-dask-simple' into …
pentschev Nov 14, 2024
453e274
skip coverage on sanity-check errors
rjzamora Nov 14, 2024
2b74f28
Add `--executor` to pytest
pentschev Nov 14, 2024
6d3cd55
Merge remote-tracking branch 'rjzamora/cudf-polars-dask-simple' into …
pentschev Nov 14, 2024
2398a2e
Enable dask-experimental tests in CI, remove duplicates
pentschev Nov 14, 2024
9aa479a
Fix wrong protocol name in deserialization test
pentschev Nov 14, 2024
64ea98e
Merge remote-tracking branch 'upstream/branch-24.12' into cudf-polars…
pentschev Nov 14, 2024
22678a5
Remove `executor` kwarg from `assert_gpu_result_equal`
pentschev Nov 14, 2024
41441ca
Merge remote-tracking branch 'upstream/branch-24.12' into cudf-polars…
rjzamora Nov 15, 2024
efadb78
Reintroduce `executor` kwarg in `assert_gpu_result_equal`
pentschev Nov 15, 2024
9b78d8f
Add basic tests for all executors to ensure 100% coverage
pentschev Nov 15, 2024
c54c217
Merge remote-tracking branch 'rjzamora/cudf-polars-dask-simple' into …
pentschev Nov 15, 2024
70da7a9
Merge remote-tracking branch 'upstream/branch-24.12' into cudf-polars…
pentschev Nov 15, 2024
3aeb1e4
Fix `executor` in `assert_gpu_result_equal`
pentschev Nov 18, 2024
485a161
Merge remote-tracking branch 'upstream/branch-24.12' into cudf-polars…
pentschev Nov 18, 2024
eb41100
Merge remote-tracking branch 'upstream/branch-24.12' into cudf-polars…
rjzamora Nov 19, 2024
e91fdb9
Merge branch 'branch-25.02' into cudf-polars-dask-simple
pentschev Nov 20, 2024
cac9e4f
Merge remote-tracking branch 'upstream/branch-25.02' into cudf-polars…
rjzamora Nov 20, 2024
addae40
Merge remote-tracking branch 'upstream/branch-25.02' into cudf-polars…
rjzamora Nov 21, 2024
dbf37d3
address code review - round 1
rjzamora Nov 21, 2024
4d21f7c
move sort tupling
rjzamora Nov 21, 2024
e241af3
remove need for stringify
rjzamora Nov 21, 2024
1064fcb
address code review - round 2
rjzamora Nov 21, 2024
bbddfb6
Merge remote-tracking branch 'upstream/branch-25.02' into cudf-polars…
rjzamora Nov 21, 2024
aeecd4d
remove global caching
rjzamora Nov 21, 2024
09c5217
use general StateInfo
rjzamora Nov 21, 2024
62f10bc
revert (for now)
rjzamora Nov 21, 2024
77113d6
Merge remote-tracking branch 'upstream/branch-25.02' into cudf-polars…
rjzamora Nov 22, 2024
9967cfb
skip coverage on singledispatch miss
rjzamora Nov 22, 2024
075d41e
typo
rjzamora Nov 22, 2024
21e598a
Rename `"cudf"` executor to `"pylibcudf"`
pentschev Nov 25, 2024
7febe21
Update `test_evaluate_dask()` with `collect()`
pentschev Nov 25, 2024
ac4d2da
Remove tests docstrings
pentschev Nov 25, 2024
2ced4a0
Improve `executor` typing
pentschev Nov 25, 2024
98b0b36
Merge remote-tracking branch 'upstream/branch-25.02' into cudf-polars…
pentschev Nov 25, 2024
af5aff8
Merge remote-tracking branch 'upstream/branch-25.02' into cudf-polars…
rjzamora Nov 25, 2024
f6f7eda
address code review
rjzamora Nov 25, 2024
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
6 changes: 6 additions & 0 deletions python/cudf_polars/cudf_polars/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ def _callback(
set_device(device),
set_memory_resource(memory_resource),
):
if os.environ.get("CUDF_POLARS_DASK", "OFF").upper() == "ON":
# Use experimental Dask executor
from cudf_polars.experimental.parallel import evaluate_dask

return evaluate_dask(ir).to_polars()
rjzamora marked this conversation as resolved.
Show resolved Hide resolved

return ir.evaluate(cache={}).to_polars()


Expand Down
9 changes: 9 additions & 0 deletions python/cudf_polars/cudf_polars/containers/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,15 @@ def filter(self, mask: Column) -> Self:
table = plc.stream_compaction.apply_boolean_mask(self.table, mask.obj)
return type(self).from_table(table, self.column_names).sorted_like(self)

@classmethod
def concat(cls, dfs: list[Self]) -> Self:
"""Concatenate a list of dataframes."""
assert len(dfs), "Cannot concatenate an empty list"
if len(dfs) == 1:
return dfs[0]
table = plc.concatenate.concatenate([df.table for df in dfs])
return cls.from_table(table, dfs[0].column_names)

def slice(self, zlice: tuple[int, int] | None) -> Self:
"""
Slice a dataframe.
Expand Down
2 changes: 1 addition & 1 deletion python/cudf_polars/cudf_polars/dsl/expressions/sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(
*by: Expr,
) -> None:
self.dtype = dtype
self.options = options
self.options = (options[0], tuple(options[1]), tuple(options[2]))
rjzamora marked this conversation as resolved.
Show resolved Hide resolved
self.children = (column, *by)

def do_evaluate(
Expand Down
26 changes: 18 additions & 8 deletions python/cudf_polars/cudf_polars/dsl/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -1468,13 +1468,20 @@ def __init__(self, schema: Schema, name: str, options: Any, df: IR):
self.options = (
tuple(indices),
tuple(pivotees),
(variable_name, schema[variable_name]),
(value_name, schema[value_name]),
variable_name,
value_name,
)
self._non_child_args = (name, self.options)
self._non_child_args = (schema, name, self.options)

def get_hashable(self) -> Hashable:
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
def get_hashable(self) -> Hashable:
def get_hashable(self) -> Hashable: # pragma: no cover; Needed by experimental

Pretty sure this is lowering test coverage.

Copy link
Member

Choose a reason for hiding this comment

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

I introduced basic testing for all executors independent of --executor pytest argument to ensure 100% coverage always.

Copy link
Member

Choose a reason for hiding this comment

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

See 9b78d8f .

"""Hashable representation of the node."""
schema_hash = tuple(self.schema.items())
return (type(self), schema_hash, self.name, str(self.options), *self.children)

@classmethod
def do_evaluate(cls, name: str, options: Any, df: DataFrame) -> DataFrame:
def do_evaluate(
cls, schema: Schema, name: str, options: Any, df: DataFrame
) -> DataFrame:
"""Evaluate and return a dataframe."""
if name == "rechunk":
# No-op in our data model
Expand All @@ -1496,8 +1503,8 @@ def do_evaluate(cls, name: str, options: Any, df: DataFrame) -> DataFrame:
(
indices,
pivotees,
(variable_name, variable_dtype),
(value_name, value_dtype),
variable_name,
value_name,
) = options
npiv = len(pivotees)
index_columns = [
Expand All @@ -1514,15 +1521,18 @@ def do_evaluate(cls, name: str, options: Any, df: DataFrame) -> DataFrame:
plc.interop.from_arrow(
pa.array(
pivotees,
type=plc.interop.to_arrow(variable_dtype),
type=plc.interop.to_arrow(schema[variable_name]),
rjzamora marked this conversation as resolved.
Show resolved Hide resolved
),
)
]
),
df.num_rows,
).columns()
value_column = plc.concatenate.concatenate(
[df.column_map[pivotee].astype(value_dtype).obj for pivotee in pivotees]
[
df.column_map[pivotee].astype(schema[value_name]).obj
for pivotee in pivotees
]
)
return DataFrame(
[
Expand Down
30 changes: 29 additions & 1 deletion python/cudf_polars/cudf_polars/dsl/nodebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
T = TypeVar("T", bound="Node[Any]")


class PartitionInfo:
"""
Partitioning information.

This class only tracks the partition count (for now).
"""

__slots__ = ("count",)

def __init__(self, count: int):
self.count = count


class Node(Generic[T]):
"""
An abstract node type.
Expand All @@ -34,9 +47,10 @@ class Node(Generic[T]):
*children).``
"""

__slots__ = ("_hash_value", "_repr_value", "children")
__slots__ = ("_hash_value", "_repr_value", "_parts_info", "children")
_hash_value: int
_repr_value: str
_parts_info: PartitionInfo
children: tuple[T, ...]
_non_child: ClassVar[tuple[str, ...]] = ()

Expand Down Expand Up @@ -150,3 +164,17 @@ def __repr__(self) -> str:
args = ", ".join(f"{arg!r}" for arg in self._ctor_arguments(self.children))
self._repr_value = f"{type(self).__name__}({args})"
return self._repr_value

@property
def parts(self) -> PartitionInfo:
"""Return Partitioning information for this node."""
try:
return self._parts_info
except AttributeError:
self._parts_info = self._get_partition_info()
return self._parts_info

def _get_partition_info(self) -> PartitionInfo:
from cudf_polars.experimental.parallel import _ir_partition_info_dispatch

return _ir_partition_info_dispatch(self)
8 changes: 8 additions & 0 deletions python/cudf_polars/cudf_polars/experimental/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES.
# SPDX-License-Identifier: Apache-2.0

"""Experimental features, which can change without any depreciation period."""

from __future__ import annotations

__all__: list[str] = []
Loading
Loading