Repository navigation
Conversation
|
|
raulcd
left a comment
There was a problem hiding this comment.
Thanks so much for working on this @contentis !
While this has been tested locally with several versions of numba-cuda this is only tested on CI with numba-cuda latest, should we remove the comaptibility layer and make it only compatible with latest? Should we test with several numba-cuda versions on CI?
I am concerned that not having the "several compatibility" versions tested on CI will eventually fail and we will have some deprecated (untested) "compatibility" code.
@pitrou what do you think?
| if hasattr(handle, "value"): | ||
| return handle.value | ||
| return int(handle) |
There was a problem hiding this comment.
Can you add comments telling which path is legacy or native?
| from cuda.bindings.driver import CUcontext | ||
| return CUcontext(handle) | ||
|
|
||
| return ctypes.c_void_p(handle) |
| assert ctx.handle == ctx.to_numba().handle.value | ||
| converted = ctx.to_numba() | ||
| assert type(converted.handle) is type(nb_ctx.handle) | ||
| if isinstance(converted.handle, ctypes.c_void_p): |
There was a problem hiding this comment.
Here as well, can you comment on which path corresponds to which Numba version(s)?
Given that this code is quite simple and exists in a module that is hardly every modified, I think it's ok. It will obsolete in 1 or 2 years and we'll be able to remove it by then, I think. |
|
@contentis Can you merge/rebase from main? There is an unexpected CI error here. |
|
@contentis did you want to proceed with this PR? |
7698132 to
ae903b2
Compare
|
I've rebased from main to help moving this along. Also note that PR mentions:
Unfortunately this is not getting fixed, got closed as not planned: NVIDIA/numba-cuda#907 (comment) :
|
Here's a more radical suggestion: how about we deprecate Numba-CUDA support in PyArrow and then remove it? The code has almost not been touched since 2018 when it was first written by @pearu , and we don't seem to get any user feedback or reports about it (the only reason we are noticing problems is because of our own CI). I don't think anyone cares at this point. |
|
As for the Python CUDA CI jobs, we can simply skip |
| fi | ||
|
|
||
| # Numba-CUDA 0.30.4 uses np.row_stack, which was removed in NumPy 2.5. | ||
| # TODO: Remove after https://github.com/NVIDIA/numba-cuda/pull/916 is released. |
There was a problem hiding this comment.
| # TODO: Remove after https://github.com/NVIDIA/numba-cuda/pull/916 is released. | |
| # Upstream recommends NumPy <=2.4, no plan to fix this: | |
| # https://github.com/NVIDIA/numba-cuda/issues/907#issuecomment-5620678407 |
| """Return the integer value of a legacy or native Numba context handle.""" | ||
| if hasattr(handle, "value"): |
There was a problem hiding this comment.
| """Return the integer value of a legacy or native Numba context handle.""" | |
| if hasattr(handle, "value"): | |
| """Return the integer value of a legacy or native Numba context handle.""" | |
| # Legacy ctypes.c_void_p handle (built-in Numba CUDA or numba-cuda <0.28) | |
| if hasattr(handle, "value"): |
| return handle.value | ||
| return int(handle) |
There was a problem hiding this comment.
| return handle.value | |
| return int(handle) | |
| return handle.value | |
| # Native cuda.bindings.driver.CUcontext handle (numba-cuda >=0.28) | |
| return int(handle) |
| return CUcontext(handle) | ||
|
|
||
| return ctypes.c_void_p(handle) |
There was a problem hiding this comment.
| return CUcontext(handle) | |
| return ctypes.c_void_p(handle) | |
| return CUcontext(handle) | |
| # Legacy handle for built-in Numba CUDA and numba-cuda <0.28 | |
| return ctypes.c_void_p(handle) |
| assert type(converted.handle) is type(nb_ctx.handle) | ||
| if isinstance(converted.handle, ctypes.c_void_p): |
There was a problem hiding this comment.
| assert type(converted.handle) is type(nb_ctx.handle) | |
| if isinstance(converted.handle, ctypes.c_void_p): | |
| assert type(converted.handle) is type(nb_ctx.handle) | |
| # Built-in Numba CUDA and numba-cuda <0.28 use ctypes.c_void_p (legacy), | |
| # numba-cuda >=0.28 uses cuda.bindings.driver.CUcontext | |
| if isinstance(converted.handle, ctypes.c_void_p): |
Or it just works :) In any case, I agree that users should switch to the NVIDIA/numba-cuda-mlir approach ( I looked for downstream users of |
|
+1 on dropping support for numba-cuda |
Closes #49437
Numba-CUDA 0.28 changed CUDA context handles from
ctypes.c_void_pto nativecuda.bindings.driver.CUcontextobjects. PyArrow currently expects incoming handles to have.valueand also always returnsctypes.c_void_pwhen converting back to Numba.I added a small compatibility layer which:
ctypeshandles and nativeCUcontextobjects..value.cuda.bindingsare intentionally imported lazily here since they are optional dependencies. Not sure how happy I am with this bit but it was the best solution in my opinion.There is also a temporary
numpy<2.5constraint for the Numba-CUDA environment. Numba-CUDA 0.30.4 currently uses the removednp.row_stackattribute with NumPy 2.5. This is already being handled upstream in NVIDIA/numba-cuda#916 and the constraint can be removed once that fix is released.Testing
I tested the full CUDA Numba interop suite locally with:
Cython compilation, linting and ShellCheck also pass.