-
Notifications
You must be signed in to change notification settings - Fork 18
291 lines (286 loc) · 11.6 KB
/
Copy pathllama-cpp-rs-check.yml
File metadata and controls
291 lines (286 loc) · 11.6 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
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
name: Llama Cpp Rs Check
on:
pull_request:
branches:
- main
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions: read-all
jobs:
check:
name: Run tests on llama-cpp-rs
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
# `RUSTFLAGS` replaces .cargo/config.toml rustflags rather than appending,
# so the $ORIGIN rpath that lets directly executed binaries find the
# llama.cpp shared libraries must be repeated here.
RUSTFLAGS: '-C link-arg=-fuse-ld=mold -C link-arg=-Wl,-rpath,$ORIGIN'
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
submodules: recursive
- name: Install Compile Deps
env:
DEBIAN_FRONTEND: noninteractive
run:
sudo apt-get update && sudo apt-get install -y build-essential curl libssl-dev libclang-dev pkg-config cmake git mold
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.11
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Clippy
run: cargo clippy --workspace --all-targets -- -D warnings
# `cargo fmt` on its own rewrites files in the runner and always exits 0,
# so it never gated anything. `--check` reports and fails instead.
- name: Fmt
run: cargo fmt --all -- --check
- name: Test
run: cargo test --workspace --exclude openai-server --exclude llama-jni
- name: sccache stats
run: sccache --show-stats || true
linux:
name: Check that it builds on linux (native)
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
# `RUSTFLAGS` replaces .cargo/config.toml rustflags rather than appending,
# so the $ORIGIN rpath that lets directly executed binaries find the
# llama.cpp shared libraries must be repeated here.
RUSTFLAGS: '-C link-arg=-fuse-ld=mold -C link-arg=-Wl,-rpath,$ORIGIN'
steps:
- name: checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
submodules: recursive
- name: Install Compile Deps
env:
DEBIAN_FRONTEND: noninteractive
run:
sudo apt-get update && sudo apt-get install -y build-essential curl libssl-dev libclang-dev pkg-config cmake git mold
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.11
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build --workspace --all-targets --exclude llama-jni
# `cargo run` and `cargo test` set LD_LIBRARY_PATH to the target directory,
# so they cannot catch a missing rpath — only running the binary directly
# exercises how a user (or a shipped artifact) actually loads the
# llama.cpp shared libraries.
- name: Verify a dynamically linked binary runs without cargo
run: |
output=$(./target/debug/simple --help 2>&1)
echo "$output" | head -5
if echo "$output" | grep -qiE 'error while loading shared libraries|cannot open shared object|no such file or directory'; then
echo "::error::binary could not locate the llama.cpp shared libraries — is the \$ORIGIN rpath still applied?"
exit 1
fi
- name: sccache stats
run: sccache --show-stats || true
package:
# Builds the crate exactly as crates.io would receive it and compiles that
# tree. Nothing else checks the published artifact: the workspace builds
# from the git checkout, which has files the `include` list in
# llama-cpp-sys-4/Cargo.toml does not ship. A llama.cpp bump that starts
# requiring a new file type — `ggml-version.h.in` did, in upstream #28364 —
# breaks the published crate while every other job stays green.
#
# Only llama-cpp-sys-4 can be verified here: llama-cpp-4 depends on it by
# version, so `cargo package` cannot resolve until the sys crate is on
# crates.io.
name: Verify the publishable package builds
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
RUSTFLAGS: '-C link-arg=-fuse-ld=mold -C link-arg=-Wl,-rpath,$ORIGIN'
steps:
- name: checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
submodules: recursive
- name: Install Compile Deps
env:
DEBIAN_FRONTEND: noninteractive
run:
sudo apt-get update && sudo apt-get install -y build-essential curl libssl-dev libclang-dev pkg-config cmake git mold
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.11
- uses: dtolnay/rust-toolchain@stable
# `--allow-dirty` because the submodule checkout leaves the tree dirty in
# CI; the packaging and verification are what matter here, not cleanliness.
- name: cargo package (with verification build)
run: cargo package -p llama-cpp-sys-4 --allow-dirty
- name: sccache stats
run: sccache --show-stats || true
feature-combos:
# Every other job builds the default feature set
# (openmp,mtmd,dynamic-link), so a break under any other combination stays
# hidden until a release tag fires prebuilt-llama.yml.
#
# These jobs *lint* as well as build. `ggml` had accumulated 47 clippy
# warnings precisely because nothing here ever turned the feature on — code
# behind an off-by-default feature is not covered by the default-feature
# jobs, so it drifts silently.
name: Check non-default feature combos (${{ matrix.label }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- label: static + mtmd
features: mtmd
- label: rpc
features: rpc
# Raw ggml tensor/graph API. Off by default, so only this job sees it.
- label: ggml
features: ggml
# Q1 quantization; gates a build-time patch as well as Rust code.
- label: q1
features: q1
# No features at all: static linkage, no mtmd/openmp. The floor every
# other combination builds on.
- label: no-default-features
features: ""
env:
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
# `RUSTFLAGS` replaces .cargo/config.toml rustflags rather than appending,
# so the $ORIGIN rpath that lets directly executed binaries find the
# llama.cpp shared libraries must be repeated here.
RUSTFLAGS: '-C link-arg=-fuse-ld=mold -C link-arg=-Wl,-rpath,$ORIGIN'
steps:
- name: checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
submodules: recursive
- name: Install Compile Deps
env:
DEBIAN_FRONTEND: noninteractive
run:
sudo apt-get update && sudo apt-get install -y build-essential curl libssl-dev libclang-dev pkg-config cmake git mold
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.11
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Build
run: |
if [ -z "${{ matrix.features }}" ]; then
cargo build -p llama-cpp-4 --no-default-features
else
cargo build -p llama-cpp-4 --no-default-features --features ${{ matrix.features }}
fi
# Lint too, not just build. A feature-gated module that compiles can still
# be accumulating warnings nobody sees.
- name: Clippy
run: |
if [ -z "${{ matrix.features }}" ]; then
cargo clippy -p llama-cpp-4 --all-targets --no-default-features -- -D warnings
else
cargo clippy -p llama-cpp-4 --all-targets --no-default-features \
--features ${{ matrix.features }} -- -D warnings
fi
# `ggml` and `q1` carry their own test files, which nothing else runs.
- name: Test
if: matrix.features == 'ggml' || matrix.features == 'q1'
run: cargo test -p llama-cpp-4 --no-default-features --features ${{ matrix.features }}
# examples/rpc is its own workspace (see its Cargo.toml), so no other job
# ever compiles it — which is how it silently went stale.
- name: Build rpc example
if: matrix.features == 'rpc'
run: cargo build --manifest-path examples/rpc/Cargo.toml
- name: sccache stats
run: sccache --show-stats || true
mac:
name: Check that it builds on mac
runs-on: macos-latest
env:
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
steps:
- name: checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
submodules: recursive
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.11
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build --workspace --exclude llama-jni
- name: sccache stats
run: sccache --show-stats || true
windows:
name: Check that it builds on windows
runs-on: windows-latest
env:
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
steps:
- name: checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
submodules: recursive
- name: Ensure patch.exe is discoverable
shell: pwsh
run: |
$gitUsrBin = Join-Path $env:ProgramFiles 'Git\usr\bin'
if (Test-Path $gitUsrBin) {
if (-not ($env:PATH -split ';' | Where-Object { $_ -ieq $gitUsrBin })) {
$gitUsrBin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
}
}
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.11
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build --workspace --exclude llama-jni
- name: Setup Vulkan SDK
uses: ./.github/actions/setup-vulkan-sdk-windows
- name: Build Vulkan
shell: pwsh
run: cargo build --features vulkan
- name: Test
run: cargo test --workspace --exclude openai-server --exclude llama-jni
- name: sccache stats
shell: pwsh
run: sccache --show-stats
llama-cpp-4-integration:
name: llama-cpp-4 integration tests (GGUF)
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
# `RUSTFLAGS` replaces .cargo/config.toml rustflags rather than appending,
# so the $ORIGIN rpath that lets directly executed binaries find the
# llama.cpp shared libraries must be repeated here.
RUSTFLAGS: '-C link-arg=-fuse-ld=mold -C link-arg=-Wl,-rpath,$ORIGIN'
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
submodules: recursive
- name: Install Compile Deps
env:
DEBIAN_FRONTEND: noninteractive
run:
sudo apt-get update && sudo apt-get install -y build-essential curl libssl-dev libclang-dev pkg-config cmake git mold
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.11
- uses: dtolnay/rust-toolchain@stable
- name: Fetch test model
run: ./scripts/fetch-test-model.sh
- name: Integration tests
env:
LLAMA_TEST_MODEL: ${{ github.workspace }}/target/test-models/stories260K.gguf
run: cargo test -p llama-cpp-4 --test test_integration -- --test-threads=1
- name: sccache stats
run: sccache --show-stats || true