Skip to content

Commit

Permalink
Add option to warm up
Browse files Browse the repository at this point in the history
  • Loading branch information
qihqi committed Mar 15, 2024
1 parent 2b9db52 commit c91936b
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions benchmarks/benchmark_serving.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,24 @@ def mock_requests(total_mock_requests: int):
return data


def sample_warmup_requests(requests):
interesting_buckets = [
0,
16,
32,
64,
128,
256,
512,
1024,]

for start, end in zip(interesting_buckets[:-1], interesting_buckets[1:]):
for request in requests:
if start < request.prompt_len <= end:
yield request
break


def main(args: argparse.Namespace):
print(args)
random.seed(args.seed)
Expand All @@ -390,6 +408,23 @@ def main(args: argparse.Namespace):
else:
input_requests = sample_requests(args.dataset, args.num_prompts, tokenizer, args.max_output_length)

if args.warmup_first:
print('Warm up start:' )
warmup_requests = list(sample_warmup_requests(input_requests)) * 2
benchmark_result, request_outputs = asyncio.run(
benchmark(
api_url=api_url,
tokenizer=tokenizer,
input_requests=warmup_requests,
request_rate=args.request_rate,
disable_tqdm=args.disable_tqdm,
session_cache=args.session_cache,
priority=args.priority,
threads=args.threads,
)
)
print('Warm up done')

benchmark_result, request_outputs = asyncio.run(
benchmark(
api_url=api_url,
Expand Down Expand Up @@ -551,6 +586,14 @@ def main(args: argparse.Namespace):
"File path to store request outputs"
),
)
parser.add_argument(
"--warmup-first",
type=bool,
default=False,
help=(
"Whether to send warmup req first"
),
)

args = parser.parse_args()
main(args)

0 comments on commit c91936b

Please sign in to comment.