Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[data] Stage fusion optimizations, off by default #22373

Merged
merged 64 commits into from
Feb 17, 2022

Conversation

ericl
Copy link
Contributor

@ericl ericl commented Feb 15, 2022

Why are these changes needed?

This PR adds the following stage fusion optimizations (off by default). In a later PR, I plan to enable this by default for DatasetPipelines.

  • Stage fusion: Whether to fuse compatible OneToOne stages.
  • Read stage fusion: Whether to fuse read stages into downstream OneToOne stages. This is accomplished by rewriting the read stage (LazyBlockList) into a transformation over a collection of read tasks (BlockList -> MapBatches(do_read)).
  • Shuffle stage fusion: Whether to fuse compatible OneToOne stages into shuffle stages that support specifying a map-side block UDF.

Stages are considered compatible if their compute strategy is the same ("tasks" vs "actors"), and they have the same Ray remote args. Currently, the PR is ignoring the remote args of read tasks, but this will be fixed as a followup (I didn't want to change the read tasks default here).

I've experimented with this locally and the memory reduction is ~50%, mostly from clearing input blocks. In the distributed setting I'd expect more savings especially under memory pressure, since fusion suppresses excess spilling / transfer of blocks.

Related issue number

Towards #18791

@ericl ericl changed the title [WIP] Stage fusion [data] Stage fusion optimizations, off by default Feb 16, 2022
Copy link
Contributor

@clarkzinzow clarkzinzow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall paradigm is looking good, making sure that read-time load balancing is preserved when given _spread_resource_prefix="node:" is the only big blocker that I see.

python/ray/data/impl/plan.py Show resolved Hide resolved
python/ray/data/impl/plan.py Show resolved Hide resolved
python/ray/data/impl/plan.py Show resolved Hide resolved
python/ray/data/impl/plan.py Outdated Show resolved Hide resolved
python/ray/data/impl/plan.py Show resolved Hide resolved
python/ray/data/dataset_pipeline.py Show resolved Hide resolved
python/ray/data/impl/plan.py Show resolved Hide resolved
Copy link
Contributor Author

@ericl ericl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Copy link
Contributor

@clarkzinzow clarkzinzow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -167,6 +167,7 @@ def test_dataset_pipeline_stats_basic(ray_start_regular_shared):
for batch in pipe.iter_batches():
pass
stats = canonicalize(pipe.stats())
print(stats)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print(stats)

@ericl ericl merged commit 786c575 into ray-project:master Feb 17, 2022
simonsays1980 pushed a commit to simonsays1980/ray that referenced this pull request Feb 27, 2022
This PR adds the following stage fusion optimizations (off by default). In a later PR, I plan to enable this by default for DatasetPipelines.
- Stage fusion: Whether to fuse compatible OneToOne stages.
- Read stage fusion: Whether to fuse read stages into downstream OneToOne stages. This is accomplished by rewriting the read stage (LazyBlockList) into a transformation over a collection of read tasks (BlockList -> MapBatches(do_read)).
- Shuffle stage fusion: Whether to fuse compatible OneToOne stages into shuffle stages that support specifying a map-side block UDF.

Stages are considered compatible if their compute strategy is the same ("tasks" vs "actors"), and they have the same Ray remote args. Currently, the PR is ignoring the remote args of read tasks, but this will be fixed as a followup (I didn't want to change the read tasks default here).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants