awkward icon indicating copy to clipboard operation
awkward copied to clipboard

fix: return ufunc as it is for user defined `vectorize`d funcs

Open Saransh-cpp opened this issue 1 year ago • 4 comments

Fixes #2603

Saransh-cpp avatar Feb 15 '24 13:02 Saransh-cpp

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 81.94%. Comparing base (b749e49) to head (0c79601). Report is 30 commits behind head on main.

Additional details and impacted files
Files Coverage Δ
src/awkward/_connect/jax/__init__.py 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

codecov[bot] avatar Feb 15 '24 13:02 codecov[bot]

@Saransh-cpp this looks good to me! I anticipate problems if the custom ufunc doesn't understand JAX arrays, but I suppose for now we can try the ufunc to see what happens. In future, we might want some kind of mechanism to associate e.g. a numba ufunc with a JAX-aware overload, but that can be a later step.

agoose77 avatar Feb 22 '24 10:02 agoose77

I anticipate problems if the custom ufunc doesn't understand JAX arrays

I see, this makes sense. Looking at this again, shouldn't this be on the user side? If I understand correctly, shouldn't a user ensure that their functions are compatible with JAX arrays if they are planning to use the jax backend?

Saransh-cpp avatar Feb 22 '24 12:02 Saransh-cpp

I anticipate problems if the custom ufunc doesn't understand JAX arrays

I see, this makes sense. Looking at this again, shouldn't this be on the user side? If I understand correctly, shouldn't a user ensure that their functions are compatible with JAX arrays if they are planning to use the jax backend?

Yes I think so. As it stands, I'm not sure what that mechanism would be. It would be nice if a user can leverage someone-else's code, and patch their ufuncs to make JAX work, for example.

agoose77 avatar Feb 22 '24 13:02 agoose77

Yes I think so. As it stands, I'm not sure what that mechanism would be. It would be nice if a user can leverage someone-else's code, and patch their ufuncs to make JAX work, for example.

Oh I see, yes that would be nice too. I can look into this if any issues pop up in the future. Thanks!

Saransh-cpp avatar Feb 26 '24 12:02 Saransh-cpp

What's the status of this one?

jpivarski avatar Mar 04 '24 23:03 jpivarski

The fix works! Jax and numba might still clash but that would be on the user side and not on the awkward side. But as mentioned by @agoose77, I'll look into providing users with an awkward-fix (maybe a decorator?) for their functions if we get any complaints.

Saransh-cpp avatar Mar 05 '24 15:03 Saransh-cpp