Tiny improve summary text in bench_one_batch_server.py (#15158)

This commit is contained in:
Liangsheng Yin
2025-12-15 14:59:11 +08:00
committed by GitHub
parent 7b9156c773
commit 372507649d
+38 -29
View File
@@ -25,6 +25,7 @@ from typing import List, Optional, Tuple
import numpy as np import numpy as np
import requests import requests
from pydantic import BaseModel from pydantic import BaseModel
from tabulate import tabulate
from transformers import AutoProcessor, PreTrainedTokenizer from transformers import AutoProcessor, PreTrainedTokenizer
from sglang.bench_serving import ( from sglang.bench_serving import (
@@ -399,17 +400,6 @@ def get_report_summary(
summary = ( summary = (
f"\nInput lens: {bench_args.input_len}. Output lens: {bench_args.output_len}.\n" f"\nInput lens: {bench_args.input_len}. Output lens: {bench_args.output_len}.\n"
) )
summary += "| batch size | input len | latency (s) | input throughput (tok/s) | output throughput (tok/s) | acc length | ITL (ms) | input cost ($/1M) | output cost ($/1M) |"
if bench_args.profile:
summary += " profile |"
summary += "\n"
summary += "| ---------- | --------- | ----------- | ------------------------- | ------------------------- | ---------- | -------- | ----------------- | ------------------ |"
if bench_args.profile:
summary += "-------------|"
summary += "\n"
if is_blackwell(): if is_blackwell():
hourly_cost_per_gpu = 4 # $4/hour for one B200 hourly_cost_per_gpu = 4 # $4/hour for one B200
@@ -419,27 +409,48 @@ def get_report_summary(
# sort result by input_len # sort result by input_len
results.sort(key=lambda x: x.input_len) results.sort(key=lambda x: x.input_len)
rows = []
headers = [
"batch size",
"input len",
"latency (s)",
"input throughput (tok/s)",
"output throughput (tok/s)",
"acc length",
"ITL (ms)",
"input cost ($/1M)",
"output cost ($/1M)",
]
if bench_args.profile:
headers.append("profile")
for res in results: for res in results:
hourly_cost = hourly_cost_per_gpu * server_args.tp_size hourly_cost = hourly_cost_per_gpu * server_args.tp_size
accept_length = round(res.acc_length, 2) if res.acc_length > 0 else "n/a" accept_length = f"{res.acc_length:.2f}" if res.acc_length > 0 else "n/a"
line = ( itl_ms = 1000 * res.batch_size / res.output_throughput
f"| {res.batch_size} | " input_cost = 1e6 / (res.input_throughput * input_util) / 3600 * hourly_cost
f"{res.input_len} | " output_cost = 1e6 / res.output_throughput / 3600 * hourly_cost
f"{res.latency:.2f} | "
f"{res.input_throughput:.2f} | " row = [
f"{res.output_throughput:.2f} | " res.batch_size,
f"{accept_length} | " res.input_len,
f"{1 / (res.output_throughput/res.batch_size) * 1000:.2f} | " f"{res.latency:.2f}",
f"{1e6 / (res.input_throughput * input_util) / 3600 * hourly_cost:.2f} | " f"{res.input_throughput:.2f}",
f"{1e6 / res.output_throughput / 3600 * hourly_cost:.2f} |" f"{res.output_throughput:.2f}",
) accept_length,
f"{itl_ms:.2f}",
f"{input_cost:.2f}",
f"{output_cost:.2f}",
]
if bench_args.profile: if bench_args.profile:
if res.profile_link: if res.profile_link:
line += f" [Profile]({res.profile_link}) |" row.append(f"[Profile]({res.profile_link})")
else: else:
line += f" n/a |" row.append("n/a")
line += "\n" rows.append(row)
summary += line
summary += tabulate(rows, headers=headers, tablefmt="github")
summary += "\n"
return summary return summary
@@ -578,8 +589,6 @@ def run_benchmark(server_args: ServerArgs, bench_args: BenchArgs):
if is_in_ci() and bench_args.append_to_github_summary: if is_in_ci() and bench_args.append_to_github_summary:
write_github_step_summary(summary) write_github_step_summary(summary)
else:
print(summary)
# Save results as pydantic models in the JSON format # Save results as pydantic models in the JSON format
if bench_args.pydantic_result_filename: if bench_args.pydantic_result_filename: