-
Notifications
You must be signed in to change notification settings - Fork 8
281 lines (272 loc) · 13.6 KB
/
run_comparative_benchmark.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# Copyright 2023 The OpenXLA Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
# Comparative Benchmarks Workflow.
name: Comparative Benchmarks
on:
# Will only run when manually triggered.
workflow_dispatch:
pull_request:
concurrency:
# A PR number if a pull request and otherwise the commit hash. This cancels
# queued and in-progress runs for the same PR (presubmit) or commit
# (postsubmit).
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true
env:
GCS_DIR: gs://openxla-github-actions-${{ github.event_name == 'pull_request' && 'presubmit' || 'postsubmit' }}-artifacts/${{ github.run_id }}/${{ github.run_attempt }}
jobs:
setup:
runs-on: ubuntu-22.04
outputs:
runner-group: ${{ steps.configure.outputs.runner-group }}
benchmark-gcs-dir: ${{ steps.configure.outputs.benchmark-gcs-dir }}
steps:
- name: "Checking out PR repository"
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
- name: "Configuring CI options"
id: configure
env:
RUNNER_GROUP: ${{ github.event_name == 'pull_request' && 'presubmit' || 'postsubmit' }}
run: |
# Just informative logging. There should only be two commits in the
# history here, but limiting the depth helps when copying from a local
# repo instead of using checkout, e.g. with
# https://github.com/nektos/act where there will be more.
git log --oneline --graph --max-count=3
# Workflow jobs can't access `env` in `runs-on`, so we need to make
# `runner-group` a job output variable.
echo "runner-group=${RUNNER_GROUP}" > "${GITHUB_OUTPUT}"
# For presubmit testing, the result artifacts are uploaded to the
# temporary workflow GCS dir. In postsubmit, the result artifacts are
# uploaded to the comparative benchmark GCS dir.
if [[ "${RUNNER_GROUP}" == "presubmit" ]]; then
BENCHMARK_GCS_DIR="${GCS_DIR}/comparative-benchmark-artifacts"
else
BENCHMARK_GCS_DIR="gs://comparative-benchmark-artifacts/$(date +'%Y-%m-%d').$(date +'%s')"
fi
echo "benchmark-gcs-dir=${BENCHMARK_GCS_DIR}" >> "${GITHUB_OUTPUT}"
build_xla_tools:
needs: setup
runs-on:
- self-hosted # must come first
- runner-group=${{ needs.setup.outputs.runner-group }}
- environment=prod
- cpu
- os-family=Linux
env:
CUDA_VERSION: 11.8
XLA_TOOLS_DIR: xla-tools-dir
BENCHMARK_GCS_DIR: ${{ needs.setup.outputs.benchmark-gcs-dir }}
outputs:
xla-tools-dir: ${{ env.XLA_TOOLS_DIR }}
xla-tools-dir-archive: ${{ steps.archive.outputs.xla-tools-dir-archive }}
xla-tools-dir-gcs-artifact: ${{ steps.upload.outputs.xla-tools-dir-gcs-artifact }}
steps:
- name: "Checking out PR repository"
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
- name: "Building XLA"
run: |
mkdir -p "${XLA_TOOLS_DIR}"
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
"gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:5e42a41cc8a606fef86630863a207d294f2070fd7bbc9c86b48c089a97eb0f89" \
./comparative_benchmark/xla_hlo/build_xla_tools.sh \
"${XLA_TOOLS_DIR}" \
"${CUDA_VERSION}"
- name: "Creating tool dir archive"
id: archive
env:
XLA_TOOLS_DIR_ARCHIVE: ${{ env.XLA_TOOLS_DIR }}.tgz
run: |
tar -zcvf ${XLA_TOOLS_DIR_ARCHIVE} ${XLA_TOOLS_DIR}
echo "xla-tools-dir-archive=${XLA_TOOLS_DIR_ARCHIVE}" >> "${GITHUB_OUTPUT}"
- name: "Uploading tool dir archive"
id: upload
env:
XLA_TOOLS_DIR_ARCHIVE: ${{ steps.archive.outputs.xla-tools-dir-archive }}
XLA_TOOLS_DIR_GCS_ARTIFACT: ${{ env.BENCHMARK_GCS_DIR }}/${{ steps.archive.outputs.xla-tools-dir-archive }}
run: |
gcloud storage cp "${XLA_TOOLS_DIR_ARCHIVE}" "${XLA_TOOLS_DIR_GCS_ARTIFACT}"
echo "xla-tools-dir-gcs-artifact=${XLA_TOOLS_DIR_GCS_ARTIFACT}" >> "${GITHUB_OUTPUT}"
benchmark_on_a2-highgpu-1g:
needs: [setup, build_xla_tools]
timeout-minutes: 1440
runs-on:
- self-hosted # must come first
- runner-group=${{ needs.setup.outputs.runner-group }}
- environment=prod
- machine-type=a2-highgpu-1g
env:
BENCHMARK_GCS_DIR: ${{ needs.setup.outputs.benchmark-gcs-dir }}
RESULTS_DIR: results-dir
TARGET_DEVICE: a2-highgpu-1g
XLA_TOOLS_DIR: ${{ needs.build_xla_tools.outputs.xla-tools-dir }}
XLA_TOOLS_DIR_ARCHIVE: ${{ needs.build_xla_tools.outputs.xla-tools-dir-archive }}
XLA_TOOLS_DIR_GCS_ARTIFACT: ${{ needs.build_xla_tools.outputs.xla-tools-dir-gcs-artifact }}
steps:
- name: "Checking out PR repository"
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
- name: "Setup"
id: setup
run: |
echo "results-gcs-dir=${BENCHMARK_GCS_DIR}/${TARGET_DEVICE}-results" >> "${GITHUB_OUTPUT}"
mkdir "${RESULTS_DIR}"
- name: "Downloading and unpacking XLA tools"
run: |
gcloud storage cp "${XLA_TOOLS_DIR_GCS_ARTIFACT}" "${XLA_TOOLS_DIR_ARCHIVE}"
tar -xvf "${XLA_TOOLS_DIR_ARCHIVE}"
- name: "Benchmarking XLA-HLO:GPU"
env:
XLA_HLO_RESULTS_JSON: xla-hlo.json
RESULTS_GCS_DIR: ${{ steps.setup.outputs.results-gcs-dir }}
run: |
RESULTS_PATH="${RESULTS_DIR}/${XLA_HLO_RESULTS_JSON}"
docker run --gpus all --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
--env "OOBI_XLA_TOOLS_DIR=${XLA_TOOLS_DIR}" \
"gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:5e42a41cc8a606fef86630863a207d294f2070fd7bbc9c86b48c089a97eb0f89" \
./comparative_benchmark/xla_hlo/benchmark_all.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
gcloud storage cp "${RESULTS_PATH}" "${RESULTS_GCS_DIR}/"
- name: "Benchmarking JAX-XLA:GPU"
env:
JAX_XLA_RESULTS_JSON: jax-xla.json
RESULTS_GCS_DIR: ${{ steps.setup.outputs.results-gcs-dir }}
run: |
RESULTS_PATH="${RESULTS_DIR}/${JAX_XLA_RESULTS_JSON}"
docker run --gpus all --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
"gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:5e42a41cc8a606fef86630863a207d294f2070fd7bbc9c86b48c089a97eb0f89" \
./comparative_benchmark/jax/benchmark_xla.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
gcloud storage cp "${RESULTS_PATH}" "${RESULTS_GCS_DIR}/"
# # Disabled due to https://github.com/openxla/openxla-pjrt-plugin/issues/203.
# - name: "Benchmarking JAX-IREE:GPU"
# env:
# JAX_IREE_RESULTS_JSON: jax-iree.json
# RESULTS_GCS_DIR: ${{ steps.setup.outputs.results-gcs-dir }}
# run: |
# RESULTS_PATH="${RESULTS_DIR}/${JAX_IREE_RESULTS_JSON}"
# docker run --gpus all --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
# "gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:5e42a41cc8a606fef86630863a207d294f2070fd7bbc9c86b48c089a97eb0f89" \
# ./comparative_benchmark/jax/benchmark_iree.sh \
# "${TARGET_DEVICE}"\
# "${RESULTS_PATH}"
# gcloud storage cp "${RESULTS_PATH}" "${RESULTS_GCS_DIR}/"
# # Disabled in favor of JAX and reducing maintenance burden.
# - name: "Benchmarking TF-XLA:GPU"
# env:
# TF_XLA_RESULTS_JSON: tf-xla.json
# RESULTS_GCS_DIR: ${{ steps.setup.outputs.results-gcs-dir }}
# run: |
# RESULTS_PATH="${RESULTS_DIR}/${TF_XLA_RESULTS_JSON}"
# docker run --gpus all --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
# "gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:5e42a41cc8a606fef86630863a207d294f2070fd7bbc9c86b48c089a97eb0f89" \
# ./comparative_benchmark/tf_xla/benchmark_all.sh \
# "${TARGET_DEVICE}"\
# "${RESULTS_PATH}"
# gcloud storage cp "${RESULTS_PATH}" "${RESULTS_GCS_DIR}/"
- name: "Benchmarking PT-Inductor:GPU"
env:
PT_INDUCTOR_RESULTS_JSON: pt-inductor.json
RESULTS_GCS_DIR: ${{ steps.setup.outputs.results-gcs-dir }}
run: |
RESULTS_PATH="${RESULTS_DIR}/${PT_INDUCTOR_RESULTS_JSON}"
docker run --gpus all --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
"gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:5e42a41cc8a606fef86630863a207d294f2070fd7bbc9c86b48c089a97eb0f89" \
./comparative_benchmark/pt_inductor/benchmark_all.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
gcloud storage cp "${RESULTS_PATH}" "${RESULTS_GCS_DIR}/"
benchmark_on_c2-standard-60:
needs: [setup, build_xla_tools]
timeout-minutes: 1440
runs-on:
- self-hosted # must come first
- runner-group=${{ needs.setup.outputs.runner-group }}
- environment=prod
- machine-type=c2-standard-60
env:
BENCHMARK_GCS_DIR: ${{ needs.setup.outputs.benchmark-gcs-dir }}
RESULTS_DIR: results-dir
TARGET_DEVICE: c2-standard-60
XLA_TOOLS_DIR: ${{ needs.build_xla_tools.outputs.xla-tools-dir }}
XLA_TOOLS_DIR_ARCHIVE: ${{ needs.build_xla_tools.outputs.xla-tools-dir-archive }}
XLA_TOOLS_DIR_GCS_ARTIFACT: ${{ needs.build_xla_tools.outputs.xla-tools-dir-gcs-artifact }}
steps:
- name: "Checking out PR repository"
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
- name: "Setup"
id: setup
run: |
echo "results-gcs-dir=${BENCHMARK_GCS_DIR}/${TARGET_DEVICE}-results" >> "${GITHUB_OUTPUT}"
mkdir "${RESULTS_DIR}"
- name: "Downloading and unpacking XLA tools"
run: |
gcloud storage cp "${XLA_TOOLS_DIR_GCS_ARTIFACT}" "${XLA_TOOLS_DIR_ARCHIVE}"
tar -xvf "${XLA_TOOLS_DIR_ARCHIVE}"
- name: "Benchmarking XLA-HLO:CPU"
env:
XLA_HLO_RESULTS_JSON: xla-hlo.json
RESULTS_GCS_DIR: ${{ steps.setup.outputs.results-gcs-dir }}
run: |
RESULTS_PATH="${RESULTS_DIR}/${XLA_HLO_RESULTS_JSON}"
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
--env "OOBI_XLA_TOOLS_DIR=${XLA_TOOLS_DIR}" \
"gcr.io/iree-oss/openxla-benchmark/base-python3.10@sha256:245a074284cfed5de60cf06a153e3bcd9a9c42702b6bb66a39bb47ef23b61669" \
./comparative_benchmark/xla_hlo/benchmark_all.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
gcloud storage cp "${RESULTS_PATH}" "${RESULTS_GCS_DIR}/"
- name: "Benchmarking JAX-XLA:CPU"
env:
JAX_XLA_RESULTS_JSON: jax-xla.json
RESULTS_GCS_DIR: ${{ steps.setup.outputs.results-gcs-dir }}
run: |
RESULTS_PATH="${RESULTS_DIR}/${JAX_XLA_RESULTS_JSON}"
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
"gcr.io/iree-oss/openxla-benchmark/base-python3.10@sha256:245a074284cfed5de60cf06a153e3bcd9a9c42702b6bb66a39bb47ef23b61669" \
./comparative_benchmark/jax/benchmark_xla.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
gcloud storage cp "${RESULTS_PATH}" "${RESULTS_GCS_DIR}/"
- name: "Benchmarking JAX-IREE:CPU"
env:
JAX_IREE_RESULTS_JSON: jax-iree.json
RESULTS_GCS_DIR: ${{ steps.setup.outputs.results-gcs-dir }}
run: |
RESULTS_PATH="${RESULTS_DIR}/${JAX_IREE_RESULTS_JSON}"
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
"gcr.io/iree-oss/openxla-benchmark/base-python3.10@sha256:245a074284cfed5de60cf06a153e3bcd9a9c42702b6bb66a39bb47ef23b61669" \
./comparative_benchmark/jax/benchmark_iree.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
gcloud storage cp "${RESULTS_PATH}" "${RESULTS_GCS_DIR}/"
# # Disabled in favor of JAX and reducing maintenance burden.
# - name: "Benchmarking TF-XLA:CPU"
# env:
# TF_XLA_RESULTS_JSON: tf-xla.json
# RESULTS_GCS_DIR: ${{ steps.setup.outputs.results-gcs-dir }}
# run: |
# RESULTS_PATH="${RESULTS_DIR}/${TF_XLA_RESULTS_JSON}"
# docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
# "gcr.io/iree-oss/openxla-benchmark/base-python3.10@sha256:245a074284cfed5de60cf06a153e3bcd9a9c42702b6bb66a39bb47ef23b61669" \
# ./comparative_benchmark/tf_xla/benchmark_all.sh \
# "${TARGET_DEVICE}"\
# "${RESULTS_PATH}"
# gcloud storage cp "${RESULTS_PATH}" "${RESULTS_GCS_DIR}/"
- name: "Benchmarking PT-Inductor:CPU"
env:
PT_INDUCTOR_RESULTS_JSON: pt-inductor.json
RESULTS_GCS_DIR: ${{ steps.setup.outputs.results-gcs-dir }}
run: |
RESULTS_PATH="${RESULTS_DIR}/${PT_INDUCTOR_RESULTS_JSON}"
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
"gcr.io/iree-oss/openxla-benchmark/base-python3.10@sha256:245a074284cfed5de60cf06a153e3bcd9a9c42702b6bb66a39bb47ef23b61669" \
./comparative_benchmark/pt_inductor/benchmark_all.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
gcloud storage cp "${RESULTS_PATH}" "${RESULTS_GCS_DIR}/"