Repository navigation
[data][1/n] Add the push-based streaming_split coordinator - #66465
goutamvenkat-anyscale merged 16 commits into
Conversation
Add Dataset.streaming_split_push_based: a coordinator actor runs the streaming executor and pushes each split's blocks, by value, to the actor hosting that split's PushBasedDataIterator, which iterates them from a local queue. Each consumer declares a prefetch_batches * batch_size row window and reports consumption; the coordinator pushes whole blocks while target_rows - (rows_pushed - rows_consumed) > 0, and feeds pushed-minus-consumed bytes to the executor's external-consumer backpressure. Deliveries are sequence-numbered and reordered on arrival, so ordering doesn't depend on the hosting actor's concurrency. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QfaKctvP9gCsC2EBTpdqnv Signed-off-by: xgui <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces a push-based streaming split mechanism for Ray Data, including a coordinator actor that pushes blocks to consumers, a local receiver that reorders out-of-order deliveries, and a custom data iterator. Feedback on these changes highlights several critical improvements: resolving a permanent memory leak of receiver objects in the global registry, replacing an inefficient busy-wait loop in the epoch barrier with a condition variable, ignoring duplicate out-of-order deliveries to prevent memory leaks, validating the split index during registration to avoid pusher thread crashes, and adding missing API decorators to the new dataset method.
Drop Dataset.streaming_split_push_based. The push-based split is built by an internal streaming_split_push_based(dataset, n, ...) helper instead, so a later PR can switch Dataset.streaming_split over directly. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QfaKctvP9gCsC2EBTpdqnv Signed-off-by: xgui <[email protected]>
Move the coordinator into its own module, push_split_coordinator.py: the epoch barrier and per-epoch executor, the per-split row window (_SplitFlow), and the external-consumer-bytes pacing feed. The pusher threads, the consumer-side receiver and PushBasedDataIterator move to the follow-up PR. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QfaKctvP9gCsC2EBTpdqnv Signed-off-by: xgui <[email protected]>
Wake barrier waiters with a Condition instead of polling every 0.1s, and reject out-of-range split indices. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QfaKctvP9gCsC2EBTpdqnv Signed-off-by: xgui <[email protected]>
…efly If the last arrival's teardown of the previous epoch raised, the other splits waited forever and a retry drove the arrival count negative. Release the barrier in a finally block and log the teardown failure. Also make the coordinator tests type-check under pyrefly. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QfaKctvP9gCsC2EBTpdqnv Signed-off-by: xgui <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Reviewed by Cursor Bugbot for commit 6ad886e. Configure here.
- Ignore consumer reports that arrive after a split finished, so a late report can't reopen its send window. - Tag metrics with the next run's dataset id, as SplitCoordinator does: the tag is fetched before the epoch's executor is created. - Report coordinator overhead in stats() (streaming_split_coordinator_s), log per-split finish counts, and restore the full schema() error. - Document why consumer reports don't refresh the pacing feed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QfaKctvP9gCsC2EBTpdqnv Signed-off-by: xgui <[email protected]>
…cstring Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QfaKctvP9gCsC2EBTpdqnv Signed-off-by: xgui <[email protected]>
Rename _create_split_dataset to create_streaming_split_dataset and move it to the shared Ray Data utils, so the push-based split and, later, Dataset.streaming_split can share it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QfaKctvP9gCsC2EBTpdqnv Signed-off-by: xgui <[email protected]>
ayushk7102
left a comment
There was a problem hiding this comment.
Can we add some more information in the PR description about why these changes are needed? we can motivate some things about the push model e.g.:
- We can handle reconstruction for lost blocks before passing refs to the workers
- Any implications of this design for mid epoch resumption, etc.
| except Exception: | ||
| logger.warning( | ||
| f"Failed to tear down epoch {starting_epoch}; starting the " | ||
| "next epoch anyway.", | ||
| exc_info=True, | ||
| ) |
There was a problem hiding this comment.
It looks like if there was a failure during the teardown of the epoch in the original split coordinator, we would re-raise for all threads. But with the new push split coordinator, we swallow the error and move on. Is this expected?
There was a problem hiding this comment.
Good catch — this now matches SplitCoordinator: a teardown failure is raised to every split for that epoch. Unlike before, the barrier is still released first, so no split hangs (the bug the earlier change fixed) and a later start_epoch can start the next epoch. Covered by test_teardown_failure_fails_epoch_for_all_splits.
…nt flow invariant Match SplitCoordinator: if tearing down the previous epoch fails, the next epoch fails for every split instead of starting anyway. The barrier is still released, so no split hangs and a retry can start a later epoch. Also document why bytes_consumed never exceeds bytes_pushed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QfaKctvP9gCsC2EBTpdqnv Signed-off-by: xgui <[email protected]>
…helper Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QfaKctvP9gCsC2EBTpdqnv Signed-off-by: xgui <[email protected]>
A sender that was mid-fetch when its split finished would otherwise add bytes no consumer reads back, inflating the pacing feed for the rest of the epoch. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QfaKctvP9gCsC2EBTpdqnv Signed-off-by: xgui <[email protected]>
Blocks are sent by value, so the consumer holds no ObjectRef and Ray Data's BlockRefCounter stopped counting a block as soon as its delivery task finished, while the consumer still pinned it. The producer's budget and output throttles then under-counted by about a prefetch window per consumer, letting it buffer more upstream (peak object store 1.11x pull's on training_ingest_regression_test). _SplitFlow now keeps each sent block's ref until the consumer reports its bytes consumed, matching how a pull consumer's prefetched refs are counted. No extra object-store memory: the consumer pins the object anyway. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QfaKctvP9gCsC2EBTpdqnv Signed-off-by: xgui <[email protected]>
The tests start actors and wait on epoch barriers with up-to-60 s timeouts; size "large" (900 s) leaves room for slower CI machines. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QfaKctvP9gCsC2EBTpdqnv Signed-off-by: xgui <[email protected]>
|
|
||
| def rows_to_send(self) -> int: | ||
| with self.cond: | ||
| return self.target_rows - (self.rows_pushed - self.rows_consumed) |
There was a problem hiding this comment.
I'm confused. If rows_pushed > rows_consumed why are we sending more?
There was a problem hiding this comment.
There can be prefetch_window
| def _finish_split(self, epoch_id: int, split_idx: int) -> None: | ||
| executor_to_shutdown = None | ||
| with self._lock: | ||
| if epoch_id != self._cur_epoch: |
There was a problem hiding this comment.
In what case can the split not correspond to the current epoch? Also shouldn't this be an error since all splits of an epoch need to finish before moving to the next epoch?
There was a problem hiding this comment.
This matches the existing pull coordinator: SplitCoordinator.notify_split_finished has the same epoch_id != self._cur_epoch early return. Since the notify is fire-and-forget, the other splits can finish the epoch and start the next one before it’s processed, at which point the old epoch’s state has already been reset, so there’s nothing left to do.
… debug_state - Wait on the barrier with Condition.wait_for: once with the blocked-client warning timeout, then without one after warning. - Build debug_state in one pass over the flows. - Explain why _finish_split can see a stale epoch: notify_split_finished is fire-and-forget on a concurrent actor, so it can run after the barrier has already moved to the next epoch. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QfaKctvP9gCsC2EBTpdqnv Signed-off-by: xgui <[email protected]>
| state["bytes_pushed"][i] = flow.bytes_pushed | ||
| state["bytes_consumed"][i] = flow.bytes_consumed | ||
| state["unconsumed_refs"][i] = flow.num_unconsumed_refs() | ||
| return dict(state) |
There was a problem hiding this comment.
why re-create the dict?
… Train integration, release tests (#66466) ## Why are these changes needed? Second PR of the push-based `streaming_split`, following #66465 (merged), which added the coordinator. It adds the data plane on top of the coordinator, connects it to Ray Train, and adds release tests that guard throughput. - **Pushers:** consumers register with the coordinator, and one thread per split sends blocks by value, sequence-numbered, while the split's row window has room. - **Consumer side:** `push_based_split_iterator.py` adds the receiver and reorder buffer, `PushSplitReceiverMixin`, and `PushBasedDataIterator`, which reuses the standard batching pipeline. Iterating on a default actor's task thread raises instead of hanging. - **Train:** `RayTrainWorker` mixes in the receiver, and the new `PushBasedDataConfig` shards datasets with the push-based split. It's opt-in, and `DataConfig` stays the default. `DatasetManager` now also tracks push coordinators, so their executors shut down with the pull ones. - **Release tests:** nightly `*.pull_vs_push` variants run each configuration with the pull split, then the push split, on the same cluster. - `training_ingest_benchmark` (full and skip training): fails if push `train/global_throughput` < 90% of pull's. On the 16-GPU `skip_training` run, push is at parity: epoch 121.35s vs 121.01s. - `training_ingest_regression_test.throughput`: fails if push steady throughput < 90% of pull's. - `training_ingest_regression_test.peak_object_store_memory`: fails if push peak object store usage > 110% of pull's. ## Rollout plan After merging with (a) mid-epoch resumption and (b) ray data fault-tolerance API, and release tests have shown no regression, we can roll out this refactor. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QfaKctvP9gCsC2EBTpdqnv --------- Signed-off-by: xgui <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>

Refactor the splitcoordinator to push based. Passing the ref as a task arg forces Ray to dereference and materialize a secondary copy on the worker node. So by the time the worker touches the data, it's already materialized in the worker’s local object store and is not affected by a remote death.
Why are these changes needed?
First PR of the push-based
streaming_splitfor Ray Train ingestion. It adds the coordinator actor only; the pushers and the consumer-side iterator follow in #66466.nsplits must reach. Waiters sleep on aConditionrather than polling._SplitFlowtracks each split'starget_rows,rows_pushed, androws_consumed. A sender may send whiletarget_rows - (rows_pushed - rows_consumed) > 0. Flow state is recreated every epoch, so a stale report can't affect the new one.Dataset.streaming_splitwill switch over in a later PR.Split out of #65842 (supersedes it), so this doesn't duplicate other work. Written with AI assistance (Claude Code) and reviewed by a human. Tests:
pytest python/ray/data/tests/test_push_split_coordinator.py(10 passed).TODO:
After mid-epoch resumption PRs are merged, this coordinator needs minor changes.
🤖 Generated with Claude Code
https://claude.ai/code/session_01QfaKctvP9gCsC2EBTpdqnv