-
Notifications
You must be signed in to change notification settings - Fork 1
fix(vllm_performance): Avoid multiple experiments using the same kubernetes deployment at the same time #268
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
+290
−152
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e5628bf
fix(vllm_performance): Avoid using an environment for multiple experi…
christian-pinto 66abdec
Merge branch 'main' of github.com:IBM/ado into cp-fix-vllm-perf-envir…
christian-pinto c055b22
Merge branch 'main' into cp-fix-vllm-perf-environments
christian-pinto fd011cf
fix(vllm_performance): Avoid multiple experiments using the same depl…
christian-pinto 9aadafb
fix(vllm_performance): Fixed wrong import
christian-pinto 41e7ddb
fix(vllm_performance): Ensure port-forward processes are killed after…
christian-pinto 614b536
fix(chore): Addressed review comments
christian-pinto 57a1d64
Merge branch 'main' of github.com:IBM/ado into cp-fix-vllm-perf-envir…
christian-pinto 4347dfc
fix(chore): Addressed more review comments
christian-pinto 90324bc
fix(chore): Addressed even more review comments
christian-pinto 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
80 changes: 80 additions & 0 deletions
80
plugins/actuators/vllm_performance/ado_actuators/vllm_performance/deployment_management.py
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 |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| # Copyright (c) IBM Corporation | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| import asyncio | ||
| import logging | ||
|
|
||
| import ray | ||
|
|
||
| from orchestrator.modules.operators.console_output import RichConsoleSpinnerMessage | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class DeploymentWaiter: | ||
| def __init__(self, k8s_name: str): | ||
| self.k8s_name = k8s_name | ||
| self.model_downloaded_event = asyncio.Event() | ||
|
|
||
|
|
||
| class DeploymentConflictManager: | ||
| def __init__(self): | ||
| self.deployments_to_wait_for: dict[str, DeploymentWaiter] = {} | ||
| self.model_already_downloaded: set[str] = set() | ||
|
|
||
| def maybe_add_deployment(self, model: str, k8s_name: str) -> bool: | ||
| if ( | ||
| model in self.model_already_downloaded | ||
| or model in self.deployments_to_wait_for | ||
| ): | ||
| return False | ||
|
|
||
| self.deployments_to_wait_for[model] = DeploymentWaiter(k8s_name=k8s_name) | ||
| return True | ||
|
|
||
| async def wait(self, request_id: str, k8s_name: str, model: str) -> None: | ||
| waiter = self.deployments_to_wait_for.get(model, None) | ||
| # making sure a deployment does not wait for itself to be READY | ||
| if waiter is not None and waiter.k8s_name != k8s_name: | ||
| console = ray.get_actor(name="RichConsoleQueue") | ||
| while True: | ||
| console.put.remote( | ||
| message=RichConsoleSpinnerMessage( | ||
| id=request_id, | ||
| label=f"({request_id}) Waiting on deployment ({waiter.k8s_name}) to download the model required for this experiment", | ||
| state="start", | ||
| ) | ||
| ) | ||
| await waiter.model_downloaded_event.wait() | ||
| # If after we got awoken the model is not among the downloaded models, it means that | ||
| # something has gone wrong, such as the deployment we were waiting for has failed. | ||
| # If am the first to wake up let me add myself as the deployment to be waited for and stop waiting. | ||
| if ( | ||
| model not in self.model_already_downloaded | ||
| and not self.maybe_add_deployment(k8s_name=k8s_name, model=model) | ||
| ): | ||
| # If I am not the first to wake up, I get the new waiter object and continue waiting | ||
| waiter = self.deployments_to_wait_for.get(model) | ||
| continue | ||
|
|
||
| console.put.remote( | ||
| message=RichConsoleSpinnerMessage( | ||
| id=request_id, | ||
| label=f"({request_id}) Done waiting for conflicting K8s deployment", | ||
| state="stop", | ||
| ) | ||
| ) | ||
| break | ||
|
|
||
| def signal(self, k8s_name: str, model: str, error: bool = False) -> None: | ||
| if model not in self.deployments_to_wait_for: | ||
| return | ||
|
|
||
| waiter = self.deployments_to_wait_for.pop(model) | ||
| if waiter.k8s_name != k8s_name: | ||
| raise ValueError( | ||
| f"This environment deployment ({k8s_name}) shouldn't have been created because it is conflicting with deployment {waiter.k8s_name}" | ||
| ) | ||
| if not error: | ||
| self.model_already_downloaded.add(model) | ||
| waiter.model_downloaded_event.set() |
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.
Uh oh!
There was an error while loading. Please reload this page.