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

fix: Exclude utilization checks for unallocated resources #1820

Merged
merged 3 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/1820.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Exclude unallocated resources from kernel idle utilization checks.
18 changes: 9 additions & 9 deletions src/ai/backend/manager/idle.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ class UtilizationIdleChecker(BaseIdleChecker):
time_window: timedelta
initial_grace_period: timedelta
_evhandlers: List[EventHandler[None, AbstractEvent]]
slot_resource_map: Mapping[str, Set[str]] = {
slot_prefix_to_utilization_metric_map: Mapping[str, Set[str]] = {
"cpu": {"cpu_util"},
"mem": {"mem"},
"cuda": {"cuda_util", "cuda_mem"},
Expand All @@ -789,7 +789,7 @@ async def populate_config(self, raw_config: Mapping[str, Any]) -> None:
}
else:
resources: list[str] = []
for r in self.slot_resource_map.values():
for r in self.slot_prefix_to_utilization_metric_map.values():
resources = [*resources, *r]
self.resource_thresholds = {r: None for r in resources}
self.thresholds_check_operator: ThresholdOperator = config.get("thresholds-check-operator")
Expand Down Expand Up @@ -889,16 +889,16 @@ async def check_idleness(

# Merge same type of (exclusive) resources as a unique resource with the values added.
# Example: {cuda.device: 0, cuda.shares: 0.5} -> {cuda: 0.5}.
unique_res_map: DefaultDict[str, Any] = defaultdict(Decimal)
for k, v in occupied_slots.items():
unique_key = k.split(".")[0]
unique_res_map[unique_key] += v
unique_res_map: DefaultDict[str, Decimal] = defaultdict(Decimal)
for slot_name, alloc in occupied_slots.items():
unique_key = slot_name.split(".")[0]
unique_res_map[unique_key] += alloc

# Do not take into account unallocated resources. For example, do not garbage collect
# a session without GPU even if cuda_util is configured in resource-thresholds.
for slot in unique_res_map:
if unique_res_map[slot] == 0:
unavailable_resources.update(self.slot_resource_map[slot])
for slot_prefix, util_metric in self.slot_prefix_to_utilization_metric_map.items():
if unique_res_map.get(slot_prefix, 0) == 0:
unavailable_resources.update(util_metric)

# Get current utilization data from all containers of the session.
if kernel["cluster_size"] > 1:
Expand Down
Loading