-
Notifications
You must be signed in to change notification settings - Fork 7k
[Data] Add PhysicalOperator.min_max_resource_usage_bounds
#52502
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0babe2d
Initial commit
bveeramani c7819ce
Update tests
bveeramani 88bffd7
Merge branch 'master' into max-resource-usage2
bveeramani 6270c19
Merge branch 'master' into max-resource-usage2
bveeramani 528110b
Fix tests
bveeramani d6df3e1
Fix tests
bveeramani 2297450
Address review comments
bveeramani 9118e4f
Address review comments
bveeramani 5b06704
Fix edge case
bveeramani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,10 +1,9 @@ | ||
| import logging | ||
| import uuid | ||
| from abc import ABC, abstractmethod | ||
| from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union | ||
| import uuid | ||
|
|
||
| import ray | ||
| from .ref_bundle import RefBundle | ||
| from ray._raylet import ObjectRefGenerator | ||
| from ray.data._internal.execution.autoscaler.autoscaling_actor_pool import ( | ||
| AutoscalingActorPool, | ||
|
|
@@ -15,10 +14,11 @@ | |
| ) | ||
| from ray.data._internal.execution.interfaces.op_runtime_metrics import OpRuntimeMetrics | ||
| from ray.data._internal.logical.interfaces import LogicalOperator, Operator | ||
| from ray.data._internal.output_buffer import OutputBlockSizeOption | ||
| from ray.data._internal.stats import StatsDict, Timer | ||
| from ray.data.context import DataContext | ||
| from ray.data._internal.output_buffer import OutputBlockSizeOption | ||
|
|
||
| from .ref_bundle import RefBundle | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
@@ -542,13 +542,18 @@ def pending_processor_usage(self) -> ExecutionResources: | |
| """ | ||
| return ExecutionResources(0, 0, 0) | ||
|
|
||
| def base_resource_usage(self) -> ExecutionResources: | ||
| """Returns the minimum amount of resources required for execution. | ||
| def min_max_resource_requirements( | ||
| self, | ||
| ) -> Tuple[ExecutionResources, ExecutionResources]: | ||
| """Returns the min and max resources to start the operator and make progress. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's expand that these are derived from operator's concurrency configuration multiplied by single task/actor resource requirements. |
||
|
|
||
| For example, an operator that creates an actor pool requiring 8 GPUs could | ||
| return ExecutionResources(gpu=8) as its base usage. | ||
| return ExecutionResources(gpu=8) as its minimum usage. | ||
|
|
||
| This method is used by the resource manager to reserve minimum resources and to | ||
| ensure that it doesn't over-provision resources. | ||
| """ | ||
| return ExecutionResources() | ||
| return ExecutionResources.zero(), ExecutionResources.inf() | ||
bveeramani marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| def incremental_resource_usage(self) -> ExecutionResources: | ||
| """Returns the incremental resources required for processing another input. | ||
|
|
||
This file contains hidden or 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -302,13 +302,28 @@ def progress_str(self) -> str: | |||||
| ) | ||||||
| return "[locality off]" | ||||||
|
|
||||||
| def base_resource_usage(self) -> ExecutionResources: | ||||||
| min_workers = self._actor_pool.min_size() | ||||||
| return ExecutionResources( | ||||||
| cpu=self._ray_remote_args.get("num_cpus", 0) * min_workers, | ||||||
| gpu=self._ray_remote_args.get("num_gpus", 0) * min_workers, | ||||||
| def min_max_resource_requirements( | ||||||
| self, | ||||||
| ) -> Tuple[ExecutionResources, ExecutionResources]: | ||||||
| min_actors = self._actor_pool.min_size() | ||||||
| assert min_actors is not None, min_actors | ||||||
|
|
||||||
| num_cpus_per_actor = self._ray_remote_args.get("num_cpus", 0) | ||||||
| num_gpus_per_actor = self._ray_remote_args.get("num_gpus", 0) | ||||||
bveeramani marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| memory_per_actor = self._ray_remote_args.get("memory", 0) | ||||||
|
|
||||||
| min_resource_usage = ExecutionResources( | ||||||
| cpu=num_cpus_per_actor * min_actors, | ||||||
| gpu=num_gpus_per_actor * min_actors, | ||||||
| memory=memory_per_actor * min_actors, | ||||||
| # To ensure that all actors are utilized, reserve enough resource budget | ||||||
| # to launch one task for each worker. | ||||||
| object_store_memory=self._metrics.obj_store_mem_max_pending_output_per_task | ||||||
| * min_actors, | ||||||
| ) | ||||||
|
|
||||||
| return min_resource_usage, ExecutionResources.for_limits() | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| def current_processor_usage(self) -> ExecutionResources: | ||||||
| # Both pending and running actors count towards our current resource usage. | ||||||
| num_active_workers = self._actor_pool.current_size() | ||||||
|
|
||||||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would we handle
Nonein the resource manager? Would it be equivalent to the default implementation?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it'd default to not knowing resource reqs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, i see that you're defaulting to [0, inf) that's fine too