Skip to content

Commit d935d9a

Browse files
huydhnfacebook-github-bot
authored andcommitted
Use only cmake for MacOS CI to save capacity (#613)
Summary: This change updates the gather script to: 1. Use only cmake for MacOS CI to save capacity. This cuts the number of MacOS job in half 2. Fix the wrong and confusing reference of `linux.2xlarge` on MacOS jobs Pull Request resolved: #613 Reviewed By: seemethere Differential Revision: D49919115 Pulled By: huydhn fbshipit-source-id: c6b8619153959259786e8c2adb3e721934c3841e
1 parent ef97148 commit d935d9a

File tree

2 files changed

+63
-29
lines changed

2 files changed

+63
-29
lines changed

.ci/scripts/gather_test_models.py

Lines changed: 61 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,42 @@
1212
from examples.models import MODEL_NAME_TO_MODEL
1313
from examples.recipes.xnnpack_optimization import MODEL_NAME_TO_OPTIONS
1414

15-
BUILD_TOOLS = [
16-
"buck2",
17-
"cmake",
18-
]
19-
DEFAULT_RUNNER = "linux.2xlarge"
20-
RUNNERS = {
21-
# This one runs OOM on smaller runner, the root cause is unclear (T163016365)
22-
"w2l": "linux.12xlarge",
23-
"ic4": "linux.12xlarge",
24-
"resnet50": "linux.12xlarge",
25-
# This one causes timeout on smaller runner, the root cause is unclear (T161064121)
26-
"dl3": "linux.12xlarge",
27-
"emformer_join": "linux.12xlarge",
15+
# NB: Skip buck2 on MacOS to cut down the number of combinations we
16+
# need to run there as the number of MacOS runner is limited. Buck2
17+
# build and test has already been covered on Linux
18+
BUILD_TOOLS = {
19+
"buck2": {"linux"},
20+
"cmake": {"linux", "macos"},
2821
}
22+
DEFAULT_RUNNERS = {
23+
"linux": "linux.2xlarge",
24+
"macos": "macos-m1-12",
25+
}
26+
CUSTOM_RUNNERS = {
27+
"linux": {
28+
# This one runs OOM on smaller runner, the root cause is unclear (T163016365)
29+
"w2l": "linux.12xlarge",
30+
"ic4": "linux.12xlarge",
31+
"resnet50": "linux.12xlarge",
32+
# This one causes timeout on smaller runner, the root cause is unclear (T161064121)
33+
"dl3": "linux.12xlarge",
34+
"emformer_join": "linux.12xlarge",
35+
}
36+
}
37+
38+
39+
def parse_args() -> Any:
40+
from argparse import ArgumentParser
41+
42+
parser = ArgumentParser("Gather all models to test on CI for the target OS")
43+
parser.add_argument(
44+
"--target-os",
45+
type=str,
46+
choices=["linux", "macos"],
47+
default="linux",
48+
help="the target OS",
49+
)
50+
return parser.parse_args()
2951

3052

3153
def set_output(name: str, val: Any) -> None:
@@ -45,6 +67,9 @@ def export_models_for_ci() -> None:
4567
"""
4668
This gathers all the example models that we want to test on GitHub OSS CI
4769
"""
70+
args = parse_args()
71+
target_os = args.target_os
72+
4873
# This is the JSON syntax for configuration matrix used by GitHub
4974
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
5075
models = {"include": []}
@@ -58,20 +83,31 @@ def export_models_for_ci() -> None:
5883
name in MODEL_NAME_TO_OPTIONS
5984
and MODEL_NAME_TO_OPTIONS[name].xnnpack_delegation,
6085
}
61-
for build_tool in BUILD_TOOLS:
86+
for build_tool in BUILD_TOOLS.keys():
87+
if target_os not in BUILD_TOOLS[build_tool]:
88+
continue
89+
6290
for q_config in quantization_configs:
6391
for d_config in delegation_configs:
64-
models["include"].append(
65-
{
66-
"build-tool": build_tool,
67-
"model": name,
68-
"xnnpack_quantization": q_config,
69-
"xnnpack_delegation": d_config,
70-
"runner": RUNNERS.get(name, DEFAULT_RUNNER),
71-
# demo_backend_delegation test only supports add_mul model
72-
"demo_backend_delegation": name == "add_mul",
73-
}
74-
)
92+
record = {
93+
"build-tool": build_tool,
94+
"model": name,
95+
"xnnpack_quantization": q_config,
96+
"xnnpack_delegation": d_config,
97+
"runner": DEFAULT_RUNNERS.get(target_os, "linux.2xlarge"),
98+
# demo_backend_delegation test only supports add_mul model
99+
"demo_backend_delegation": name == "add_mul",
100+
}
101+
102+
# NB: Some model requires much bigger Linux runner to avoid
103+
# running OOM. The team is investigating the root cause
104+
if target_os in CUSTOM_RUNNERS and name in CUSTOM_RUNNERS.get(
105+
target_os, {}
106+
):
107+
record["runner"] = CUSTOM_RUNNERS[target_os][name]
108+
109+
models["include"].append(record)
110+
75111
set_output("models", json.dumps(models))
76112

77113

.github/workflows/trunk.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
install_pip_dependencies
3535
install_executorch
3636
37-
PYTHONPATH="${PWD}" python .ci/scripts/gather_test_models.py
37+
PYTHONPATH="${PWD}" python .ci/scripts/gather_test_models.py --target-os macos
3838
3939
test-models-macos:
4040
name: test-models-macos
@@ -44,7 +44,7 @@ jobs:
4444
matrix: ${{ fromJSON(needs.gather-models.outputs.models) }}
4545
fail-fast: false
4646
with:
47-
runner: macos-m1-12
47+
runner: ${{ matrix.runner }}
4848
submodules: 'true'
4949
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
5050
timeout: 90
@@ -70,7 +70,6 @@ jobs:
7070
strategy:
7171
matrix:
7272
include:
73-
- build-tool: buck2
7473
- build-tool: cmake
7574
fail-fast: false
7675
with:
@@ -95,7 +94,6 @@ jobs:
9594
strategy:
9695
matrix:
9796
include:
98-
- build-tool: buck2
9997
- build-tool: cmake
10098
fail-fast: false
10199
with:

0 commit comments

Comments
 (0)