-
-
Notifications
You must be signed in to change notification settings - Fork 2
218 lines (206 loc) · 8.15 KB
/
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
name: Benchmark
on:
workflow_dispatch:
inputs:
repository:
type: string
description: name of repository triggers this workflow, e.g. FluxML/NNlib.jl
pr_id:
type: string
description: id of the pull request that triggers this workflow
target_url:
type: string
description: url of target
baseline_url:
type: string
description: url of baseline
enable_gpu:
type: boolean
description: run gpu benchmarks
jobs:
Cache:
runs-on: ubuntu-latest
env:
TARGET_URL: ${{ github.event.inputs.target_url || format('{0}#{1}', github.event.pull_request.head.repo.html_url, github.event.pull_request.head.sha) }}
BASELINE_URL: ${{ github.event.inputs.baseline_url || format('{0}#{1}', github.event.pull_request.base.repo.html_url, github.event.pull_request.base.sha) }}
steps:
- uses: actions/checkout@v3
-
name: Print target&baseline repo url
run: |
echo "Target repo url: $TARGET_URL"
echo "Baseline repo url: $BASELINE_URL"
-
name: Get current time
run: echo "TIME=$(date +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
-
id: restore-cache
uses: actions/cache/restore@v3
with:
path: ~/.julia
key: bm-${{ github.run_id }}-${{ github.run_attempt }}-${{ env.TARGET_URL }}-${{ env.BASELINE_URL }}-${{ env.TIME }}
restore-keys: bm-${{ github.run_id }}-${{ github.run_attempt }}-${{ env.TARGET_URL }}-${{ env.BASELINE_URL }}-${{ env.TIME }}
# cache-matched-key is '' when cache/restore cannot hit cache even used "restore-keys"
- uses: julia-actions/setup-julia@v1
if: ${{ steps.restore-cache.outputs.cache-matched-key == '' }}
- uses: julia-actions/julia-buildpkg@v1
if: ${{ steps.restore-cache.outputs.cache-matched-key == '' }}
-
name: Install dependencies
if: ${{ steps.restore-cache.outputs.cache-matched-key == '' }}
run: |
julia --project=benchmark benchmark/runbenchmarks.jl --cache-setup \
--arch=cpu \
--target=$TARGET_URL --baseline=$BASELINE_URL
-
uses: actions/cache/save@v3
if: ${{ steps.restore-cache.outputs.cache-matched-key == '' }}
with:
path: ~/.julia
key: bm-${{ github.run_id }}-${{ github.run_attempt }}-${{ env.TARGET_URL }}-${{ env.BASELINE_URL }}-${{ env.TIME }}
RunBenchmark:
needs: [Cache]
runs-on: ubuntu-latest
env:
TARGET_URL: ${{ github.event.inputs.target_url || format('{0}#{1}', github.event.pull_request.head.repo.html_url, github.event.pull_request.head.sha) }}
BASELINE_URL: ${{ github.event.inputs.baseline_url || format('{0}#{1}', github.event.pull_request.base.repo.html_url, github.event.pull_request.base.sha) }}
strategy:
matrix:
bm: [
# for test
#"nnlib(attention,activations,gemm)", "nnlib(conv)",
#"nnlib(pooling,softmax)", "nnlib(dropout,upsample)",
"flux"
]
steps:
-
name: Print target&baseline repo url
run: |
echo "Target repo url: $TARGET_URL"
echo "Baseline repo url: $BASELINE_URL"
-
name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- run: |
git fetch origin benchmark-tuning:benchmark-tuning
git fetch origin benchmark-results:benchmark-results
-
name: Setup julia
uses: julia-actions/setup-julia@v1
-
name: Restore cache
uses: actions/cache@v3
with:
path: ~/.julia
# This "key" is required, but the time of this job is definitely different from "Cache" job.
# Therefore cache cannot be hit. So this is a fake key.
key: bm-${{ github.run_id }}-${{ github.run_attempt }}-${{ env.TARGET_URL }}-${{ env.BASELINE_URL }}-
restore-keys: |
bm-${{ github.run_id }}-${{ github.run_attempt }}-${{ env.TARGET_URL }}-${{ env.BASELINE_URL }}-
bm-${{ github.run_id }}-${{ github.run_attempt }}-
-
name: Build pkg
uses: julia-actions/julia-buildpkg@v1
-
id: benchmark
name: Run benchmark
run: |
julia --project=benchmark benchmark/runbenchmarks.jl --pr \
--arch=cpu \
--target=$TARGET_URL --baseline=$BASELINE_URL \
--enable="${{ matrix.bm }}" \
--fetch-result
-
name: Print report
run: |
cat benchmark/report.md
-
name: Upload report
uses: actions/upload-artifact@v3
with:
name: fluxml-benchmark-result-${{ matrix.bm }}
path: |
benchmark/result-baseline.json
benchmark/result-target.json
MergeReport:
needs: [RunBenchmark]
if: ${{ github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
env:
TARGET_URL: ${{ github.event.inputs.target_url || format('{0}#{1}', github.event.pull_request.head.repo.html_url, github.event.pull_request.head.sha) }}
BASELINE_URL: ${{ github.event.inputs.baseline_url || format('{0}#{1}', github.event.pull_request.base.repo.html_url, github.event.pull_request.base.sha) }}
steps:
- uses: actions/checkout@v3
-
name: Download all reports
uses: actions/download-artifact@v3
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/julia-buildpkg@v1
-
name: Merge reports
run: |
julia --project=benchmark benchmark/runbenchmarks.jl --merge-reports \
--arch=cpu \
--target=$TARGET_URL --baseline=$BASELINE_URL \
--push-result --push-password=${{ github.token }}
-
name: Upload final report
uses: actions/upload-artifact@v3
with:
name: final-report
path: benchmark/report.md
Comment:
needs: [MergeReport]
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.repository != '' && github.event.inputs.pr_id != '' }}
runs-on: ubuntu-latest
steps:
-
name: Download report
uses: actions/download-artifact@v3
with:
name: final-report
-
name: Get app token
id: get-app-token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.BENCH_APP_ID }}
installation_id: ${{ secrets.BENCH_INSTALL_ID }}
private_key: ${{ secrets.BENCH_PRIVATE_KEY }}
-
name: Comment
uses: peter-evans/create-or-update-comment@v2
with:
repository: ${{ github.event.inputs.repository }}
issue-number: ${{ github.event.inputs.pr_id }}
token: ${{ steps.get-app-token.outputs.token }}
body-file: report.md
DryPrint:
needs: [MergeReport]
if: ${{ github.event.inputs.repository == '' || github.event.inputs.pr_id == '' }}
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: final-report
- run: |
cat report.md
GPU:
if: ${{ github.event.inputs.enable_gpu && github.event.inputs.target_url != '' && github.event.inputs.baseline_url != '' }}
runs-on: ubuntu-latest
env:
REPOSITORY: ${{ github.event.inputs.repository }}
PR_ID: ${{ github.event.inputs.pr_id || github.event.pull_request.number }}
TARGET_URL: ${{ github.event.inputs.target_url || format('{0}#{1}', github.event.pull_request.head.repo.html_url, github.event.pull_request.head.sha) }}
BASELINE_URL: ${{ github.event.inputs.baseline_url || format('{0}#{1}', github.event.pull_request.base.repo.html_url, github.event.pull_request.base.sha) }}
steps:
- uses: buildkite/[email protected]
with:
buildkite-token: ${{ secrets.BENCH_BK_API_KEY }}
pipeline: julialang/fluxmlbenchmarks-dot-jl
branch: main
message: ":github: Triggered from a GitHub Action"
build-env-vars: '{ "TARGET_URL": "${{ env.TARGET_URL }}", "BASELINE_URL": "${{ env.BASELINE_URL}}", "REPOSITORY": "${{ env.REPOSITORY }}", "PR_ID": "${{ env.PR_ID }}" }'
ignore-pipeline-branch-filter: true