Skip to content

Commit 212f34d

Browse files
committed
enable mm allreduce test
Signed-off-by: Ronald1995 <ronaldautomobile@163.com>
1 parent af04ee9 commit 212f34d

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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

vllm_ascend/patch/worker/patch_common/patch_linear.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from vllm.distributed import (get_tensor_model_parallel_rank,
2626
split_tensor_along_last_dim)
2727
from vllm.distributed.parallel_state import get_tp_group
28+
from vllm.logger import logger
2829
from vllm.model_executor.layers.linear import RowParallelLinear
2930

3031
from vllm_ascend import envs
@@ -142,4 +143,5 @@ def calc_output(self, input_parallel: torch.Tensor) -> torch.Tensor:
142143

143144

144145
if envs.VLLM_ASCEND_ENABLE_MATMUL_ALLREDUCE:
146+
logger.info("AscendRowParallelLinear: Matmul all-reduce is enabled. ")
145147
vllm.model_executor.layers.linear.RowParallelLinear = AscendRowParallelLinear

0 commit comments

Comments
 (0)