Add triton-ascend in UT and e2e
- vLLM version: v0.12.0
- vLLM main:
ad32e3e19c
---------
Signed-off-by: Meihan-chen <jcccx.cmh@gmail.com>
40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
#
|
|
# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
|
|
# Copyright 2023 The vLLM team.
|
|
#
|
|
# 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.
|
|
# This file is a part of the vllm-ascend project.
|
|
#
|
|
import sys
|
|
from unittest.mock import MagicMock
|
|
|
|
from vllm_ascend.utils import adapt_patch # noqa E402
|
|
from vllm_ascend.utils import register_ascend_customop
|
|
|
|
# triton and torch_npu is not available in the environment, so we need to mock them
|
|
sys.modules['torch_npu'].npu.current_device = MagicMock(return_value=0)
|
|
sys.modules['torch_npu._inductor'] = MagicMock()
|
|
|
|
triton_runtime = MagicMock()
|
|
triton_runtime.driver.active.utils.get_device_properties.return_value = {
|
|
'num_aic': 8,
|
|
'num_vectorcore': 8,
|
|
}
|
|
sys.modules['triton.runtime'] = triton_runtime
|
|
|
|
adapt_patch()
|
|
adapt_patch(True)
|
|
|
|
# register Ascend CustomOp here because uts will use this
|
|
register_ascend_customop()
|