Skip to content

Commit a131826

Browse files
authored
[Benchmark]Deprecate v2 (#9238)
Issue: pytorch/test-infra#6294 Remove benchmark v2 schema logics, still keep the way to store v3 with v3 folder, since we might have higher version of schema in the future next step is introduce the failure handling for benchmark record
1 parent 630d0cc commit a131826

File tree

3 files changed

+54
-171
lines changed

3 files changed

+54
-171
lines changed

.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-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:

0 commit comments

Comments
 (0)