-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
GH-40384: [Python] Expand the C Device Interface bindings to support import on CUDA device #40385
GH-40384: [Python] Expand the C Device Interface bindings to support import on CUDA device #40385
Conversation
|
e91517d
to
42e883c
Compare
@github-actions crossbow submit test-cuda-python |
Revision: 05dd7a5 Submitted crossbow builds: ursacomputing/crossbow @ actions-b585ced356
|
@github-actions crossbow submit test-cuda-python |
Revision: 83b0d58 Submitted crossbow builds: ursacomputing/crossbow @ actions-17a7524191
|
python/pyarrow/_cuda.pyx
Outdated
@@ -965,6 +965,56 @@ def read_record_batch(object buffer, object schema, *, | |||
return pyarrow_wrap_batch(batch) | |||
|
|||
|
|||
def _import_device_array_cuda(in_ptr, type): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't we decide at some point that we would have a registration system on the C++ side, so that per-device type memory mappers could be added at library initialization time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good point, I forgot about that given this conditional import works in python .. Will look into the registry!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registry was added in #40699
Revision: 73bfca1 Submitted crossbow builds: ursacomputing/crossbow @ actions-f86b23b51b
|
@github-actions crossbow submit test-cuda-python |
Revision: 78a7fb5 Submitted crossbow builds: ursacomputing/crossbow @ actions-bba6bd0230
|
python/pyarrow/lib.pyx
Outdated
try: | ||
import pyarrow.cuda # no-cython-lint | ||
except ImportError: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to silence the error? The error message could be more informative than the error the user would later get when a device array fails importing...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Pushed a change to capture the error message, and to actually raise a more informative error message here about pyarrow not being built with CUDA support (embedding the original import error message), instead of using the message from the C++ registry.
python/pyarrow/array.pxi
Outdated
void* c_type_ptr | ||
shared_ptr[CArray] c_array | ||
|
||
if c_device_array.device_type == 2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could perhaps instead add kDLCUDA
to
arrow/python/pyarrow/includes/libarrow.pxd
Lines 1322 to 1323 in f8784ac
ctypedef enum DLDeviceType: | |
kDLCPU = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's for DLPack, and also those definitions are the same, I would prefer to not mix them in our code. But added a similar line to libarrow.pxd to expose ARROW_DEVICE_CUDA
, which also makes the above easier to read
Are the AppVeyor failures unrelated? |
@github-actions crossbow submit test-cuda-python |
Revision: 3e9f913 Submitted crossbow builds: ursacomputing/crossbow @ actions-80c1cb7576
|
@github-actions crossbow submit test-cuda-python |
Revision: eca6869 Submitted crossbow builds: ursacomputing/crossbow @ actions-246d24263e
|
After merging your PR, Conbench analyzed the 6 benchmarking runs that have been run so far on merge-commit 89d6354. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 1 possible false positive for unstable benchmarks that are known to sometimes produce them. |
…yArrow (#40717) ### Rationale for this change PyArrow implementation for the specification additions being proposed in #40708 ### What changes are included in this PR? New `__arrow_c_device_array__` method to `pyarrow.Array` and `pyarrow.RecordBatch`, and support in the `pyarrow.array(..)`, `pyarrow.record_batch(..)` and `pyarrow.table(..)` functions to consume objects that have those methods. ### Are these changes tested? Yes (for CPU only for now, #40385 is a prerequisite to test this for CUDA) * GitHub Issue: #38325
…a in PyArrow (apache#40717) ### Rationale for this change PyArrow implementation for the specification additions being proposed in apache#40708 ### What changes are included in this PR? New `__arrow_c_device_array__` method to `pyarrow.Array` and `pyarrow.RecordBatch`, and support in the `pyarrow.array(..)`, `pyarrow.record_batch(..)` and `pyarrow.table(..)` functions to consume objects that have those methods. ### Are these changes tested? Yes (for CPU only for now, apache#40385 is a prerequisite to test this for CUDA) * GitHub Issue: apache#38325
Rationale for this change
Follow-up on #39979 which added
_export_to_c_device
/_import_from_c_device
methods, but for now only for CPU devices.What changes are included in this PR?
pyarrow.cuda
is imported before importing data through the C Interface, to ensure the CUDA device is registeredAre these changes tested?
Yes, added tests for CUDA.