Skip to content

Add from_arrow_host functions for cudf interop with nanoarrow - #15645

Merged
rapids-bot[bot] merged 32 commits into
NVIDIA:branch-24.08from
zeroshade:from-arrow-device-host
May 29, 2024
Merged

Add from_arrow_host functions for cudf interop with nanoarrow#15645
rapids-bot[bot] merged 32 commits into
NVIDIA:branch-24.08from
zeroshade:from-arrow-device-host

Conversation

@zeroshade

Copy link
Copy Markdown
Contributor

Description

Following up from #15458 and continuing the work to address #14926 adding host memory version of from_arrow_device which will perform the copies from host memory to create cudf objects.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@zeroshade
zeroshade requested a review from a team as a code owner May 3, 2024 21:31
@copy-pr-bot

copy-pr-bot Bot commented May 3, 2024

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added libcudf Affects libcudf (C++/CUDA) code. CMake CMake build issue labels May 3, 2024
@zeroshade

Copy link
Copy Markdown
Contributor Author

@vyasr @davidwendt I've got this up! There's still another test or two I need to add, but I figured it would be good to get this PR filed before the weekend and get some eyes on it.

@davidwendt davidwendt added 3 - Ready for Review Ready for review by team improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels May 6, 2024
Comment thread cpp/include/cudf/interop.hpp Outdated
Comment thread cpp/include/cudf/interop.hpp Outdated
Comment thread cpp/src/interop/from_arrow_device.cu Outdated
@davidwendt

Copy link
Copy Markdown
Contributor

/ok to test

@davidwendt

Copy link
Copy Markdown
Contributor

/ok to test

Comment thread cpp/src/interop/from_arrow_device.cu Outdated
@davidwendt

Copy link
Copy Markdown
Contributor

/ok to test

@davidwendt davidwendt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps rename the from_arrow_device_host_test.cpp to from_arrow_host_test.cpp?

Comment thread cpp/src/interop/from_arrow_device.cu Outdated
Comment thread cpp/src/interop/from_arrow_device.cu Outdated
#include <cudf/types.hpp>

#include <thrust/iterator/counting_iterator.h>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole file could use a lot more comments explaining what exactly is happening and getting tested; there are very few comments here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added some more comments to this. if there are specific areas where it's unclear what is going on, let me know and i'll add some more comments to those areas. I had figured the test names and code was sufficient, but that might be because i'm already familiar with a lot of the nano arrow code patterns

@zeroshade
zeroshade requested a review from a team as a code owner May 14, 2024 17:37
Comment thread cpp/src/interop/from_arrow_host.cu Outdated
Comment on lines +421 to +422
ArrowSchemaView view;
NANOARROW_THROW_NOT_OK(ArrowSchemaViewInit(&view, schema, nullptr));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should move this and the CUDF_EXPECTS checks to the detail function.
Same for the cudf::from_arrow_host_column API

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure. Any particular reason?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is our normal pattern. https://github.com/rapidsai/cudf/blob/branch-24.06/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md#libcudf-api-and-implementation
The public API does the nvtx range and calls a detail function with a similar signature with no default parameters.
The detail functions may also be called by other internal functions and we would want those paths to also check parameters, etc.

Comment thread cpp/src/interop/from_arrow_host.cu Outdated
Comment thread cpp/tests/interop/nanoarrow_utils.hpp Outdated
Co-authored-by: David Wendt <45795991+davidwendt@users.noreply.github.com>
@vyasr

vyasr commented May 23, 2024

Copy link
Copy Markdown
Contributor

/ok to test

@vyasr

vyasr commented May 23, 2024

Copy link
Copy Markdown
Contributor

/ok to test

@vyasr

vyasr commented May 23, 2024

Copy link
Copy Markdown
Contributor

Style again :(

@davidwendt

Copy link
Copy Markdown
Contributor

Looks like you will need to update these https://github.com/rapidsai/cudf/blob/8b5ff188e79bb79ca0c2d581e94d3a91654a2d31/cpp/tests/interop/from_arrow_device_test.cpp#L52
to expect the std::invalid_argument exception instead of cudf::logic_error

@davidwendt

Copy link
Copy Markdown
Contributor

/ok to test

@davidwendt

Copy link
Copy Markdown
Contributor

/ok to test

@vyasr vyasr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zeroshade One thing I meant to mention earlier but I completely forgot to ask about: would it make sense/be simpler to implement these methods by copying the arrow array to an ArrowDeviceArray with device_type ARROW_DEVICE_GPU and then calling the from_arrow_device functions? No need to walk it back at this point since we've come this far, but I wanted to at least have the conversation.

Comment thread cpp/src/interop/from_arrow_host.cu Outdated
Co-authored-by: Vyas Ramasubramani <vyas.ramasubramani@gmail.com>
@zeroshade

Copy link
Copy Markdown
Contributor Author

@vyasr Just to make sure I understand the suggestion, you're saying recursively spin through the ArrowArray and explicitly, and blindly, copy each buffer to the device using cudaMemcpy and then just wrap it with an ArrowDeviceArray and call the existing from_host_device function?

That's definitely an idea we could go with that would highly simplify the code. Though I'd have to look through because I think there might be scenarios where that would end up performing an extra copy or so of the data? I don't remember offhand if we pre-emptively copy to the device before every transformation already or not. You might be right though, it might be a great way to simplify this. I'll definitely look into it after we get this merged (since you said we don't need to walk this back at this point)

@vyasr
vyasr changed the base branch from branch-24.06 to branch-24.08 May 28, 2024 16:38
@vyasr

vyasr commented May 28, 2024

Copy link
Copy Markdown
Contributor

/ok to test

@vyasr

vyasr commented May 28, 2024

Copy link
Copy Markdown
Contributor

Yup, that's exactly what I'm suggesting. It would make maintaining easier, and it would also make testing easier since we'd effectively only have one real conversion test path to test (and it facilitates testing from higher level bindings in Java and Python where we can easily generate Arrow host data but not device data right now). But yeah we don't need to wait to merge this PR.

@zeroshade

Copy link
Copy Markdown
Contributor Author

I don't think the test failures are my fault here. Is there anything else needed on my end to get this merged?

@vyasr

vyasr commented May 28, 2024

Copy link
Copy Markdown
Contributor

No, nothing on your end. Unfortunately we're just having some CI outages. You're all good here.

@vyasr

vyasr commented May 29, 2024

Copy link
Copy Markdown
Contributor

/ok to test

@vyasr

vyasr commented May 29, 2024

Copy link
Copy Markdown
Contributor

/merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 - Ready for Review Ready for review by team CMake CMake build issue improvement Improvement / enhancement to an existing function libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants