@@ -3,6 +3,16 @@ name: android-perf
33on :
44 schedule :
55 - 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
616 # Note: GitHub has an upper limit of 10 inputs
717 workflow_dispatch :
818 inputs :
3040 description : The list of configs used the benchmark
3141 required : false
3242 type : string
33- test_spec :
34- description : The test spec to drive the test on AWS devices
35- required : false
36- type : string
3743 workflow_call :
3844 inputs :
3945 models :
6066 description : The list of configs used the benchmark
6167 required : false
6268 type : string
63- test_spec :
64- description : The test spec to drive the test on AWS devices
65- required : false
66- type : string
6769
6870concurrency :
6971 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' }}
8486 # Separate default values from the workflow dispatch. To ensure defaults are accessible
8587 # during scheduled runs and to provide flexibility for different defaults between
8688 # 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' }}
9092 run : |
9193 set -ex
9294 MODELS="${{ inputs.models }}"
@@ -125,6 +127,43 @@ jobs:
125127 echo "devices=$(echo "$MAPPED_ARNS_JSON" | jq -c .)" >> $GITHUB_OUTPUT
126128 echo "delegates=$(echo $DELEGATES | jq -Rc 'split(",")')" >> $GITHUB_OUTPUT
127129
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+
128167 export-models :
129168 name : export-models
130169 uses : pytorch/test-infra/.github/workflows/linux_job.yml@main
@@ -170,9 +209,18 @@ jobs:
170209 echo "Unsupported delegate ${{ matrix.delegate }}"
171210 exit 1
172211 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}"
174218 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}"
176224 fi
177225 echo "::endgroup::"
178226
@@ -212,6 +260,7 @@ jobs:
212260 uses : pytorch/test-infra/.github/workflows/mobile_job.yml@main
213261 needs :
214262 - set-parameters
263+ - prepare-test-specs
215264 - build-benchmark-app
216265 - export-models
217266 strategy :
@@ -231,10 +280,7 @@ jobs:
231280 device-pool-arn : ${{ matrix.device }}
232281 android-app-archive : https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/minibench/app-debug.apk
233282 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
238284
239285 upload-benchmark-results :
240286 needs :
0 commit comments