char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Sigbjørn Skjæretci : move more jobs to ccache-buckets (#28375)8b4b3558f

char/aliceai-t5-moe
8.4 KiB287 linesraw
1name: CI (apple)
2
3on:
4  workflow_dispatch: # allows manual triggering
5  push:
6    branches:
7      - master
8    paths: [
9      '.github/workflows/build-apple.yml',
10      '**/CMakeLists.txt',
11      '**/.cmake',
12      '**/*.h',
13      '**/*.hpp',
14      '**/*.c',
15      '**/*.cpp',
16      '**/*.swift',
17      '**/*.m',
18      '**/*.metal'
19    ]
20
21  pull_request:
22    types: [opened, synchronize, reopened]
23    paths: [
24      '.github/workflows/build-apple.yml',
25      'ggml/src/ggml-metal/**',
26      'ggml/src/ggml-rpc/**'
27    ]
28
29concurrency:
30  group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
31  cancel-in-progress: true
32
33env:
34  GGML_NLOOP: 3
35  GGML_N_THREADS: 1
36  LLAMA_ARG_LOG_COLORS: 1
37  LLAMA_ARG_LOG_PREFIX: 1
38  LLAMA_ARG_LOG_TIMESTAMPS: 1
39
40jobs:
41  macos-latest-arm64:
42    runs-on: macos-latest
43
44    steps:
45      - name: Clone
46        id: checkout
47        uses: actions/checkout@v6
48
49      - name: ccache
50        uses: ggml-org/ccache-action@v1.2.24
51        with:
52          key: apple-arm64
53          save: false
54
55      - name: ccache-buckets-restore
56        uses: ./.github/actions/ccache-buckets
57        env:
58          HF_TOKEN: ${{ secrets.HF_TOKEN_CI }}
59        with:
60          key: apple-arm64
61          folder: llama.cpp
62          hf_bucket: ggml-org/cache
63
64      - name: Build
65        id: cmake_build
66        run: |
67          sysctl -a
68          cmake -B build \
69            -DCMAKE_BUILD_RPATH="@loader_path" \
70            -DLLAMA_FATAL_WARNINGS=ON \
71            -DLLAMA_BUILD_BORINGSSL=ON \
72            -DGGML_METAL_EMBED_LIBRARY=OFF \
73            -DGGML_METAL_SHADER_DEBUG=ON \
74            -DGGML_RPC=ON \
75            -DCMAKE_OSX_DEPLOYMENT_TARGET=13.3
76          time cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
77
78      - name: ccache-buckets-save
79        if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
80        uses: ./.github/actions/ccache-buckets
81        env:
82          HF_TOKEN: ${{ secrets.HF_TOKEN_CACHE_OUTPUT }}
83        with:
84          key: apple-arm64
85          folder: llama.cpp
86          evict-old-files: 1d
87          hf_bucket: ggml-org/cache
88          save: true
89
90      - name: Check for leaks
91        run: |
92          cmd=(./build/bin/test-thread-safety -hf ggml-org/gemma-3-270m-qat-GGUF -ngl 99 -p "$(printf 'hello %.0s' {1..128})" -n 16 -c 512 -ub 32 -np 2 -t 2 -lv 1)
93          leaks -atExit -- "${cmd[@]}"
94          # Graphics devices are leaked by Metal in Apple code sometimes, so we ignore those leaks
95          OBJC_DEBUG_MISSING_POOLS=YES "${cmd[@]}" 2>&1 | awk '{ print } index($0, "autoreleased with no pool in place") && !/class [a-zA-Z0-9]+Device autoreleased/ { found = 1 } END { exit found }'
96
97      - name: Test
98        id: cmake_test
99        run: |
100          cd build
101          ctest -L main -E "test-llama-archs" --verbose --timeout 900
102
103  macos-latest-x64:
104    runs-on: macos-15-intel
105
106    steps:
107      - name: Clone
108        id: checkout
109        uses: actions/checkout@v6
110
111      - name: ccache
112        uses: ggml-org/ccache-action@v1.2.24
113        with:
114          key: apple-x64
115          save: false
116
117      - name: ccache-buckets-restore
118        uses: ./.github/actions/ccache-buckets
119        env:
120          HF_TOKEN: ${{ secrets.HF_TOKEN_CI }}
121        with:
122          key: apple-x64
123          folder: llama.cpp
124          hf_bucket: ggml-org/cache
125
126      - name: Build
127        id: cmake_build
128        run: |
129          sysctl -a
130          # Metal is disabled due to intermittent failures with Github runners not having a GPU:
131          # https://github.com/ggml-org/llama.cpp/actions/runs/8635935781/job/23674807267#step:5:2313
132          cmake -B build \
133            -DCMAKE_BUILD_RPATH="@loader_path" \
134            -DLLAMA_FATAL_WARNINGS=ON \
135            -DLLAMA_BUILD_BORINGSSL=ON \
136            -DGGML_METAL=OFF \
137            -DGGML_RPC=ON \
138            -DCMAKE_OSX_DEPLOYMENT_TARGET=13.3
139          time cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
140
141      - name: ccache-buckets-save
142        if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
143        uses: ./.github/actions/ccache-buckets
144        env:
145          HF_TOKEN: ${{ secrets.HF_TOKEN_CACHE_OUTPUT }}
146        with:
147          key: apple-x64
148          folder: llama.cpp
149          evict-old-files: 1d
150          hf_bucket: ggml-org/cache
151          save: true
152
153      - name: Test
154        id: cmake_test
155        run: |
156          cd build
157          ctest -L main --verbose --timeout 900
158
159  macos-latest-ios-xcode:
160    runs-on: macos-latest
161
162    steps:
163      - name: Checkout code
164        uses: actions/checkout@v6
165
166      - name: Setup Xcode
167        uses: ggml-org/setup-xcode@v1
168        with:
169          xcode-version: latest-stable
170
171      - name: Build
172        id: cmake_build
173        run: |
174          sysctl -a
175          cmake -B build -G Xcode \
176            -DGGML_METAL_EMBED_LIBRARY=ON \
177            -DLLAMA_OPENSSL=OFF \
178            -DLLAMA_BUILD_APP=OFF \
179            -DLLAMA_BUILD_EXAMPLES=OFF \
180            -DLLAMA_BUILD_TOOLS=OFF \
181            -DLLAMA_BUILD_TESTS=OFF \
182            -DLLAMA_BUILD_SERVER=OFF \
183            -DCMAKE_SYSTEM_NAME=iOS \
184            -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
185            -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
186          cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
187
188      - name: xcodebuild for swift package
189        id: xcodebuild
190        run: |
191          ./build-xcframework.sh
192
193      - name: Upload xcframework artifact
194        uses: actions/upload-artifact@v6
195        with:
196          name: llama-xcframework
197          path: build-apple/llama.xcframework/
198          retention-days: 1
199
200      - name: Build Xcode project
201        run: |
202          xcodebuild -downloadPlatform iOS
203          xcodebuild -project examples/llama.swiftui/llama.swiftui.xcodeproj -scheme llama.swiftui -sdk iphoneos CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= -destination 'generic/platform=iOS' FRAMEWORK_FOLDER_PATH=./build-ios build
204
205  macos-latest-tvos:
206    runs-on: macos-latest
207
208    steps:
209      - name: Clone
210        id: checkout
211        uses: actions/checkout@v6
212
213      - name: Build
214        id: cmake_build
215        run: |
216          sysctl -a
217          cmake -B build -G Xcode \
218            -DGGML_METAL_EMBED_LIBRARY=ON \
219            -DLLAMA_BUILD_COMMON=OFF \
220            -DLLAMA_BUILD_APP=OFF \
221            -DLLAMA_BUILD_EXAMPLES=OFF \
222            -DLLAMA_BUILD_TOOLS=OFF \
223            -DLLAMA_BUILD_TESTS=OFF \
224            -DLLAMA_BUILD_SERVER=OFF \
225            -DCMAKE_SYSTEM_NAME=tvOS \
226            -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
227            -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
228          cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
229
230  macos-latest-visionos:
231    runs-on: macos-latest
232
233    steps:
234      - name: Clone
235        id: checkout
236        uses: actions/checkout@v6
237
238      - name: Build
239        id: cmake_build
240        run: |
241          sysctl -a
242          cmake -B build -G Xcode \
243            -DGGML_METAL_EMBED_LIBRARY=ON \
244            -DLLAMA_BUILD_COMMON=OFF \
245            -DLLAMA_BUILD_APP=OFF \
246            -DLLAMA_BUILD_EXAMPLES=OFF \
247            -DLLAMA_BUILD_TOOLS=OFF \
248            -DLLAMA_BUILD_TESTS=OFF \
249            -DLLAMA_BUILD_SERVER=OFF \
250            -DCMAKE_SYSTEM_NAME=visionOS \
251            -DCMAKE_OSX_DEPLOYMENT_TARGET=1.0 \
252            -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
253          cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
254
255  macos-latest-swift:
256    runs-on: macos-latest
257    needs: macos-latest-ios-xcode
258
259    strategy:
260      matrix:
261        destination: ['generic/platform=macOS', 'generic/platform=iOS', 'generic/platform=tvOS']
262
263    steps:
264      - name: Clone
265        id: checkout
266        uses: actions/checkout@v6
267
268      - name: Download xcframework artifact
269        uses: actions/download-artifact@v7
270        with:
271          name: llama-xcframework
272          path: build-apple/llama.xcframework/
273
274      - name: Build llama.cpp with CMake
275        id: cmake_build
276        run: |
277          sysctl -a
278          cmake -B build -G Xcode \
279            -DGGML_METAL_EMBED_LIBRARY=ON \
280            -DLLAMA_OPENSSL=OFF \
281            -DLLAMA_BUILD_APP=OFF \
282            -DLLAMA_BUILD_EXAMPLES=OFF \
283            -DLLAMA_BUILD_TOOLS=OFF \
284            -DLLAMA_BUILD_TESTS=OFF \
285            -DLLAMA_BUILD_SERVER=OFF \
286            -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
287          cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)