Skip to content

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

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

Use cudf::pack with pinned mr in TableChunk::copy#966
nirandaperera wants to merge 2 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.


/**
* @brief Move device buffer data into a Buffer.
* @brief Move device/ pinned host buffer data into a Buffer.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* @brief Move device/ pinned host buffer data into a Buffer.
* @brief Move device or pinned host buffer data into a Buffer.

Comment on lines +313 to +314
* @param mem_type The memory type of the underlying @p data. This requires to be a
* device accessible memory type (ie. MemoryType::DEVICE or MemoryType::PINNED_HOST).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* @param mem_type The memory type of the underlying @p data. This requires to be a
* device accessible memory type (ie. MemoryType::DEVICE or MemoryType::PINNED_HOST).
* @param mem_type The memory type of the underlying @p data. A device accessible memory
* type is required (ie. MemoryType::DEVICE or MemoryType::PINNED_HOST).

RAPIDSMPF_EXPECTS(
pinned_mr_ != PinnedMemoryResource::Disabled,
"pinned memory resource is not available",
std::invalid_argument
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: should this actually be a std::runtime_error? The memory type isn't technically invalid, it is an error only from a runtime/system perspective.

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.

Yeah, I think that's reasonable.

Comment on lines +164 to +167
// a. reservaiton in pinned memory - Use cudf::pack to directly copy the table
// data to pinned memory.
// b. reservaiton in host memory - Use cudf::pack to copy the table data to
// intermediate device memory and then copy to host memory.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// a. reservaiton in pinned memory - Use cudf::pack to directly copy the table
// data to pinned memory.
// b. reservaiton in host memory - Use cudf::pack to copy the table data to
// intermediate device memory and then copy to host memory.
// a. reservation in pinned memory - Use cudf::pack to directly copy the table
// data to pinned memory.
// b. reservation in host memory - Use cudf::pack to copy the table data to
// intermediate device memory and then copy to host memory.

Comment on lines +197 to +198
// use cudf pack with pinned mr. When the pinned mr is warmed up, the
// performance
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the performance ...?

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 lost the train of thought! LOL.

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.

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.

2 participants