Skip to content

Commit 8fc5dc9

Browse files
whx-sjtuhw_whx
andauthored
[Worker] Register mindie_turbo while initializing NPUWorker (vllm-project#13)
Add `try_register_lib` and import mindie-turbo when init. --------- Signed-off-by: hw_whx <wanghexiang7@huawei.com> Co-authored-by: hw_whx <wanghexiang7@huawei.com>
1 parent 4495fc6 commit 8fc5dc9

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

vllm_ascend/utils.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
3+
# This file is a part of the vllm-ascend project.
4+
# Adapted from vllm-project/vllm/vllm/worker/worker.py
5+
# Copyright 2023 The vLLM team.
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
from vllm.logger import init_logger
21+
22+
logger = init_logger(__name__)
23+
24+
25+
def try_register_lib(lib_name: str, lib_info: str = ""):
26+
import importlib
27+
import importlib.util
28+
try:
29+
module_spec = importlib.util.find_spec(lib_name)
30+
if module_spec is not None:
31+
importlib.import_module(lib_name)
32+
if lib_info:
33+
logger.info(lib_info)
34+
except Exception:
35+
pass

vllm_ascend/worker.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
WorkerInput)
4848

4949
from vllm_ascend.model_runner import NPUModelRunner
50+
from vllm_ascend.utils import try_register_lib
5051

5152
logger = init_logger(__name__)
5253

@@ -69,6 +70,11 @@ def __init__(
6970
) -> None:
7071

7172
WorkerBase.__init__(self, vllm_config=vllm_config)
73+
# Try to import mindie_turbo to accelerate vLLM inference.
74+
try_register_lib(
75+
"mindie_turbo",
76+
"MindIE Turbo is installed. vLLM inference will be accelerated with MindIE Turbo."
77+
)
7278
# distribute related config
7379
self.parallel_config.rank = rank
7480
self.local_rank = local_rank

0 commit comments

Comments
 (0)