Skip to content

Commit eff4af7

Browse files
authored
Merge branch 'main' into add_mv3_testcase
2 parents ba0dea7 + b0c2c7c commit eff4af7

File tree

80 files changed

+1523
-390
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1523
-390
lines changed

.ci/scripts/gather_test_models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# This source code is licensed under the BSD-style license found in the
66
# LICENSE file in the root directory of this source tree.
77

8+
# WARNING: The CI runner logic should directly be in the corresponding yml files
9+
# This file will be deleted once the reference in periodic.yml is deleted.
10+
811
import itertools
912
import json
1013
import os
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
set -eux
8+
9+
buck2 test //extension/apple:ExecuTorch

.ci/scripts/unittest-macos.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ if [[ "$BUILD_TOOL" == "cmake" ]]; then
3535
.ci/scripts/unittest-macos-cmake.sh
3636
elif [[ "$BUILD_TOOL" == "buck2" ]]; then
3737
.ci/scripts/unittest-buck2.sh
38+
.ci/scripts/unittest-macos-buck2.sh
3839
else
3940
echo "Unknown build tool $BUILD_TOOL"
4041
exit 1

.github/scripts/extract_benchmark_results.py

Lines changed: 48 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -86,36 +86,6 @@ def parse_args() -> Any:
8686
action=ValidateDir,
8787
help="the directory to keep the benchmark results",
8888
)
89-
parser.add_argument(
90-
"--repo",
91-
type=str,
92-
required=True,
93-
help="which GitHub repo this workflow run belongs to",
94-
)
95-
parser.add_argument(
96-
"--head-branch",
97-
type=str,
98-
required=True,
99-
help="the head branch that runs",
100-
)
101-
parser.add_argument(
102-
"--workflow-name",
103-
type=str,
104-
required=True,
105-
help="the name of the benchmark workflow",
106-
)
107-
parser.add_argument(
108-
"--workflow-run-id",
109-
type=int,
110-
required=True,
111-
help="the id of the benchmark workflow",
112-
)
113-
parser.add_argument(
114-
"--workflow-run-attempt",
115-
type=int,
116-
required=True,
117-
help="which retry of the workflow this is",
118-
)
11989
parser.add_argument(
12090
"--benchmark-configs",
12191
type=str,
@@ -153,9 +123,10 @@ def extract_android_benchmark_results(
153123
# This is to handle the case where there is no benchmark results
154124
warning(f"Fail to load the benchmark results from {artifact_s3_url}")
155125
return []
126+
return []
156127

157128

158-
def initialize_ios_metadata(test_name: str) -> Dict[str, any]:
129+
def initialize_ios_metadata(test_name: str) -> Dict[str, Any]:
159130
"""
160131
Extract the benchmark metadata from the test name, for example:
161132
test_forward_llama2_pte_iOS_17_2_1_iPhone15_4
@@ -364,14 +335,7 @@ def transform(
364335
app_type: str,
365336
benchmark_results: List,
366337
benchmark_config: Dict[str, str],
367-
repo: str,
368-
head_branch: str,
369-
workflow_name: str,
370-
workflow_run_id: int,
371-
workflow_run_attempt: int,
372338
job_name: str,
373-
job_id: int,
374-
schema_version: str,
375339
) -> List:
376340
"""
377341
Transform the benchmark results into the format writable into the benchmark database
@@ -381,87 +345,51 @@ def transform(
381345
for r in benchmark_results:
382346
r["deviceInfo"]["device"] = job_name
383347

384-
if schema_version == "v2":
385-
# TODO (huydhn): Clean up this branch after ExecuTorch dashboard migrates to v3
386-
return [
387-
{
388-
# GH-info to identify where the benchmark is run
389-
"repo": repo,
390-
"head_branch": head_branch,
391-
"workflow_id": workflow_run_id,
392-
"run_attempt": workflow_run_attempt,
393-
"job_id": job_id,
394-
# The model
395-
"name": f"{r['benchmarkModel']['name']} {r['benchmarkModel'].get('backend', '')}".strip(),
396-
"dtype": (
397-
r["benchmarkModel"]["quantization"]
398-
if r["benchmarkModel"]["quantization"]
399-
else "unknown"
400-
),
401-
# The metric value
402-
"metric": r["metric"],
403-
"actual": r["actualValue"],
404-
"target": r["targetValue"],
405-
# The device
406-
"device": r["deviceInfo"]["device"],
407-
"arch": r["deviceInfo"].get("os", ""),
408-
# Not used here, just set it to something unique here
409-
"filename": workflow_name,
410-
"test_name": app_type,
411-
"runner": job_name,
412-
}
413-
for r in benchmark_results
414-
]
415-
elif schema_version == "v3":
416-
v3_benchmark_results = []
417-
# From https://github.com/pytorch/pytorch/wiki/How-to-integrate-with-PyTorch-OSS-benchmark-database
418-
return [
419-
{
420-
"benchmark": {
421-
"name": "ExecuTorch",
422-
"mode": "inference",
423-
"extra_info": {
424-
"app_type": app_type,
425-
# Just keep a copy of the benchmark config here
426-
"benchmark_config": json.dumps(benchmark_config),
427-
},
428-
},
429-
"model": {
430-
"name": benchmark_config.get("model", r["benchmarkModel"]["name"]),
431-
"type": "OSS model",
432-
"backend": benchmark_config.get(
433-
"config", r["benchmarkModel"].get("backend", "")
434-
),
348+
# From https://github.com/pytorch/pytorch/wiki/How-to-integrate-with-PyTorch-OSS-benchmark-database
349+
return [
350+
{
351+
"benchmark": {
352+
"name": "ExecuTorch",
353+
"mode": "inference",
354+
"extra_info": {
355+
"app_type": app_type,
356+
# Just keep a copy of the benchmark config here
357+
"benchmark_config": json.dumps(benchmark_config),
435358
},
436-
"metric": {
437-
"name": r["metric"],
438-
"benchmark_values": [r["actualValue"]],
439-
"target_value": r["targetValue"],
440-
"extra_info": {
441-
"method": r.get("method", ""),
442-
},
359+
},
360+
"model": {
361+
"name": benchmark_config.get("model", r["benchmarkModel"]["name"]),
362+
"type": "OSS model",
363+
"backend": benchmark_config.get(
364+
"config", r["benchmarkModel"].get("backend", "")
365+
),
366+
},
367+
"metric": {
368+
"name": r["metric"],
369+
"benchmark_values": [r["actualValue"]],
370+
"target_value": r["targetValue"],
371+
"extra_info": {
372+
"method": r.get("method", ""),
443373
},
444-
"runners": [
445-
{
446-
"name": r["deviceInfo"]["device"],
447-
"type": r["deviceInfo"]["os"],
448-
"avail_mem_in_gb": r["deviceInfo"].get("availMem", ""),
449-
"total_mem_in_gb": r["deviceInfo"].get("totalMem", ""),
450-
}
451-
],
452-
}
453-
for r in benchmark_results
454-
]
374+
},
375+
"runners": [
376+
{
377+
"name": r["deviceInfo"]["device"],
378+
"type": r["deviceInfo"]["os"],
379+
"avail_mem_in_gb": r["deviceInfo"].get("availMem", ""),
380+
"total_mem_in_gb": r["deviceInfo"].get("totalMem", ""),
381+
}
382+
],
383+
}
384+
for r in benchmark_results
385+
]
455386

456387

457388
def main() -> None:
458389
args = parse_args()
459390

460391
# Across all devices, keeping both schemas for now until ExecuTorch dashboard migrates to v3
461-
all_benchmark_results = {
462-
"v2": [],
463-
"v3": [],
464-
}
392+
all_benchmark_results = []
465393
benchmark_config = {}
466394

467395
with open(args.artifacts) as f:
@@ -482,7 +410,7 @@ def main() -> None:
482410
benchmark_config = read_benchmark_config(
483411
artifact_s3_url, args.benchmark_configs
484412
)
485-
413+
benchmark_results = []
486414
if app_type == "ANDROID_APP":
487415
benchmark_results = extract_android_benchmark_results(
488416
job_name, artifact_type, artifact_s3_url
@@ -494,32 +422,17 @@ def main() -> None:
494422
)
495423

496424
if benchmark_results:
497-
for schema in all_benchmark_results.keys():
498-
results = transform(
499-
app_type,
500-
benchmark_results,
501-
benchmark_config,
502-
args.repo,
503-
args.head_branch,
504-
args.workflow_name,
505-
args.workflow_run_id,
506-
args.workflow_run_attempt,
507-
job_name,
508-
extract_job_id(args.artifacts),
509-
schema,
510-
)
511-
all_benchmark_results[schema].extend(results)
512-
513-
for schema in all_benchmark_results.keys():
514-
if not all_benchmark_results.get(schema):
515-
continue
516-
517-
output_dir = os.path.join(args.output_dir, schema)
518-
os.makedirs(output_dir, exist_ok=True)
425+
results = transform(
426+
app_type, benchmark_results, benchmark_config, job_name
427+
)
428+
all_benchmark_results.extend(results)
519429

430+
# add v3 in case we have higher version of schema
431+
output_dir = os.path.join(args.output_dir, "v3")
432+
os.makedirs(output_dir, exist_ok=True)
520433
output_file = os.path.basename(args.artifacts)
521434
with open(f"{output_dir}/{output_file}", "w") as f:
522-
json.dump(all_benchmark_results[schema], f)
435+
json.dump(all_benchmark_results, f)
523436

524437

525438
if __name__ == "__main__":

.github/workflows/_android.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
3131
# Build LLM Demo for Android
3232
bash build/build_android_library.sh ${ARTIFACTS_DIR_NAME}
33+
bash build/build_android_instrumentation.sh
3334
3435
# Running Android emulator directly on the runner and not using Docker
3536
run-emulator:

.github/workflows/android-perf.yml

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -462,29 +462,14 @@ jobs:
462462
${CONDA_RUN} python .github/scripts/extract_benchmark_results.py \
463463
--artifacts "${ARTIFACTS_BY_JOB}" \
464464
--output-dir benchmark-results \
465-
--repo ${{ github.repository }} \
466-
--head-branch ${{ github.head_ref || github.ref_name }} \
467-
--workflow-name "${{ github.workflow }}" \
468-
--workflow-run-id ${{ github.run_id }} \
469-
--workflow-run-attempt ${{ github.run_attempt }} \
470465
--benchmark-configs benchmark-configs
471466
done
472467
473-
for SCHEMA in v2 v3; do
474-
for BENCHMARK_RESULTS in benchmark-results/"${SCHEMA}"/*.json; do
475-
cat "${BENCHMARK_RESULTS}"
476-
echo
477-
done
468+
for BENCHMARK_RESULTS in benchmark-results/v3/*.json; do
469+
cat "${BENCHMARK_RESULTS}"
470+
echo
478471
done
479472
480-
# TODO (huydhn): Remove v2 schema once the benchmark dashboard finishes the migration
481-
- name: Upload the benchmark results (v2)
482-
uses: pytorch/test-infra/.github/actions/upload-benchmark-results@main
483-
with:
484-
benchmark-results-dir: benchmark-results/v2
485-
dry-run: false
486-
schema-version: v2
487-
488473
- name: Upload the benchmark results (v3)
489474
uses: pytorch/test-infra/.github/actions/upload-benchmark-results@main
490475
with:

.github/workflows/apple-perf.yml

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -521,29 +521,14 @@ jobs:
521521
${CONDA_RUN} python .github/scripts/extract_benchmark_results.py \
522522
--artifacts "${ARTIFACTS_BY_JOB}" \
523523
--output-dir benchmark-results \
524-
--repo ${{ github.repository }} \
525-
--head-branch ${{ github.head_ref || github.ref_name }} \
526-
--workflow-name "${{ github.workflow }}" \
527-
--workflow-run-id ${{ github.run_id }} \
528-
--workflow-run-attempt ${{ github.run_attempt }} \
529524
--benchmark-configs benchmark-configs
530525
done
531526
532-
for SCHEMA in v2 v3; do
533-
for BENCHMARK_RESULTS in benchmark-results/"${SCHEMA}"/*.json; do
534-
cat "${BENCHMARK_RESULTS}"
535-
echo
536-
done
527+
for BENCHMARK_RESULTS in benchmark-results/v3/*.json; do
528+
cat "${BENCHMARK_RESULTS}"
529+
echo
537530
done
538531
539-
# TODO (huydhn): Remove v2 schema once the benchmark dashboard finishes the migration
540-
- name: Upload the benchmark results (v2)
541-
uses: pytorch/test-infra/.github/actions/upload-benchmark-results@main
542-
with:
543-
benchmark-results-dir: benchmark-results/v2
544-
dry-run: false
545-
schema-version: v2
546-
547532
- name: Upload the benchmark results (v3)
548533
uses: pytorch/test-infra/.github/actions/upload-benchmark-results@main
549534
with:

.github/workflows/apple.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
with:
5050
runner: macos-latest-xlarge
5151
python-version: '3.11'
52-
submodules: 'true'
52+
submodules: 'recursive'
5353
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
5454
timeout: 90
5555
secrets-env: BUILD_CERTIFICATE_BASE64 EXECUTORCH_DEMO_BUILD_PROVISION_PROFILE_BASE64 KEYCHAIN_PASSWORD
@@ -136,7 +136,7 @@ jobs:
136136
with:
137137
runner: macos-latest-xlarge
138138
python-version: '3.11'
139-
submodules: 'true'
139+
submodules: 'recursive'
140140
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
141141
upload-artifact: executorch-frameworks-ios
142142
timeout: 90
@@ -279,7 +279,7 @@ jobs:
279279
with:
280280
runner: macos-latest-xlarge
281281
python-version: '3.11'
282-
submodules: 'true'
282+
submodules: 'recursive'
283283
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
284284
upload-artifact: ios-benchmark-app
285285
secrets-env: BUILD_CERTIFICATE_BASE64 EXECUTORCH_BENCHMARK_BUILD_PROVISION_PROFILE_BASE64 KEYCHAIN_PASSWORD

0 commit comments

Comments
 (0)