-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f18e9a2
commit d541806
Showing
10 changed files
with
619 additions
and
5 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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
put -r pipeline_*.json | ||
put -r benchmark_*.json | ||
ls -hal |
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,117 @@ | ||
# SPDX-FileCopyrightText: (c) 2024 Tenstorrent AI ULC | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import os | ||
import pathlib | ||
import json | ||
from loguru import logger | ||
from pydantic_models import BenchmarkMeasurement, CompleteBenchmarkRun | ||
|
||
|
||
def create_json_from_report(pipeline, workflow_outputs_dir): | ||
results = [] | ||
reports = _get_model_reports(workflow_outputs_dir, pipeline.github_pipeline_id) | ||
|
||
for job_id, report_paths in reports.items(): | ||
for report_path in report_paths: | ||
with open(report_path) as report_file: | ||
report_data = json.load(report_file) | ||
results.append(_map_benchmark_data(pipeline, job_id, report_data)) | ||
logger.info(f"Created benchmark data for job: {job_id} model: {report_data['model']}") | ||
return results | ||
|
||
|
||
def get_benchmark_filename(report): | ||
ts = report.run_start_ts.strftime("%Y-%m-%dT%H:%M:%S%z") | ||
return f"benchmark_{report.github_job_id}_{ts}.json" | ||
|
||
|
||
def _get_model_reports(workflow_outputs_dir, workflow_run_id: int): | ||
""" | ||
This function searches for perf reports in the artifacts directory | ||
and returns a mapping of job IDs to the paths of the perf reports. | ||
We expect that report filename is in format `<report_name>_<job_id>.json`. | ||
""" | ||
job_paths_map = {} | ||
artifacts_dir = f"{workflow_outputs_dir}/{workflow_run_id}/artifacts" | ||
|
||
logger.info(f"Searching for perf reports in {artifacts_dir}") | ||
|
||
for root, _, files in os.walk(artifacts_dir): | ||
for file in files: | ||
if file.endswith(".json"): | ||
logger.debug(f"Found perf report {file}") | ||
file_path = pathlib.Path(root) / file | ||
filename = file_path.name | ||
try: | ||
job_id = int(filename.split(".")[-2].split("_")[-1]) | ||
except ValueError: | ||
logger.warning(f"Could not extract job ID from {filename}") | ||
continue | ||
report_paths = job_paths_map.get(job_id, []) | ||
report_paths.append(file_path) | ||
job_paths_map[job_id] = report_paths | ||
return job_paths_map | ||
|
||
|
||
def _map_benchmark_data(pipeline, job_id, report_data): | ||
|
||
# get job information from pipeline | ||
job = next(job for job in pipeline.jobs if job.github_job_id == job_id) | ||
|
||
return CompleteBenchmarkRun( | ||
run_start_ts=pipeline.pipeline_start_ts, | ||
run_end_ts=pipeline.pipeline_end_ts, | ||
run_type="", | ||
git_repo_name=None, | ||
git_commit_hash=pipeline.git_commit_hash, | ||
git_commit_ts=None, | ||
git_branch_name=pipeline.git_branch_name, | ||
github_pipeline_id=pipeline.github_pipeline_id, | ||
github_pipeline_link=pipeline.github_pipeline_link, | ||
github_job_id=job.github_job_id, | ||
user_name=pipeline.git_author, | ||
docker_image=job.docker_image, | ||
device_hostname=job.host_name, | ||
device_ip=None, | ||
device_info=None, | ||
ml_model_name=report_data["model"], | ||
ml_model_type=None, | ||
num_layers=None, | ||
batch_size=report_data.get("batch_size", None), | ||
config_params={}, | ||
precision=None, | ||
dataset_name=None, | ||
profiler_name=None, | ||
input_sequence_length=None, | ||
output_sequence_length=None, | ||
image_dimension=None, | ||
perf_analysis=None, | ||
training=report_data.get("training", False), | ||
measurements=[ | ||
BenchmarkMeasurement( | ||
step_start_ts=job.job_start_ts, | ||
step_end_ts=job.job_end_ts, | ||
iteration=0, | ||
step_name="", | ||
step_warm_up_num_iterations=None, | ||
name="samples_per_sec", | ||
value=report_data["samples_per_sec"], | ||
target=None, | ||
device_power=None, | ||
device_temperature=None, | ||
), | ||
BenchmarkMeasurement( | ||
step_start_ts=job.job_start_ts, | ||
step_end_ts=job.job_end_ts, | ||
iteration=0, | ||
step_name="", | ||
step_warm_up_num_iterations=None, | ||
name="total_time", | ||
value=report_data["total_time"], | ||
target=None, | ||
device_power=None, | ||
device_temperature=None, | ||
), | ||
], | ||
) |
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
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
22 changes: 22 additions & 0 deletions
22
...s/collect_data/test/data/12141788622/artifacts/forge-benchmark-e2e-mnist_33854708624.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,22 @@ | ||
{ | ||
"model": "MNIST Linear", | ||
"config": "", | ||
"date": "24-12-03", | ||
"hash": "c47f41a", | ||
"machine_name": "8cb186cee6d2", | ||
"samples_per_sec": 0.23979727678872859, | ||
"total_samples": 1, | ||
"total_time": 4.170189142227173, | ||
"training": false, | ||
"batch_size": 1, | ||
"output": "forge-benchmark-e2e-mnist_33854708624.json", | ||
"arch": "", | ||
"chips": "", | ||
"device": "", | ||
"galaxy": "", | ||
"perf_analysis": "", | ||
"load_tti": "", | ||
"save_tti": "", | ||
"task": "", | ||
"evaluation_score": "" | ||
} |
Oops, something went wrong.