Skip to content

Commit a80efd7

Browse files
committed
Use a template for Android test spec
1 parent a64ed1b commit a80efd7

File tree

3 files changed

+37
-76
lines changed

3 files changed

+37
-76
lines changed

.github/workflows/android-perf.yml

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ on:
3030
description: The list of configs used the benchmark
3131
required: false
3232
type: string
33-
test_spec:
34-
description: The test spec to drive the test on AWS devices
35-
required: false
36-
type: string
3733
workflow_call:
3834
inputs:
3935
models:
@@ -60,10 +56,6 @@ on:
6056
description: The list of configs used the benchmark
6157
required: false
6258
type: string
63-
test_spec:
64-
description: The test spec to drive the test on AWS devices
65-
required: false
66-
type: string
6759

6860
concurrency:
6961
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' }}
@@ -125,6 +117,32 @@ jobs:
125117
echo "devices=$(echo "$MAPPED_ARNS_JSON" | jq -c .)" >> $GITHUB_OUTPUT
126118
echo "delegates=$(echo $DELEGATES | jq -Rc 'split(",")')" >> $GITHUB_OUTPUT
127119
120+
- name: Prepare the spec
121+
shell: bash
122+
working-directory: extension/benchmark/android/benchmark
123+
run: |
124+
set -eux
125+
126+
# The model will be exported in the next step to this S3 path
127+
MODEL_PATH="s3://gha-artifacts/${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.delegate }}/model.zip"
128+
# We could write a script to properly use jinja here, but there is only one variable,
129+
# so let's just sed it
130+
sed -i -e 's,{{ model_path }},'"${MODEL_PATH}"',g' android-llm-device-farm-test-spec.yml.j2
131+
cp android-llm-device-farm-test-spec.yml.j2 android-llm-device-farm-test-spec.yml
132+
133+
# Just print the test spec for debugging
134+
cat android-llm-device-farm-test-spec.yml
135+
136+
- name: Upload the spec
137+
uses: seemethere/upload-artifact-s3@v5
138+
with:
139+
s3-bucket: gha-artifacts
140+
s3-prefix: |
141+
${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.delegate }}
142+
retention-days: 1
143+
if-no-files-found: error
144+
path: extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml
145+
128146
export-models:
129147
name: export-models
130148
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
@@ -231,10 +249,7 @@ jobs:
231249
device-pool-arn: ${{ matrix.device }}
232250
android-app-archive: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/minibench/app-debug.apk
233251
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
252+
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 }}
238253

239254
upload-benchmark-results:
240255
needs:

.github/workflows/upload-android-test-specs.yml

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ on:
44
pull_request:
55
paths:
66
- .github/workflows/upload-android-test-specs.yml
7-
- extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml
7+
- extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml.j2
88
push:
99
branches:
1010
- main
1111
paths:
1212
- .github/workflows/upload-android-test-specs.yml
13-
- extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml
13+
- extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml.j2
1414

1515
concurrency:
1616
# NB: This concurency group needs to be different than the one used in android-perf, otherwise
@@ -19,21 +19,6 @@ concurrency:
1919
cancel-in-progress: true
2020

2121
jobs:
22-
upload-android-test-spec-for-validation:
23-
runs-on: linux.2xlarge
24-
steps:
25-
- uses: actions/checkout@v3
26-
27-
- name: Upload the spec as a GitHub artifact for validation
28-
uses: seemethere/upload-artifact-s3@v5
29-
with:
30-
s3-bucket: gha-artifacts
31-
s3-prefix: |
32-
${{ github.repository }}/${{ github.run_id }}/artifacts
33-
retention-days: 1
34-
if-no-files-found: error
35-
path: extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml
36-
3722
validate-android-test-spec:
3823
needs: upload-android-test-spec-for-validation
3924
uses: ./.github/workflows/android-perf.yml
@@ -45,50 +30,3 @@ jobs:
4530
models: stories110M
4631
devices: samsung_galaxy_s22
4732
delegates: xnnpack
48-
test_spec: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/android-llm-device-farm-test-spec.yml
49-
50-
upload-android-test-spec:
51-
needs: validate-android-test-spec
52-
runs-on: ubuntu-22.04
53-
timeout-minutes: 15
54-
permissions:
55-
id-token: write
56-
contents: read
57-
steps:
58-
- uses: actions/checkout@v3
59-
60-
- uses: actions/setup-python@v4
61-
with:
62-
python-version: '3.11'
63-
cache: pip
64-
65-
- name: configure aws credentials
66-
uses: aws-actions/[email protected]
67-
with:
68-
role-to-assume: arn:aws:iam::308535385114:role/gha_executorch_upload-frameworks-android
69-
aws-region: us-east-1
70-
71-
- name: Only push to S3 when running the workflow manually from main branch
72-
if: ${{ github.ref == 'refs/heads/main' }}
73-
shell: bash
74-
run: |
75-
set -eux
76-
echo "UPLOAD_ON_MAIN=1" >> "${GITHUB_ENV}"
77-
78-
- name: Upload the spec to S3 ossci-android bucket
79-
shell: bash
80-
working-directory: extension/benchmark/android/benchmark/
81-
env:
82-
SPEC_FILE: android-llm-device-farm-test-spec.yml
83-
run: |
84-
set -eux
85-
86-
pip install awscli==1.32.18
87-
88-
AWS_CMD="aws s3 cp --dryrun"
89-
if [[ "${UPLOAD_ON_MAIN:-0}" == "1" ]]; then
90-
AWS_CMD="aws s3 cp"
91-
fi
92-
93-
shasum -a 256 "${SPEC_FILE}"
94-
${AWS_CMD} "${SPEC_FILE}" s3://ossci-android/executorch/ --acl public-read

extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml renamed to extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml.j2

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ phases:
88

99
pre_test:
1010
commands:
11+
# Download the model from S3
12+
- aws s3 cp {{ model_path }} model.zip
13+
- unzip model.zip && ls -la
14+
15+
# Copy the extracted model to sdcard
16+
- adb -s $DEVICEFARM_DEVICE_UDID push *.bin /sdcard
17+
- adb -s $DEVICEFARM_DEVICE_UDID push *.pte /sdcard
18+
1119
# Prepare the model and the tokenizer
1220
- adb -s $DEVICEFARM_DEVICE_UDID shell "ls -la /sdcard/"
1321
- adb -s $DEVICEFARM_DEVICE_UDID shell "mkdir -p /data/local/tmp/minibench/"

0 commit comments

Comments
 (0)