Skip to content

Commit dc3a901

Browse files
authored
Merge pull request #28 from pytorch/run-benchmark-all-commits
Add a cron shell script to run all vLLM commits from its main branch
2 parents 3884779 + c5d4409 commit dc3a901

File tree

6 files changed

+180
-3
lines changed

6 files changed

+180
-3
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
output/
22
*.log
33
*.xml
4+
vllm-benchmarks/commit

Diff for: vllm-benchmarks/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ take sometimes.
1111

1212
### vLLM benchmark on PyTorch infra
1313

14+
* Run the benchmark on all vLLM main commits continuously
15+
16+
```
17+
HF_TOKEN=<REDACTED> ./cron.sh
18+
```
19+
1420
* Run the benchmark on the latest commit in a branch, i.e. `main`
1521

1622
```

Diff for: vllm-benchmarks/cron.sh

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
3+
set -eux
4+
5+
pull_vllm() {
6+
# I'm doing the checkout step here so that this script can be run without GHA
7+
if [[ ! -d "vllm" ]]; then
8+
git clone https://github.com/vllm-project/vllm.git
9+
fi
10+
11+
pushd vllm
12+
# Clean up any local changes to the benchmark suite
13+
git checkout .buildkite/nightly-benchmarks/
14+
15+
git checkout main
16+
git fetch origin && git pull origin main
17+
popd
18+
}
19+
20+
run() {
21+
COMMIT=$1
22+
HEAD_BRANCH=main
23+
24+
set +e
25+
./run.sh ${COMMIT}
26+
set -eux
27+
28+
NOT_EXIST=0
29+
30+
S3_PATH="v3/vllm-project/vllm/${HEAD_BRANCH}/${COMMIT}/benchmark_results.json"
31+
aws s3api head-object --bucket ossci-benchmarks --key ${S3_PATH} || NOT_EXIST=1
32+
33+
if [[ ${NOT_EXIST:-0} == "0" ]]; then
34+
echo "${COMMIT}" > commit
35+
echo "Mark ${COMMIT} as the latest commit that has been benchmarked on main"
36+
37+
S3_PATH="last-green-commits/vllm-project/vllm/${HEAD_BRANCH}/commit"
38+
aws s3 cp commit "s3://ossci-benchmarks/${S3_PATH}"
39+
fi
40+
}
41+
42+
run_benchmarks() {
43+
pushd vllm
44+
HEAD_BRANCH=main
45+
HEAD_SHA=$(git rev-parse --verify HEAD)
46+
popd
47+
48+
rm commit || true
49+
# Get the last green commit from S3
50+
S3_PATH="last-green-commits/vllm-project/vllm/${HEAD_BRANCH}/commit"
51+
aws s3 cp "s3://ossci-benchmarks/${S3_PATH}" .
52+
LAST_GREEN_COMMIT=$(cat commit)
53+
54+
if [[ "${LAST_GREEN_COMMIT}" == "${HEAD_SHA}" ]]; then
55+
echo "Skip ${HEAD_BRANCH}/${HEAD_SHA} because all older commits have already been benchmarked"
56+
else
57+
COMMITS=$(python get_commits.py --repo vllm --from-commit ${LAST_GREEN_COMMIT})
58+
echo "${COMMITS}" | while IFS= read -r COMMIT ; do run ${COMMIT} ; done
59+
fi
60+
}
61+
62+
while :
63+
do
64+
pull_vllm
65+
run_benchmarks
66+
sleep 300
67+
done
68+
69+
popd

Diff for: vllm-benchmarks/get_commits.py

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
from typing import Any, List, Optional
5+
from git import Repo
6+
from argparse import Action, ArgumentParser, Namespace
7+
8+
9+
MAX_LOOKBACK = 100
10+
11+
12+
class ValidateDir(Action):
13+
def __call__(
14+
self,
15+
parser: ArgumentParser,
16+
namespace: Namespace,
17+
values: Any,
18+
option_string: Optional[str] = None,
19+
) -> None:
20+
if os.path.isdir(values):
21+
setattr(namespace, self.dest, values)
22+
return
23+
24+
parser.error(f"{values} is not a valid directory")
25+
26+
27+
def parse_args() -> Any:
28+
parser = ArgumentParser("Get the list of commits from a repo")
29+
parser.add_argument(
30+
"--repo",
31+
type=str,
32+
required=True,
33+
action=ValidateDir,
34+
help="the directory that the repo is checked out",
35+
)
36+
parser.add_argument(
37+
"--from-commit",
38+
type=str,
39+
required=True,
40+
help="gather all commits from this commit (exclusive)",
41+
)
42+
parser.add_argument(
43+
"--to-commit",
44+
type=str,
45+
default="",
46+
help="gather all commits to this commit (inclusive)",
47+
)
48+
parser.add_argument(
49+
"--branch",
50+
type=str,
51+
default="main",
52+
help="the target branch",
53+
)
54+
55+
return parser.parse_args()
56+
57+
58+
def get_commits(
59+
repo_dir: str, branch_name: str, from_commit: str, to_commit: str
60+
) -> List[str]:
61+
commits = []
62+
found_to_commit = True if to_commit == "" else False
63+
64+
repo = Repo(repo_dir)
65+
# The commit is sorted where the latest one comes first
66+
for index, commit in enumerate(repo.iter_commits(branch_name)):
67+
if index > MAX_LOOKBACK:
68+
break
69+
70+
if not found_to_commit and str(commit) == to_commit:
71+
found_to_commit = True
72+
73+
if not found_to_commit:
74+
continue
75+
76+
if str(commit) == from_commit:
77+
break
78+
79+
commits.append(commit)
80+
81+
return commits
82+
83+
84+
def main() -> None:
85+
args = parse_args()
86+
for commit in reversed(
87+
get_commits(
88+
args.repo,
89+
args.branch,
90+
args.from_commit,
91+
args.to_commit,
92+
)
93+
):
94+
print(commit)
95+
96+
97+
if __name__ == "__main__":
98+
main()

Diff for: vllm-benchmarks/run.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ setup_vllm() {
2424
fi
2525

2626
pushd vllm
27-
2827
# Clean up any local changes to the benchmark suite
2928
git checkout .buildkite/nightly-benchmarks/
3029

@@ -97,7 +96,7 @@ cleanup
9796
setup_vllm
9897

9998
pushd vllm
100-
export HEAD_BRANCH=$(git rev-parse --abbrev-ref HEAD)
99+
export HEAD_BRANCH=main
101100
export HEAD_SHA=$(git rev-parse --verify HEAD)
102101

103102
S3_PATH="v3/vllm-project/vllm/${HEAD_BRANCH}/${HEAD_SHA}/benchmark_results.json"

Diff for: vllm-benchmarks/upload_benchmark_results.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ def parse_args() -> Any:
7171

7272
def get_git_metadata(vllm_dir: str) -> Tuple[str, str]:
7373
repo = Repo(vllm_dir)
74-
return repo.active_branch.name, repo.head.object.hexsha
74+
try:
75+
return repo.active_branch.name, repo.head.object.hexsha
76+
except TypeError:
77+
# This is a detached HEAD, default the branch to main
78+
return "main", repo.head.object.hexsha
7579

7680

7781
def get_benchmark_metadata(head_branch: str, head_sha: str) -> Dict[str, Any]:

0 commit comments

Comments
 (0)