2025-11-29 18:37:11 +08:00
|
|
|
import os
|
|
|
|
|
import subprocess
|
|
|
|
|
import sys
|
|
|
|
|
from unittest.mock import patch
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
2026-01-06 08:44:29 +08:00
|
|
|
MODELS = ["Qwen/Qwen3-30B-A3B"]
|
2025-11-29 18:37:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("model", MODELS)
|
|
|
|
|
@pytest.mark.parametrize("max_tokens", [32])
|
|
|
|
|
@patch.dict(os.environ, {"ASCEND_RT_VISIBLE_DEVICES": "0,1,2,3"})
|
2025-12-23 14:13:42 +08:00
|
|
|
def test_qwen3_inference_dp2_tp2(model, max_tokens):
|
2025-11-29 18:37:11 +08:00
|
|
|
script = "examples/offline_data_parallel.py"
|
|
|
|
|
|
|
|
|
|
env = os.environ.copy()
|
|
|
|
|
|
|
|
|
|
cmd = [
|
|
|
|
|
sys.executable,
|
|
|
|
|
script,
|
|
|
|
|
"--model",
|
|
|
|
|
model,
|
|
|
|
|
"--dp-size",
|
|
|
|
|
"2",
|
|
|
|
|
"--tp-size",
|
|
|
|
|
"2",
|
|
|
|
|
"--node-size",
|
|
|
|
|
"1",
|
|
|
|
|
"--node-rank",
|
|
|
|
|
"0",
|
|
|
|
|
"--trust-remote-code",
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
print(f"Running subprocess: {' '.join(cmd)}")
|
|
|
|
|
proc = subprocess.run(cmd,
|
|
|
|
|
env=env,
|
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
|
stderr=subprocess.STDOUT,
|
|
|
|
|
timeout=600)
|
2025-12-01 19:01:55 +08:00
|
|
|
output = proc.stdout.decode(errors='ignore')
|
2025-11-29 18:37:11 +08:00
|
|
|
|
|
|
|
|
print(output)
|
|
|
|
|
|
|
|
|
|
assert "DP rank 0 needs to process" in output
|
|
|
|
|
assert "DP rank 1 needs to process" in output
|
|
|
|
|
assert "Generated text:" in output
|
|
|
|
|
assert proc.returncode == 0
|