Skip to content

RapidsMPF SPMD mode in PDSH benchmarks - #21652

Merged
rapids-bot[bot] merged 8 commits into
NVIDIA:mainfrom
madsbk:rapidsmpf-spmd-benchmarks
Mar 11, 2026
Merged

RapidsMPF SPMD mode in PDSH benchmarks#21652
rapids-bot[bot] merged 8 commits into
NVIDIA:mainfrom
madsbk:rapidsmpf-spmd-benchmarks

Conversation

@madsbk

@madsbk madsbk commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Update the PDSH benchmarks to support --cluster=spmd runs.

Run using something like:

rrun -n 2 python \
  python/cudf_polars/cudf_polars/experimental/benchmarks/pdsh.py \
  --executor=streaming \
  --suffix="" \
  --spill-device=0.5 \
  --shuffle=rapidsmpf \
  --runtime=rapidsmpf \
  --stream-policy=pool \
  --no-print-results --no-summarize \
  --iterations=10 \
  --path /datasets/datasets/tpch-rs/scale-10 \
  --cluster spmd \
  1

@madsbk madsbk self-assigned this Mar 4, 2026
@madsbk madsbk added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Mar 4, 2026
@github-actions github-actions Bot added Python Affects Python cuDF API. cudf-polars Issues specific to cudf-polars labels Mar 4, 2026
@GPUtester GPUtester moved this to In Progress in cuDF Python Mar 4, 2026
@madsbk madsbk mentioned this pull request Mar 4, 2026
rapids-bot Bot pushed a commit that referenced this pull request Mar 6, 2026
This PR adds an `spmd` cluster type to the streaming executor, enabling multi-GPU execution via the `rrun` launcher without requiring Dask.

With this mode, users can run the same Python program on multiple ranks (SPMD style) and use RapidsMPF collectives directly from Python. Each rank processes its own slice of data and coordinates through collectives such as `allgather`.

### Example

Launch with:

```
rrun -n 4 python script.py
```

```python
from cudf_polars.experimental.rapidsmpf.spmd import (
    allgather_polars_dataframe,
    spmd_execution,
)
from cudf_polars.experimental.rapidsmpf.collectives.common import reserve_op_id

with spmd_execution() as (ctx, engine):
    rank = ctx.comm().rank

    # Each rank holds its own slice of the data
    local = pl.LazyFrame({"a": [rank], "b": [rank * 10]})
    local_result = (
        local.group_by("a")
        .agg(pl.col("b").sum())
        .collect(engine=engine)
    )

    # Gather results from all ranks
    with reserve_op_id() as op_id:
        full_result = allgather_polars_dataframe(
            ctx=ctx, local_df=local_result, op_id=op_id
        )  # all ranks gets an identical copy of `full_result`

```

### Running the pdsh benchmarks

Update: the benchmark update has been moved to a follow-up PR: #21652

Authors:
  - Mads R. B. Kristensen (https://github.com/madsbk)

Approvers:
  - Lawrence Mitchell (https://github.com/wence-)

URL: #21619
@madsbk
madsbk force-pushed the rapidsmpf-spmd-benchmarks branch 3 times, most recently from 6805d3a to e9463fe Compare March 6, 2026 16:50
@madsbk
madsbk force-pushed the rapidsmpf-spmd-benchmarks branch from e9463fe to 55825f0 Compare March 8, 2026 20:59
@madsbk
madsbk marked this pull request as ready for review March 8, 2026 20:59
@madsbk
madsbk requested a review from a team as a code owner March 8, 2026 20:59
@madsbk
madsbk requested review from rjzamora and wence- March 8, 2026 20:59
@NVIDIA NVIDIA deleted a comment from copy-pr-bot Bot Mar 8, 2026
) -> None:
"""Run benchmark queries using SPMD execution via the ``rrun`` launcher."""
if run_config.collect_traces:
warnings.warn(

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.

I'd say error rather than warn.

More generally, is there something that prevents us from making --collect-traces (and I'm assuming cudf-polars' structured logging) work with spmd? Single node / process, everything is easy. For multi-node with Dask, we need to call some logging config at the start and collect the logs at the end (we could also configure logging to stream the logs, but that's immaterial). Presumably we can do something similar with spmd, using rank 0 to collect the logs?

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, I think this is possible, but let’s wait until we have the full picture related to the new Ray frontend.

I have changed the warning to a NotImplementedError.

@TomAugspurger TomAugspurger left a comment

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.

The diff here looks pretty large, but IIUC, the primary changes are

  1. Refactoring parts of run_polars into _run_query_loop, essentially unchanged
  2. Adding a new run_polars_smpd, with a branch to take that from run_polars if specified
  3. Some minor adjustments (using ternary expressions, moving some things like dask client initialization around)

If that understanding is correct, then I think my only question (non-blocking) is around the structured logging.

Comment thread python/cudf_polars/cudf_polars/experimental/benchmarks/utils.py Outdated
@madsbk

madsbk commented Mar 10, 2026

Copy link
Copy Markdown
Contributor Author

If that understanding is correct, then I think my only question (non-blocking) is around the structured logging.

Yes, your understanding is correct. 🙂

Most of the differences are just refactoring so that at least some of the code can be reused in run_polars_spmd().
The structure is now:

  • run_polars(benchmark, args) - thin dispatcher to run_polars_single_or_dask or run_polars_spmd.
  • run_polars_single_or_dask(...) - full Dask/single-process path.
  • run_polars_spmd(...) - SPMD path.

@madsbk

madsbk commented Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit 990d73f into NVIDIA:main Mar 11, 2026
89 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in cuDF Python Mar 11, 2026
@madsbk
madsbk deleted the rapidsmpf-spmd-benchmarks branch March 11, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cudf-polars Issues specific to cudf-polars improvement Improvement / enhancement to an existing function non-breaking Non-breaking change Python Affects Python cuDF API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants