Repository navigation
[Data] Fix shuffle v2 failures with reordered columns and empty blocks - #67812
Draft
XiaoHongbo-Hope wants to merge 1 commit into
Draft
XiaoHongbo-Hope wants to merge 1 commit into
XiaoHongbo-Hope wants to merge 1 commit into
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Signed-off-by: xiaohongbo <[email protected]>
XiaoHongbo-Hope
force-pushed
the
fix/shuffle-v2-arrow-schema
branch
from
November 5, 2026 06:44
f5f9850 to
4825966
Compare
richardliaw
pushed a commit
that referenced
this pull request
Nov 13, 2026
## Summary
`Dataset.sort()` now honors `DataContext.use_disk_based_hash_shuffle`
(`RAY_DATA_ENABLE_DISK_SHUFFLE=1`) under `SHUFFLE_V2`, like keyed
repartition, aggregations, and joins. Off by default.
## Before
Sort ignored the flag. `DiskHashShuffleReduceOp` could only emit
partitions in completion order, and the disk shard writer rejected
compatible but non-identical block schemas (null vs int64).
## After
- Flag on: `SortSamplingOp -> DiskSortShuffleMapOp ->
DiskHashShuffleReduceOp(preserve_partition_order=True)`.
- `DiskHashShuffleReduceOp` gains `preserve_partition_order` (reuses
`ReorderingBundleQueue`); the fusion rule forwards it.
- Boundary resolution moves into `SortRangePartitioner`, shared by
`SortShuffleMapOp` and the new `DiskSortShuffleMapOp`.
- **All disk shuffles:** the shard writer concatenates with
`transform_pyarrow.concat(promote_types=True)`.
```mermaid
flowchart LR
subgraph Before
direction TB
B1[_plan_sort_v2] --> B2[SortShuffleMapOp] --> B3["ShuffleReduceOp (ordered)"]
B4[DiskHashShuffleMapOp] --> B5["DiskHashShuffleReduceOp (FIFO)"]
end
subgraph After
direction TB
A1["_plan_sort_v2 (picks transport)"] --> A2[SortShuffleMapOp] --> A3["ShuffleReduceOp (ordered)"]
A1 --> A4[DiskSortShuffleMapOp] --> A5["DiskHashShuffleReduceOp (ordered or FIFO)"]
A6[SortRangePartitioner] -.-> A2
A6 -.-> A4
end
Before ~~~ After
class A4,A6 added
class A1,A2,A5 changed
classDef added fill:#c8e6c9,stroke:#2e7d32,color:#000
classDef changed fill:#fff9c4,stroke:#f9a825,color:#000
```
## Benchmark
1 TB sort (1000 x 1 GB partitions, 32 nodes), from a temporary release
entry run on this PR ([build
113798](https://buildkite.com/ray-project/release/builds/113798)) and
reverted since `tpch_*_disk_shuffle` already covers sort on disk.
| | object store | disk |
|---|---|---|
| End-to-end time | 3467 s | 3089 s (-11%) |
| Spilled | 1724 GB / 508k objects | 1486 GB / 2.1k objects |
| Peak driver memory | 1.96 GB | 0.43 GB |
Disk removes the map shards from the object store (the 500k small
spilled objects); the remaining spill is the 1 TB input and materialized
output on a 596 GB object store.
## Subsystems
physical planning, logical planning (fusion rule), execution / shuffle,
docs
## Testing
- `test_sort_shuffle_v2.py test_hash_shuffle_disk_smoke.py
test_hash_shuffle_disk_repartition.py`: 47 passed (sort tests
parametrized over `object_store`/`disk`).
- `test_execution_optimizer_advanced.py test_stats.py -k sort`: 16
passed. `test_sort.py -k shuffle_v2_disk`: 12 passed.
- `pre-commit run` on changed files: clean.
## Notes
- Not a duplicate (`gh pr list --search "disk shuffle sort"`). #67812
touches the same writer concat without type promotion; small rebase for
whichever lands second.
- AI assistance (Claude Code) was used. Every changed line has been
manually reviewed.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Signed-off-by: Sirui Huang <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Shuffle v2 fails when blocks have reordered columns or schema-less empty inputs. This fixes concatenation in reducers and disk map buffers, preserves a non-empty mapper's schema for empty partitions, and skips sorting empty results.
Scope: keyed repartition accepts reordered columns with matching names and types. Type mismatches are rejected within and across mappers; this PR does not add non-key type promotion or cross-mapper schema conversion. Key types are checked before partitions are emitted to avoid splitting equal values across partitions.
Subsystems: Execution; Shuffle / aggregation.
flowchart LR A[Validate schemas within mapper] --> B[Partition and concatenate reordered columns] B --> C[Validate schemas across mappers] C --> D[Emit partitions with typed empties]Validation with patched Ray 2.60 (Python 3.11, PyArrow 22):
python -m pytest --noconftest -o addopts='' -q python/ray/data/tests/unit/test_hash_shuffle_reducers.py: 62 passed, covering reordered columns, empty inputs, and rejected type changes with both shuffle transports and batching on/off.pre-commit runandgit diff --checkpassed.AI-assisted implementation and testing. No matching fix found in the initial shuffle/schema PR search. Draft pending human review.