Skip to content

[Fix/n] Return External Consumer Bytes for Downstream Capacity to Activate Backpressure - #65474

Merged
justinvyu merged 3 commits into
ray-project:masterfrom
rayhhome:block-ref-counter-fix
Aug 14, 2026
Merged

justinvyu merged 3 commits into
ray-project:masterfrom
rayhhome:block-ref-counter-fix

Conversation

@rayhhome

Copy link
Copy Markdown
Contributor

Description

#64456 applies the block ref counter to track the object store memory and control backpressure signals based on downstream capacity, but this had lead to spilling in training pipelines. This is mainly due to backpressure not being applied to the terminal operator even though the external consumer is not consuming blocks quickly enough.

This PR adds back the early return for DownstreamCapacityBackpressurePolicy's _get_downstream_capacity_size_bytes, so that for terminal operators, the downstream capacity is the external consumer bytes tracked instead of 0.

Related issues

Fixes #64456.

@rayhhome rayhhome self-assigned this Aug 13, 2026
@rayhhome rayhhome added go add ONLY when ready to merge, run all tests data Ray Data-related issues labels Aug 13, 2026
@rayhhome
rayhhome marked this pull request as ready for review August 13, 2026 23:32
@rayhhome
rayhhome requested a review from a team as a code owner August 13, 2026 23:32
Copilot AI lite review requested due to automatic review settings August 13, 2026 23:32

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

Let's add a test

@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 updates the _get_downstream_capacity_size_bytes method in downstream_capacity_backpressure_policy.py to handle cases where an operator has no output dependencies by returning the external consumer bytes. There are no review comments, and I have no feedback to provide.

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.

Pull request overview

This PR adjusts Ray Data’s DownstreamCapacityBackpressurePolicy to correctly account for downstream capacity when a pipeline ends at a terminal operator with no in-DAG downstream operators, by using externally-consumed (iterator/prefetch) bytes as the capacity signal. This addresses missing backpressure at the terminal boundary that can lead to spilling in training ingest pipelines.

Changes:

  • Reintroduces an early return in _get_downstream_capacity_size_bytes() for operators with no output_dependencies.
  • Uses ResourceManager.get_external_consumer_bytes() as the downstream capacity for terminal operators (instead of implicitly treating capacity as 0).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@justinvyu
justinvyu enabled auto-merge (squash) August 14, 2026 00:19
@justinvyu
justinvyu merged commit d8ee27e into ray-project:master Aug 14, 2026
7 checks passed
@rayhhome
rayhhome deleted the block-ref-counter-fix branch August 14, 2026 18:55
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…ivate Backpressure (ray-project#65474)

ray-project#64456 applies the block ref counter to track the object store memory
and control backpressure signals based on downstream capacity, but this
had lead to spilling in training pipelines. This is mainly due to
backpressure not being applied to the terminal operator even though the
external consumer is not consuming blocks quickly enough.

This PR adds back the early return for
`DownstreamCapacityBackpressurePolicy`'s
`_get_downstream_capacity_size_bytes`, so that for terminal operators,
the downstream capacity is the external consumer bytes tracked instead
of 0.

---------

Signed-off-by: Sirui Huang <[email protected]>
Signed-off-by: 400Ping <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…ivate Backpressure (ray-project#65474)

ray-project#64456 applies the block ref counter to track the object store memory
and control backpressure signals based on downstream capacity, but this
had lead to spilling in training pipelines. This is mainly due to
backpressure not being applied to the terminal operator even though the
external consumer is not consuming blocks quickly enough.

This PR adds back the early return for
`DownstreamCapacityBackpressurePolicy`'s
`_get_downstream_capacity_size_bytes`, so that for terminal operators,
the downstream capacity is the external consumer bytes tracked instead
of 0.

---------

Signed-off-by: Sirui Huang <[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