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

Schedule guvectorize'd functions over dask.distributed #9495

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

crusaderky
Copy link

Copy link
Collaborator

@guilhermeleobas guilhermeleobas left a comment

Choose a reason for hiding this comment

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

@crusaderky, thanks for your contribution. Do you have a test case using Dask where current code would fail?

Comment on lines +323 to +338
class NEP13Array:
"""https://numpy.org/neps/nep-0013-ufunc-overrides.html"""
def __init__(self, array):
self.array = array

def __array__(self):
return self.array

def tolist(self):
return self.array.tolist()

def __array_ufunc__(self, ufunc, method, *args, **kwargs):
if method != "__call__":
return NotImplemented

return NEP13Array(ufunc(*[np.asarray(x) for x in args], **kwargs))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this change needed for the PR to work?

Copy link
Author

Choose a reason for hiding this comment

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

No; I felt that it would make it easier to understand the test code if these two very similar, and yet subtly different stub classes were presented right next to each other. I can revert if you prefer.

@crusaderky
Copy link
Author

crusaderky commented Mar 22, 2024

@crusaderky, thanks for your contribution. Do you have a test case using Dask where current code would fail?

import dask.array as da
import distributed
import numba

client = distributed.Client()

@numba.guvectorize(["f8,f8[:]"], "()->()")
def double(x, out):
    out[:] = x * 2

double(da.arange(5)).compute()

Output:

_pickle.PicklingError: Can't pickle <ufunc 'double'>: it's not the same object as __main__.double

Copy link
Collaborator

@guilhermeleobas guilhermeleobas left a comment

Choose a reason for hiding this comment

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

Can confirm the changes fixes the issue.

@guilhermeleobas
Copy link
Collaborator

@guilhermeleobas guilhermeleobas added 4 - Waiting on author Waiting for author to respond to review and removed 3 - Ready for Review labels Apr 5, 2024
@crusaderky
Copy link
Author

@guilhermeleobas guilhermeleobas added 5 - Ready to merge Review and testing done, is ready to merge and removed 4 - Waiting on author Waiting for author to respond to review labels Apr 22, 2024
Copy link
Collaborator

@guilhermeleobas guilhermeleobas left a comment

Choose a reason for hiding this comment

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

Thanks, @crusaderky

Sorry for the delay on this last review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 - Ready to merge Review and testing done, is ready to merge
Projects
None yet
3 participants