Skip to content

Commit a54f8c8

Browse files
authored
Add custom AAR support to llm-android workflow (#176)
1 parent d80c7bf commit a54f8c8

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

.github/workflows/llm-android.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ on:
3232
description: 'Custom URL for tokenizer file (only used when model_preset is custom)'
3333
required: false
3434
type: string
35+
local_aar:
36+
description: 'URL to download a local AAR file. When set, the workflow will download the AAR and use it instead of the Maven dependency.'
37+
required: false
38+
type: string
3539

3640
permissions:
3741
contents: read
@@ -74,6 +78,12 @@ jobs:
7478
- name: Setup Gradle
7579
uses: gradle/actions/setup-gradle@v4
7680

81+
- name: Download local AAR
82+
if: ${{ inputs.local_aar }}
83+
run: |
84+
mkdir -p llm/android/LlamaDemo/app/libs
85+
curl -fL -o llm/android/LlamaDemo/app/libs/executorch.aar "${{ inputs.local_aar }}"
86+
7787
- name: AVD cache
7888
uses: actions/cache@v4
7989
id: avd-cache
@@ -145,6 +155,7 @@ jobs:
145155
uses: reactivecircus/android-emulator-runner@v2
146156
env:
147157
MODEL_PRESET: ${{ inputs.model_preset || 'stories' }}
158+
USE_LOCAL_AAR: ${{ inputs.local_aar != '' }}
148159
with:
149160
api-level: ${{ env.API_LEVEL }}
150161
arch: ${{ env.ARCH }}
@@ -154,7 +165,7 @@ jobs:
154165
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot-save -memory 16384
155166
disable-animations: true
156167
working-directory: llm/android/LlamaDemo
157-
script: bash ./scripts/run-ci-tests.sh "$MODEL_PRESET" "$MODEL_FILE" "$TOKENIZER_FILE"
168+
script: bash ./scripts/run-ci-tests.sh "$MODEL_PRESET" "$MODEL_FILE" "$TOKENIZER_FILE" "$USE_LOCAL_AAR"
158169

159170
- name: Add model response to summary
160171
if: always()

llm/android/LlamaDemo/scripts/run-ci-tests.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# LICENSE file in the root directory of this source tree.
77

88
# CI test script for running instrumentation tests with pre-downloaded models
9-
# Usage: ./run-ci-tests.sh <model_preset> <model_file> <tokenizer_file>
9+
# Usage: ./run-ci-tests.sh <model_preset> <model_file> <tokenizer_file> [use_local_aar]
1010
#
1111
# This script is designed for CI environments where models are pre-downloaded
1212
# to /tmp/llama_models/ before the emulator starts.
@@ -16,11 +16,13 @@ set -ex
1616
MODEL_PRESET="$1"
1717
MODEL_FILE="$2"
1818
TOKENIZER_FILE="$3"
19+
USE_LOCAL_AAR="${4:-false}"
1920

2021
echo "=== Test Configuration ==="
2122
echo "MODEL_PRESET: $MODEL_PRESET"
2223
echo "MODEL_FILE: $MODEL_FILE"
2324
echo "TOKENIZER_FILE: $TOKENIZER_FILE"
25+
echo "USE_LOCAL_AAR: $USE_LOCAL_AAR"
2426

2527
echo "=== Emulator Memory Info ==="
2628
adb shell cat /proc/meminfo | head -5
@@ -90,9 +92,11 @@ adb logcat > /tmp/logcat.txt &
9092
LOGCAT_PID=$!
9193

9294
echo "=== Starting Gradle ==="
93-
./gradlew connectedCheck \
94-
-PskipModelDownload=true \
95-
-PmodelPreset="$MODEL_PRESET"
95+
GRADLE_ARGS="-PskipModelDownload=true -PmodelPreset=\"$MODEL_PRESET\""
96+
if [ "$USE_LOCAL_AAR" = "true" ]; then
97+
GRADLE_ARGS="$GRADLE_ARGS -PuseLocalAar=true"
98+
fi
99+
eval ./gradlew connectedCheck "$GRADLE_ARGS"
96100
TEST_EXIT_CODE=$?
97101

98102
echo "=== Model directory after Gradle ==="

0 commit comments

Comments
 (0)