Skip to content

Commit cd248b4

Browse files
huydhnfacebook-github-bot
authored andcommitted
Run LlamaDemo app on AWS Device Farm (#3004)
Summary: This upload the built LlamaDemo app to S3 and use them to run the test on Device Farm Pull Request resolved: #3004 Reviewed By: kirklandsign Differential Revision: D56073767 Pulled By: huydhn fbshipit-source-id: 088a1af2463f035dcc8b06ec96d83162746f2df1
1 parent 17c64a3 commit cd248b4

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

.github/workflows/android.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
submodules: 'true'
3434
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
3535
timeout: 90
36+
upload-artifact: android-apps
3637
script: |
3738
set -eux
3839
@@ -45,3 +46,62 @@ jobs:
4546
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
4647
# Build Android demo app
4748
bash build/test_android_ci.sh
49+
50+
mkdir -p artifacts-to-be-uploaded
51+
# Copy the app and its test suite to S3
52+
cp examples/demo-apps/android/LlamaDemo/app/build/outputs/apk/debug/*.apk artifacts-to-be-uploaded/
53+
cp examples/demo-apps/android/LlamaDemo/app/build/outputs/apk/androidTest/debug/*.apk artifacts-to-be-uploaded/
54+
# Also copy the share libraries
55+
cp cmake-out-android/lib/*.a artifacts-to-be-uploaded/
56+
57+
# Upload the app and its test suite to S3 so that they can be downloaded by the test job
58+
upload-artifacts:
59+
needs: test-demo-android
60+
runs-on: linux.2xlarge
61+
steps:
62+
- name: Download the artifacts
63+
uses: actions/download-artifact@v3
64+
with:
65+
# The name here needs to match the name of the upload-artifact parameter
66+
name: android-apps
67+
path: ${{ runner.temp }}/artifacts/
68+
69+
- name: Verify the artifacts
70+
shell: bash
71+
working-directory: ${{ runner.temp }}/artifacts/
72+
run: |
73+
ls -lah ./
74+
75+
- name: Upload the artifacts to S3
76+
uses: seemethere/upload-artifact-s3@v5
77+
with:
78+
s3-bucket: gha-artifacts
79+
s3-prefix: |
80+
${{ github.repository }}/${{ github.run_id }}/artifact
81+
retention-days: 14
82+
if-no-files-found: ignore
83+
path: ${{ runner.temp }}/artifacts/
84+
85+
# Let's see how expensive this job is, we might want to tone it down by running it periodically
86+
test-llama-app:
87+
needs: upload-artifacts
88+
permissions:
89+
id-token: write
90+
contents: read
91+
uses: pytorch/test-infra/.github/workflows/mobile_job.yml@main
92+
with:
93+
device-type: android
94+
runner: ubuntu-latest
95+
test-infra-ref: ''
96+
# This is the ARN of ExecuTorch project on AWS
97+
project-arn: arn:aws:devicefarm:us-west-2:308535385114:project:02a2cf0f-6d9b-45ee-ba1a-a086587469e6
98+
# This is the custom Android device pool that only includes Samsung Galaxy S2x
99+
device-pool-arn: arn:aws:devicefarm:us-west-2:308535385114:devicepool:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/e59f866a-30aa-4aa1-87b7-4510e5820dfa
100+
# Uploaded to S3 from the previous job, the name of the app comes from the project itself
101+
android-app-archive: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifact/app-debug.apk
102+
android-test-archive: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifact/app-debug-androidTest.apk
103+
# The test spec can be downloaded from https://ossci-assets.s3.amazonaws.com/android-llama2-device-farm-test-spec.yml
104+
test-spec: arn:aws:devicefarm:us-west-2:308535385114:upload:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/414cb54d-4d83-4576-8317-93244e4dc50e
105+
# The exported llama2 model and its tokenizer, can be downloaded from https://ossci-assets.s3.amazonaws.com/executorch-android-llama2-7b.zip.
106+
# Among the input, this is the biggest file and uploading it to AWS beforehand makes the test run much faster
107+
extra-data: arn:aws:devicefarm:us-west-2:308535385114:upload:02a2cf0f-6d9b-45ee-ba1a-a086587469e6/bd15825b-ddab-4e47-9fef-a9c8935778dd

build/test_android_ci.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ build_android_llama_demo_app() {
3232
pushd examples/demo-apps/android/LlamaDemo
3333
ANDROID_NDK=/opt/ndk ANDROID_ABI=arm64-v8a ./gradlew setup
3434
ANDROID_HOME=/opt/android/sdk ./gradlew build
35+
ANDROID_HOME=/opt/android/sdk ./gradlew assembleAndroidTest
3536
popd
3637
}
3738

examples/demo-apps/android/LlamaDemo/app/src/androidTest/java/com/example/executorchllamademo/PerfTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class PerfTest implements LlamaCallback {
2828
private static final String TOKENIZER_BIN = "tokenizer.bin";
2929

3030
// From https://github.com/pytorch/executorch/blob/main/examples/models/llama2/README.md
31-
private static final Float EXPECTED_TPS = 7.0F;
31+
private static final Float EXPECTED_TPS = 10.0F;
3232

3333
private final List<String> results = new ArrayList<>();
3434
private final List<Float> tokensPerSecond = new ArrayList<>();

0 commit comments

Comments
 (0)