Save the benchmarking results to PyTorch Benchmark Format JSON file
(args: argparse.Namespace, results: dict[str, Any], file_name: str)
| 1011 | |
| 1012 | |
| 1013 | def save_to_pytorch_benchmark_format(args: argparse.Namespace, results: dict[str, Any], file_name: str) -> None: |
| 1014 | """Save the benchmarking results to PyTorch Benchmark Format JSON file""" |
| 1015 | metrics = [ |
| 1016 | "median_ttft_ms", |
| 1017 | "mean_ttft_ms", |
| 1018 | "std_ttft_ms", |
| 1019 | "p99_ttft_ms", |
| 1020 | "mean_tpot_ms", |
| 1021 | "median_tpot_ms", |
| 1022 | "std_tpot_ms", |
| 1023 | "p99_tpot_ms", |
| 1024 | "median_itl_ms", |
| 1025 | "mean_itl_ms", |
| 1026 | "std_itl_ms", |
| 1027 | "p99_itl_ms", |
| 1028 | ] |
| 1029 | # These raw data might be useful, but they are rather big. They can be added |
| 1030 | # later if needed |
| 1031 | ignored_metrics = ["ttfts", "itls", "generated_texts", "errors"] |
| 1032 | pt_records = convert_to_pytorch_benchmark_format( |
| 1033 | args=args, |
| 1034 | metrics={k: [results[k]] for k in metrics}, |
| 1035 | extra_info={k: results[k] for k in results if k not in metrics and k not in ignored_metrics}, |
| 1036 | ) |
| 1037 | if pt_records: |
| 1038 | # Don't use json suffix here as we don't want CI to pick it up |
| 1039 | pt_file = f"{os.path.splitext(file_name)[0]}.pytorch.json" |
| 1040 | write_to_json(pt_file, pt_records) |
| 1041 | |
| 1042 | |
| 1043 | def main(args: argparse.Namespace): |
no test coverage detected