Skip to content

Commit 9c20f87

Browse files
authored
Merge pull request #65 from evilsocket/copilot/add-ci-matrix-cuda-vulkan-metal-rocm
ci: add GPU backend test matrix and transform all builds into test jobs
2 parents 787215f + 56d255b commit 9c20f87

3 files changed

Lines changed: 120 additions & 29 deletions

File tree

.github/workflows/ci.yml

Lines changed: 107 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ jobs:
4747
- name: Protocol tests
4848
run: cargo test -p cake-core --test protocol
4949

50-
build-android:
51-
name: Build (Android aarch64)
50+
test-android:
51+
name: Test (Android aarch64)
5252
runs-on: ubuntu-latest
5353
permissions:
5454
contents: read
@@ -101,23 +101,17 @@ jobs:
101101
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
102102
run: cargo ndk -t aarch64-linux-android clippy -p cake-core --lib --no-default-features --features "llama,qwen2,qwen3_5" -p cake-mobile -- -D warnings
103103

104-
- name: Compile tests (cake-core lib, Android)
105-
env:
106-
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
107-
run: cargo ndk -t aarch64-linux-android test -p cake-core --lib --no-default-features --features "llama,qwen2,qwen3_5,qwen3,qwen3_moe,qwen3_5_moe,phi4,mistral,gemma3,falcon3,olmo2,exaone4,flux,vibevoice,luxtts" --no-run
104+
- name: Unit tests (cake-core lib)
105+
run: cargo test -p cake-core --lib
108106

109-
- name: Compile tests (cake-core unit, Android)
110-
env:
111-
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
112-
run: cargo ndk -t aarch64-linux-android test -p cake-core --test unit --no-default-features --features "llama,qwen2,qwen3_5,qwen3,qwen3_moe,qwen3_5_moe,phi4,mistral,gemma3,falcon3,olmo2,exaone4,flux,vibevoice,luxtts" --no-run
107+
- name: Unit tests (cake-core external)
108+
run: cargo test -p cake-core --test unit
113109

114-
- name: Compile tests (cake-core protocol, Android)
115-
env:
116-
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
117-
run: cargo ndk -t aarch64-linux-android test -p cake-core --test protocol --no-default-features --features "llama,qwen2,qwen3_5,qwen3,qwen3_moe,qwen3_5_moe,phi4,mistral,gemma3,falcon3,olmo2,exaone4,flux,vibevoice,luxtts" --no-run
110+
- name: Protocol tests
111+
run: cargo test -p cake-core --test protocol
118112

119-
build-ios:
120-
name: Build (iOS arm64)
113+
test-ios:
114+
name: Test (iOS arm64)
121115
runs-on: macos-latest
122116
permissions:
123117
contents: read
@@ -150,20 +144,106 @@ jobs:
150144
IPHONEOS_DEPLOYMENT_TARGET: "16.0"
151145
run: cargo clippy --target=aarch64-apple-ios -p cake-core --lib --no-default-features --features "llama,qwen2,qwen3_5,metal" -p cake-mobile --features metal -- -D warnings
152146

153-
- name: Compile tests (cake-core lib, iOS)
147+
- name: Unit tests (cake-core lib, Metal)
148+
run: cargo test -p cake-core --lib --features metal
149+
150+
- name: Unit tests (cake-core external, Metal)
151+
run: cargo test -p cake-core --test unit --features metal
152+
153+
- name: Protocol tests (Metal)
154+
run: cargo test -p cake-core --test protocol --features metal
155+
156+
test-features:
157+
name: Test (${{ matrix.name }})
158+
runs-on: ${{ matrix.os }}
159+
permissions:
160+
contents: read
161+
strategy:
162+
fail-fast: false
163+
matrix:
164+
include:
165+
- name: linux-cuda
166+
os: ubuntu-latest
167+
features: cuda
168+
cuda: "12.4.0"
169+
compute_cap: "89"
170+
171+
- name: linux-flash-attn
172+
os: ubuntu-latest
173+
features: flash-attn
174+
cuda: "12.4.0"
175+
compute_cap: "89"
176+
177+
- name: linux-vulkan
178+
os: ubuntu-latest
179+
features: vulkan
180+
cuda: ""
181+
compute_cap: ""
182+
183+
- name: linux-rocm
184+
os: ubuntu-latest
185+
features: rocm
186+
cuda: ""
187+
compute_cap: ""
188+
189+
- name: macos-metal
190+
os: macos-latest
191+
features: metal
192+
cuda: ""
193+
compute_cap: ""
194+
195+
steps:
196+
- uses: actions/checkout@v4
197+
198+
- name: Install Rust
199+
uses: dtolnay/rust-toolchain@stable
200+
with:
201+
components: clippy
202+
203+
- name: Install system dependencies (Linux)
204+
if: runner.os == 'Linux'
205+
run: sudo apt-get update && sudo apt-get install -y lld
206+
207+
- name: Install CUDA toolkit
208+
if: matrix.cuda != ''
209+
uses: Jimver/cuda-toolkit@v0.2.30
210+
with:
211+
cuda: ${{ matrix.cuda }}
212+
method: local
213+
linux-local-args: '["--toolkit"]'
214+
log-file-suffix: '${{ matrix.name }}.txt'
215+
216+
- name: Create CUDA runtime stub
217+
if: matrix.cuda != ''
218+
run: |
219+
STUBS_DIR="${CUDA_PATH}/lib64/stubs"
220+
sudo ln -s "${STUBS_DIR}/libcuda.so" "${STUBS_DIR}/libcuda.so.1"
221+
echo "LD_LIBRARY_PATH=${STUBS_DIR}:${LD_LIBRARY_PATH}" >> "$GITHUB_ENV"
222+
223+
- name: Cache cargo registry & build
224+
uses: actions/cache@v4
225+
with:
226+
path: |
227+
~/.cargo/registry
228+
~/.cargo/git
229+
target
230+
key: ${{ runner.os }}-cargo-${{ matrix.name }}-${{ hashFiles('**/Cargo.lock') }}
231+
restore-keys: ${{ runner.os }}-cargo-${{ matrix.name }}-
232+
233+
- name: Unit tests (cake-core lib)
154234
env:
155-
IPHONEOS_DEPLOYMENT_TARGET: "16.0"
156-
run: cargo test --target=aarch64-apple-ios -p cake-core --lib --no-default-features --features "llama,qwen2,qwen3_5,qwen3,qwen3_moe,qwen3_5_moe,phi4,mistral,gemma3,falcon3,olmo2,exaone4,flux,vibevoice,luxtts,metal" --no-run
235+
CUDA_COMPUTE_CAP: ${{ matrix.compute_cap }}
236+
run: cargo test -p cake-core --lib --features "${{ matrix.features }}"
157237

