Skip to content
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
27 changes: 15 additions & 12 deletions python/aibrix/aibrix/gpu_optimizer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@ def new_deployment(deployment):
min_replicas = int(label)

return DeploymentStates(
deployment.metadata.name,
deployment.spec.replicas if deployment.spec.replicas is not None else 0,
min_replicas,
name=deployment.metadata.name,
namespace=deployment.metadate.namespace,
replicas=deployment.spec.replicas
if deployment.spec.replicas is not None
else 0,
min_replicas=min_replicas,
)


Expand All @@ -101,7 +104,7 @@ def start_serving_thread(watch_ver, deployment, watch_event: bool) -> bool:
watch_ver, deployment_name, namespace, lambda: new_deployment(deployment)
)
logger.info(
f'Deployment "{deployment_name}" found in watch version {watch_ver}, added to the model monitor for "{model_name}"'
f'Deployment "{namespace}/{deployment_name}" found in watch version {watch_ver}, added to the model monitor for "{model_name}"'
)
return False

Expand All @@ -120,11 +123,11 @@ def start_serving_thread(watch_ver, deployment, watch_event: bool) -> bool:
model_monitors[model_name] = model_monitor
if watch_event:
logger.info(
f'New model monitor started for "{model_name}". Deployment "{deployment_name}" added.'
f'New model monitor started for "{model_name}". Deployment "{namespace}/{deployment_name}" added.'
)
else:
logger.info(
f'Model monitor started for existed "{model_name}". Deployment "{deployment_name}" added.'
f'Model monitor started for existed "{model_name}". Deployment "{namespace}/{deployment_name}" added.'
)
return True

Expand All @@ -137,15 +140,15 @@ def update_deployment(watch_ver, deployment):
namespace = deployment.metadata.namespace
if model_monitor is None:
logger.warning(
f'Updating "{deployment_name}" in the model monitor, but "{model_name}" has not monitored.'
f'Updating "{namespace}/{deployment_name}" in the model monitor, but "{model_name}" has not monitored.'
)
return

if model_monitor.add_deployment(
watch_ver, deployment_name, namespace, lambda: new_deployment(deployment)
):
logger.info(
f'Updated "{deployment_name}" in the model monitor for "{model_name}".'
f'Updated "{namespace}/{deployment_name}" in the model monitor for "{model_name}".'
)


Expand All @@ -157,20 +160,20 @@ def remove_deployment(deployment):
namespace = deployment.metadata.namespace
if model_monitor is None:
logger.warning(
f'Removing "{deployment_name}" from the model monitor, but "{model_name}" has not monitored.'
f'Removing "{namespace}/{deployment_name}" from the model monitor, but "{model_name}" has not monitored.'
)
return

if model_monitor.remove_deployment(deployment_name, namespace) == 0:
model_monitor.stop()
del model_monitors[model_name]
logger.info(
f'Removing "{deployment_name}" from the model monitor, no deployment left in "{model_name}", stopping the model monitor.'
f'Removing "{namespace}/{deployment_name}" from the model monitor, no deployment left in "{model_name}", stopping the model monitor.'
)
return

logger.info(
f'Removing "{deployment_name}" from the model monitor for "{model_name}".'
f'Removing "{namespace}/{deployment_name}" from the model monitor for "{model_name}".'
)


Expand Down Expand Up @@ -316,7 +319,7 @@ def main(signal, timeout):
start_serving_thread(watch_version, deployment, False)
except Exception as e:
logger.warning(
f"Error on handle existing deployment {deployment.metadata.name}: {e}"
f"Error on handle existing deployment {deployment.metadata.namepsace}/{deployment.metadata.name}: {e} "
)
except client.rest.ApiException as ae:
logger.error(
Expand Down
9 changes: 6 additions & 3 deletions python/aibrix/aibrix/gpu_optimizer/load_monitor/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@
class DeploymentStates:
"""States of a deployment with resource version."""

def __init__(self, name: str, replicas: int = 1, min_replicas: int = 0):
def __init__(
self, name: str, namespace: str = "", replicas: int = 1, min_replicas: int = 0
):
self.name = name
self.namespace = namespace
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Currently it is redundant, but I think it will be useful in the near future. 🤔


# _replicas stores optimized value
self._replicas = replicas
Expand Down Expand Up @@ -226,7 +229,7 @@ def read_deployment_num_replicas(self, deployment_name: str, namespace: str) ->
key = self._deployment_entry_point(deployment_name, namespace)
if key not in self.deployments:
raise Exception(
f"Deployment {namespace}:{deployment_name} of model {self.model_name} is not monitored"
f"Deployment {namespace}/{deployment_name} of model {self.model_name} is not monitored"
)
return self.deployments[key].replicas

Expand All @@ -240,7 +243,7 @@ def update_deployment_num_replicas(
key = self._deployment_entry_point(deployment_name, namespace)
if key not in self.deployments:
raise Exception(
f"Deployment {namespace}:{deployment_name} of model {self.model_name} is not monitored"
f"Deployment {namespace}/{deployment_name} of model {self.model_name} is not monitored"
)

if overriding:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ def get_debug_model_montior(
if profile_reader is not None:
for _, profile in enumerate(profile_reader.read()):
debug_monitor.add_deployment(
"0", profile.gpu, None, DeploymentStates(profile.gpu, 0)
"0",
profile.gpu,
None,
DeploymentStates(name=profile.gpu, replicas=0),
)

return debug_monitor
Expand Down