-
Notifications
You must be signed in to change notification settings - Fork 29
132 lines (119 loc) · 4.44 KB
/
Copy pathllm-android.yml
File metadata and controls
132 lines (119 loc) · 4.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# 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:
model_preset:
description: 'Model preset to use'
required: true
type: choice
options:
- stories
- llama
- qwen3
- custom
default: 'stories'
custom_pte_url:
description: 'Custom URL for model .pte file (only used when model_preset is custom)'
required: false
type: string
custom_tokenizer_url:
description: 'Custom URL for tokenizer file (only used when model_preset is custom)'
required: false
type: string
permissions:
contents: read
jobs:
instrumentation-test:
runs-on: 8-core-ubuntu
env:
API_LEVEL: 34
ARCH: x86_64
EMULATOR_OPTIONS: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
RAM_SIZE: 16384M
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 }}-ram${{ env.RAM_SIZE }}
- 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: true
ram-size: ${{ env.RAM_SIZE }}
emulator-options: ${{ env.EMULATOR_OPTIONS }}
disable-animations: false
working-directory: llm/android/LlamaDemo
script: echo "Generated AVD snapshot for caching."
- name: Configure AVD RAM
run: |
# Find and update AVD config to set RAM
AVD_DIR="$HOME/.android/avd"
for config in "$AVD_DIR"/*.avd/config.ini; do
if [ -f "$config" ]; then
echo "Updating RAM in $config"
sed -i 's/hw.ramSize=.*/hw.ramSize=16384/' "$config" || true
grep -q "hw.ramSize" "$config" || echo "hw.ramSize=16384" >> "$config"
cat "$config" | grep -E "hw.ramSize|AvdId"
fi
done
- name: Run instrumentation tests
uses: reactivecircus/android-emulator-runner@v2
env:
MODEL_PRESET: ${{ inputs.model_preset || 'stories' }}
CUSTOM_PTE_URL: ${{ inputs.custom_pte_url }}
CUSTOM_TOKENIZER_URL: ${{ inputs.custom_tokenizer_url }}
with:
api-level: ${{ env.API_LEVEL }}
arch: ${{ env.ARCH }}
force-avd-creation: false
ram-size: ${{ env.RAM_SIZE }}
emulator-options: -no-snapshot-save -memory 16384 ${{ env.EMULATOR_OPTIONS }}
disable-animations: true
working-directory: llm/android/LlamaDemo
script: |
adb shell cat /proc/meminfo | head -5
adb shell rm -rf /data/local/tmp/llama
adb shell mkdir -p /data/local/tmp/llama
adb logcat -c && adb logcat > /tmp/logcat.txt &
LOGCAT_PID=$!
if [ "$MODEL_PRESET" = "custom" ]; then GRADLE_ARGS="-PmodelPreset=$MODEL_PRESET -PcustomPteUrl=$CUSTOM_PTE_URL -PcustomTokenizerUrl=$CUSTOM_TOKENIZER_URL"; else GRADLE_ARGS="-PmodelPreset=$MODEL_PRESET"; fi
./gradlew connectedCheck $GRADLE_ARGS; TEST_EXIT_CODE=$?; kill $LOGCAT_PID || true; exit $TEST_EXIT_CODE
- name: Upload logcat
if: always()
uses: actions/upload-artifact@v4
with:
name: logcat
path: /tmp/logcat.txt
retention-days: 7