-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
653ba46
commit 159c583
Showing
14 changed files
with
193 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ on: | |
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
cancel_previous_workflows: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ on: | |
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
cancel_previous_workflows: | ||
|
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 |
---|---|---|
|
@@ -4,6 +4,9 @@ on: | |
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
cancel_previous_workflows: | ||
|
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 |
---|---|---|
|
@@ -4,6 +4,9 @@ on: | |
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
cancel_previous_workflows: | ||
|
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 |
---|---|---|
|
@@ -4,6 +4,9 @@ on: | |
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
whl_build: | ||
|
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
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,92 @@ | ||
# Copyright (c) 2024, Alibaba Group; | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
|
||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import threading | ||
import time | ||
import ray | ||
import torch | ||
import pytest | ||
|
||
from ray.util.scheduling_strategies import NodeAffinitySchedulingStrategy | ||
|
||
from vllm.engine.arg_utils import EngineArgs | ||
|
||
from llumnix.backends.backend_interface import BackendType | ||
from llumnix.llumlet.llumlet import Llumlet | ||
from llumnix.internal_config import MigrationConfig | ||
from llumnix.queue.queue_type import QueueType | ||
# pylint: disable=unused-import | ||
from tests.conftest import setup_ray_env | ||
|
||
@ray.remote(num_cpus=1, max_concurrency=4) | ||
class MockLlumlet(Llumlet): | ||
def __init__(self, *args, **kwargs) -> None: | ||
super().__init__(*args, **kwargs) | ||
self.origin_step = self.backend_engine.engine.step | ||
|
||
def set_error_step(self, broken: bool): | ||
self.backend_engine._stop_event.set() | ||
if self.backend_engine._thread.is_alive(): | ||
self.backend_engine._thread.join() | ||
|
||
def raise_error_step(): | ||
self.origin_step() | ||
raise ValueError("Mock engine step error") | ||
|
||
if broken: | ||
self.backend_engine.engine.step = raise_error_step | ||
else: | ||
self.backend_engine.engine.step = self.origin_step | ||
|
||
self.backend_engine._thread = threading.Thread( | ||
target=self.backend_engine._start_engine_loop, args=(), daemon=True, name="engine_loop" | ||
) | ||
self.backend_engine._thread.start() | ||
|
||
@pytest.mark.skipif(torch.cuda.device_count() < 1, reason="Need at least 1 GPU to run the test.") | ||
def test_engine_step_exception(setup_ray_env): | ||
engine_args = EngineArgs(model="facebook/opt-125m", worker_use_ray=True) | ||
migration_config = MigrationConfig("LCFS", "rpc", 16, 1, 4, 5, 20) | ||
node_id = ray.get_runtime_context().get_node_id() | ||
scheduling_strategy = NodeAffinitySchedulingStrategy(node_id=node_id, soft=False) | ||
|
||
origin_free_memory, _ = torch.cuda.mem_get_info() | ||
|
||
actor_name = "instance_0" | ||
llumlet = MockLlumlet.options(name=actor_name, namespace='llumnix', | ||
scheduling_strategy=scheduling_strategy).remote( | ||
output_queue_type=QueueType.RAYQUEUE, | ||
instance_id="0", | ||
backend_type=BackendType.VLLM, | ||
migration_config=migration_config, | ||
engine_args=engine_args, | ||
node_id=node_id | ||
) | ||
ray.get(llumlet.is_ready.remote()) | ||
|
||
all_actors = ray.util.list_named_actors(True) | ||
all_actor_names = [actor["name"] for actor in all_actors] | ||
assert actor_name in all_actor_names | ||
|
||
cur_free_memory, _ = torch.cuda.mem_get_info() | ||
assert cur_free_memory < origin_free_memory | ||
|
||
ray.get(llumlet.set_error_step.remote(True)) | ||
time.sleep(3) | ||
|
||
all_actors = ray.util.list_named_actors(True) | ||
all_actor_names = [actor["name"] for actor in all_actors] | ||
assert actor_name not in all_actor_names | ||
|
||
cur_free_memory, _ = torch.cuda.mem_get_info() | ||
assert origin_free_memory == cur_free_memory |
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