Skip to content

Commit 187a456

Browse files
authored
Enable testing on Snapdragon devices (ggml-org#21051)
* Add the tests that we want to run on external CI * remove extra files * Fixes python issues, reove the deadlock on CI * remove unecessary changes * use override to ty.toml * fix pre-commit and try tests with secret in external repo not upstream * skip if key is unavailable * Fix feedback * switch hexagon to snapdragon * cleanup * fix secrets * remove the copyrights at the top of the files
1 parent 185cbff commit 187a456

11 files changed

Lines changed: 764 additions & 99 deletions

File tree

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: CI (snapdragon)
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
paths:
9+
- '.github/workflows/build-and-test-snapdragon.yml'
10+
- 'ggml/include/ggml-hexagon.h'
11+
- 'ggml/src/ggml-hexagon/**'
12+
- 'docs/backend/snapdragon/**'
13+
- 'scripts/snapdragon/**'
14+
- 'CMakePresets.json'
15+
16+
pull_request:
17+
types: [opened, synchronize, reopened]
18+
paths:
19+
- '.github/workflows/build-and-test-snapdragon.yml'
20+
- 'ggml/include/ggml-hexagon.h'
21+
- 'ggml/src/ggml-hexagon/**'
22+
- 'docs/backend/snapdragon/**'
23+
- 'scripts/snapdragon/**'
24+
- 'CMakePresets.json'
25+
26+
concurrency:
27+
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
28+
cancel-in-progress: true
29+
30+
jobs:
31+
android-ndk-snapdragon:
32+
runs-on: ubuntu-latest
33+
container:
34+
image: 'ghcr.io/snapdragon-toolchain/arm64-android:v0.3'
35+
defaults:
36+
run:
37+
shell: bash
38+
39+
steps:
40+
- name: Clone
41+
uses: actions/checkout@v6
42+
with:
43+
fetch-depth: 0
44+
lfs: false
45+
46+
- name: Build Llama.CPP for Snapdragon Android
47+
id: build_llama_cpp_snapdragon_android
48+
run: |
49+
cp docs/backend/snapdragon/CMakeUserPresets.json .
50+
cmake --preset arm64-android-snapdragon-release -B build
51+
cmake --build build
52+
cmake --install build --prefix pkg-adb/llama.cpp
53+
54+
- name: Upload Llama.CPP Snapdragon Android Build Artifact
55+
if: ${{ always() && steps.build_llama_cpp_snapdragon_android.outcome == 'success' }}
56+
uses: actions/upload-artifact@v6
57+
with:
58+
name: llama-cpp-android-arm64-snapdragon
59+
path: pkg-adb/llama.cpp
60+
61+
check-secret:
62+
runs-on: ubuntu-latest
63+
outputs:
64+
has-key: ${{ steps.check.outputs.has-key }}
65+
steps:
66+
- id: check
67+
run: echo "has-key=${{ secrets.QDC_API_KEY != '' }}" >> "$GITHUB_OUTPUT"
68+
69+
test-snapdragon-qdc:
70+
name: Test on QDC Android Device (${{ matrix.device }})
71+
needs: [android-ndk-snapdragon, check-secret]
72+
if: needs.check-secret.outputs.has-key == 'true'
73+
runs-on: ubuntu-latest
74+
strategy:
75+
fail-fast: false
76+
matrix:
77+
device: [SM8750, SM8650, SM8850]
78+
79+
steps:
80+
- name: Checkout
81+
uses: actions/checkout@v6
82+
83+
- name: Download build artifact
84+
uses: actions/download-artifact@v4
85+
with:
86+
name: llama-cpp-android-arm64-snapdragon
87+
path: pkg-snapdragon/
88+
89+
- name: Set up Python
90+
uses: actions/setup-python@v5
91+
with:
92+
python-version: '3.x'
93+
cache: pip
94+
95+
- name: Install QDC SDK wheel
96+
run: |
97+
curl -fSL -o qdc_sdk.zip https://softwarecenter.qualcomm.com/api/download/software/tools/Qualcomm_Device_Cloud_SDK/All/0.2.3/qualcomm_device_cloud_sdk-0.2.3.zip
98+
unzip qdc_sdk.zip -d qdc_sdk
99+
pip install qdc_sdk/qualcomm_device_cloud_sdk-0.2.3-py3-none-any.whl
100+
101+
- name: Run QDC tests (${{ matrix.device }})
102+
run: |
103+
python scripts/snapdragon/qdc/run_qdc_jobs.py \
104+
--test all \
105+
--pkg-dir pkg-snapdragon/llama.cpp \
106+
--model-url "https://huggingface.co/bartowski/Llama-3.2-1B-Instruct-GGUF/resolve/main/Llama-3.2-1B-Instruct-Q4_0.gguf" \
107+
--device ${{ matrix.device }}
108+
env:
109+
QDC_API_KEY: ${{ secrets.QDC_API_KEY }}
110+
111+
- name: Cleanup
112+
if: always()
113+
run: rm -rf pkg-snapdragon qdc_sdk qdc_sdk.zip

.github/workflows/build-android.yml

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
name: CI (android)
22

33
on:
4-
workflow_dispatch: # allows manual triggering
4+
workflow_dispatch:
55
push:
66
branches:
77
- master
8-
paths: [
9-
'.github/workflows/build-android.yml',
10-
'**/CMakeLists.txt',
11-
'**/.cmake',
12-
'**/*.h',
13-
'**/*.hpp',
14-
'**/*.c',
15-
'**/*.cpp'
16-
]
8+
paths:
9+
- '.github/workflows/build-android.yml'
10+
- '**/CMakeLists.txt'
11+
- '**/.cmake'
12+
- '**/*.h'
13+
- '**/*.hpp'
14+
- '**/*.c'
15+
- '**/*.cpp'
1716

1817
pull_request:
1918
types: [opened, synchronize, reopened]
20-
paths: [
21-
'.github/workflows/build-android.yml',
22-
'examples/llama.android/**'
23-
]
19+
paths:
20+
- '.github/workflows/build-android.yml'
21+
- 'examples/llama.android/**'
2422

2523
concurrency:
2624
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
@@ -67,35 +65,24 @@ jobs:
6765
defaults:
6866
run:
6967
shell: bash
70-
strategy:
71-
matrix:
72-
include:
73-
- build: 'arm64-cpu'
74-
defines: '-D ANDROID_ABI=arm64-v8a -D ANDROID_PLATFORM=android-31 -D CMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake -D GGML_NATIVE=OFF -DGGML_CPU_ARM_ARCH=armv8.5-a+fp16+i8mm -G Ninja -D LLAMA_OPENSSL=OFF -D GGML_OPENMP=OFF'
75-
- build: 'arm64-snapdragon'
76-
defines: '--preset arm64-android-snapdragon-release'
7768

7869
steps:
7970
- name: Clone
80-
id: checkout
8171
uses: actions/checkout@v6
8272
with:
8373
fetch-depth: 0
8474
lfs: false
8575

86-
- name: Build Llama.CPP for Hexagon Android
87-
id: build_llama_cpp_hexagon_android
76+
- name: Build
77+
id: ndk_build
8878
run: |
89-
if [[ "${{ matrix.build }}" == "arm64-snapdragon" ]]; then
90-
cp docs/backend/snapdragon/CMakeUserPresets.json .
91-
fi
92-
cmake ${{ matrix.defines }} -B build
79+
cmake -D ANDROID_ABI=arm64-v8a -D ANDROID_PLATFORM=android-31 -D CMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake -D GGML_NATIVE=OFF -DGGML_CPU_ARM_ARCH=armv8.5-a+fp16+i8mm -G Ninja -D LLAMA_OPENSSL=OFF -D GGML_OPENMP=OFF -B build
9380
cmake --build build
9481
cmake --install build --prefix pkg-adb/llama.cpp
9582
96-
- name: Upload Llama.CPP Hexagon Android Build Artifact
97-
if: ${{ always() && steps.build_llama_cpp_hexagon_android.outcome == 'success' }}
83+
- name: Upload Android Build Artifact
84+
if: ${{ always() && steps.ndk_build.outcome == 'success' }}
9885
uses: actions/upload-artifact@v6
9986
with:
100-
name: llama-cpp-android-${{ matrix.build }}
87+
name: llama-cpp-android-arm64-cpu
10188
path: pkg-adb/llama.cpp

scripts/snapdragon/qdc/readme.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

scripts/snapdragon/qdc/requirements.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ iniconfig==2.1.0
88
outcome==1.3.0.post0
99
packaging==25.0
1010
pluggy==1.6.0
11-
Pygments==2.19.2
1211
PySocks==1.7.1
1312
pytest==8.4.2
14-
pytest-dependency==0.6.0
1513
selenium==4.36.0
16-
setuptools==80.9.0
1714
sniffio==1.3.1
1815
sortedcontainers==2.4.0
1916
tomli==2.3.0

0 commit comments

Comments
 (0)