MojoLlama
Archived Mojo/MAX quantizer and serving research repository (read-only history)
Brought by drakestapleton
MojoLlama / .onedev-buildspec.yml
| 1 | version: 6 |
| 2 | |
| 3 | jobs: |
| 4 | |
| 5 | # ============================================================================ |
| 6 | # JOB 1: Build — Compile C kernels, build artifacts |
| 7 | # ============================================================================ |
| 8 | - name: Build Kernels |
| 9 | steps: |
| 10 | |
| 11 | - type: CheckoutStep |
| 12 | name: checkout |
| 13 | cloneCredential: |
| 14 | type: DefaultCredential |
| 15 | withLfs: false |
| 16 | withSubmodules: false |
| 17 | cloneDepth: 1 |
| 18 | condition: SUCCESSFUL |
| 19 | optional: false |
| 20 | |
| 21 | - type: CommandStep |
| 22 | name: install deps + compile C kernels |
| 23 | condition: SUCCESSFUL |
| 24 | optional: false |
| 25 | runInContainer: true |
| 26 | image: python:3.11 |
| 27 | interpreter: |
| 28 | type: DefaultInterpreter |
| 29 | commands: | |
| 30 | set -e |
| 31 | echo "=== System Dependencies ===" |
| 32 | apt-get update -qq && apt-get install -y -qq gcc 2>/dev/null |
| 33 | |
| 34 | echo "=== Python Dependencies ===" |
| 35 | pip install flask numpy gguf regex ftfy --break-system-packages -q |
| 36 | |
| 37 | echo "=== Build C AVX2 Kernels (Parallel) ===" |
| 38 | echo "-> q4_matmul.so" |
| 39 | gcc -O3 -march=native -shared -fPIC \ |
| 40 | -o src/mojollama/model/libq4matmul.so \ |
| 41 | src/mojollama/model/q4_matmul_c.c & |
| 42 | |
| 43 | echo "-> q4_kernel_avx2.so" |
| 44 | gcc -O3 -mavx2 -mfma -mf16c -shared -fPIC \ |
| 45 | -o src/mojollama/kernels/q4_kernel_avx2.so \ |
| 46 | src/mojollama/kernels/q4_kernel_avx2.c & |
| 47 | |
| 48 | echo "-> q4_kernel_omp.so (OMP)" |
| 49 | gcc -O3 -mavx2 -mfma -mf16c -fopenmp -shared -fPIC \ |
| 50 | -o src/mojollama/kernels/q4_kernel_omp.so \ |
| 51 | src/mojollama/kernels/q4_kernel_omp.c & |
| 52 | |
| 53 | echo "-> cengine_batch.so (AVX2 batch)" |
| 54 | gcc -O3 -mavx2 -mfma -mf16c -fopenmp -shared -fPIC \ |
| 55 | -o src/mojollama/kernels/cengine_batch.so \ |
| 56 | src/mojollama/kernels/cengine_batch.c & |
| 57 | |
| 58 | wait |
| 59 | echo "All kernels compiled successfully" |
| 60 | |
| 61 | echo "=== Verify Shared Libraries ===" |
| 62 | find src -name "*.so" -exec file {} \; | grep -c "ELF" || echo "No .so files found" |
| 63 | ls -lh src/mojollama/kernels/*.so src/mojollama/model/*.so 2>/dev/null || true |
| 64 | |
| 65 | - type: PublishArtifactStep |
| 66 | name: publish kernel artifacts |
| 67 | condition: SUCCESSFUL |
| 68 | optional: false |
| 69 | artifacts: 'src/**/*.so' |
| 70 | |
| 71 | - type: SetBuildVersionStep |
| 72 | name: set build version |
| 73 | condition: SUCCESSFUL |
| 74 | optional: false |
| 75 | buildVersion: '@commit_hash@' |
| 76 | |
| 77 | triggers: |
| 78 | - type: BranchUpdateTrigger |
| 79 | branches: main dev |
| 80 | |
| 81 | retryCondition: never |
| 82 | |
| 83 | |
| 84 | # ============================================================================ |
| 85 | # JOB 2: Deploy — Publish static site + smoke test |
| 86 | # ============================================================================ |
| 87 | - name: Deploy Site |
| 88 | jobDependencies: |
| 89 | - jobName: Build Kernels |
| 90 | requireSuccessful: true |
| 91 | steps: |
| 92 | |
| 93 | - type: CheckoutStep |
| 94 | name: checkout |
| 95 | cloneCredential: |
| 96 | type: DefaultCredential |
| 97 | withLfs: false |
| 98 | withSubmodules: false |
| 99 | cloneDepth: 1 |
| 100 | condition: SUCCESSFUL |
| 101 | optional: false |
| 102 | |
| 103 | - type: PublishSiteStep |
| 104 | name: deploy www to ~site |
| 105 | condition: SUCCESSFUL |
| 106 | optional: false |
| 107 | sourcePath: www |
| 108 | artifacts: "**" |
| 109 | |
| 110 | - type: CommandStep |
| 111 | name: install deps + smoke test |
| 112 | condition: SUCCESSFUL |
| 113 | optional: true |
| 114 | runInContainer: true |
| 115 | image: python:3.11 |
| 116 | interpreter: |
| 117 | type: DefaultInterpreter |
| 118 | commands: | |
| 119 | set -e |
| 120 | echo "=== Python Dependencies ===" |
| 121 | pip install flask numpy gguf regex ftfy --break-system-packages -q |
| 122 | |
| 123 | export PYTHONPATH=/onedev-build/work/src:$PYTHONPATH |
| 124 | |
| 125 | echo "=== Verify Python imports ===" |
| 126 | python3 -c "import sys; sys.path.insert(0,'src'); from mojollama.server import app; print('OK')" 2>&1 || echo "import check non-fatal" |
| 127 | |
| 128 | echo "=== Verify Site Files ===" |
| 129 | if [ -f www/index.html ]; then |
| 130 | echo "index.html: $(wc -c < www/index.html) bytes" |
| 131 | echo "Studio UI: $([ -f www/studio.html ] && echo 'PRESENT' || echo 'MISSING')" |
| 132 | echo "Chat UI: $([ -f www/chat.html ] && echo 'PRESENT' || echo 'MISSING')" |
| 133 | fi |
| 134 | |
| 135 | echo "" |
| 136 | echo "========================================" |
| 137 | echo " MojoLlama Site Deployed" |
| 138 | echo " URL: https://git.bamse.cloud/a730/MojoLlama/~site/" |
| 139 | echo " Studio: ~/studio.html" |
| 140 | echo " Chat: ~/chat.html" |
| 141 | echo "========================================" |
| 142 | |
| 143 | triggers: |
| 144 | - type: BranchUpdateTrigger |
| 145 | branches: main |
| 146 | |
| 147 | retryCondition: never |
| 148 | |
| 149 | |
| 150 | # ============================================================================ |
| 151 | # JOB 3: Quick Test (dev-only) — Fast CI for feature branches |
| 152 | # ============================================================================ |
| 153 | - name: Quick Test |
| 154 | steps: |
| 155 | |
| 156 | - type: CheckoutStep |
| 157 | name: checkout |
| 158 | cloneCredential: |
| 159 | type: DefaultCredential |
| 160 | withLfs: false |
| 161 | withSubmodules: false |
| 162 | cloneDepth: 1 |
| 163 | condition: SUCCESSFUL |
| 164 | optional: false |
| 165 | |
| 166 | - type: CommandStep |
| 167 | name: lint HTML + validate site |
| 168 | condition: SUCCESSFUL |
| 169 | optional: false |
| 170 | runInContainer: true |
| 171 | image: python:3.11 |
| 172 | interpreter: |
| 173 | type: DefaultInterpreter |
| 174 | commands: | |
| 175 | set -e |
| 176 | echo "=== Validate HTML Files ===" |
| 177 | for f in www/index.html www/studio.html www/chat.html; do |
| 178 | if [ -f "$f" ]; then |
| 179 | LINES=$(wc -l < "$f") |
| 180 | echo "OK $f ($LINES lines)" |
| 181 | else |
| 182 | echo "MISSING $f" |
| 183 | fi |
| 184 | done |
| 185 | |
| 186 | echo "=== Check Required Tags ===" |
| 187 | for f in www/index.html www/studio.html www/chat.html; do |
| 188 | if [ -f "$f" ]; then |
| 189 | HAS_TITLE=$(grep -c '<title>' "$f" || true) |
| 190 | HAS_DOCTYPE=$(grep -c '<!DOCTYPE html>' "$f" || true) |
| 191 | echo " $f: DOCTYPE=$HAS_DOCTYPE TITLE=$HAS_TITLE" |
| 192 | fi |
| 193 | done |
| 194 | |
| 195 | echo "HTML validation complete" |
| 196 | |
| 197 | triggers: |
| 198 | - type: BranchUpdateTrigger |
| 199 | branches: dev |
| 200 | |
| 201 | retryCondition: never |
| 202 | |
| 203 | # ──────────────────────────────────────────────────────────────────────── |
| 204 | # Docker image build — runs on main branch pushes |
| 205 | # ──────────────────────────────────────────────────────────────────────── |
| 206 | - name: Build Docker Image |
| 207 | steps: |
| 208 | - type: CheckoutStep |
| 209 | name: checkout |
| 210 | cloneCredential: |
| 211 | type: DefaultCredential |
| 212 | withLfs: false |
| 213 | withSubmodules: false |
| 214 | cloneDepth: 1 |
| 215 | condition: SUCCESSFUL |
| 216 | optional: false |
| 217 | |
| 218 | - type: CommandStep |
| 219 | name: build mojollama Docker image |
| 220 | condition: SUCCESSFUL |
| 221 | optional: false |
| 222 | runInContainer: true |
| 223 | image: docker:27 |
| 224 | interpreter: |
| 225 | type: DefaultInterpreter |
| 226 | commands: | |
| 227 | |
| 228 | echo "=== Build Docker Image ===" |
| 229 | docker build \ |
| 230 | --file Dockerfile \ |
| 231 | --tag mojollama:latest \ |
| 232 | --tag mojollama:$(date -u +%Y%m%d-%H%M%S) \ |
| 233 | . |
| 234 | |
| 235 | echo "" |
| 236 | echo "=== Image Info ===" |
| 237 | docker images mojollama |
| 238 | |
| 239 | echo "" |
| 240 | echo "=== Verify Image (syntax check) ===" |
| 241 | docker run --rm mojollama:latest --help 2>&1 || true |
| 242 | |
| 243 | triggers: |
| 244 | - type: BranchUpdateTrigger |
| 245 | branches: main |
| 246 | |
| 247 | retryCondition: never |