[2/N] CI refactor: sperate some backend-independent CPU tasks. (#13447)

This commit is contained in:
Liangsheng Yin
2025-11-18 02:08:19 +08:00
committed by GitHub
parent ff00b6adbe
commit 6042010964
8 changed files with 69 additions and 24 deletions
+30 -5
View File
@@ -1,10 +1,19 @@
import argparse
import glob
from typing import List
from sglang.test.ci.ci_register import CIRegistry, HWBackend, collect_tests
from sglang.test.ci.ci_utils import TestFile, run_unittest_files
LABEL_MAPPING = {HWBackend.CUDA: ["stage-a-test-1"]}
HW_MAPPING = {
"cpu": HWBackend.CPU,
"cuda": HWBackend.CUDA,
}
LABEL_MAPPING = {
HWBackend.CUDA: ["stage-a-test-1"],
HWBackend.CPU: ["default"],
}
def _filter_tests(
@@ -13,8 +22,8 @@ def _filter_tests(
ci_tests = [t for t in ci_tests if t.backend == hw]
ret = []
for t in ci_tests:
assert t.stage in LABEL_MAPPING[hw], f"Unknown stage {t.stage} for backend {hw}"
if t.stage == suite:
assert t.suite in LABEL_MAPPING[hw], f"Unknown stage {t.suite} for backend {hw}"
if t.suite == suite:
ret.append(t)
return ret
@@ -22,7 +31,7 @@ def _filter_tests(
def run_per_commit(hw: HWBackend, suite: str):
files = glob.glob("per_commit/**/*.py", recursive=True)
ci_tests = _filter_tests(collect_tests(files), hw, suite)
test_files = [TestFile(t.filename, t.estimation_time) for t in ci_tests]
test_files = [TestFile(t.filename, t.est_time) for t in ci_tests]
run_unittest_files(
test_files,
@@ -32,7 +41,23 @@ def run_per_commit(hw: HWBackend, suite: str):
def main():
run_per_commit(HWBackend.CUDA, "stage-a-test-1")
parser = argparse.ArgumentParser()
parser.add_argument(
"--hw",
type=str,
choices=["cpu", "cuda"],
required=True,
help="Hardware backend to run tests on.",
)
parser.add_argument(
"--suite",
type=str,
required=True,
help="Test suite to run.",
)
args = parser.parse_args()
hw = HW_MAPPING[args.hw]
run_per_commit(hw, args.suite)
if __name__ == "__main__":