Skip to content

Cudf-free shuffler tests - #1084

Merged
rapids-bot[bot] merged 11 commits into
rapidsai:mainfrom
nirandaperera:cuda-free-dist-tests
Jun 11, 2026
Merged

Cudf-free shuffler tests#1084
rapids-bot[bot] merged 11 commits into
rapidsai:mainfrom
nirandaperera:cuda-free-dist-tests

Conversation

@nirandaperera

@nirandaperera nirandaperera commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

[C++] Make shuffler distributed tests cudf-free

Summary

The shuffler round-trip tests depended on cudf for input generation and result checking (random_table_with_index, partition_and_pack/unpack_and_concat, CUDF_TEST_EXPECT_TABLES_EQUIVALENT, cudf::test::BaseFixture), which made them heavy and coupled to the cudf integration. This replaces that with a self-contained, conservation-preserving data model built directly from PackedData, so the shuffler tests no longer depend on cudf and run as part of the default (non-BUILD_CUDF_TESTS) build.

Changes

C++ utilities

  • Add ceil_div and a chunk_indices view to utils/misc.hpp. chunk_indices tiles [0, count) into exactly num_chunks contiguous (possibly empty) ranges whose sizes sum to count.
  • ceil_div is computed as x / y + (x % y != 0) rather than the naive (x + y - 1) / y, which overflows for large unsigned values and is UB on signed overflow near the type maximum.
  • Add compile-time edge-case coverage for ceil_div in test_misc.cpp (static_asserts for exact/remainder division, zero numerator, denominator of one, and values at uint64/int64 maxima).

C++ shuffler tests (now cudf-free)

  • Rework the shuffler tests (test_shuffler.cpp, streaming/test_shuffler.cpp) around make_partition_data (produces routed chunks) and validate_partition_data (verifies received chunks), dropping all cudf/cudf_test usage and switching to rmm:: stream/MR helpers and ::testing::Test.
  • Generalize the test helpers generate_packed_data/validate_packed_data in tests/utils.hpp over the element type and build device buffers via the buffer resource + cuda_memcpy_async instead of cudf.
  • De-couple streaming/test_allgather.cpp from cudf_streaming/integrations/partition.hpp.
  • cpp/tests/CMakeLists.txt: move test_shuffler.cpp, streaming/test_shuffler.cpp, and streaming/test_allgather.cpp out of the BUILD_CUDF_TESTS block into the default build; the cudf block now only carries test_partition.cpp, test_shuffler_many_streams.cpp, and streaming/test_leaf_actor.cpp.

Python (now cudf-free)

  • Add a PackedData.from_device_buffer(gpu_data, metadata, stream, br) factory (plus .pyi stub) so packed data can be built from an rmm DeviceBuffer without cudf.
  • Add shared, cudf-free shuffle test helpers to rapidsmpf/testing.py: chunk_indices, generate_packed_data, validate_packed_data, make_partition_data, and validate_partition_data.
  • Rewrite the Python shuffler tests (tests/test_shuffler.py, tests/streaming/test_shuffler.py) around those helpers and the Shuffler/ShufflerAsync object interfaces, removing the cudf / cudf_streaming / pylibcudf dependencies.

Depends on #1087

@copy-pr-bot

copy-pr-bot Bot commented Jun 7, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@nirandaperera nirandaperera added breaking Introduces a breaking change improvement Improves an existing functionality labels Jun 7, 2026
@nirandaperera

Copy link
Copy Markdown
Contributor Author

/ok to test

