Skip to content

[Data] enable GPU_SHUFFLE in grouped_data.py - #62410

Merged
goutamvenkat-anyscale merged 12 commits into
ray-project:masterfrom
leewyang:enable_gpu_shuffle
Apr 21, 2026
Merged

goutamvenkat-anyscale merged 12 commits into
ray-project:masterfrom
leewyang:enable_gpu_shuffle

Conversation

@leewyang

@leewyang leewyang commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Description

This PR enables GPU_SHUFFLE in grouped_data.py, i.e. groupby(). The map_groups() is still left on CPU for now.

Related issues

Related to #61371

Additional information

  • Also adds should_sort argument to the GPU shuffle path so the groups are correctly ordered.
  • Fixes a bug in test_gpu_shuffle.py

@leewyang
leewyang requested a review from a team as a code owner April 7, 2026 23:24

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces a should_sort parameter to the GPU shuffle implementation, enabling optional sorting of data by key columns during the shuffle process. Key changes include updating the BulkRapidsMPFShuffler to perform sorting before Arrow conversion, modifying the execution planner to propagate the sort flag, and ensuring cudf dataframes are converted to Arrow without preserving indices. Additionally, GPU_SHUFFLE is now correctly handled in the partition logic for map_groups. I have no feedback to provide.

@ray-gardener ray-gardener Bot added data Ray Data-related issues community-contribution Contributed by the community labels Apr 8, 2026
Comment thread python/ray/data/tests/conftest.py Resolved
@leewyang
leewyang force-pushed the enable_gpu_shuffle branch from 311bcdb to d24c001 Compare April 8, 2026 17:29
Comment thread python/ray/data/tests/conftest.py Resolved
leewyang added 3 commits April 8, 2026 17:44
Signed-off-by: Lee Yang <[email protected]>
Signed-off-by: Lee Yang <[email protected]>
Signed-off-by: Lee Yang <[email protected]>
Comment thread python/ray/data/tests/conftest.py Resolved
Signed-off-by: Lee Yang <[email protected]>
Comment on lines +251 to +253
first_time = True
while not self.shuffler.finished() or first_time:
first_time = False

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.

Why does this flag exist?

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.

this is emulating a do/while to fix a race condition where shuffler.finished() was true before entering the loop.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 1f3f526. Configure here.

# partition id produces exactly one block, so downstream queues
# that require contiguous key ranges (e.g. ReorderingBundleQueue)
# don't stall.
block = pa.Table.from_pylist([], schema=self._arrow_schema)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

_arrow_schema is None when actor receives no data

Medium Severity

self._arrow_schema is initialized to None and only set during insert_batch. When there are more GPU ranks than input blocks, the round-robin distribution in _add_input_inner means some actors never receive an insert_batch call. For those actors, self._arrow_schema remains None. When finish_and_extract encounters a zero-column partition on such an actor, pa.Table.from_pylist([], schema=None) produces a columnless table instead of an empty table with the correct schema, causing a schema mismatch with blocks from other actors.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1f3f526. Configure here.

@goutamvenkat-anyscale goutamvenkat-anyscale added the go add ONLY when ready to merge, run all tests label Apr 18, 2026
@goutamvenkat-anyscale
goutamvenkat-anyscale merged commit e8f818d into ray-project:master Apr 21, 2026
4 checks passed
HLDKNotFound pushed a commit to chichic21039/ray that referenced this pull request Apr 22, 2026
## Description
This PR enables GPU_SHUFFLE in grouped_data.py, i.e. `groupby()`. The
`map_groups()` is still left on CPU for now.

## Related issues
Related to ray-project#61371

## Additional information
- Also adds `should_sort` argument to the GPU shuffle path so the groups
are correctly ordered.
- Fixes a bug in test_gpu_shuffle.py

---------

Signed-off-by: Lee Yang <[email protected]>
Co-authored-by: Goutam <[email protected]>
@leewyang
leewyang deleted the enable_gpu_shuffle branch May 6, 2026 21:52
Lucas61000 pushed a commit to Lucas61000/ray that referenced this pull request May 15, 2026
## Description
This PR enables GPU_SHUFFLE in grouped_data.py, i.e. `groupby()`. The
`map_groups()` is still left on CPU for now.

## Related issues
Related to ray-project#61371

## Additional information
- Also adds `should_sort` argument to the GPU shuffle path so the groups
are correctly ordered.
- Fixes a bug in test_gpu_shuffle.py

---------

Signed-off-by: Lee Yang <[email protected]>
Co-authored-by: Goutam <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community data Ray Data-related issues go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants