-
Notifications
You must be signed in to change notification settings - Fork 915
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
Automatically select GroupBy.apply
algorithm based on if the UDF is jittable
#13113
Merged
rapids-bot
merged 12 commits into
rapidsai:branch-23.06
from
brandon-b-miller:fea-groupby-apply-fallback
May 16, 2023
Merged
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b3a736a
initial untested
brandon-b-miller da6659f
cleanup
brandon-b-miller acc966e
Merge branch 'branch-23.06' into fea-groupby-apply-fallback
brandon-b-miller 7795929
fixes
brandon-b-miller 9ecd4d4
Merge branch 'branch-23.06' into fea-groupby-apply-fallback
brandon-b-miller bb8e894
merge latest and resolve conflicts
brandon-b-miller 9dadf35
update docs
brandon-b-miller 064f52d
remove todo
brandon-b-miller c110e20
Merge branch 'branch-23.06' into fea-groupby-apply-fallback
brandon-b-miller ad4dbaa
inline function
brandon-b-miller 11d4f73
Mention auto as a valid engine type
wence- 6f2cebc
Merge branch 'branch-23.06' into fea-groupby-apply-fallback
brandon-b-miller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,10 @@ | |
from cudf.core.column_accessor import ColumnAccessor | ||
from cudf.core.mixins import Reducible, Scannable | ||
from cudf.core.multiindex import MultiIndex | ||
from cudf.core.udf.groupby_utils import jit_groupby_apply | ||
from cudf.core.udf.groupby_utils import ( | ||
_jit_groupby_eligible, | ||
jit_groupby_apply, | ||
) | ||
from cudf.utils.utils import GetAttrGetItemMixin, _cudf_nvtx_annotate | ||
|
||
|
||
|
@@ -1144,11 +1147,9 @@ def _jit_groupby_apply( | |
self, function, group_names, offsets, group_keys, grouped_values, *args | ||
): | ||
# Nulls are not yet supported | ||
for colname in self.grouping.values._data.keys(): | ||
if self.obj._data[colname].has_nulls(): | ||
raise ValueError( | ||
"Nulls not yet supported with groupby JIT engine" | ||
) | ||
# TODO: don't check this twice under `engine='auto'` | ||
if self.grouping.has_nulls: | ||
raise ValueError("Nulls not yet supported with groupby JIT engine") | ||
|
||
chunk_results = jit_groupby_apply( | ||
offsets, grouped_values, function, *args | ||
|
@@ -1198,7 +1199,7 @@ def _iterative_groupby_apply( | |
result.index = cudf.MultiIndex._from_data(index_data) | ||
return result | ||
|
||
def apply(self, function, *args, engine="cudf"): | ||
def apply(self, function, *args, engine="auto"): | ||
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. docstring needs to be updated to discuss new 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. Added some docs here. |
||
"""Apply a python transformation function over the grouped chunk. | ||
|
||
Parameters | ||
|
@@ -1294,6 +1295,11 @@ def mult(df): | |
raise TypeError(f"type {type(function)} is not callable") | ||
group_names, offsets, group_keys, grouped_values = self._grouped() | ||
|
||
if engine == "auto": | ||
if _jit_groupby_eligible(grouped_values, function, args): | ||
engine = "jit" | ||
else: | ||
engine = "cudf" | ||
if engine == "jit": | ||
result = self._jit_groupby_apply( | ||
function, | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is there (will there be?) a bug for this? Or do you intend to fix it here?
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.
I thought this might be a perf hit but since each column caches its null count I think it's actually ok to just leave it.