Save the benchmarking results to PyTorch Benchmark Format JSON file
(args: argparse.Namespace, results: dict[str, Any], file_name: str)
| 639 | |
| 640 | |
| 641 | def save_to_pytorch_benchmark_format(args: argparse.Namespace, results: dict[str, Any], file_name: str) -> None: |
| 642 | """Save the benchmarking results to PyTorch Benchmark Format JSON file""" |
| 643 | metrics = [ |
| 644 | "median_ttft_ms", |
| 645 | "mean_ttft_ms", |
| 646 | "std_ttft_ms", |
| 647 | "p99_ttft_ms", |
| 648 | "mean_tpot_ms", |
| 649 | "median_tpot_ms", |
| 650 | "std_tpot_ms", |
| 651 | "p99_tpot_ms", |
| 652 | "median_itl_ms", |
| 653 | "mean_itl_ms", |
| 654 | "std_itl_ms", |
| 655 | "p99_itl_ms", |
| 656 | ] |
| 657 | # These raw data might be useful, but they are rather big. They can be added |
| 658 | # later if needed |
| 659 | ignored_metrics = ["ttfts", "itls", "generated_texts", "errors"] |
| 660 | pt_records = convert_to_pytorch_benchmark_format( |
| 661 | args=args, |
| 662 | metrics={k: [results[k]] for k in metrics}, |
| 663 | extra_info={k: results[k] for k in results if k not in metrics and k not in ignored_metrics}, |
| 664 | ) |
| 665 | if pt_records: |
| 666 | # Don't use json suffix here as we don't want CI to pick it up |
| 667 | pt_file = f"{os.path.splitext(file_name)[0]}.pytorch.json" |
| 668 | write_to_json(pt_file, pt_records) |
| 669 | |
| 670 | |
| 671 | def check_health(api_base_url: str) -> bool: |
no test coverage detected