Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/llm-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ on:
description: 'Custom URL for tokenizer file (only used when model_preset is custom)'
required: false
type: string
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
Expand Down Expand Up @@ -74,6 +78,12 @@ jobs:
- 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: AVD cache
uses: actions/cache@v4
id: avd-cache
Expand Down Expand Up @@ -145,6 +155,7 @@ jobs:
uses: reactivecircus/android-emulator-runner@v2
env:
MODEL_PRESET: ${{ inputs.model_preset || 'stories' }}
USE_LOCAL_AAR: ${{ inputs.local_aar != '' }}
with:
api-level: ${{ env.API_LEVEL }}
arch: ${{ env.ARCH }}
Expand All @@ -154,7 +165,7 @@ jobs:
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot-save -memory 16384
disable-animations: true
working-directory: llm/android/LlamaDemo
script: bash ./scripts/run-ci-tests.sh "$MODEL_PRESET" "$MODEL_FILE" "$TOKENIZER_FILE"
script: bash ./scripts/run-ci-tests.sh "$MODEL_PRESET" "$MODEL_FILE" "$TOKENIZER_FILE" "$USE_LOCAL_AAR"

- name: Add model response to summary
if: always()
Expand Down
12 changes: 8 additions & 4 deletions llm/android/LlamaDemo/scripts/run-ci-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# LICENSE file in the root directory of this source tree.

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

echo "=== Test Configuration ==="
echo "MODEL_PRESET: $MODEL_PRESET"
echo "MODEL_FILE: $MODEL_FILE"
echo "TOKENIZER_FILE: $TOKENIZER_FILE"
echo "USE_LOCAL_AAR: $USE_LOCAL_AAR"

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

echo "=== Starting Gradle ==="
./gradlew connectedCheck \
-PskipModelDownload=true \
-PmodelPreset="$MODEL_PRESET"
GRADLE_ARGS="-PskipModelDownload=true -PmodelPreset=\"$MODEL_PRESET\""
if [ "$USE_LOCAL_AAR" = "true" ]; then
GRADLE_ARGS="$GRADLE_ARGS -PuseLocalAar=true"
fi
eval ./gradlew connectedCheck "$GRADLE_ARGS"
TEST_EXIT_CODE=$?

echo "=== Model directory after Gradle ==="
Expand Down