Comment thread cpp/include/rapidsmpf/memory/spill.hpp
Comment thread cpp/tests/utils.hpp
@nirandaperera
nirandaperera marked this pull request as ready for review June 8, 2026 17:37
@nirandaperera
nirandaperera requested review from a team as code owners June 8, 2026 17:37
@nirandaperera
nirandaperera requested a review from pentschev June 8, 2026 18:33
@nirandaperera
nirandaperera force-pushed the cuda-free-dist-tests branch from 0ce351e to fb06ec7 Compare June 8, 2026 21:06
@nirandaperera
nirandaperera marked this pull request as draft June 8, 2026 21:06
Signed-off-by: niranda perera <niranda.perera@gmail.com>
@nirandaperera
nirandaperera force-pushed the cuda-free-dist-tests branch from fb06ec7 to 8820818 Compare June 9, 2026 17:58
@nirandaperera
nirandaperera marked this pull request as ready for review June 9, 2026 17:58
Signed-off-by: niranda perera <niranda.perera@gmail.com>
Comment thread cpp/include/rapidsmpf/utils/misc.hpp Outdated
Comment thread cpp/tests/test_shuffler.cpp
Comment thread cpp/tests/streaming/test_shuffler.cpp Outdated
Comment thread cpp/tests/streaming/test_shuffler.cpp Outdated
Signed-off-by: niranda perera <niranda.perera@gmail.com>
Signed-off-by: niranda perera <niranda.perera@gmail.com>
Comment thread cpp/tests/test_shuffler.cpp
Comment thread cpp/tests/test_shuffler.cpp
Comment thread python/rapidsmpf/rapidsmpf/testing.py
Comment thread python/rapidsmpf/rapidsmpf/testing.py
Comment thread python/rapidsmpf/rapidsmpf/testing.py Outdated
A ``PackedData`` containing the integer sequence.
"""
data = np.arange(offset, offset + n_elements, dtype=_DTYPE).tobytes()
gpu_data = rmm.DeviceBuffer.to_device(data, stream=stream)

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.

Please allocate this test payload through br.device_mr (or a small BR-backed helper) before wrapping it in PackedData. to_device() uses the current/default RMM resource and from_device_buffer() only adopts the allocation, so the replacement tests bypass BufferResource tracking that the old partition_and_pack(..., br=br) path covered.

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.

Done

Comment thread python/rapidsmpf/rapidsmpf/tests/streaming/test_shuffler.py
Signed-off-by: niranda perera <niranda.perera@gmail.com>
Signed-off-by: niranda perera <niranda.perera@gmail.com>

@madsbk madsbk left a comment

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.

Comment on lines +144 to +153
/// Conservation-preserving data model shared by the shuffler round-trip tests.
///
/// The index range `[0, total_num_rows)` is split into `total_num_partitions^2`
/// contiguous sub-regions via `chunk_indices` (front-loaded, so trailing sub-regions
/// are empty when `N < P*P`). Sub-region `(local_pidx, split_idx)` is piece
/// `k = local_pidx * P + split_idx` and is routed to destination partition
/// `split_idx`. The pieces exactly tile `[0, N)`, so the total shuffled row
/// count equals `N` regardless of rank or partition counts (conservation). A
/// per-shuffle `base` offset is added to every value so distinct shuffles carry
/// distinct data.

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.

Is this supposed to be part of make_partition_data docs? Currently looks like a strange placing not really connected to anything.

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 was trying to explain test approach here, especially the P^2 splits because I felt that a new reader might find it a little confusing.

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.

Since this relates to make_partition_data, validate_partition_data, test_shuffler methods I thought this is the best place to put it, more as a detail rather than a doc string.

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.

It's a strange placement, but I don't have a better idea where to put it either. Let's leave it there for now.

Comment thread python/rapidsmpf/rapidsmpf/streaming/chunks/partition.pyx
Comment on lines +155 to +141
async def do_shuffle(
context: Context,
comm: Communicator,
ch_in: Channel[TableChunk],
ch_out: Channel[TableChunk],
ch_in: Channel[PartitionMapChunk],
ch_out: Channel[PartitionVectorChunk],

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.

I can't add the comment on the exact lines, but assumes this extends to line 146:

This replacement still bypasses the exported streaming actor wrapper. The removed cudf-based test drove rapidsmpf.streaming.coll.shuffler.shuffler() in the channel pipeline (see that in 26.06 for example), which exercised streaming/coll/shuffler.pyx including the cpp_shuffler call and PartitionAssignment mapping. This new actor instantiates ShufflerAsync directly, so a regression in the public shuffler() wrapper would no longer be caught. Now that PartitionMapChunk.from_packed_data_map() exists, can this test use the actual shuffler() actor between ch_in and ch_shuffled?

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.

Yes you are right. I was more focused on porting the previous tests as is, and missed this detail. I removed the do_shuffle actor alltogether, because we can strictly replace it from shuffle actor as you said.

@pentschev

Copy link
Copy Markdown
Member

I have opened #1092 and #1093 adding cuDF-free coverage for the remaining missing tests. Both require changes from this PR (specifically, rapidsmpf.testing.generate_packed_data and rapidsmpf.testing.validate_packed_data). I think after this PR #1084 plus the aforementioned PRs are merged we would have covered everything missing and could then remove all remaining cuDF pieces without functionality coverage loss.

Signed-off-by: niranda perera <niranda.perera@gmail.com>
Signed-off-by: niranda perera <niranda.perera@gmail.com>
@nirandaperera
nirandaperera requested a review from pentschev June 11, 2026 15:31

@pentschev pentschev left a comment

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.

Thanks @nirandaperera , one final minor request, otherwise LGTM.

Comment thread python/rapidsmpf/rapidsmpf/tests/streaming/test_shuffler.py
Co-authored-by: Peter Andreas Entschev <peter@entschev.com>
@nirandaperera

Copy link
Copy Markdown
Contributor Author

Thanks @pentschev

@nirandaperera

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit 3cad33f into rapidsai:main Jun 11, 2026
66 checks passed
rapids-bot Bot pushed a commit that referenced this pull request Jun 12, 2026
Removes the remaining cuDF-specific dependency surface from RapidsMPF after the cuDF-dependent coverage was moved out and replaced with RapidsMPF-native tests.

This removes:
- `BUILD_CUDF_TESTS` and the `cudf_streaming` CMake fetch path
- cuDF/cudf_streaming links from C++ tests, examples, and benchmarks
- cuDF-only C++ tests, examples, benchmarks, and NDSH benchmark tooling
- Python examples/tests/benchmark code that imports or requires cuDF/pylibcudf
- cuDF-related package dependencies from `dependencies.yaml`, generated conda envs, pyproject metadata, and conda recipes
- CI smoke-test references to deleted cuDF-specific binaries
- documentation and comments that described RapidsMPF APIs in cuDF-specific terms

The remaining shuffler, streaming, memory, communicator, and Ray coverage stays library-neutral and is covered by the tests added in the preceding PRs.

Depends on #1084 and #1092 .

Authors:
  - Peter Andreas Entschev (https://github.com/pentschev)
  - Niranda Perera (https://github.com/nirandaperera)

Approvers:
  - Niranda Perera (https://github.com/nirandaperera)
  - Vyas Ramasubramani (https://github.com/vyasr)

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

Labels

breaking Introduces a breaking change improvement Improves an existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants