Skip to content

[data][1/n] Add the push-based streaming_split coordinator - #66465

Merged
goutamvenkat-anyscale merged 16 commits into
ray-project:masterfrom
xinyuangui2:push-split-coordinator
Oct 14, 2026
Merged

goutamvenkat-anyscale merged 16 commits into
ray-project:masterfrom
xinyuangui2:push-split-coordinator

Conversation

@xinyuangui2

@xinyuangui2 xinyuangui2 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

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_split for Ray Train ingestion. It adds the coordinator actor only; the pushers and the consumer-side iterator follow in #66466.

  • Epoch lifecycle: runs one streaming executor per epoch behind a barrier that all n splits must reach. Waiters sleep on a Condition rather than polling.
  • Row window: _SplitFlow tracks each split's target_rows, rows_pushed, and rows_consumed. A sender may send while target_rows - (rows_pushed - rows_consumed) > 0. Flow state is recreated every epoch, so a stale report can't affect the new one.
  • Pacing: bytes sent but not yet consumed feed the executor's external-consumer backpressure.
  • Scope: internal only. There's no public API change and the pull path is untouched. Dataset.streaming_split will 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

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]>
@xinyuangui2 xinyuangui2 added the go add ONLY when ready to merge, run all tests label Sep 24, 2026
@xinyuangui2
xinyuangui2 marked this pull request as ready for review September 24, 2026 20:20
@xinyuangui2
xinyuangui2 requested a review from a team as a code owner September 24, 2026 20:21

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

Comment thread python/ray/data/dataset.py Resolved
xinyuangui2 and others added 3 commits September 24, 2026 20:25
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]>
@xinyuangui2 xinyuangui2 changed the title [data][1/n] Add push-based streaming_split [data][1/n] Add the push-based streaming_split coordinator Sep 24, 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.

Stale Bugbot comment from a previous run.

…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]>

@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 3 potential issues.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 6ad886e. Configure here.

xinyuangui2 and others added 3 commits October 8, 2026 20:27
- 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]>
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 ayushk7102 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.

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.

Comment on lines +298 to +303
except Exception:
logger.warning(
f"Failed to tear down epoch {starting_epoch}; starting the "
"next epoch anyway.",
exc_info=True,
)

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.

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?

https://github.com/ray-project/ray/blob/master/python/ray/data/_internal/iterator/stream_split_iterator.py#L315-L337

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.

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.

xinyuangui2 and others added 6 commits October 9, 2026 19:36
…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]>
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)

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'm confused. If rows_pushed > rows_consumed why are we sending more?

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.

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:

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.

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?

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 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)

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 re-create the dict?

@goutamvenkat-anyscale
goutamvenkat-anyscale enabled auto-merge (squash) October 14, 2026 23:12
@goutamvenkat-anyscale
goutamvenkat-anyscale merged commit 8a93d58 into ray-project:master Oct 14, 2026
7 checks passed
richardliaw pushed a commit that referenced this pull request Nov 4, 2026
… 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]>
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.

3 participants