(args)
| 90 | |
| 91 | |
| 92 | def main(args): |
| 93 | base_url = f"http://{args.host}:{args.port}" |
| 94 | |
| 95 | input_requests = prepare_input_requests(args.num_prompts, args.dataset_name, args.dataset_path) |
| 96 | |
| 97 | if len(args.max_concurrency) != len(args.s_itl_base_model): |
| 98 | raise ValueError("--max_concurrency should be same length as --s_itl_base_model") |
| 99 | |
| 100 | for max_concurrency, s_itl in zip(args.max_concurrency, args.s_itl_base_model): |
| 101 | # Warmup |
| 102 | print("Starting warmup...") |
| 103 | with open(os.devnull, "w") as f: |
| 104 | with contextlib.redirect_stdout(f): |
| 105 | send_one_batch( |
| 106 | base_url, |
| 107 | max_concurrency, |
| 108 | input_requests[0:max_concurrency], |
| 109 | True, |
| 110 | ) |
| 111 | |
| 112 | # Benchmark |
| 113 | record = send_one_batch(base_url, max_concurrency, input_requests, False) |
| 114 | |
| 115 | metric_header = "Speed up" |
| 116 | print("{s:{c}^{n}}".format(s=metric_header, n=50, c="-")) |
| 117 | for draft_token_step in args.draft_token_steps: |
| 118 | speedup = calculate_speedup( |
| 119 | args.acceptance_rate, |
| 120 | draft_token_step, |
| 121 | s_itl, |
| 122 | record["mean_s_itl_ms"], |
| 123 | ) |
| 124 | print("{:<40} {:<10.2f}".format(f"Speed up on {draft_token_step} steps draft", speedup)) |
| 125 | print("=" * 50) |
| 126 | |
| 127 | |
| 128 | if __name__ == "__main__": |
no test coverage detected