Skip to content

Moving spill/unspill_partitions from cudf_streaming - #1087

Merged
rapids-bot[bot] merged 3 commits into
rapidsai:mainfrom
nirandaperera:moving-back-spill-unspill
Jun 9, 2026
Merged

Moving spill/unspill_partitions from cudf_streaming#1087
rapids-bot[bot] merged 3 commits into
rapidsai:mainfrom
nirandaperera:moving-back-spill-unspill

Conversation

@nirandaperera

Copy link
Copy Markdown
Contributor

Moves the cuDF-independent spill/unspill helpers from cudf_streaming::integrations::partition (in the cudf repo) back into librapidsmpf. They only need PackedData and BufferResource, so they don't belong behind a libcudf dependency.

Changes

C++

  • New cpp/include/rapidsmpf/memory/spill.hpp and cpp/src/memory/spill.cpp defining rapidsmpf::spill_partitions / rapidsmpf::unspill_partitions (wired into cpp/CMakeLists.txt).
  • New cpp/tests/test_spilling.cpp for a roundtrip test (extracted from test_partition.cpp).
  • All call sites in cpp/tests/test_shuffler.cpp, cpp/examples/example_shuffle.cpp, cpp/benchmarks/bench_shuffle.cpp, and cpp/benchmarks/streaming/ndsh/join.cpp switched from cudf_streaming::integrations::unspill_partitions to rapidsmpf::unspill_partitions, with the new header included.

Python

  • New Cython bindings at python/rapidsmpf/rapidsmpf/memory/spill.{pyx,pxd,pyi} exposing spill_partitions / unspill_partitions via rapidsmpf.memory.spill (added to memory/CMakeLists.txt).
  • New python/rapidsmpf/rapidsmpf/tests/test_spill.py (extracted from test_partition.py).
  • All call sites in bulk_mpi_shuffle.py, ray/bulk_ray_shuffle.py, ray/ray_shuffle_example.py, and tests/test_shuffler.py switched to importing from rapidsmpf.memory.spill.

Signed-off-by: niranda perera <niranda.perera@gmail.com>
@nirandaperera
nirandaperera requested review from a team as code owners June 8, 2026 19:55

@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.

LGTM.

@pentschev pentschev added bug Something isn't working non-breaking Introduces a non-breaking change labels Jun 8, 2026
Signed-off-by: niranda perera <niranda.perera@gmail.com>
@nirandaperera
nirandaperera requested a review from a team as a code owner June 9, 2026 05:11
@nirandaperera
nirandaperera requested a review from bdice June 9, 2026 05:11
@nirandaperera
nirandaperera force-pushed the moving-back-spill-unspill branch from fb1c467 to 6ea2bf9 Compare June 9, 2026 05:13
@nirandaperera

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit 5234785 into rapidsai:main Jun 9, 2026
129 checks passed
rapids-bot Bot pushed a commit to NVIDIA/cudf that referenced this pull request Jun 10, 2026
Removed `spill/unspill_partitions` from partition.hpp and use rapidsmpf utils.

Depends on rapidsai/rapidsmpf#1087

Authors:
  - Niranda Perera (https://github.com/nirandaperera)

Approvers:
  - Peter Andreas Entschev (https://github.com/pentschev)

URL: #22810
rapids-bot Bot pushed a commit that referenced this pull request Jun 11, 2026
## `[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_assert`s 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

Authors:
  - Niranda Perera (https://github.com/nirandaperera)

Approvers:
  - Mads R. B. Kristensen (https://github.com/madsbk)
  - Peter Andreas Entschev (https://github.com/pentschev)

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

Labels

bug Something isn't working non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants