-
Notifications
You must be signed in to change notification settings - Fork 8
344 lines (321 loc) · 12.3 KB
/
ci.yml
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
name: ci
permissions:
contents: read
pull-requests: read
actions: read
env:
VERSION: "${{ github.ref_name }}"
on:
workflow_dispatch: { }
push:
tags:
- "v*.*.*"
branches:
- main
paths-ignore:
- "docs/**"
- "**.md"
- "**.mdx"
- "**.png"
- "**.jpg"
pull_request:
branches:
- main
paths-ignore:
- "docs/**"
- "**.md"
- "**.mdx"
- "**.png"
- "**.jpg"
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
cancel-in-progress: true
jobs:
darwin-metal:
if: ${{ false }}
strategy:
fail-fast: false
matrix:
arch: [ amd64, arm64 ]
# see https://github.com/actions/runner-images?tab=readme-ov-file#available-images,
# https://support.apple.com/en-us/102894.
runs-on: ${{ matrix.arch == 'amd64' && 'macos-13' || 'macos-14' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
- name: Setup XCode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.2'
- name: Setup Cache
timeout-minutes: 5
uses: actions/cache@v3
with:
key: cache-darwin-metal-${{ matrix.arch }}-${{ hashFiles('**/.gitmodules') }}
path: |
${{ github.workspace }}/.cache
- name: Deps
run: |
brew update && brew install ccache
- name: Build
run: |
echo "===== BUILD ====="
mkdir -p ${{ github.workspace }}/.cache
CCACHE_DIR=${{ github.workspace }}/.cache/ccache make -j LLAMA_METAL=1 LLAMA_NO_OPENMP=1 ${{ matrix.arch == 'amd64' && 'CFLAGS="-mfma -mf16c -mavx -mavx2" CXXFLAGS="-mfma -mf16c -mavx -mavx2"' || '' }}
echo "===== RESULT ====="
if [ -f ${{ github.workspace }}/bin/llama-box ]; then
ldd ${{ github.workspace }}/bin/llama-box
else
exit 1
fi
echo "===== PACKAGE ====="
mkdir -p ${{ github.workspace }}/out
zip -j ${{ github.workspace }}/out/llama-box-darwin-${{ matrix.arch }}-metal.zip ${{ github.workspace }}/bin/*
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
path: ${{ github.workspace }}/out/*.zip
name: llama-box-darwin-${{ matrix.arch }}-metal
linux-hip:
if: ${{ false }}
strategy:
fail-fast: false
matrix:
arch: [ amd64 ]
version: [ '6.0.2' ]
runs-on: ubuntu-22.04
steps:
- name: Maximize Space
# see https://github.com/easimon/maximize-build-space/blob/master/action.yml.
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo docker image prune --all --force
- name: Clone
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
- name: Setup Cache
timeout-minutes: 5
uses: actions/cache@v3
with:
key: cache-linux-hip-${{ matrix.arch }}-${{ matrix.version }}-${{ hashFiles('**/.gitmodules') }}
path: |
${{ github.workspace }}/.cache
- name: Setup QEMU
if: ${{ matrix.arch == 'arm64' }}
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:qemu-v7.0.0
platforms: "arm64"
- name: Build
# disable OpenMP to support static linking,
# see https://github.com/ggerganov/llama.cpp/issues/7743#issuecomment-2148342691,
# https://github.com/ggerganov/llama.cpp/issues/7719#issuecomment-2147631216.
# build fat binary,
# see https://github.com/ggerganov/llama.cpp/pull/1087#issuecomment-1682807878,
# https://llvm.org/docs/AMDGPUUsage.html.
env:
GPU_TARGETS: "gfx803 gfx900 gfx906 gfx908 gfx90a gfx940 gfx941 gfx942 gfx1010 gfx1030 gfx1100 gfx1101 gfx1102"
run: |
echo "===== SCRIPT ====="
cat <<EOF > /tmp/entrypoint.sh
#!/bin/bash
apt-get update && apt-get install -y build-essential git libgomp1 ccache
git config --global --add safe.directory /workspace/llama.cpp
make -j LLAMA_HIPBLAS=1 LLAMA_NO_OPENMP=1 ${{ matrix.arch == 'amd64' && 'CFLAGS="-mfma -mf16c -mavx -mavx2" CXXFLAGS="-mfma -mf16c -mavx -mavx2"' || '' }}
EOF
chmod +x /tmp/entrypoint.sh
cat /tmp/entrypoint.sh
echo "===== BUILD ====="
mkdir -p ${{ github.workspace }}/.cache
docker run \
--rm \
--privileged \
--platform linux/${{ matrix.arch }} \
--volume ${{ github.workspace }}:/workspace \
--volume /tmp/entrypoint.sh:/entrypoint.sh \
--entrypoint /entrypoint.sh \
--workdir /workspace \
--env CCACHE_DIR=/workspace/.cache/ccache \
--env CC=/opt/rocm/llvm/bin/clang \
--env CXX=/opt/rocm/llvm/bin/clang++ \
--env GPU_TARGETS="${{ env.GPU_TARGETS }}" \
--env AMDGPU_TARGETS="${{ env.GPU_TARGETS }}" \
rocm/dev-ubuntu-22.04:${{ matrix.version }}-complete
echo "===== RESULT ====="
if [ -f ${{ github.workspace }}/bin/llama-box ]; then
ldd ${{ github.workspace }}/bin/llama-box
else
exit 1
fi
echo "===== PACKAGE ====="
mkdir -p ${{ github.workspace }}/out
zip -j ${{ github.workspace }}/out/llama-box-linux-${{ matrix.arch }}-hip-${{ matrix.version }}.zip ${{ github.workspace }}/bin/*
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
path: ${{ github.workspace }}/out/*.zip
name: llama-box-linux-${{ matrix.arch }}-hip-${{ matrix.version }}
linux-cuda:
if: ${{ false }}
strategy:
fail-fast: false
matrix:
arch: [ amd64 ]
version: [ '12.2.0', '11.7.1' ]
runs-on: ubuntu-22.04
steps:
- name: Maximize Space
# see https://github.com/easimon/maximize-build-space/blob/master/action.yml.
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo docker image prune --all --force
- name: Clone
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
- name: Setup Cache
timeout-minutes: 5
uses: actions/cache@v3
with:
key: cache-linux-cuda-${{ matrix.arch }}-${{ matrix.version }}-${{ hashFiles('**/.gitmodules') }}
path: |
${{ github.workspace }}/.cache
- name: Setup QEMU
if: ${{ matrix.arch == 'arm64' }}
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:qemu-v7.0.0
platforms: "arm64"
- name: Build
# disable OpenMP to support static linking,
# see https://github.com/ggerganov/llama.cpp/issues/7743#issuecomment-2148342691,
# https://github.com/ggerganov/llama.cpp/issues/7719#issuecomment-2147631216.
run: |
echo "===== SCRIPT ====="
cat <<EOF > /tmp/entrypoint.sh
#!/bin/bash
apt-get update && apt-get install -y build-essential git libgomp1 ccache
git config --global --add safe.directory /workspace/llama.cpp
make -j LLAMA_CUDA=1 LLAMA_NO_OPENMP=1 LLAMA_CUDA_FORCE_MMQ=1 ${{ matrix.arch == 'amd64' && 'CFLAGS="-mfma -mf16c -mavx -mavx2" CXXFLAGS="-mfma -mf16c -mavx -mavx2"' || '' }}
EOF
chmod +x /tmp/entrypoint.sh
cat /tmp/entrypoint.sh
echo "===== BUILD ====="
mkdir -p ./.cache
docker run \
--rm \
--privileged \
--platform linux/${{ matrix.arch }} \
--volume ${{ github.workspace }}:/workspace \
--workdir /workspace \
--volume /tmp/entrypoint.sh:/entrypoint.sh \
--entrypoint /entrypoint.sh \
--env CCACHE_DIR=/workspace/.cache/ccache \
--env CUDA_DOCKER_ARCH=all \
nvidia/cuda:${{ matrix.version }}-devel-ubuntu22.04
echo "===== RESULT ====="
if [ -f ${{ github.workspace }}/bin/llama-box ]; then
ldd ${{ github.workspace }}/bin/llama-box
else
exit 1
fi
echo "===== PACKAGE ====="
mkdir -p ${{ github.workspace }}/out
zip -j ${{ github.workspace }}/out/llama-box-linux-${{ matrix.arch }}-cuda-${{ matrix.version }}.zip ${{ github.workspace }}/bin/*
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
path: ${{ github.workspace }}/out/*.zip
name: llama-box-linux-${{ matrix.arch }}-cuda-${{ matrix.version }}
windows-hip:
strategy:
fail-fast: false
matrix:
arch: [ amd64 ]
# see https://www.amd.com/en/developer/resources/rocm-hub/hip-sdk.html.
version: [ '6.0.2' ]
runs-on: windows-2022
steps:
- name: Clone
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
- name: Setup Cache
timeout-minutes: 5
uses: actions/cache@v3
with:
key: cache-windows-hip-${{ matrix.arch }}-${{ matrix.version }}-${{ hashFiles('**/.gitmodules') }}
path: |
${{ github.workspace }}/.cache
- name: Deps
run: |
$ErrorActionPreference = "Stop"
$WarningPreference = 'SilentlyContinue'
$VerbosePreference = 'SilentlyContinue'
$DebugPreference = 'SilentlyContinue'
$ProgressPreference = 'SilentlyContinue'
Write-Host "I install make"
choco install make
Write-Host "I install ccache"
choco install make ccache
Write-Host "I install AMD HIP SDK"
Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-${{ startsWith(matrix.version, '6') && '23.Q4' || '23.Q3' }}-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe"
Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
Write-Host "I configure the PATH environment variable"
$path = $(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | Split-Path | Split-Path)
$newMachinePath = $path + ";" + [System.Environment]::GetEnvironmentVariable("Path","Machine")
[Environment]::SetEnvironmentVariable("Path", $newMachinePath, [System.EnvironmentVariableTarget]::Machine)
$env:Path = $path + ";" + $env:Path
Write-Host "I verify Clang"
clang.exe --version
- name: Build
env:
GPU_TARGETS: "gfx803 gfx900 gfx906 gfx908 gfx90a gfx940 gfx941 gfx942 gfx1010 gfx1030 gfx1100 gfx1101 gfx1102"
run: |
Write-Host "===== BUILD ====="
New-Item -Force -ItemType Directory -Path "${{ github.workspace }}/.cache" -ErrorAction Ignore | Out-Null
$env:CCACHE_DIR = "${{ github.workspace }}/.cache/ccache"
make -j LLAMA_HIPBLAS=1 LLAMA_NO_OPENMP=1 ${{ matrix.arch == 'amd64' && 'CFLAGS="-mfma -mf16c -mavx -mavx2"' || '' }}
Write-Host "===== RESULT ====="
if (Test-Path -Path "${{ github.workspace }}/bin/llama-box.exe") {
llvm-objdump.exe -p "${{ github.workspace }}/bin/llama-box.exe"
} else {
exit 1
}
release:
if: ${{ startsWith(github.ref, 'refs/tags/') }}
permissions:
contents: write
actions: read
id-token: write
runs-on: ubuntu-22.04
needs:
- darwin-metal
- linux-hip
- linux-cuda
steps:
- name: Download Artifact
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/out
merge-multiple: true
- name: Release
uses: softprops/action-gh-release@v1
with:
fail_on_unmatched_files: true
tag_name: "${{ env.VERSION }}"
prerelease: ${{ contains(github.ref, 'rc') }}
files: ${{ github.workspace }}/out/*