Skip to content

Commit 9d808f2

Browse files
committed
enable mm allreduce test
Signed-off-by: Ronald1995 <ronaldautomobile@163.com>
1 parent 875a86c commit 9d808f2

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

tests/e2e/multicard/test_external_launcher.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626
from pathlib import Path
2727

2828
import pytest
29+
import torch_npu
2930

3031
MODELS = ["Qwen/Qwen3-0.6B"]
3132
MOE_MODELS = ["Qwen/Qwen3-30B-A3B"]
33+
DEVICE_NAME = torch_npu.npu.get_device_name(0)[:10]
3234

3335

3436
@pytest.mark.parametrize("model", MODELS)
@@ -147,3 +149,38 @@ def test_external_launcher_and_sleepmode():
147149
assert "Generated text:" in output
148150
assert "Sleep and wake up successfully!!" in output
149151
assert proc.returncode == 0
152+
153+
154+
@pytest.mark.skipif(
155+
DEVICE_NAME != "Ascend910B",
156+
reason="This test is only for Ascend910B devices.",
157+
)
158+
@pytest.mark.parametrize("model", MODELS)
159+
@patch.dict(os.environ, {"VLLM_ASCEND_ENABLE_MATMUL_ALLREDUCE": "1"})
160+
def test_mm_allreduce(model):
161+
script = Path(
162+
__file__
163+
).parent.parent.parent.parent / "examples" / "offline_external_launcher.py"
164+
env = os.environ.copy()
165+
cmd = [
166+
sys.executable,
167+
str(script),
168+
"--model",
169+
model,
170+
"--trust-remote-code",
171+
]
172+
173+
print(f"Running subprocess: {' '.join(cmd)}")
174+
proc = subprocess.run(
175+
cmd,
176+
env=env,
177+
stdout=subprocess.PIPE,
178+
stderr=subprocess.STDOUT,
179+
timeout=600,
180+
)
181+
182+
output = proc.stdout.decode()
183+
print(output)
184+
185+
assert "Generated text:" in output
186+
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)