-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Populate the benchmark metadata (#5918)
To ease the process of gathering the benchmark metadata before uploading the the database, I'm adding a script `.github/scripts/benchmarks/gather_metadata.py` to gather this information and pass it to the upload script. From #5839, the benchmark metadata includes the following required fields: ``` -- Metadata `timestamp` UInt64, `schema_version` String DEFAULT 'v3', `name` String, -- About the change `repo` String DEFAULT 'pytorch/pytorch', `head_branch` String, `head_sha` String, `workflow_id` UInt64, `run_attempt` UInt32, `job_id` UInt64, -- The raw records on S3 `s3_path` String, ``` I'm going to test this out with PT2 compiler instruction count benchmark at pytorch/pytorch#140493 ### Testing https://github.com/pytorch/test-infra/actions/runs/11831746632/job/32967412160?pr=5918#step:5:105 gathers the metadata and upload the benchmark results correctly Also, an actual upload at https://github.com/pytorch/pytorch/actions/runs/11831781500/job/33006545698#step:24:138
- Loading branch information
Showing
7 changed files
with
342 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
.github/scripts/benchmark-results-dir-for-testing/v3/add_loop_eager.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"benchmark": {"name": "pr_time_benchmarks", "extra_info": {"is_dynamic": false, "device": "cpu", "description": "a loop over 100 add node"}}, "model": {"name": "add_loop_eager", "type": "add_loop", "backend": "eager"}, "metric": {"name": "compile_time_instruction_count", "benchmark_values": [3086359081]}}] |
1 change: 1 addition & 0 deletions
1
.github/scripts/benchmark-results-dir-for-testing/v3/add_loop_eager_dynamic.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"benchmark": {"name": "pr_time_benchmarks", "extra_info": {"is_dynamic": true, "device": "cpu", "description": "a loop over 100 add node"}}, "model": {"name": "add_loop_eager_dynamic", "type": "add_loop", "backend": "eager"}, "metric": {"name": "compile_time_instruction_count", "benchmark_values": [5712213247]}}] |
1 change: 1 addition & 0 deletions
1
.github/scripts/benchmark-results-dir-for-testing/v3/add_loop_inductor_dynamic_gpu.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"benchmark": {"name": "pr_time_benchmarks", "extra_info": {"is_dynamic": true, "device": "cuda", "description": "a loop over 100 add node"}}, "model": {"name": "add_loop_inductor_dynamic_gpu", "type": "add_loop", "backend": "inductor"}, "metric": {"name": "compile_time_instruction_count", "benchmark_values": [40859830085]}}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
import os | ||
import json | ||
import time | ||
from typing import Any | ||
|
||
|
||
def parse_args() -> Any: | ||
from argparse import ArgumentParser | ||
|
||
parser = ArgumentParser("gather some metadata about the benchmark") | ||
# v3 is defined at torchci/clickhouse_queries/oss_ci_benchmark_v3/query.sql | ||
parser.add_argument( | ||
"--schema-version", | ||
choices=["v2", "v3"], | ||
required=True, | ||
help="the database schema to use", | ||
) | ||
parser.add_argument( | ||
"--repo", | ||
type=str, | ||
required=True, | ||
help="the name of repository where the benchmark is run", | ||
) | ||
parser.add_argument( | ||
"--head-branch", | ||
type=str, | ||
required=True, | ||
help="the name of branch where the benchmark is run", | ||
) | ||
parser.add_argument( | ||
"--head-sha", | ||
type=str, | ||
required=True, | ||
help="the commit that the benchmark uses", | ||
) | ||
parser.add_argument( | ||
"--workflow-id", | ||
type=int, | ||
required=True, | ||
help="the benchmark workflow id", | ||
) | ||
parser.add_argument( | ||
"--run-attempt", | ||
type=int, | ||
default=1, | ||
help="the workflow run attempt", | ||
) | ||
parser.add_argument( | ||
"--job-id", | ||
type=int, | ||
required=True, | ||
help="the benchmark job id", | ||
) | ||
parser.add_argument( | ||
"--job-name", | ||
type=str, | ||
required=True, | ||
help="the benchmark job name", | ||
) | ||
|
||
return parser.parse_args() | ||
|
||
|
||
def set_output(name: str, val: Any) -> None: | ||
if os.getenv("GITHUB_OUTPUT"): | ||
with open(str(os.getenv("GITHUB_OUTPUT")), "a") as env: | ||
print(f"{name}={val}", file=env) | ||
else: | ||
print(f"::set-output name={name}::{val}") | ||
|
||
|
||
def main() -> None: | ||
args = parse_args() | ||
|
||
# From https://github.com/pytorch/test-infra/pull/5839 | ||
metadata = { | ||
"timestamp": int(time.time()), | ||
"schema_version": args.schema_version, | ||
"name": args.job_name, | ||
"repo": args.repo, | ||
"head_branch": args.head_branch, | ||
"head_sha": args.head_sha, | ||
"workflow_id": args.workflow_id, | ||
"run_attempt": args.run_attempt, | ||
"job_id": args.job_id, | ||
} | ||
set_output("metadata", json.dumps(metadata)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.