-
Notifications
You must be signed in to change notification settings - Fork 509
119 lines (103 loc) · 4.4 KB
/
build.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
name: build
# Trigger on push, pull request, or via manual dispatch.
on:
push:
pull_request:
types: [opened, reopened, labeled, unlabeled, synchronize]
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} (${{ matrix.preset }}) ${{ matrix.build_type }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
# When adding another, also add to copybara's github_check_runs.
os: ['ubuntu-latest', 'macos-latest', 'windows-latest', 'ubuntu-20.04']
build_type: ['Release']
preset: ['make', 'windows']
exclude:
- os: ubuntu-20.04
preset: windows
- os: ubuntu-latest
preset: windows
- os: macos-latest
preset: windows
- os: windows-latest
preset: make
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.preset }}-${{ matrix.build_type }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
# Set up ccache
- name: ccache
uses: hendrikmuhs/[email protected]
- name: Configure CMake
run: >
cmake --preset ${{ matrix.preset }}
-S ${{ github.workspace }} -B ${{ github.workspace }}/build
-D CMAKE_BUILD_TYPE=${{ matrix.build_type }}
-D CMAKE_C_COMPILER_LAUNCHER=ccache
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache
- name: Build
run: cmake --build ${{ github.workspace }}/build --preset ${{ matrix.preset }} --config ${{ matrix.build_type }} -j 4
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: gemma-${{ matrix.os }}-${{ matrix.preset }}-${{ matrix.build_type }}
path: |
${{ github.workspace }}/build/${{ matrix.build_type }}/gemma.exe
${{ github.workspace }}/build/${{ matrix.build_type }}/libgemma.lib
${{ github.workspace }}/build/gemma
${{ github.workspace }}/build/libgemma.a
- if: matrix.os == 'ubuntu-20.04'
name: Upload build artifacts to Kaggle
uses: pculliton/[email protected]
env:
KAGGLE_USERNAME: ${{ secrets.KAGGLE_USERNAME }}
KAGGLE_KEY: ${{ secrets.KAGGLE_KEY }}
with:
id: "phillipculliton/gemma-build-artifacts"
files: |
build/gemma
build/_deps/sentencepiece-build/src/libsentencepiece.so.0
- if: matrix.os == 'ubuntu-20.04'
name: Create code for new test notebook version
run: |
cat > runner.py << EOF
import subprocess
subprocess.run(["cp", "/kaggle/input/gemma-build-artifacts/gemma", "/kaggle/working"])
subprocess.run(["chmod", "700", "/kaggle/working/gemma"])
subprocess.run(["cp", "/kaggle/input/gemma-build-artifacts/_deps/sentencepiece-build/src/libsentencepiece.so.0", "/kaggle/working"])
output = subprocess.run(["/kaggle/working/gemma", "--tokenizer", "/kaggle/input/gemma/gemmacpp/2b-it-sfp/4/tokenizer.spm", "--compressed_weights", "/kaggle/input/gemma/gemmacpp/2b-it-sfp/4/2b-it-sfp.sbs", "--model", "2b-it", "--verbosity", "0", "--max_generated_tokens", "128"], stdout=subprocess.PIPE, input='Write an email to the moon.', encoding='ascii').stdout
assert("write an email to the moon." not in output.lower());
assert("moon" in output.lower());
EOF
- if: matrix.os == 'ubuntu-20.04'
name: Run kaggle test notebook
uses: pculliton/[email protected]
with:
username: ${{ secrets.KAGGLE_USERNAME }}
key: ${{ secrets.KAGGLE_KEY }}
title: GemmaCPP-CI-2
code_file: runner.py
dataset_sources: "phillipculliton/gemma-build-artifacts"
model_sources: "google/gemma/gemmaCpp/2b-it-sfp/4"
enable_gpu: False
kernel_type: script
bazel:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
egress-policy: audit # cannot be block - runner does git checkout
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.0.0
- uses: bazelbuild/setup-bazelisk@b39c379c82683a5f25d34f0d062761f62693e0b2 # v3.0.0
- uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1
with:
path: ~/.cache/bazel
key: bazel-${{ runner.os }}
- run: bazel build --cxxopt=-std=c++20 //:all