Skip to content
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

Add from_arrow_host functions for cudf interop with nanoarrow #15645

Merged
merged 32 commits into from
May 29, 2024

Conversation

zeroshade
Copy link
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 link

copy-pr-bot bot commented May 3, 2024

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
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
cpp/include/cudf/interop.hpp Outdated Show resolved Hide resolved
cpp/include/cudf/interop.hpp Outdated Show resolved Hide resolved
cpp/src/interop/from_arrow_device.cu Outdated Show resolved Hide resolved
@davidwendt
Copy link
Contributor

/ok to test

@davidwendt
Copy link
Contributor

/ok to test

@davidwendt
Copy link
Contributor

/ok to test

Copy link
Contributor

@davidwendt davidwendt left a comment

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?

cpp/src/interop/from_arrow_device.cu Outdated Show resolved Hide resolved
#include <cudf/types.hpp>

#include <thrust/iterator/counting_iterator.h>

Copy link
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
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 on lines 421 to 422
ArrowSchemaView view;
NANOARROW_THROW_NOT_OK(ArrowSchemaViewInit(&view, schema, nullptr));
Copy link
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
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
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.

cpp/src/interop/from_arrow_host.cu Outdated Show resolved Hide resolved
Co-authored-by: David Wendt <45795991+davidwendt@users.noreply.github.com>
@vyasr
Copy link
Contributor

vyasr commented May 23, 2024

/ok to test

@vyasr
Copy link
Contributor

vyasr commented May 23, 2024

/ok to test

@vyasr
Copy link
Contributor

vyasr commented May 23, 2024

Style again :(

@davidwendt
Copy link
Contributor

Looks like you will need to update these

EXPECT_THROW(cudf::from_arrow_device(nullptr, nullptr), cudf::logic_error);

to expect the std::invalid_argument exception instead of cudf::logic_error

@davidwendt
Copy link
Contributor

/ok to test

@davidwendt
Copy link
Contributor

/ok to test

Copy link
Contributor

@vyasr vyasr left a comment

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.

cpp/src/interop/from_arrow_host.cu Outdated Show resolved Hide resolved
Co-authored-by: Vyas Ramasubramani <vyas.ramasubramani@gmail.com>
@zeroshade
Copy link
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
Copy link
Contributor

vyasr commented May 28, 2024

/ok to test

@vyasr
Copy link
Contributor

vyasr commented May 28, 2024

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
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
Copy link
Contributor

vyasr commented May 28, 2024

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

@vyasr
Copy link
Contributor

vyasr commented May 29, 2024

/ok to test

@vyasr
Copy link
Contributor

vyasr commented May 29, 2024

/merge

@rapids-bot rapids-bot bot merged commit eafa570 into rapidsai:branch-24.08 May 29, 2024
70 checks passed
@zeroshade zeroshade deleted the from-arrow-device-host branch May 29, 2024 19:15
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
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants