[CI] Parallelize unit tests in CI (#1219)

This commit is contained in:
Mingyi
2024-08-25 21:54:02 -07:00
committed by GitHub
parent 632d506d0b
commit 97589a60a2
6 changed files with 99 additions and 75 deletions

View File

@@ -18,10 +18,12 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
unit-test: unit-test-jobs:
if: github.repository == 'sgl-project/sglang' || github.event_name == 'pull_request' if: github.repository == 'sgl-project/sglang' || github.event_name == 'pull_request'
runs-on: 1-gpu-runner runs-on: 1-gpu-runner
strategy:
matrix:
test_type: ['backend-0', 'backend-1', 'frontend']
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3
@@ -32,14 +34,23 @@ jobs:
pip install -e "python[dev]" pip install -e "python[dev]"
pip install flashinfer -i https://flashinfer.ai/whl/cu121/torch2.4/ --force-reinstall pip install flashinfer -i https://flashinfer.ai/whl/cu121/torch2.4/ --force-reinstall
- name: Test Backend Runtime - name: Run test
timeout-minutes: 20 timeout-minutes: 20
run: | run: |
cd test/srt if [ "${{ matrix.test_type }}" = "frontend" ]; then
python3 run_suite.py --suite minimal
- name: Test Frontend Language
timeout-minutes: 10
run: |
cd test/lang cd test/lang
python3 run_suite.py --suite minimal python3 run_suite.py --suite minimal
elif [ "${{ matrix.test_type }}" = "backend-0" ]; then
cd test/srt
python3 run_suite.py --suite minimal --range-begin 0 --range-end 8
elif [ "${{ matrix.test_type }}" = "backend-1" ]; then
cd test/srt
python3 run_suite.py --suite minimal --range-begin 8
fi
unit-test:
needs: unit-test-jobs
runs-on: ubuntu-latest
steps:
- name: Merge step
run: echo "This is an empty merge step"

View File

@@ -465,7 +465,7 @@ def run_unittest_files(files: List[str], timeout_per_file: float):
def run_one_file(filename): def run_one_file(filename):
filename = os.path.join(os.getcwd(), filename) filename = os.path.join(os.getcwd(), filename)
print(f"\n\nRun {filename}\n\n", flush=True) print(f"\n\nRun:\npython3 {filename}\n\n", flush=True)
process = subprocess.Popen( process = subprocess.Popen(
["python3", filename], stdout=None, stderr=None, env=os.environ ["python3", filename], stdout=None, stderr=None, env=os.environ
) )

View File

@@ -1,6 +1,5 @@
import argparse import argparse
import glob import glob
import multiprocessing as mp
from sglang.test.test_utils import run_unittest_files from sglang.test.test_utils import run_unittest_files
@@ -49,6 +48,18 @@ if __name__ == "__main__":
choices=list(suites.keys()) + ["all"], choices=list(suites.keys()) + ["all"],
help="The suite to run", help="The suite to run",
) )
arg_parser.add_argument(
"--range-begin",
type=int,
default=0,
help="The begin index of the range of the files to run.",
)
arg_parser.add_argument(
"--range-end",
type=int,
default=None,
help="The end index of the range of the files to run.",
)
args = arg_parser.parse_args() args = arg_parser.parse_args()
if args.suite == "all": if args.suite == "all":
@@ -56,5 +67,7 @@ if __name__ == "__main__":
else: else:
files = suites[args.suite] files = suites[args.suite]
files = files[args.range_begin : args.range_end]
exit_code = run_unittest_files(files, args.timeout_per_file) exit_code = run_unittest_files(files, args.timeout_per_file)
exit(exit_code) exit(exit_code)