From 2475175805fe9be7170e7077b35eadb1a1ea0517 Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Wed, 14 Jan 2026 15:52:23 -0800 Subject: [PATCH 1/2] Split LlamaDemo Android workflow into separate file Move LlamaDemo build and instrumentation tests to llm-android.yml with pull_request trigger. Keep android-build.yml for nightly builds of both LlamaDemo and DeepLabV3Demo on schedule only. --- .github/workflows/android-build.yml | 70 ---------------- .github/workflows/llm-android.yml | 124 ++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+), 70 deletions(-) create mode 100644 .github/workflows/llm-android.yml diff --git a/.github/workflows/android-build.yml b/.github/workflows/android-build.yml index c6f77fd00c..e66a839a97 100644 --- a/.github/workflows/android-build.yml +++ b/.github/workflows/android-build.yml @@ -7,8 +7,6 @@ name: Android Build on: - pull_request: - branches: [main] schedule: # Run nightly at midnight UTC - cron: '0 0 * * *' @@ -69,71 +67,3 @@ jobs: name: ${{ matrix.name }}-apk path: ${{ matrix.path }}/app/build/outputs/apk/ if-no-files-found: warn - - instrumentation-test: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - name: LlamaDemo - path: llm/android/LlamaDemo - env: - API_LEVEL: 34 - ARCH: x86_64 - EMULATOR_OPTIONS: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - - name: Instrumentation Test ${{ matrix.name }} - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Enable KVM group perms - run: | - echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules - sudo udevadm control --reload-rules - sudo udevadm trigger --name-match=kvm - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v4 - - - name: AVD cache - uses: actions/cache@v4 - id: avd-cache - with: - path: | - ~/.android/avd/* - ~/.android/adb* - key: avd-${{ env.API_LEVEL }}-${{ env.ARCH }} - - - name: Create AVD and generate snapshot for caching - if: steps.avd-cache.outputs.cache-hit != 'true' - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: ${{ env.API_LEVEL }} - arch: ${{ env.ARCH }} - force-avd-creation: false - ram-size: 16384M - emulator-options: ${{ env.EMULATOR_OPTIONS }} - disable-animations: false - working-directory: ${{ matrix.path }} - script: echo "Generated AVD snapshot for caching." - - - name: Run instrumentation tests - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: ${{ env.API_LEVEL }} - arch: ${{ env.ARCH }} - force-avd-creation: false - ram-size: 6144M - emulator-options: -no-snapshot-save ${{ env.EMULATOR_OPTIONS }} - disable-animations: true - working-directory: ${{ matrix.path }} - script: | - ./gradlew connectedCheck diff --git a/.github/workflows/llm-android.yml b/.github/workflows/llm-android.yml new file mode 100644 index 0000000000..f29c04a32a --- /dev/null +++ b/.github/workflows/llm-android.yml @@ -0,0 +1,124 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +name: LlamaDemo Android + +on: + pull_request: + branches: [main] + paths: + - 'llm/android/**' + - '.github/workflows/llm-android.yml' + workflow_dispatch: + inputs: + local_aar: + description: 'URL to download a local AAR file. When set, the workflow will download the AAR and use it instead of the Maven dependency.' + required: false + type: string + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + name: Build LlamaDemo + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Download local AAR + if: ${{ inputs.local_aar }} + run: | + mkdir -p llm/android/LlamaDemo/app/libs + curl -fL -o llm/android/LlamaDemo/app/libs/executorch.aar "${{ inputs.local_aar }}" + + - name: Build with Gradle + working-directory: llm/android/LlamaDemo + run: | + if [ -n "${{ inputs.local_aar }}" ]; then + ./gradlew build --no-daemon -PuseLocalAar=true + else + ./gradlew build --no-daemon + fi + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: LlamaDemo-apk + path: llm/android/LlamaDemo/app/build/outputs/apk/ + if-no-files-found: warn + + instrumentation-test: + runs-on: ubuntu-latest + env: + API_LEVEL: 34 + ARCH: x86_64 + EMULATOR_OPTIONS: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + + name: Instrumentation Test LlamaDemo + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Enable KVM group perms + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: AVD cache + uses: actions/cache@v4 + id: avd-cache + with: + path: | + ~/.android/avd/* + ~/.android/adb* + key: avd-${{ env.API_LEVEL }}-${{ env.ARCH }} + + - name: Create AVD and generate snapshot for caching + if: steps.avd-cache.outputs.cache-hit != 'true' + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ env.API_LEVEL }} + arch: ${{ env.ARCH }} + force-avd-creation: false + ram-size: 16384M + emulator-options: ${{ env.EMULATOR_OPTIONS }} + disable-animations: false + working-directory: llm/android/LlamaDemo + script: echo "Generated AVD snapshot for caching." + + - name: Run instrumentation tests + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ env.API_LEVEL }} + arch: ${{ env.ARCH }} + force-avd-creation: false + ram-size: 6144M + emulator-options: -no-snapshot-save ${{ env.EMULATOR_OPTIONS }} + disable-animations: true + working-directory: llm/android/LlamaDemo + script: | + ./gradlew connectedCheck From 852cead3ece3af77cfefcf3839bd58cc8c9082a1 Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Wed, 14 Jan 2026 15:53:02 -0800 Subject: [PATCH 2/2] Use metal runner and Qwen3-4B model for LlamaDemo instrumentation tests Switch instrumentation-test job to linux.24xl.spr-metal runner and download Qwen3-4B-INT8-INT4 model and tokenizer from HuggingFace instead of stories model. --- .github/workflows/llm-android.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/llm-android.yml b/.github/workflows/llm-android.yml index f29c04a32a..2d0d7b6a96 100644 --- a/.github/workflows/llm-android.yml +++ b/.github/workflows/llm-android.yml @@ -62,11 +62,13 @@ jobs: if-no-files-found: warn instrumentation-test: - runs-on: ubuntu-latest + runs-on: linux.24xl.spr-metal env: API_LEVEL: 34 ARCH: x86_64 EMULATOR_OPTIONS: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + MODEL_URL: https://huggingface.co/pytorch/Qwen3-4B-INT8-INT4/resolve/main/model.pte + TOKENIZER_URL: https://huggingface.co/pytorch/Qwen3-4B-INT8-INT4/resolve/main/tokenizer.json name: Instrumentation Test LlamaDemo steps: @@ -88,6 +90,12 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 + - name: Download model and tokenizer + run: | + mkdir -p llm/android/LlamaDemo/app/src/androidTest/assets + curl -fL -o llm/android/LlamaDemo/app/src/androidTest/assets/model.pte "${{ env.MODEL_URL }}" + curl -fL -o llm/android/LlamaDemo/app/src/androidTest/assets/tokenizer.json "${{ env.TOKENIZER_URL }}" + - name: AVD cache uses: actions/cache@v4 id: avd-cache