Skip to content

Commit b2598c3

Browse files
authored
enable mm allreduce test (#2192)
### What this PR does / why we need it? This PR is to add e2e test for using npu_mm_all_reduce_base fusion kernel. ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? not involved - vLLM version: v0.10.0 - vLLM main: vllm-project/vllm@5d5d419 Signed-off-by: Ronald1995 <[email protected]>
1 parent 4604882 commit b2598c3

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

tests/e2e/multicard/test_external_launcher.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@
2424
import subprocess
2525
import sys
2626
from pathlib import Path
27+
from unittest.mock import patch
2728

2829
import pytest
30+
import torch_npu
2931

3032
MODELS = ["Qwen/Qwen3-0.6B"]
3133
MOE_MODELS = ["Qwen/Qwen3-30B-A3B"]
34+
DEVICE_NAME = torch_npu.npu.get_device_name(0)[:10]
3235

3336

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