Skip to content

GH-49437: [Python][GPU] Support legacy and native Numba CUDA context handles - #50923

Open
contentis wants to merge 1 commit into
apache:mainfrom
contentis:GH-49437-numba-context-handles
Open

GH-49437: [Python][GPU] Support legacy and native Numba CUDA context handles#50923
contentis wants to merge 1 commit into
apache:mainfrom
contentis:GH-49437-numba-context-handles

Conversation

@contentis

@contentis contentis commented Aug 20, 2026

Copy link
Copy Markdown

Closes #49437

Numba-CUDA 0.28 changed CUDA context handles from ctypes.c_void_p to native cuda.bindings.driver.CUcontext objects. PyArrow currently expects incoming handles to have .value and also always returns ctypes.c_void_p when converting back to Numba.

I added a small compatibility layer which:

  • Accepts both legacy ctypes handles and native CUcontext objects.
  • Returns the representation expected by the installed Numba implementation.
  • Explicitly tests both representations instead of assuming .value.
  • Removes CUDA 11 from the Python CUDA jobs while keeping the existing C++ CUDA 11 coverage.
  • Numba and cuda.bindings are 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.5 constraint for the Numba-CUDA environment. Numba-CUDA 0.30.4 currently uses the removed np.row_stack attribute 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:

  • Numba-CUDA 0.27: 50 passed
  • Numba-CUDA 0.28: 50 passed
  • Numba-CUDA 0.30.4: 50 passed

Cython compilation, linting and ShellCheck also pass.

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #49437 has been automatically assigned in GitHub to PR creator.

@tadeja tadeja added the CI: Extra: CUDA Run extra CUDA CI label Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Python][C++][GPU] Python Cuda jobs fail with 'cuda.bindings.driver.CUcontext' object has no attribute 'value'

2 participants