run-benchmarks.sh 2.9 KB
Newer Older
1
2
#!/bin/bash

Simon Mo's avatar
Simon Mo committed
3
4
5
# This script is run by buildkite to run the benchmarks and upload the results to buildkite

set -ex
Simon Mo's avatar
Simon Mo committed
6
set -o pipefail
Simon Mo's avatar
Simon Mo committed
7
8
9
10

# cd into parent directory of this file
cd "$(dirname "${BASH_SOURCE[0]}")/.."

11
(which wget && which curl) || (apt-get update && apt-get install -y wget curl)
Simon Mo's avatar
Simon Mo committed
12

13
# run python-based benchmarks and upload the result to buildkite
14
python3 benchmarks/benchmark_latency.py --output-json latency_results.json 2>&1 | tee benchmark_latency.txt
15
bench_latency_exit_code=$?
Simon Mo's avatar
Simon Mo committed
16

17
python3 benchmarks/benchmark_throughput.py --input-len 256 --output-len 256 --output-json throughput_results.json 2>&1 | tee benchmark_throughput.txt
18
bench_throughput_exit_code=$?
Simon Mo's avatar
Simon Mo committed
19

20
# run server-based benchmarks and upload the result to buildkite
Simon Mo's avatar
Simon Mo committed
21
22
23
24
25
26
27
python3 -m vllm.entrypoints.openai.api_server --model meta-llama/Llama-2-7b-chat-hf &
server_pid=$!
wget https://huggingface.co/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered/resolve/main/ShareGPT_V3_unfiltered_cleaned_split.json

# wait for server to start, timeout after 600 seconds
timeout 600 bash -c 'until curl localhost:8000/v1/models; do sleep 1; done' || exit 1
python3 benchmarks/benchmark_serving.py \
28
29
30
    --backend vllm \
    --dataset-name sharegpt \
    --dataset-path ./ShareGPT_V3_unfiltered_cleaned_split.json \
Simon Mo's avatar
Simon Mo committed
31
32
33
    --model meta-llama/Llama-2-7b-chat-hf \
    --num-prompts 20 \
    --endpoint /v1/completions \
34
35
36
    --tokenizer meta-llama/Llama-2-7b-chat-hf \
    --save-result \
    2>&1 | tee benchmark_serving.txt
Simon Mo's avatar
Simon Mo committed
37
38
39
bench_serving_exit_code=$?
kill $server_pid

Simon Mo's avatar
Simon Mo committed
40
41
# write the results into a markdown file
echo "### Latency Benchmarks" >> benchmark_results.md
Simon Mo's avatar
Simon Mo committed
42
sed -n '1p' benchmark_latency.txt >> benchmark_results.md # first line
Simon Mo's avatar
Simon Mo committed
43
echo "" >> benchmark_results.md
Simon Mo's avatar
Simon Mo committed
44
45
sed -n '$p' benchmark_latency.txt >> benchmark_results.md # last line

Simon Mo's avatar
Simon Mo committed
46
echo "### Throughput Benchmarks" >> benchmark_results.md
Simon Mo's avatar
Simon Mo committed
47
sed -n '1p' benchmark_throughput.txt >> benchmark_results.md # first line
Simon Mo's avatar
Simon Mo committed
48
echo "" >> benchmark_results.md
Simon Mo's avatar
Simon Mo committed
49
50
51
52
53
sed -n '$p' benchmark_throughput.txt >> benchmark_results.md # last line

echo "### Serving Benchmarks" >> benchmark_results.md
sed -n '1p' benchmark_serving.txt >> benchmark_results.md # first line
echo "" >> benchmark_results.md
54
echo '```' >> benchmark_results.md
55
tail -n 24 benchmark_serving.txt >> benchmark_results.md # last 24 lines
56
echo '```' >> benchmark_results.md
Simon Mo's avatar
Simon Mo committed
57

58
# if the agent binary is not found, skip uploading the results, exit 0
59
if [ ! -f /usr/bin/buildkite-agent ]; then
60
61
62
    exit 0
fi

Simon Mo's avatar
Simon Mo committed
63
# upload the results to buildkite
64
buildkite-agent annotate --style "info" --context "benchmark-results" < benchmark_results.md
65
66
67
68
69
70
71
72
73

# exit with the exit code of the benchmarks
if [ $bench_latency_exit_code -ne 0 ]; then
    exit $bench_latency_exit_code
fi

if [ $bench_throughput_exit_code -ne 0 ]; then
    exit $bench_throughput_exit_code
fi
Simon Mo's avatar
Simon Mo committed
74
75
76
77

if [ $bench_serving_exit_code -ne 0 ]; then
    exit $bench_serving_exit_code
fi
78

79
rm ShareGPT_V3_unfiltered_cleaned_split.json
80
buildkite-agent artifact upload "*.json"