-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[data] Inherit block size from downstream ops (#41019)
Stacked on #40757 Compute the block size for each operation before applying other optimizer rules that depend on it (SplitReadOutputBlocksRule). This also simplifies the block sizing, so we always propagate an op's target block size to all upstream ops, until we find an op that has a different block size set. Related issue number Closes #41018. --------- Signed-off-by: Stephanie Wang <swang@cs.berkeley.edu>
- Loading branch information
1 parent
64e5373
commit 6f7378c
Showing
11 changed files
with
182 additions
and
87 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
30 changes: 30 additions & 0 deletions
30
python/ray/data/_internal/logical/rules/inherit_target_max_block_size.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from typing import Optional | ||
|
||
from ray.data._internal.execution.interfaces import PhysicalOperator | ||
from ray.data._internal.logical.interfaces import PhysicalPlan, Rule | ||
|
||
|
||
class InheritTargetMaxBlockSizeRule(Rule): | ||
"""For each op that has overridden the default target max block size, | ||
propagate to upstream ops until we reach an op that has also overridden the | ||
target max block size.""" | ||
|
||
def apply(self, plan: PhysicalPlan) -> PhysicalPlan: | ||
self._propagate_target_max_block_size_to_upstream_ops(plan.dag) | ||
return plan | ||
|
||
def _propagate_target_max_block_size_to_upstream_ops( | ||
self, dag: PhysicalOperator, target_max_block_size: Optional[int] = None | ||
): | ||
if dag.target_max_block_size is not None: | ||
# Set the target block size to inherit for | ||
# upstream ops. | ||
target_max_block_size = dag.target_max_block_size | ||
elif target_max_block_size is not None: | ||
# Inherit from downstream op. | ||
dag.set_target_max_block_size(target_max_block_size) | ||
|
||
for upstream_op in dag.input_dependencies: | ||
self._propagate_target_max_block_size_to_upstream_ops( | ||
upstream_op, target_max_block_size | ||
) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.