Skip to content

Commit 3df1cc9

Browse files
spzalafacebook-github-bot
authored andcommitted
Add test runner on ibm cloud (#1755)
Summary: Add test runner on ibm cloud. Ref # #1545 Pull Request resolved: #1755 Reviewed By: FindHao Differential Revision: D47305250 Pulled By: xuzhao9 fbshipit-source-id: 451b578ddaa57a0718e817e0c53ec9b60919db04
1 parent 02ff72b commit 3df1cc9

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: TorchBench Userbenchmark test on IBM Cloud
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
userbenchmark_name:
6+
description: "Name of the user benchmark to run"
7+
userbenchmark_options:
8+
description: "Option of the user benchmark to run"
9+
env:
10+
PLATFORM_NAME: "ibm_cloud"
11+
TORCHBENCH_USERBENCHMARK_SCRIBE_GRAPHQL_ACCESS_TOKEN: ${{ secrets.TORCHBENCH_USERBENCHMARK_SCRIBE_GRAPHQL_ACCESS_TOKEN }}
12+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
13+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
14+
CONDA_ENV: "torchbench"
15+
DOCKER_IMAGE: "ghcr.io/pytorch/torchbench:latest"
16+
SETUP_SCRIPT: "/workspace/setup_instance.sh"
17+
jobs:
18+
run-userbenchmark:
19+
runs-on: [self-hosted, testrunner1545]
20+
timeout-minutes: 1440 # 24 hours
21+
steps:
22+
- name: Checkout TorchBench
23+
uses: actions/checkout@v3
24+
with:
25+
path: benchmark
26+
- name: Install Conda
27+
run: |
28+
cd benchmark
29+
bash scripts/install_conda.sh
30+
- name: Pull docker image
31+
uses: pytorch/test-infra/.github/actions/pull-docker-image@main
32+
with:
33+
docker-image: ${{ env.DOCKER_IMAGE }}
34+
- name: Run Docker Image
35+
run: |
36+
CONTAINER_ID=$(docker run \
37+
-e CONDA_ENV \
38+
-e SETUP_SCRIPT \
39+
--tty \
40+
--detach \
41+
-v "${PWD}/benchmark:/benchmark" \
42+
-w / \
43+
"${{ env.DOCKER_IMAGE }}" \
44+
tail -f /dev/null
45+
)
46+
echo "Container ID: ${CONTAINER_ID}"
47+
# Write the CONTAINER_ID to GITHUB_ENV
48+
echo "CONTAINER_ID=${CONTAINER_ID}" >> "${GITHUB_ENV}"
49+
- name: Install TorchBench
50+
run: |
51+
docker exec -t -w "/benchmark" "${CONTAINER_ID}" bash /benchmark/scripts/torchbench_install.sh
52+
- name: Run user benchmark
53+
run: |
54+
# remove old results
55+
if [ -d benchmark-output ]; then rm -Rf benchmark-output; fi
56+
pushd benchmark
57+
if [ -d .userbenchmark ]; then rm -Rf .userbenchmark; fi
58+
# Run userbenchmark
59+
MANUAL_WORKFLOW="${{ github.event.inputs.userbenchmark_name }}"
60+
if [ -z "${MANUAL_WORKFLOW}" ]; then
61+
# Figure out what userbenchmarks we should run, and run it
62+
docker exec -t -w "/benchmark" "${CONTAINER_ID}" bash -c ". ${SETUP_SCRIPT} && conda activate ${CONDA_ENV} && \
63+
python .github/scripts/userbenchmark/schedule-benchmarks.py --platform ${PLATFORM_NAME}"
64+
if [ -d ./.userbenchmark ]; then
65+
cp -r ./.userbenchmark ../benchmark-output
66+
else
67+
mkdir ../benchmark-output
68+
fi
69+
else
70+
docker exec -t -w "/benchmark" "${CONTAINER_ID}" bash -c ". ${SETUP_SCRIPT} && conda activate ${CONDA_ENV} && \
71+
python run_benchmark.py \
72+
\"${{ github.event.inputs.userbenchmark_name }}\" ${{ github.event.inputs.userbenchmark_options }}"
73+
cp -r ./.userbenchmark/"${{ github.event.inputs.userbenchmark_name }}" ../benchmark-output
74+
fi
75+
- name: Upload result jsons to Scribe
76+
run: |
77+
pushd benchmark
78+
. scripts/activate_conda.sh
79+
RESULTS=($(find ${PWD}/../benchmark-output -name "metrics-*.json" -maxdepth 2 | sort -r))
80+
echo "Uploading result jsons: ${RESULTS}"
81+
for r in ${RESULTS[@]}; do
82+
python ./scripts/userbenchmark/upload_scribe.py --userbenchmark_json "${r}" --userbenchmark_platform "${PLATFORM_NAME}"
83+
python ./scripts/userbenchmark/upload_s3.py --upload-file "${r}" --userbenchmark_platform "${PLATFORM_NAME}"
84+
done
85+
- name: Upload artifact
86+
uses: actions/upload-artifact@v3
87+
with:
88+
name: TorchBench result
89+
path: benchmark-output/
90+
- name: Teardown Linux
91+
uses: pytorch/test-infra/.github/actions/teardown-linux@main
92+
if: always()
93+
94+
concurrency:
95+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
96+
cancel-in-progress: true

0 commit comments

Comments
 (0)