[NPU] Add GitHub test summary and deduplicate test code. Part 1 (#23835)
Co-authored-by: Elizaveta Martirosian <elizaveta.martirosian@gmail.com> Co-authored-by: root <root@localhost.localdomain> Co-authored-by: Elizaveta Martirosian <you@example.com> Co-authored-by: ronnie_zheng <zl19940307@163.com>
This commit is contained in:
co-authored by
Elizaveta Martirosian
root
Elizaveta Martirosian
ronnie_zheng
parent
3259a2c789
commit
ebbaab5597
@@ -1,17 +1,13 @@
|
||||
import os
|
||||
import unittest
|
||||
from types import SimpleNamespace
|
||||
|
||||
from sglang.srt.utils import kill_process_tree
|
||||
from sglang.test.ascend.gsm8k_ascend_mixin import GSM8KAscendMixin
|
||||
from sglang.test.ascend.test_ascend_utils import LLaDA2_0_MINI_WEIGHTS_PATH
|
||||
from sglang.test.ci.ci_register import register_npu_ci
|
||||
from sglang.test.few_shot_gsm8k import run_eval as run_eval_few_shot_gsm8k
|
||||
from sglang.test.send_one import BenchArgs, send_one_prompt
|
||||
from sglang.test.test_utils import (
|
||||
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
|
||||
DEFAULT_URL_FOR_TEST,
|
||||
CustomTestCase,
|
||||
is_in_ci,
|
||||
popen_launch_server,
|
||||
write_github_step_summary,
|
||||
)
|
||||
|
||||
@@ -19,59 +15,27 @@ register_npu_ci(est_time=400, suite="stage-b-test-4-npu-a3", nightly=False)
|
||||
register_npu_ci(est_time=400, suite="nightly-1-npu-a3", nightly=True)
|
||||
|
||||
|
||||
class TestLLaDA2Mini(CustomTestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls._old_disable_acl = os.environ.get("SGLANG_NPU_DISABLE_ACL_FORMAT_WEIGHT")
|
||||
os.environ["SGLANG_NPU_DISABLE_ACL_FORMAT_WEIGHT"] = "1"
|
||||
class TestLLaDA2Mini(GSM8KAscendMixin, CustomTestCase):
|
||||
model = LLaDA2_0_MINI_WEIGHTS_PATH
|
||||
|
||||
cls.model = "/root/.cache/modelscope/hub/models/inclusionAI/LLaDA2.0-mini"
|
||||
cls.base_url = DEFAULT_URL_FOR_TEST
|
||||
|
||||
other_args = [
|
||||
"--trust-remote-code",
|
||||
"--disable-radix-cache",
|
||||
"--mem-fraction-static",
|
||||
"0.9",
|
||||
"--max-running-requests",
|
||||
"1",
|
||||
"--attention-backend",
|
||||
"ascend",
|
||||
"--dllm-algorithm",
|
||||
"LowConfidence", # TODO: Add dLLM configurations
|
||||
]
|
||||
|
||||
cls.process = popen_launch_server(
|
||||
cls.model,
|
||||
cls.base_url,
|
||||
timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
|
||||
other_args=other_args,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
kill_process_tree(cls.process.pid)
|
||||
|
||||
if cls._old_disable_acl is None:
|
||||
os.environ.pop("SGLANG_NPU_DISABLE_ACL_FORMAT_WEIGHT", None)
|
||||
else:
|
||||
os.environ["SGLANG_NPU_DISABLE_ACL_FORMAT_WEIGHT"] = cls._old_disable_acl
|
||||
|
||||
def test_gsm8k(self):
|
||||
args = SimpleNamespace(
|
||||
num_shots=5,
|
||||
data_path=None,
|
||||
num_questions=200,
|
||||
max_new_tokens=512,
|
||||
parallel=128,
|
||||
host="http://127.0.0.1",
|
||||
port=int(self.base_url.split(":")[-1]),
|
||||
)
|
||||
metrics = run_eval_few_shot_gsm8k(args)
|
||||
print(f"{metrics=}")
|
||||
|
||||
self.assertGreater(metrics["accuracy"], 0.88)
|
||||
self.assertGreater(metrics["output_throughput"], 70)
|
||||
other_args = [
|
||||
"--trust-remote-code",
|
||||
"--disable-radix-cache",
|
||||
"--mem-fraction-static",
|
||||
"0.9",
|
||||
"--max-running-requests",
|
||||
"1",
|
||||
"--attention-backend",
|
||||
"ascend",
|
||||
"--dllm-algorithm",
|
||||
"LowConfidence", # TODO: Add dLLM configurations
|
||||
]
|
||||
env = {
|
||||
**os.environ,
|
||||
"SGLANG_NPU_DISABLE_ACL_FORMAT_WEIGHT": "1", # Need to avoid OOM issue
|
||||
}
|
||||
accuracy = 0.88
|
||||
output_throughput = 70
|
||||
|
||||
def test_bs_1_speed(self):
|
||||
args = BenchArgs(port=int(self.base_url.split(":")[-1]), max_new_tokens=2048)
|
||||
|
||||
+54
-70
@@ -1,92 +1,76 @@
|
||||
import subprocess
|
||||
import unittest
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from sglang.srt.utils import kill_process_tree
|
||||
from sglang.test.ascend.gsm8k_ascend_mixin import GSM8KAscendMixin
|
||||
from sglang.test.ascend.test_ascend_utils import (
|
||||
QWEN2_5_7B_INSTRUCT_WEIGHTS_PATH,
|
||||
write_results_to_github_step_summary,
|
||||
)
|
||||
from sglang.test.ci.ci_register import register_npu_ci
|
||||
from sglang.test.few_shot_gsm8k import run_eval as run_eval_few_shot_gsm8k
|
||||
from sglang.test.test_utils import (
|
||||
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
|
||||
DEFAULT_URL_FOR_TEST,
|
||||
CustomTestCase,
|
||||
SimpleNamespace,
|
||||
popen_launch_server,
|
||||
run_bench_one_batch,
|
||||
)
|
||||
|
||||
register_npu_ci(est_time=400, suite="stage-b-test-1-npu-a2", nightly=False)
|
||||
register_npu_ci(est_time=400, suite="nightly-1-npu-a3", nightly=True)
|
||||
|
||||
MODEL = "/root/.cache/modelscope/hub/models/Qwen/Qwen2.5-7B-Instruct"
|
||||
GSM8K_EXP_ACCURACY = 0.84
|
||||
EXP_PREFILL_LATENCY = 0.045
|
||||
|
||||
TOKENS_TO_CAPTURE = [i for i in range(128, 4096, 128)]
|
||||
|
||||
|
||||
class TestPiecewiseGraphPrefillCorrectness(CustomTestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.model = MODEL
|
||||
cls.base_url = DEFAULT_URL_FOR_TEST
|
||||
cls.url = urlparse(DEFAULT_URL_FOR_TEST)
|
||||
cls.process = popen_launch_server(
|
||||
cls.model,
|
||||
cls.base_url,
|
||||
timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
|
||||
other_args=[
|
||||
"--trust-remote-code",
|
||||
"--mem-fraction-static",
|
||||
0.8,
|
||||
"--attention-backend",
|
||||
"ascend",
|
||||
"--cuda-graph-bs",
|
||||
128,
|
||||
"--enforce-piecewise-cuda-graph",
|
||||
"--piecewise-cuda-graph-tokens",
|
||||
*TOKENS_TO_CAPTURE,
|
||||
],
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
kill_process_tree(cls.process.pid)
|
||||
|
||||
def test_gsm8k(self):
|
||||
print(f"##=== Testing accuracy: {self.model} ===##")
|
||||
args = SimpleNamespace(
|
||||
num_shots=5,
|
||||
data_path=None,
|
||||
num_questions=1319,
|
||||
max_new_tokens=512,
|
||||
parallel=128,
|
||||
host=f"http://{self.url.hostname}",
|
||||
port=int(self.url.port),
|
||||
)
|
||||
|
||||
metrics = run_eval_few_shot_gsm8k(args)
|
||||
self.assertGreaterEqual(
|
||||
metrics["accuracy"],
|
||||
GSM8K_EXP_ACCURACY,
|
||||
)
|
||||
class TestPiecewiseGraphPrefillCorrectness(GSM8KAscendMixin, CustomTestCase):
|
||||
model = QWEN2_5_7B_INSTRUCT_WEIGHTS_PATH
|
||||
other_args = [
|
||||
"--trust-remote-code",
|
||||
"--mem-fraction-static",
|
||||
0.8,
|
||||
"--attention-backend",
|
||||
"ascend",
|
||||
"--cuda-graph-bs",
|
||||
128,
|
||||
"--enforce-piecewise-cuda-graph",
|
||||
"--piecewise-cuda-graph-tokens",
|
||||
*TOKENS_TO_CAPTURE,
|
||||
]
|
||||
accuracy = 0.84
|
||||
num_questions = 1319
|
||||
|
||||
|
||||
class TestPiecewiseGraphPrefillBenchmark(CustomTestCase):
|
||||
model = QWEN2_5_7B_INSTRUCT_WEIGHTS_PATH
|
||||
other_args = [
|
||||
"--trust-remote-code",
|
||||
"--mem-fraction-static",
|
||||
0.8,
|
||||
"--attention-backend",
|
||||
"ascend",
|
||||
"--enforce-piecewise-cuda-graph",
|
||||
"--piecewise-cuda-graph-tokens",
|
||||
] + TOKENS_TO_CAPTURE
|
||||
|
||||
latency = 0.045
|
||||
|
||||
def test_latency(self):
|
||||
print(f"##=== Testing prefill latency: {MODEL} ===##")
|
||||
prefill_latency, _, _ = run_bench_one_batch(
|
||||
MODEL,
|
||||
other_args=[
|
||||
"--trust-remote-code",
|
||||
"--mem-fraction-static",
|
||||
0.8,
|
||||
"--attention-backend",
|
||||
"ascend",
|
||||
"--enforce-piecewise-cuda-graph",
|
||||
"--piecewise-cuda-graph-tokens",
|
||||
]
|
||||
+ TOKENS_TO_CAPTURE,
|
||||
)
|
||||
self.assertLess(prefill_latency, EXP_PREFILL_LATENCY)
|
||||
print(f"##=== Testing prefill latency: {self.model} ===##")
|
||||
model_metrics = {
|
||||
"server": subprocess.list2cmdline(map(str, self.other_args)),
|
||||
"client": "bench_one_batch",
|
||||
"latency_threshold": self.latency,
|
||||
}
|
||||
try:
|
||||
prefill_latency, _, _ = run_bench_one_batch(
|
||||
self.model,
|
||||
other_args=self.other_args,
|
||||
)
|
||||
model_metrics["latency"] = float(prefill_latency)
|
||||
self.assertLess(prefill_latency, self.latency)
|
||||
except Exception as e:
|
||||
model_metrics["error"] = e
|
||||
print(f"Error testing {self.model}: {e}")
|
||||
self.fail(f"Test failed for {self.model}: {e}")
|
||||
finally:
|
||||
write_results_to_github_step_summary({self.model: model_metrics})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
+40
-85
@@ -1,22 +1,16 @@
|
||||
import os
|
||||
import unittest
|
||||
from types import SimpleNamespace
|
||||
|
||||
from sglang.srt.utils import kill_process_tree
|
||||
from sglang.test.ascend.gsm8k_ascend_mixin import GSM8KAscendMixin
|
||||
from sglang.test.ascend.test_ascend_utils import DEEPSEEK_V3_2_W8A8_WEIGHTS_PATH
|
||||
from sglang.test.ascend.test_mmlu import TestMMLU
|
||||
from sglang.test.ci.ci_register import register_npu_ci
|
||||
from sglang.test.few_shot_gsm8k import run_eval as run_gsm8k
|
||||
from sglang.test.run_eval import run_eval
|
||||
from sglang.test.test_utils import (
|
||||
DEFAULT_URL_FOR_TEST,
|
||||
CustomTestCase,
|
||||
popen_launch_server,
|
||||
)
|
||||
from sglang.test.test_utils import CustomTestCase
|
||||
|
||||
register_npu_ci(est_time=400, suite="nightly-16-npu-a3", nightly=True)
|
||||
|
||||
|
||||
class TestDeepEpDeepseekV32(CustomTestCase):
|
||||
class TestDeepEpDeepseekV32(GSM8KAscendMixin, TestMMLU, CustomTestCase):
|
||||
"""Testcase: Verify that for the DeepSeek V3.2 model in the single-machine colocation scenario,
|
||||
its inference accuracy on the MMLU and GSM8K dataset meets the preset standard when the parameter --deepep-mode auto is configured.
|
||||
|
||||
@@ -24,84 +18,45 @@ class TestDeepEpDeepseekV32(CustomTestCase):
|
||||
[Test Target] --moe-a2a-backend deepep;--deepep-mode
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.model = DEEPSEEK_V3_2_W8A8_WEIGHTS_PATH
|
||||
cls.base_url = DEFAULT_URL_FOR_TEST
|
||||
cls.process = popen_launch_server(
|
||||
cls.model,
|
||||
cls.base_url,
|
||||
timeout=6000,
|
||||
other_args=[
|
||||
"--trust-remote-code",
|
||||
"--tp-size",
|
||||
"16",
|
||||
"--quantization",
|
||||
"modelslim",
|
||||
"--moe-a2a-backend",
|
||||
"deepep",
|
||||
"--deepep-mode",
|
||||
"auto",
|
||||
"--mem-fraction-static",
|
||||
0.82,
|
||||
"--disable-cuda-graph",
|
||||
"--disable-radix-cache",
|
||||
"--context-length",
|
||||
40960,
|
||||
"--max-prefill-tokens",
|
||||
40960,
|
||||
"--max-total-tokens",
|
||||
40960,
|
||||
],
|
||||
env={
|
||||
"PYTORCH_NPU_ALLOC_CONF": "expandable_segments:True",
|
||||
"STREAMS_PER_DEVICE": "32",
|
||||
"SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK": "16",
|
||||
"HCCL_BUFFSIZE": "1600",
|
||||
"HCCL_OP_EXPANSION_MODE": "AIV",
|
||||
"SGLANG_NPU_USE_MLAPO": "0",
|
||||
"SGLANG_NPU_USE_MULTI_STREAM": "1",
|
||||
"TASK_QUEUE_ENABLE": "0",
|
||||
**os.environ,
|
||||
},
|
||||
)
|
||||
model = DEEPSEEK_V3_2_W8A8_WEIGHTS_PATH
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
kill_process_tree(cls.process.pid)
|
||||
timeout_for_server_launch = 60000
|
||||
other_args = [
|
||||
"--trust-remote-code",
|
||||
"--tp-size",
|
||||
"16",
|
||||
"--quantization",
|
||||
"modelslim",
|
||||
"--moe-a2a-backend",
|
||||
"deepep",
|
||||
"--deepep-mode",
|
||||
"auto",
|
||||
"--mem-fraction-static",
|
||||
0.82,
|
||||
"--disable-cuda-graph",
|
||||
"--disable-radix-cache",
|
||||
"--context-length",
|
||||
40960,
|
||||
"--max-prefill-tokens",
|
||||
40960,
|
||||
"--max-total-tokens",
|
||||
40960,
|
||||
]
|
||||
|
||||
def test_mmlu(self):
|
||||
expect_score = 0.85
|
||||
args = SimpleNamespace(
|
||||
base_url=self.base_url,
|
||||
model=self.model,
|
||||
eval_name="mmlu",
|
||||
num_examples=128,
|
||||
num_threads=32,
|
||||
)
|
||||
print("Starting mmlu test...")
|
||||
metrics = run_eval(args)
|
||||
self.assertGreater(metrics["score"], expect_score)
|
||||
env = {
|
||||
**os.environ,
|
||||
"PYTORCH_NPU_ALLOC_CONF": "expandable_segments:True",
|
||||
"STREAMS_PER_DEVICE": "32",
|
||||
"SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK": "16",
|
||||
"HCCL_BUFFSIZE": "1600",
|
||||
"HCCL_OP_EXPANSION_MODE": "AIV",
|
||||
"SGLANG_NPU_USE_MLAPO": "0",
|
||||
"SGLANG_NPU_USE_MULTI_STREAM": "1",
|
||||
"TASK_QUEUE_ENABLE": "0",
|
||||
}
|
||||
|
||||
def test_gsm8k(self):
|
||||
expect_accuracy = 0.95
|
||||
args = SimpleNamespace(
|
||||
num_shots=8,
|
||||
data_path=None,
|
||||
timeout=60000,
|
||||
num_questions=200,
|
||||
max_new_tokens=512,
|
||||
parallel=128,
|
||||
host="http://127.0.0.1",
|
||||
port=int(self.base_url.split(":")[-1]),
|
||||
)
|
||||
print("Starting gsm8k test...")
|
||||
metrics = run_gsm8k(args)
|
||||
self.assertGreaterEqual(
|
||||
metrics["accuracy"],
|
||||
expect_accuracy,
|
||||
f'Accuracy of {self.model} is {str(metrics["accuracy"])}, is lower than {expect_accuracy}',
|
||||
)
|
||||
accuracy = 0.95 # Test GSM8K accuracy ≥0.95
|
||||
accuracy_mmlu = 0.85 # Test MMLU accuracy ≥0.85
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -1,99 +1,61 @@
|
||||
import os
|
||||
import unittest
|
||||
from types import SimpleNamespace
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from sglang.srt.utils import kill_process_tree
|
||||
from sglang.test.ascend.gsm8k_ascend_mixin import GSM8KAscendMixin
|
||||
from sglang.test.ascend.test_ascend_utils import (
|
||||
QWEN3_8B_EAGLE3_WEIGHTS_PATH,
|
||||
QWEN3_8B_WEIGHTS_PATH,
|
||||
)
|
||||
from sglang.test.ci.ci_register import register_npu_ci
|
||||
from sglang.test.few_shot_gsm8k import run_eval as run_eval_few_shot_gsm8k
|
||||
from sglang.test.test_utils import (
|
||||
DEFAULT_URL_FOR_TEST,
|
||||
CustomTestCase,
|
||||
popen_launch_server,
|
||||
)
|
||||
from sglang.test.test_utils import CustomTestCase
|
||||
|
||||
register_npu_ci(est_time=400, suite="nightly-1-npu-a3", nightly=True)
|
||||
|
||||
|
||||
class TestNpuEagle3(CustomTestCase):
|
||||
class TestNpuEagle3(GSM8KAscendMixin, CustomTestCase):
|
||||
"""Testcase: Verify GSM8K inference accuracy ≥0.81 for model with specified EAGLE3 speculative inference parameters.
|
||||
|
||||
[Test Category] Speculative Decoding
|
||||
[Test Target] --speculative-draft-model-quantization; --speculative-algorithm; --speculative-draft-model-path; --speculative-num-steps; --speculative-eagle-topk; --speculative-num-draft-tokens; --speculative-attention-mode
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.model = QWEN3_8B_WEIGHTS_PATH
|
||||
cls.accuracy = 0.81
|
||||
cls.base_url = DEFAULT_URL_FOR_TEST
|
||||
cls.url = urlparse(DEFAULT_URL_FOR_TEST)
|
||||
model = QWEN3_8B_WEIGHTS_PATH
|
||||
timeout_for_server_launch = 1500
|
||||
other_args = [
|
||||
"--trust-remote-code",
|
||||
"--attention-backend",
|
||||
"ascend",
|
||||
"--disable-radix-cache",
|
||||
"--speculative-draft-model-quantization",
|
||||
"unquant",
|
||||
"--speculative-algorithm",
|
||||
"EAGLE3",
|
||||
"--speculative-draft-model-path",
|
||||
QWEN3_8B_EAGLE3_WEIGHTS_PATH,
|
||||
"--speculative-num-steps",
|
||||
"4",
|
||||
"--speculative-eagle-topk",
|
||||
"1",
|
||||
"--speculative-num-draft-tokens",
|
||||
"5",
|
||||
"--speculative-attention-mode",
|
||||
"decode",
|
||||
"--tp-size",
|
||||
"1",
|
||||
"--mem-fraction-static",
|
||||
"0.7",
|
||||
"--disable-cuda-graph",
|
||||
"--dtype",
|
||||
"bfloat16",
|
||||
]
|
||||
|
||||
cls.common_args = [
|
||||
"--trust-remote-code",
|
||||
"--attention-backend",
|
||||
"ascend",
|
||||
"--disable-radix-cache",
|
||||
"--speculative-draft-model-quantization",
|
||||
"unquant",
|
||||
"--speculative-algorithm",
|
||||
"EAGLE3",
|
||||
"--speculative-draft-model-path",
|
||||
QWEN3_8B_EAGLE3_WEIGHTS_PATH,
|
||||
"--speculative-num-steps",
|
||||
"4",
|
||||
"--speculative-eagle-topk",
|
||||
"1",
|
||||
"--speculative-num-draft-tokens",
|
||||
"5",
|
||||
"--speculative-attention-mode",
|
||||
"decode",
|
||||
"--tp-size",
|
||||
"1",
|
||||
"--mem-fraction-static",
|
||||
"0.7",
|
||||
"--disable-cuda-graph",
|
||||
"--dtype",
|
||||
"bfloat16",
|
||||
]
|
||||
env = {
|
||||
**os.environ,
|
||||
"SGLANG_ENABLE_OVERLAP_PLAN_STREAM": "1",
|
||||
}
|
||||
|
||||
cls.extra_envs = {
|
||||
"SGLANG_ENABLE_OVERLAP_PLAN_STREAM": "1",
|
||||
}
|
||||
os.environ.update(cls.extra_envs)
|
||||
|
||||
def test_gsm8k(self):
|
||||
process = popen_launch_server(
|
||||
self.model,
|
||||
self.base_url,
|
||||
timeout=1500,
|
||||
other_args=[
|
||||
*self.common_args,
|
||||
],
|
||||
)
|
||||
|
||||
try:
|
||||
args = SimpleNamespace(
|
||||
num_shots=5,
|
||||
data_path=None,
|
||||
num_questions=1319,
|
||||
max_new_tokens=512,
|
||||
parallel=128,
|
||||
host=f"http://{self.url.hostname}",
|
||||
port=int(self.url.port),
|
||||
)
|
||||
|
||||
metrics = run_eval_few_shot_gsm8k(args)
|
||||
self.assertGreaterEqual(
|
||||
metrics["accuracy"],
|
||||
self.accuracy,
|
||||
)
|
||||
finally:
|
||||
kill_process_tree(process.pid)
|
||||
accuracy = 0.81
|
||||
num_questions = 1319
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user