Skip to content

[Data][3/n] Migrate Shuffle V2 to Unified Phase Metrics - #67570

Merged
richardliaw merged 40 commits into
ray-project:masterfrom
rayhhome:shuffle-metrics-v2
Nov 19, 2026
Merged

richardliaw merged 40 commits into
ray-project:masterfrom
rayhhome:shuffle-metrics-v2

Conversation

@rayhhome

Copy link
Copy Markdown
Contributor

Description

Migrates shuffle v2 onto the ShuffleOperatorMetrics component from #66968. PR 3 of 3, stacked on #66968 and #67359.

Today the four v2 operators (ShuffleMapOp, ShuffleReduceOp, DiskHashShuffleMapOp, DiskHashShuffleReduceOp) each keep their own block-stats list and a copy of the output-estimate block. Map stages report 0 worker time and num_outputs_total() is None; reduce stages recompute the estimate on every output bundle, and the disk reduce's estimate is stuck at 0.

This PR gives each operator one phase (map or reduce), aliased to the operator's own metrics, so every exported metric name and stats row is unchanged. What changes:

  • Map tasks report their worker wall time; map operators report num_outputs_total() == num_partitions.
  • Reduce estimates are computed once per finished task, so the disk reduce now reports a real estimate and non-row-preserving reduces return a row estimate instead of None.
  • The four copies of the estimate block are gone.

SortShuffleMapOp inherits the metrics unification changes introduced in this PR as it subclasses ShuffleMapOp.

Related issues

Stacked on #66968 and #67359. Related to #61636.

Additional information

The disk reduce still submits its tasks with an empty metrics bundle. Passing the wrapper's partition bytes would feed obj_store_mem_pending_task_inputs, which the downstream capacity backpressure policy reads, so that is a backpressure change rather than a metrics one and is not made here.

AI assistance (Claude Code) was used; every line was manually reviewed and locally tested.

@rayhhome rayhhome self-assigned this Oct 29, 2026
@rayhhome rayhhome added data Ray Data-related issues go add ONLY when ready to merge, run all tests labels Oct 29, 2026
Copilot AI balanced review requested due to automatic review settings October 29, 2026 23:14
@rayhhome
rayhhome requested a review from a team as a code owner October 29, 2026 23:14

@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 structured framework for tracking and reporting metrics, block stats, and progress bars for individual phases of shuffle-family operators (such as map, reduce, shuffle, and finalize stages) via the new ShufflePhaseMetrics and ShuffleOperatorMetrics classes. Both CPU and GPU-based shuffle operators have been refactored to delegate metrics tracking to these phase-specific objects, enabling more granular observability. I have no feedback to provide as there are no review comments.

Copilot AI 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.

🟡 Changes recommended

Skipped empty partitions inflate shuffle output estimates, while output-phase metrics double-count GPU-shuffle rows in dashboard dataset totals.

2 open issues
What changed in this PR

This stacked PR migrates Shuffle V2 to shared phase metrics, building on the instrumentation and GPU shuffle migrations. It consolidates task accounting, block statistics, and output estimates across shuffle operators.

Changes:

  • Replaces duplicated V2 metrics logic with single-phase components and records map worker time.
  • Adds shared phase reporting for GPU shuffle, including progress bars and Prometheus exports.
  • Expands tests for metrics, statistics, progress, and output estimates.
File Description
python/​ray/​data/​tests/​test_shuffle_phase_metrics.py Tests shared phase accounting and reporting.
python/​ray/​data/​tests/​test_hash_shuffle_v2.py Tests V2 map metrics and reduce estimates.
python/​ray/​data/​tests/​test_gpu_shuffle.py Tests GPU phase metrics, progress, and estimates.
python/​ray/​data/​tests/​test_gpu_aggregate.py Checks aggregation progress labels and stats keys.
python/​ray/​data/​BUILD.bazel Registers the phase-metrics test target.
python/​ray/​data/​_internal/​stats.py Exports phase snapshots and aggregates per-node metrics.
python/​ray/​data/​_internal/​gpu_shuffle/​hash_shuffle.py Integrates shared shuffle and finalize phases.
python/​ray/​data/​_internal/​gpu_shuffle/​hash_aggregate.py Reuses phase reporting with an aggregation label.
python/​ray/​data/​_internal/​execution/​streaming_executor.py Passes phase metrics to the stats manager.
python/​ray/​data/​_internal/​execution/​operators/​shuffle_phase_metrics.py Introduces shared phase accounting and estimates.
python/​ray/​data/​_internal/​execution/​operators/​shuffle_operators/​shuffle_reduce_operator.py Migrates reduce metrics and completion-time estimates.
python/​ray/​data/​_internal/​execution/​operators/​shuffle_operators/​shuffle_map_operator.py Migrates map metrics and reports worker time.
python/​ray/​data/​_internal/​execution/​operators/​shuffle_operators/​disk_shuffle_reduce_operator.py Migrates disk reduce metrics and estimates.
python/​ray/​data/​_internal/​execution/​operators/​shuffle_operators/​disk_shuffle_map_operator.py Migrates disk map metrics and reports partition totals.
python/​ray/​data/​_internal/​execution/​interfaces/​physical_operator.py Adds the phase-metrics interface.
python/​ray/​data/​_internal/​execution/​interfaces/​op_runtime_metrics.py Allows phase snapshots to omit operator resource usage.

Review effort: Balanced

Comment thread python/ray/data/_internal/stats.py Resolved

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

Stale Bugbot comment from a previous run.

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

Stale Bugbot comment from a previous run.

@rayhhome rayhhome removed their assignment Nov 3, 2026

@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 using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 4f47935. Configure here.

@richardliaw
richardliaw merged commit 74942b9 into ray-project:master Nov 19, 2026
6 checks passed
@rayhhome
rayhhome deleted the shuffle-metrics-v2 branch November 20, 2026 00:22
elliot-barn added a commit that referenced this pull request Nov 23, 2026
…nto releases/2.61.0 (#68472)

## Description

Cherry-pick of #68433 (`1729626bbb`) onto `releases/2.61.0`. Lets the
upstream read or map fuse into the disk-shuffle writer, and sets the
polars thread limit inside the task rather than through the runtime env.

The pick applied without conflicts. Seven master commits that touch the
same files are not on the release branch (#67143, #68158, #68202 and its
revert #68383, #68319, #67570, #68118), so the picked files differ from
master in five places. Reviewers from Data, please confirm none of those
is a prerequisite.

## Testing

Ran locally against the `releases/2.61.0` wheel (`7c8ca5ea51`) with the
picked files overlaid: `test_hash_shuffle_v2.py`,
`test_operator_fusion.py` and `test_execution_optimizer_advanced.py`,
232 passed, 2 skipped.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: You-Cheng Lin <[email protected]>
Signed-off-by: elliot-barn <[email protected]>
Co-authored-by: You-Cheng Lin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

4 participants