-
Notifications
You must be signed in to change notification settings - Fork 917
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
Cleanup how args and kwargs are passed in _fast_slow_function_call
#16266
Draft
Matt711
wants to merge
2
commits into
rapidsai:branch-25.02
Choose a base branch
from
Matt711:bug/fix-args-and-kwargs
base: branch-25.02
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -874,7 +874,6 @@ def _fast_slow_function_call( | |||||
func: Callable, | ||||||
/, | ||||||
*args, | ||||||
**kwargs, | ||||||
) -> Any: | ||||||
""" | ||||||
Call `func` with all `args` and `kwargs` converted to their | ||||||
|
@@ -893,8 +892,8 @@ def _fast_slow_function_call( | |||||
color=_CUDF_PANDAS_NVTX_COLORS["EXECUTE_FAST"], | ||||||
domain="cudf_pandas", | ||||||
): | ||||||
fast_args, fast_kwargs = _fast_arg(args), _fast_arg(kwargs) | ||||||
result = func(*fast_args, **fast_kwargs) | ||||||
fast_args = _fast_arg(args) | ||||||
result = func(*fast_args) | ||||||
if result is NotImplemented: | ||||||
# try slow path | ||||||
raise Exception() | ||||||
|
@@ -906,12 +905,9 @@ def _fast_slow_function_call( | |||||
color=_CUDF_PANDAS_NVTX_COLORS["EXECUTE_SLOW"], | ||||||
domain="cudf_pandas", | ||||||
): | ||||||
slow_args, slow_kwargs = ( | ||||||
_slow_arg(args), | ||||||
_slow_arg(kwargs), | ||||||
) | ||||||
slow_args = (_slow_arg(args),) | ||||||
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.
Suggested change
|
||||||
with disable_module_accelerator(): | ||||||
slow_result = func(*slow_args, **slow_kwargs) | ||||||
slow_result = func(*slow_args) | ||||||
except Exception as e: | ||||||
warnings.warn( | ||||||
"The result from pandas could not be computed. " | ||||||
|
@@ -936,10 +932,10 @@ def _fast_slow_function_call( | |||||
color=_CUDF_PANDAS_NVTX_COLORS["EXECUTE_SLOW"], | ||||||
domain="cudf_pandas", | ||||||
): | ||||||
slow_args, slow_kwargs = _slow_arg(args), _slow_arg(kwargs) | ||||||
slow_args = _slow_arg(args) | ||||||
with disable_module_accelerator(): | ||||||
result = func(*slow_args, **slow_kwargs) | ||||||
return _maybe_wrap_result(result, func, *args, **kwargs), fast | ||||||
result = func(*slow_args) | ||||||
return _maybe_wrap_result(result, func, *args), fast | ||||||
|
||||||
|
||||||
def _transform_arg( | ||||||
|
@@ -1054,7 +1050,7 @@ def _slow_arg(arg: Any) -> Any: | |||||
return _transform_arg(arg, "_fsproxy_slow", seen) | ||||||
|
||||||
|
||||||
def _maybe_wrap_result(result: Any, func: Callable, /, *args, **kwargs) -> Any: | ||||||
def _maybe_wrap_result(result: Any, func: Callable, /, *args) -> Any: | ||||||
""" | ||||||
Wraps "result" in a fast-slow proxy if is a "proxiable" object. | ||||||
""" | ||||||
|
@@ -1063,7 +1059,7 @@ def _maybe_wrap_result(result: Any, func: Callable, /, *args, **kwargs) -> Any: | |||||
return typ._fsproxy_wrap(result, func) | ||||||
elif _is_intermediate_type(result): | ||||||
typ = get_intermediate_type_map()[type(result)] | ||||||
return typ._fsproxy_wrap(result, method_chain=(func, args, kwargs)) | ||||||
return typ._fsproxy_wrap(result, method_chain=(func, args)) | ||||||
elif _is_final_class(result): | ||||||
return get_final_type_map()[result] | ||||||
elif isinstance(result, list): | ||||||
|
Oops, something went wrong.
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.
Could you update this docstring to note that
args
containsfunc
's args and kwargs?