-
Notifications
You must be signed in to change notification settings - Fork 29
134 lines (114 loc) · 4.41 KB
/
Copy pathllm-android.yml
File metadata and controls
134 lines (114 loc) · 4.41 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
133
134
# 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:
pte_url:
description: 'URL to download model .pte file'
required: false
type: string
default: 'https://ossci-android.s3.amazonaws.com/executorch/stories/snapshot-20260114/stories110M.pte'
tokenizer_url:
description: 'URL to download tokenizer file'
required: false
type: string
default: 'https://ossci-android.s3.amazonaws.com/executorch/stories/snapshot-20260114/tokenizer.model'
permissions:
contents: read
env:
# Default URLs for pull_request trigger (workflow_dispatch inputs override these)
DEFAULT_PTE_URL: 'https://ossci-android.s3.amazonaws.com/executorch/stories/snapshot-20260114/stories110M.pte'
DEFAULT_TOKENIZER_URL: 'https://ossci-android.s3.amazonaws.com/executorch/stories/snapshot-20260114/tokenizer.model'
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
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: Download model files
run: |
PTE_URL="${{ inputs.pte_url || env.DEFAULT_PTE_URL }}"
TOKENIZER_URL="${{ inputs.tokenizer_url || env.DEFAULT_TOKENIZER_URL }}"
mkdir -p /tmp/llama-models
echo "Downloading model from $PTE_URL"
curl -fL -o /tmp/llama-models/model.pte "$PTE_URL"
echo "Downloading tokenizer from $TOKENIZER_URL"
curl -fL -o /tmp/llama-models/tokenizer.model "$TOKENIZER_URL"
ls -la /tmp/llama-models/
- 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: 16384M
emulator-options: -no-snapshot-save ${{ env.EMULATOR_OPTIONS }}
disable-animations: true
working-directory: llm/android/LlamaDemo
script: |
adb shell mkdir -p /data/local/tmp/llama/
adb push /tmp/llama-models/model.pte /data/local/tmp/llama/
adb push /tmp/llama-models/tokenizer.model /data/local/tmp/llama/
# Start logcat in background and save to file
adb logcat -c
adb logcat > /tmp/logcat.txt &
LOGCAT_PID=$!
# Run tests
./gradlew connectedCheck -PskipModelDownload=true || TEST_EXIT_CODE=$?
# Stop logcat
kill $LOGCAT_PID || true
# Exit with the test exit code
exit ${TEST_EXIT_CODE:-0}
- name: Upload logcat
if: always()
uses: actions/upload-artifact@v4
with:
name: logcat
path: /tmp/logcat.txt
retention-days: 7