|
| 1 | +# |
| 2 | +# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved. |
| 3 | +# Copyright 2023 The vLLM team. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# |
| 17 | + |
| 18 | +import os |
| 19 | +import subprocess |
| 20 | +import sys |
| 21 | +from pathlib import Path |
| 22 | +from unittest.mock import patch |
| 23 | + |
| 24 | +import pytest |
| 25 | +import torch_npu |
| 26 | + |
| 27 | +MODELS = ["Qwen/Qwen3-0.6B"] |
| 28 | +DEVICE_NAME = torch_npu.npu.get_device_name(0)[:10] |
| 29 | + |
| 30 | + |
| 31 | +@pytest.mark.skipif( |
| 32 | + DEVICE_NAME != "Ascend910B", |
| 33 | + reason="This test is only for Ascend910B devices.", |
| 34 | +) |
| 35 | +@pytest.mark.parametrize("model", MODELS) |
| 36 | +@patch.dict(os.environ, {"VLLM_ASCEND_ENABLE_MATMUL_ALLREDUCE": "1"}) |
| 37 | +def test_external_launcher(model): |
| 38 | + script = Path( |
| 39 | + __file__ |
| 40 | + ).parent.parent.parent.parent / "examples" / "offline_external_launcher.py" |
| 41 | + env = os.environ.copy() |
| 42 | + cmd = [ |
| 43 | + sys.executable, |
| 44 | + str(script), |
| 45 | + "--model", |
| 46 | + model, |
| 47 | + "--trust-remote-code", |
| 48 | + ] |
| 49 | + |
| 50 | + print(f"Running subprocess: {' '.join(cmd)}") |
| 51 | + proc = subprocess.run( |
| 52 | + cmd, |
| 53 | + env=env, |
| 54 | + stdout=subprocess.PIPE, |
| 55 | + stderr=subprocess.STDOUT, |
| 56 | + timeout=600, |
| 57 | + ) |
| 58 | + output = proc.stdout.decode() |
| 59 | + |
| 60 | + print(output) |
| 61 | + |
| 62 | + assert "AscendRowParallelLinear: Matmul all-reduce is enabled" in output |
| 63 | + assert "Generated text:" in output |
| 64 | + assert proc.returncode == 0 |
0 commit comments