[CI] Batch CPU test workers (#37252)

This commit is contained in:
Xiaoyu Zhang
2026-09-02 10:35:14 +08:00
committed by GitHub
parent 1aa8299d1d
commit 403a15c163
3 changed files with 21 additions and 3 deletions
+1 -1
View File
@@ -158,7 +158,7 @@ jobs:
SGLANG_SKIP_RUST_TESTS: ${{ fromJson(inputs.check_changes).rust_workspace == 'true' && 'false' || 'true' }} SGLANG_SKIP_RUST_TESTS: ${{ fromJson(inputs.check_changes).rust_workspace == 'true' && 'false' || 'true' }}
run: | run: |
cd test/ cd test/
python3 run_suite.py --hw cpu --suite ${{ inputs.self_name }} --auto-partition-id ${{ matrix.partition }} --auto-partition-size ${{ fromJson(inputs.partitions)[inputs.self_name].size }} --partition-model-file /tmp/partition-model.json $CONTINUE_ON_ERROR_FLAG python3 run_suite.py --hw cpu --suite ${{ inputs.self_name }} --auto-partition-id ${{ matrix.partition }} --auto-partition-size ${{ fromJson(inputs.partitions)[inputs.self_name].size }} --partition-model-file /tmp/partition-model.json --fork-worker-batch-size 20 $CONTINUE_ON_ERROR_FLAG
# PRs save only what the base lacks; the implicit if: success() keeps a # PRs save only what the base lacks; the implicit if: success() keeps a
# half-downloaded cache unpublished. # half-downloaded cache unpublished.
@@ -33,6 +33,10 @@ def _normalize_exit_code(code) -> int:
def _run_file(filename: str) -> int: def _run_file(filename: str) -> int:
sys.argv = [filename, "-f"] sys.argv = [filename, "-f"]
# Match ``python /path/to/test.py``: tests may import helper modules that
# live next to the executed file. runpy.run_path() does not update
# sys.path[0] for us, and this child exits after the file finishes.
sys.path[0] = os.path.dirname(os.path.abspath(filename))
try: try:
runpy.run_path(filename, run_name="__main__") runpy.run_path(filename, run_name="__main__")
return 0 return 0
+16 -2
View File
@@ -54,14 +54,28 @@ class TestForkTestWorker(CustomTestCase):
assert "SGLANG_FORK_WORKER_TEST" not in os.environ assert "SGLANG_FORK_WORKER_TEST" not in os.environ
raise SystemExit(3) raise SystemExit(3)
""")) """))
helper = Path(tmpdir) / "sibling_helper.py"
helper.write_text("VALUE = 42\n")
sibling_import = Path(tmpdir) / "sibling_import.py"
sibling_import.write_text(textwrap.dedent("""
import os
import sys
from sibling_helper import VALUE
assert sys.path[0] == os.path.dirname(__file__)
assert VALUE == 42
"""))
results = [] results = []
for filename in (first, second): for filename in (first, second, sibling_import):
process.stdin.write(json.dumps({"filename": str(filename)}) + "\n") process.stdin.write(json.dumps({"filename": str(filename)}) + "\n")
process.stdin.flush() process.stdin.flush()
results.append(json.loads(result_stream.readline())) results.append(json.loads(result_stream.readline()))
self.assertEqual([result["returncode"] for result in results], [0, 3]) self.assertEqual(
[result["returncode"] for result in results], [0, 3, 0]
)
self.assertTrue(all(result["elapsed"] >= 0 for result in results)) self.assertTrue(all(result["elapsed"] >= 0 for result in results))
process.stdin.write(json.dumps({"command": "stop"}) + "\n") process.stdin.write(json.dumps({"command": "stop"}) + "\n")