158-
- name: Compile tests (cake-core unit, iOS)
238+
- name: Unit tests (cake-core external)
159239
env:
160-
IPHONEOS_DEPLOYMENT_TARGET: "16.0"
161-
run: cargo test --target=aarch64-apple-ios -p cake-core --test unit --no-default-features --features "llama,qwen2,qwen3_5,qwen3,qwen3_moe,qwen3_5_moe,phi4,mistral,gemma3,falcon3,olmo2,exaone4,flux,vibevoice,luxtts,metal" --no-run
240+
CUDA_COMPUTE_CAP: ${{ matrix.compute_cap }}
241+
run: cargo test -p cake-core --test unit --features "${{ matrix.features }}"
162242

163-
- name: Compile tests (cake-core protocol, iOS)
243+
- name: Protocol tests
164244
env:
165-
IPHONEOS_DEPLOYMENT_TARGET: "16.0"
166-
run: cargo test --target=aarch64-apple-ios -p cake-core --test protocol --no-default-features --features "llama,qwen2,qwen3_5,qwen3,qwen3_moe,qwen3_5_moe,phi4,mistral,gemma3,falcon3,olmo2,exaone4,flux,vibevoice,luxtts,metal" --no-run
245+
CUDA_COMPUTE_CAP: ${{ matrix.compute_cap }}
246+
run: cargo test -p cake-core --test protocol --features "${{ matrix.features }}"
167247

168248
clippy:
169249
name: Clippy
@@ -186,5 +266,5 @@ jobs:
186266
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
187267
restore-keys: ${{ runner.os }}-cargo-clippy-
188268

189-
- name: Clippy (cake-core + cake-cli)
190-
run: cargo clippy -p cake-core --lib --tests -p cake-cli -- -D warnings
269+
- name: Clippy (cake-core + cake-cli, all features)
270+
run: cargo clippy -p cake-core --lib --tests -p cake-cli --features "vulkan,rocm" -- -D warnings

.github/workflows/release.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,36 +61,42 @@ jobs:
6161
target: ""
6262
features: ""
6363
cuda: ""
64+
compute_cap: ""
6465

6566
- name: linux-x86_64-cuda-11.8
6667
os: ubuntu-latest
6768
target: ""
6869
features: cuda
6970
cuda: "11.8.0"
71+
compute_cap: "89"
7072

7173
- name: linux-x86_64-cuda-12.4
7274
os: ubuntu-latest
7375
target: ""
7476
features: cuda
7577
cuda: "12.4.0"
78+
compute_cap: "89"
7679

7780
- name: linux-x86_64-cuda-13.0
7881
os: ubuntu-latest
7982
target: ""
8083
features: cuda
8184
cuda: "13.0.0"
85+
compute_cap: "89"
8286

8387
- name: linux-aarch64-cpu
8488
os: ubuntu-latest
8589
target: aarch64-unknown-linux-gnu
8690
features: ""
8791
cuda: ""
92+
compute_cap: ""
8893

8994
- name: macos-arm64-metal
9095
os: macos-latest
9196
target: ""
9297
features: metal
9398
cuda: ""
99+
compute_cap: ""
94100

95101
steps:
96102
- name: Checkout repository
@@ -108,17 +114,21 @@ jobs:
108114

109115
- name: Install CUDA toolkit
110116
if: matrix.cuda != ''
111-
uses: Jimver/cuda-toolkit@v0.2.16
117+
uses: Jimver/cuda-toolkit@v0.2.30
112118
with:
113119
cuda: ${{ matrix.cuda }}
114-
method: network
120+
method: local
121+
linux-local-args: '["--toolkit"]'
122+
log-file-suffix: '${{ matrix.name }}.txt'
115123

116124
- name: Build release binary (native, default features)
117125
if: matrix.target == '' && matrix.features == ''
118126
run: cargo build --verbose --release -p cake-cli
119127

120128
- name: Build release binary (native, extra features)
121129
if: matrix.target == '' && matrix.features != ''
130+
env:
131+
CUDA_COMPUTE_CAP: ${{ matrix.compute_cap }}
122132
run: cargo build --verbose --release -p cake-cli --features "${{ matrix.features }}"
123133

124134
- name: Build release binary (cross)

cake-core/src/backends/rocm/ffi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub const ROCBLAS_OPERATION_NONE: c_int = 111;
4444
impl RocmFfi {
4545
/// Load HIP and rocBLAS from the library path.
4646
/// Searches LD_LIBRARY_PATH, then default system paths.
47+
#[allow(clippy::missing_transmute_annotations)]
4748
pub fn load() -> std::result::Result<Self, String> {
4849
unsafe {
4950
let hip_lib = libloading::Library::new("libamdhip64.so")

0 commit comments

Comments
 (0)