-
Notifications
You must be signed in to change notification settings - Fork 89
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
Should cupy ufuncs work on awkward arrays that are correctly on-device? #3232
Comments
I don't know if CuPy has an equivalent of NEP 13 (or NEP 18) to dispatch from In a web-search, I didn't find anything. |
The reason I am asking about this is because it's fairly straightforward to define custom ufunc kernels in cupy to accelerate things like invariant mass and deltaphi (fusing loops, etc). It would then be nice to have the ability to apply custom cupy functions directly to awkward arrays. |
It is the case that if you call |
Yes, I am aware. But that doesn't work with custom ufuncs as far as I know? |
Custom ufuncs from |
Correct, I was trying to find a work-around for that and ran into this problem instead. :-) |
Hi, CuPy maintainer here! I'd like to understand what exactly is the want here. Specifically, isn't it possible to give CuPy ndarrays to NumPy to enjoy NEP 13? (e.g. |
@kmaehashi Thanks for your interest! I would like to use cupy ufuncs with awkward arrays, which are a generalization of numpy and it supports cpu and gpu backends. Right now it can use NEP-13 to dispatch from numpy to cupy when the array is on the GPU, however you cannot use The example that caused this to crop up actually arose when trying to use numba-cuda, and you can see a bit more of what's going on in this PR: NVIDIA/numba-cuda#37. To put it succinctly: I would like to be able to dispatch cupy ufuncs to awkward arrays, which right now only works if there is a numpy equivalent of the ufunc. However, that is not generally the case and quickly causes pain! |
Version of Awkward Array
2.6.7
Description and code to reproduce
Awkward knows how to dispatch through numpy ufuncs, and will dispatch to cupy ufuncs when encountering the "cuda" backend.
However, when using cupy ufuncs on awkward arrays with cuda backing it doesn't work out of the box!
Here is a reproducer:
it outputs:
It would be really nice if I could use cupy ufuncs on awkward arrays just as easily I can use numpy ufuncs.
I am not sure if this is a bug or a feature request.
The text was updated successfully, but these errors were encountered: