@@ -3,6 +3,16 @@ name: android-perf
3
3
on :
4
4
schedule :
5
5
- cron : 0 0 * * *
6
+ pull_request :
7
+ paths :
8
+ - .github/workflows/android-perf.yml
9
+ - extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml.j2
10
+ push :
11
+ branches :
12
+ - main
13
+ paths :
14
+ - .github/workflows/android-perf.yml
15
+ - extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml.j2
6
16
# Note: GitHub has an upper limit of 10 inputs
7
17
workflow_dispatch :
8
18
inputs :
30
40
description : The list of configs used the benchmark
31
41
required : false
32
42
type : string
33
- test_spec :
34
- description : The test spec to drive the test on AWS devices
35
- required : false
36
- type : string
37
43
workflow_call :
38
44
inputs :
39
45
models :
60
66
description : The list of configs used the benchmark
61
67
required : false
62
68
type : string
63
- test_spec :
64
- description : The test spec to drive the test on AWS devices
65
- required : false
66
- type : string
67
69
68
70
concurrency :
69
71
group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
84
86
# Separate default values from the workflow dispatch. To ensure defaults are accessible
85
87
# during scheduled runs and to provide flexibility for different defaults between
86
88
# on-demand and periodic benchmarking.
87
- CRON_DEFAULT_MODELS : " stories110M,dl3,mv3,mv2,ic4,ic3,vit"
88
- CRON_DEFAULT_DEVICES : " samsung_galaxy_s22"
89
- CRON_DEFAULT_DELEGATES : " xnnpack,qnn"
89
+ CRON_DEFAULT_MODELS : ${{ github.event_name == 'schedule' && ' stories110M,dl3,mv3,mv2,ic4,ic3,vit' || 'stories110M' }}
90
+ CRON_DEFAULT_DEVICES : samsung_galaxy_s22
91
+ CRON_DEFAULT_DELEGATES : ${{ github.event_name == 'schedule' && ' xnnpack,qnn' || 'xnnpack' }}
90
92
run : |
91
93
set -ex
92
94
MODELS="${{ inputs.models }}"
@@ -125,6 +127,43 @@ jobs:
125
127
echo "devices=$(echo "$MAPPED_ARNS_JSON" | jq -c .)" >> $GITHUB_OUTPUT
126
128
echo "delegates=$(echo $DELEGATES | jq -Rc 'split(",")')" >> $GITHUB_OUTPUT
127
129
130
+ prepare-test-specs :
131
+ runs-on : linux.2xlarge
132
+ needs : set-parameters
133
+ strategy :
134
+ matrix :
135
+ model : ${{ fromJson(needs.set-parameters.outputs.models) }}
136
+ delegate : ${{ fromJson(needs.set-parameters.outputs.delegates) }}
137
+ fail-fast : false
138
+ steps :
139
+ - uses : actions/checkout@v3
140
+
141
+ - name : Prepare the spec
142
+ shell : bash
143
+ working-directory : extension/benchmark/android/benchmark
144
+ run : |
145
+ set -eux
146
+
147
+ # The model will be exported in the next step to this S3 path
148
+ MODEL_PATH="https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.delegate }}/model.zip"
149
+ # We could write a script to properly use jinja here, but there is only one variable,
150
+ # so let's just sed it
151
+ sed -i -e 's,{{ model_path }},'"${MODEL_PATH}"',g' android-llm-device-farm-test-spec.yml.j2
152
+ cp android-llm-device-farm-test-spec.yml.j2 android-llm-device-farm-test-spec.yml
153
+
154
+ # Just print the test spec for debugging
155
+ cat android-llm-device-farm-test-spec.yml
156
+
157
+ - name : Upload the spec
158
+ uses : seemethere/upload-artifact-s3@v5
159
+ with :
160
+ s3-bucket : gha-artifacts
161
+ s3-prefix : |
162
+ ${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.delegate }}
163
+ retention-days : 1
164
+ if-no-files-found : error
165
+ path : extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml
166
+
128
167
export-models :
129
168
name : export-models
130
169
uses : pytorch/test-infra/.github/workflows/linux_job.yml@main
@@ -170,9 +209,18 @@ jobs:
170
209
echo "Unsupported delegate ${{ matrix.delegate }}"
171
210
exit 1
172
211
fi
173
- PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh "${{ matrix.model }}" "${BUILD_MODE}" "${DTYPE}" "${DELEGATE_CONFIG}" "${ARTIFACTS_DIR_NAME}"
212
+ PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh \
213
+ -model "${{ matrix.model }}" \
214
+ -build_tool "${BUILD_MODE}" \
215
+ -dtype "${DTYPE}" \
216
+ -mode "${DELEGATE_CONFIG}" \
217
+ -upload "${ARTIFACTS_DIR_NAME}"
174
218
else
175
- PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh "${{ matrix.model }}" "${BUILD_MODE}" "${{ matrix.delegate }}" "${ARTIFACTS_DIR_NAME}"
219
+ PYTHON_EXECUTABLE=python bash .ci/scripts/test_model.sh \
220
+ "${{ matrix.model }}" \
221
+ "${BUILD_MODE}" \
222
+ "${{ matrix.delegate }}" \
223
+ "${ARTIFACTS_DIR_NAME}"
176
224
fi
177
225
echo "::endgroup::"
178
226
@@ -212,6 +260,7 @@ jobs:
212
260
uses : pytorch/test-infra/.github/workflows/mobile_job.yml@main
213
261
needs :
214
262
- set-parameters
263
+ - prepare-test-specs
215
264
- build-benchmark-app
216
265
- export-models
217
266
strategy :
@@ -231,10 +280,7 @@ jobs:
231
280
device-pool-arn : ${{ matrix.device }}
232
281
android-app-archive : https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/minibench/app-debug.apk
233
282
android-test-archive : https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/minibench/app-debug-androidTest.apk
234
- # NB: Need to set the default spec here so that it works for periodic too
235
- test-spec : ${{ inputs.test_spec || 'https://ossci-android.s3.amazonaws.com/executorch/android-llm-device-farm-test-spec.yml' }}
236
- # Uploaded to S3 from the previous job
237
- extra-data : https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.delegate }}/model.zip
283
+ test-spec : https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.delegate }}/android-llm-device-farm-test-spec.yml
238
284
239
285
upload-benchmark-results :
240
286
needs :
@@ -298,15 +344,25 @@ jobs:
298
344
--workflow-run-attempt ${{ github.run_attempt }}
299
345
done
300
346
301
- ls -lah benchmark-results
302
-
303
- for BENCHMARK_RESULTS in benchmark-results/*.json; do
304
- cat "${BENCHMARK_RESULTS}"
305
- echo
347
+ for SCHEMA in v2 v3; do
348
+ for BENCHMARK_RESULTS in benchmark-results/"${SCHEMA}"/*.json; do
349
+ cat "${BENCHMARK_RESULTS}"
350
+ echo
351
+ done
306
352
done
307
353
308
- - name : Upload the benchmark results
354
+ # TODO (huydhn): Remove v2 schema once the benchmark dashboard finishes the migration
355
+ - name : Upload the benchmark results (v2)
356
+ uses : pytorch/test-infra/.github/actions/upload-benchmark-results@main
357
+ with :
358
+ benchmark-results-dir : benchmark-results/v2
359
+ dry-run : false
360
+ schema-version : v2
361
+
362
+ - name : Upload the benchmark results (v3)
309
363
uses : pytorch/test-infra/.github/actions/upload-benchmark-results@main
310
364
with :
311
- benchmark-results-dir : ' benchmark-results'
365
+ benchmark-results-dir : benchmark-results/v3
312
366
dry-run : false
367
+ schema-version : v3
368
+ github-token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments