Skip to content

Use cudf::pack with pinned mr in TableChunk::copy#966

Open
nirandaperera wants to merge 11 commits intorapidsai:mainfrom
nirandaperera:table_chunk_pinned_copy
Open

Use cudf::pack with pinned mr in TableChunk::copy#966
nirandaperera wants to merge 11 commits intorapidsai:mainfrom
nirandaperera:table_chunk_pinned_copy

Conversation

@nirandaperera
Copy link
Copy Markdown
Contributor

@nirandaperera nirandaperera commented Apr 13, 2026

In a previous analysis we found that using cudf::pack with a pinned mem resource performs similar to,

  1. packing to device memory and copying.
  2. chunk packing into pinned memory directly.

Since (1) use unreserved device memory, TableChunk::copy is prone to OOM. This PR changes pinned memory to use cudf::pack directly.

Depends on #967

Signed-off-by: niranda perera <niranda.perera@gmail.com>
@nirandaperera nirandaperera requested a review from a team as a code owner April 13, 2026 23:33
@nirandaperera nirandaperera added improvement Improves an existing functionality non-breaking Introduces a non-breaking change labels Apr 13, 2026
@nirandaperera
Copy link
Copy Markdown
Contributor Author

This PR depends on #967 because it now requires precise packed sizes for pinned memory.

Comment thread cpp/include/rapidsmpf/memory/buffer_resource.hpp Outdated
Comment thread cpp/include/rapidsmpf/memory/buffer_resource.hpp Outdated
Comment thread cpp/src/memory/buffer_resource.cpp Outdated
Comment thread cpp/src/streaming/cudf/table_chunk.cpp Outdated
Comment thread cpp/src/streaming/cudf/table_chunk.cpp Outdated
Copy link
Copy Markdown
Member

@pentschev pentschev left a comment

Choose a reason for hiding this comment

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

Looks good overall, left some requests for typo fixes and phrasing improvements, and a nit.

nirandaperera and others added 4 commits April 17, 2026 08:17
Co-authored-by: Peter Andreas Entschev <peter@entschev.com>
Signed-off-by: niranda perera <niranda.perera@gmail.com>
@nirandaperera nirandaperera requested a review from pentschev April 20, 2026 22:46
Copy link
Copy Markdown
Member

@pentschev pentschev left a comment

Choose a reason for hiding this comment

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

Thanks Niranda.

Comment thread cpp/src/streaming/cudf/table_chunk.cpp Outdated
Comment thread cpp/src/streaming/cudf/table_chunk.cpp
Comment on lines +218 to +223
auto pinned_host_buffer = std::make_unique<HostBuffer>(
HostBuffer::from_rmm_device_buffer(std::move(data), stream, pinned_mr())
);
return std::unique_ptr<Buffer>(
new Buffer(std::move(pinned_host_buffer), stream, MemoryType::PINNED_HOST)
);
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.

We need to think about this going forward. I don't really like the split in the type system between the pinned host buffer and the rmm::device_buffer storage.

Remind me why we need the pinned host buffer to be stored as a HostBuffer inside the Buffer object?

Copy link
Copy Markdown
Contributor Author

@nirandaperera nirandaperera Apr 21, 2026

Choose a reason for hiding this comment

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

I don't really like the split in the type system between the pinned host buffer and the rmm::device_buffer storage.

This was required, because say we pass a pinned MR to a cudf operation, all allocations made by cudf are returned as rmm::device_buffer. So, we need a way to move it into a Host buffer.

Remind me why we need the pinned host buffer to be stored as a HostBuffer inside the Buffer object?

PinnedBuffer and HostBuffer were merged together because both impls were very similar. So, now both pinned and host data ptr is passed on to the HostBuffer.
TBH I think we may be able to merge all buffer classes in to a single impl, with the rmm MR changes. Let's see.

@nirandaperera nirandaperera requested a review from wence- April 22, 2026 17:22
Signed-off-by: niranda perera <niranda.perera@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants