|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | +# repository_dispatch: |
| 5 | +# types: [manual-build] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + create_release: |
| 9 | + description: 'Create new release' |
| 10 | + required: true |
| 11 | + type: boolean |
| 12 | +# push: |
| 13 | +# branches: |
| 14 | +# - master |
| 15 | +# paths: ['.github/workflows/**', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp'] |
| 16 | +# pull_request: |
| 17 | +# types: [opened, synchronize, reopened] |
| 18 | +# paths: ['**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp'] |
| 19 | + |
| 20 | +env: |
| 21 | + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} |
| 22 | + |
| 23 | +jobs: |
| 24 | + ubuntu-focal-make: |
| 25 | + runs-on: ubuntu-20.04 |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Clone |
| 29 | + id: checkout |
| 30 | + uses: actions/checkout@v1 |
| 31 | + |
| 32 | + - name: Dependencies |
| 33 | + id: depends |
| 34 | + run: | |
| 35 | + sudo apt-get update |
| 36 | + sudo apt-get install build-essential gcc-8 |
| 37 | +
|
| 38 | + - name: Build |
| 39 | + id: make_build |
| 40 | + run: | |
| 41 | + CC=gcc-8 make |
| 42 | +
|
| 43 | + ubuntu-latest-cmake: |
| 44 | + runs-on: ubuntu-latest |
| 45 | + |
| 46 | + steps: |
| 47 | + - name: Clone |
| 48 | + id: checkout |
| 49 | + uses: actions/checkout@v1 |
| 50 | + |
| 51 | + - name: Dependencies |
| 52 | + id: depends |
| 53 | + run: | |
| 54 | + sudo apt-get update |
| 55 | + sudo apt-get install build-essential |
| 56 | +
|
| 57 | + - name: Build |
| 58 | + id: cmake_build |
| 59 | + run: | |
| 60 | + mkdir build |
| 61 | + cd build |
| 62 | + cmake .. |
| 63 | + cmake --build . --config Release |
| 64 | +
|
| 65 | + - name: Test |
| 66 | + id: cmake_test |
| 67 | + run: | |
| 68 | + cd build |
| 69 | + ctest --verbose |
| 70 | +
|
| 71 | + ubuntu-latest-cmake-sanitizer: |
| 72 | + runs-on: ubuntu-latest |
| 73 | + |
| 74 | + continue-on-error: true |
| 75 | + |
| 76 | + strategy: |
| 77 | + matrix: |
| 78 | + sanitizer: [ADDRESS, THREAD, UNDEFINED] |
| 79 | + build_type: [Debug, Release] |
| 80 | + |
| 81 | + steps: |
| 82 | + - name: Clone |
| 83 | + id: checkout |
| 84 | + uses: actions/checkout@v1 |
| 85 | + |
| 86 | + - name: Dependencies |
| 87 | + id: depends |
| 88 | + run: | |
| 89 | + sudo apt-get update |
| 90 | + sudo apt-get install build-essential |
| 91 | +
|
| 92 | + - name: Build |
| 93 | + id: cmake_build |
| 94 | + run: | |
| 95 | + mkdir build |
| 96 | + cd build |
| 97 | + cmake .. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} |
| 98 | + cmake --build . --config ${{ matrix.build_type }} |
| 99 | +
|
| 100 | + - name: Test |
| 101 | + id: cmake_test |
| 102 | + run: | |
| 103 | + cd build |
| 104 | + ctest --verbose |
| 105 | +
|
| 106 | + macOS-latest-make: |
| 107 | + runs-on: macos-latest |
| 108 | + |
| 109 | + steps: |
| 110 | + - name: Clone |
| 111 | + id: checkout |
| 112 | + uses: actions/checkout@v1 |
| 113 | + |
| 114 | + - name: Dependencies |
| 115 | + id: depends |
| 116 | + run: | |
| 117 | + brew update |
| 118 | +
|
| 119 | + - name: Build |
| 120 | + id: make_build |
| 121 | + run: | |
| 122 | + make |
| 123 | +
|
| 124 | + macOS-latest-cmake: |
| 125 | + runs-on: macos-latest |
| 126 | + |
| 127 | + steps: |
| 128 | + - name: Clone |
| 129 | + id: checkout |
| 130 | + uses: actions/checkout@v1 |
| 131 | + |
| 132 | + - name: Dependencies |
| 133 | + id: depends |
| 134 | + run: | |
| 135 | + brew update |
| 136 | +
|
| 137 | + - name: Build |
| 138 | + id: cmake_build |
| 139 | + run: | |
| 140 | + mkdir build |
| 141 | + cd build |
| 142 | + cmake -DLLAMA_AVX2=OFF -DLLAMA_CUBLAS=0 .. |
| 143 | + cmake --build . --config Release |
| 144 | +
|
| 145 | + - name: Test |
| 146 | + id: cmake_test |
| 147 | + run: | |
| 148 | + cd build |
| 149 | + ctest --verbose |
| 150 | +
|
| 151 | + windows-latest-cmake: |
| 152 | + runs-on: windows-latest |
| 153 | + env: |
| 154 | + OPENBLAS_VERSION: 0.3.23 |
| 155 | + OPENCL_VERSION: 2023.04.17 |
| 156 | + CLBLAST_VERSION: 1.6.0 |
| 157 | + |
| 158 | + strategy: |
| 159 | + matrix: |
| 160 | + include: |
| 161 | + - build: 'avx2' |
| 162 | + defines: '-DLLAMA_BUILD_SERVER=ON' |
| 163 | + - build: 'avx' |
| 164 | + defines: '-DLLAMA_BUILD_SERVER=ON -DLLAMA_AVX2=OFF' |
| 165 | + - build: 'avx512' |
| 166 | + defines: '-DLLAMA_BUILD_SERVER=ON -DLLAMA_AVX512=ON -DBUILD_SHARED_LIBS=ON' |
| 167 | + # - build: 'clblast' |
| 168 | + # defines: '-DLLAMA_BUILD_SERVER=ON -DLLAMA_CLBLAST=ON -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/clblast"' |
| 169 | + - build: 'openblas' |
| 170 | + defines: '-DLLAMA_BUILD_SERVER=ON -DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS="$env:RUNNER_TEMP/openblas/include" -DBLAS_LIBRARIES="$env:RUNNER_TEMP/openblas/lib/openblas.lib"' |
| 171 | + |
| 172 | + steps: |
| 173 | + - name: Clone |
| 174 | + id: checkout |
| 175 | + uses: actions/checkout@v1 |
| 176 | + |
| 177 | + # - name: Download OpenCL SDK |
| 178 | + # id: get_opencl |
| 179 | + # if: ${{ matrix.build == 'clblast' }} |
| 180 | + # run: | |
| 181 | + # curl.exe -o $env:RUNNER_TEMP/opencl.zip -L "https://github.com/KhronosGroup/OpenCL-SDK/releases/download/v${env:OPENCL_VERSION}/OpenCL-SDK-v${env:OPENCL_VERSION}-Win-x64.zip" |
| 182 | + # mkdir $env:RUNNER_TEMP/opencl |
| 183 | + # tar.exe -xvf $env:RUNNER_TEMP/opencl.zip --strip-components=1 -C $env:RUNNER_TEMP/opencl |
| 184 | + |
| 185 | + # - name: Download CLBlast |
| 186 | + # id: get_clblast |
| 187 | + # if: ${{ matrix.build == 'clblast' }} |
| 188 | + # run: | |
| 189 | + # curl.exe -o $env:RUNNER_TEMP/clblast.7z -L "https://github.com/CNugteren/CLBlast/releases/download/${env:CLBLAST_VERSION}/CLBlast-${env:CLBLAST_VERSION}-windows-x64.7z" |
| 190 | + # curl.exe -o $env:RUNNER_TEMP/CLBlast.LICENSE.txt -L "https://github.com/CNugteren/CLBlast/raw/${env:CLBLAST_VERSION}/LICENSE" |
| 191 | + # 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/clblast.7z |
| 192 | + # rename-item $env:RUNNER_TEMP/CLBlast-${env:CLBLAST_VERSION}-windows-x64 clblast |
| 193 | + # foreach ($f in (gci -Recurse -Path "$env:RUNNER_TEMP/clblast" -Filter '*.cmake')) { |
| 194 | + # $txt = Get-Content -Path $f -Raw |
| 195 | + # $txt.Replace('C:/vcpkg/packages/opencl_x64-windows/', "$($env:RUNNER_TEMP.Replace('\','/'))/opencl/") | Set-Content -Path $f -Encoding UTF8 |
| 196 | + # } |
| 197 | + |
| 198 | + - name: Download OpenBLAS |
| 199 | + id: get_openblas |
| 200 | + if: ${{ matrix.build == 'openblas' }} |
| 201 | + run: | |
| 202 | + curl.exe -o $env:RUNNER_TEMP/openblas.zip -L "https://github.com/xianyi/OpenBLAS/releases/download/v${env:OPENBLAS_VERSION}/OpenBLAS-${env:OPENBLAS_VERSION}-x64.zip" |
| 203 | + curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE" |
| 204 | + mkdir $env:RUNNER_TEMP/openblas |
| 205 | + tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas |
| 206 | + $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath) |
| 207 | + $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim())) |
| 208 | + $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe') |
| 209 | + & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll |
| 210 | +
|
| 211 | + - name: Build |
| 212 | + id: cmake_build |
| 213 | + run: | |
| 214 | + mkdir build |
| 215 | + cd build |
| 216 | + cmake .. ${{ matrix.defines }} |
| 217 | + cmake --build . --config Release |
| 218 | +
|
| 219 | + # - name: Add clblast.dll |
| 220 | + # id: add_clblast_dll |
| 221 | + # if: ${{ matrix.build == 'clblast' }} |
| 222 | + # run: | |
| 223 | + # cp $env:RUNNER_TEMP/clblast/lib/clblast.dll ./build/bin/Release |
| 224 | + # cp $env:RUNNER_TEMP/CLBlast.LICENSE.txt ./build/bin/Release/CLBlast-${env:CLBLAST_VERSION}.txt |
| 225 | + |
| 226 | + - name: Add libopenblas.dll |
| 227 | + id: add_libopenblas_dll |
| 228 | + if: ${{ matrix.build == 'openblas' }} |
| 229 | + run: | |
| 230 | + cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll |
| 231 | + cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt |
| 232 | +
|
| 233 | + - name: Check AVX512F support |
| 234 | + id: check_avx512f |
| 235 | + if: ${{ matrix.build == 'avx512' }} |
| 236 | + continue-on-error: true |
| 237 | + run: | |
| 238 | + cd build |
| 239 | + $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath) |
| 240 | + $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim())) |
| 241 | + $cl = $(join-path $msvc 'bin\Hostx64\x64\cl.exe') |
| 242 | + echo 'int main(void){unsigned int a[4];__cpuid(a,7);return !(a[1]&65536);}' >> avx512f.c |
| 243 | + & $cl /O2 /GS- /kernel avx512f.c /link /nodefaultlib /entry:main |
| 244 | + .\avx512f.exe && echo "AVX512F: YES" && ( echo HAS_AVX512F=1 >> $env:GITHUB_ENV ) || echo "AVX512F: NO" |
| 245 | +
|
| 246 | + - name: Test |
| 247 | + id: cmake_test |
| 248 | + if: ${{ matrix.build != 'clblast' && (matrix.build != 'avx512' || env.HAS_AVX512F == '1') }} # Test AVX-512 only when possible |
| 249 | + run: | |
| 250 | + cd build |
| 251 | + ctest -C Release --verbose |
| 252 | +
|
| 253 | + - name: Get commit hash |
| 254 | + id: commit |
| 255 | + if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} |
| 256 | + uses: pr-mpt/actions-commit-hash@v2 |
| 257 | + |
| 258 | + - name: Pack artifacts |
| 259 | + id: pack_artifacts |
| 260 | + if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} |
| 261 | + run: | |
| 262 | + Copy-Item LICENSE .\build\bin\Release\ggllm.cpp.txt |
| 263 | + 7z a ggllm-falcon-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip .\build\bin\Release\* |
| 264 | +
|
| 265 | + - name: Upload artifacts |
| 266 | + if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} |
| 267 | + uses: actions/upload-artifact@v3 |
| 268 | + with: |
| 269 | + path: | |
| 270 | + ggllm-falcon-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip |
| 271 | +
|
| 272 | + windows-latest-cmake-cublas: |
| 273 | + runs-on: windows-latest |
| 274 | + |
| 275 | + strategy: |
| 276 | + matrix: |
| 277 | + cuda: ['12.1.0', '11.7.1'] |
| 278 | + build: ['cublas'] |
| 279 | + |
| 280 | + steps: |
| 281 | + - name: Clone |
| 282 | + id: checkout |
| 283 | + uses: actions/checkout@v1 |
| 284 | + |
| 285 | + |
| 286 | + id: cuda-toolkit |
| 287 | + with: |
| 288 | + cuda: ${{ matrix.cuda }} |
| 289 | + # TODO(green-sky): _dev seems to fail, and non dev are not enought |
| 290 | + #sub-packages: '["nvcc", "cudart", "cublas", "cudart_dev", "cublas_dev"]' |
| 291 | + |
| 292 | + - name: Build |
| 293 | + id: cmake_build |
| 294 | + run: | |
| 295 | + mkdir build |
| 296 | + cd build |
| 297 | + cmake .. -DLLAMA_BUILD_SERVER=ON -DLLAMA_CUBLAS=ON |
| 298 | + cmake --build . --config Release |
| 299 | +
|
| 300 | + - name: Get commit hash |
| 301 | + id: commit |
| 302 | + if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} |
| 303 | + uses: pr-mpt/actions-commit-hash@v2 |
| 304 | + |
| 305 | + - name: Pack artifacts |
| 306 | + id: pack_artifacts |
| 307 | + if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} |
| 308 | + run: | |
| 309 | + 7z a ggllm-falcon-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip .\build\bin\Release\* |
| 310 | +
|
| 311 | + - name: Upload artifacts |
| 312 | + if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} |
| 313 | + uses: actions/upload-artifact@v3 |
| 314 | + with: |
| 315 | + path: | |
| 316 | + ggllm-falcon-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip |
| 317 | +
|
| 318 | + - name: Copy and pack Cuda runtime |
| 319 | + if: ${{ matrix.cuda == '12.1.0' }} |
| 320 | + # TODO(green-sky): paths are cuda 12 specific |
| 321 | + run: | |
| 322 | + echo "Cuda install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}" |
| 323 | + mkdir '.\build\bin\cudart\' |
| 324 | + cp "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin\cudart64_12.dll" '.\build\bin\cudart\' |
| 325 | + cp "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin\cublas64_12.dll" '.\build\bin\cudart\' |
| 326 | + cp "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin\cublasLt64_12.dll" '.\build\bin\cudart\' |
| 327 | + 7z a cudart-ggllm-falcon-bin-win-cu${{ matrix.cuda }}-x64.zip .\build\bin\cudart\* |
| 328 | +
|
| 329 | + - name: Copy and pack Cuda runtime |
| 330 | + if: ${{ matrix.cuda == '11.7.1' }} |
| 331 | + # if: ${{ matrix.cuda == '12.0' }} |
| 332 | + # TODO(green-sky): paths are cuda 11 specific |
| 333 | + run: | |
| 334 | + echo "Cuda install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}" |
| 335 | + mkdir '.\build\bin\cudart\' |
| 336 | + ls "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin" |
| 337 | + cp "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin\cudart64_110.dll" '.\build\bin\cudart\' |
| 338 | + cp "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin\cublas64_11.dll" '.\build\bin\cudart\' |
| 339 | + cp "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin\cublasLt64_11.dll" '.\build\bin\cudart\' |
| 340 | + 7z a cudart-ggllm-falcon-bin-win-cu${{ matrix.cuda }}-x64.zip .\build\bin\cudart\* |
| 341 | +
|
| 342 | + - name: Upload Cuda runtime |
| 343 | + if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} |
| 344 | + uses: actions/upload-artifact@v3 |
| 345 | + with: |
| 346 | + path: | |
| 347 | + cudart-ggllm-falcon-bin-win-cu${{ matrix.cuda }}-x64.zip |
| 348 | +
|
| 349 | + release: |
| 350 | + if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} |
| 351 | + |
| 352 | + runs-on: ubuntu-latest |
| 353 | + |
| 354 | + needs: |
| 355 | + - ubuntu-focal-make |
| 356 | + - ubuntu-latest-cmake |
| 357 | + - macOS-latest-make |
| 358 | + - macOS-latest-cmake |
| 359 | + - windows-latest-cmake |
| 360 | + - windows-latest-cmake-cublas |
| 361 | + |
| 362 | + steps: |
| 363 | + - name: Download artifacts |
| 364 | + id: download-artifact |
| 365 | + uses: actions/download-artifact@v3 |
| 366 | + |
| 367 | + - name: Get commit hash |
| 368 | + id: commit |
| 369 | + uses: pr-mpt/actions-commit-hash@v2 |
| 370 | + |
| 371 | + - name: Create release |
| 372 | + id: create_release |
| 373 | + uses: anzz1/action-create-release@v1 |
| 374 | + env: |
| 375 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 376 | + with: |
| 377 | + tag_name: ${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }} |
| 378 | + |
| 379 | + - name: Upload release |
| 380 | + id: upload_release |
| 381 | + uses: actions/github-script@v3 |
| 382 | + with: |
| 383 | + github-token: ${{secrets.GITHUB_TOKEN}} |
| 384 | + script: | |
| 385 | + const path = require('path'); |
| 386 | + const fs = require('fs'); |
| 387 | + const release_id = '${{ steps.create_release.outputs.id }}'; |
| 388 | + for (let file of await fs.readdirSync('./artifact')) { |
| 389 | + if (path.extname(file) === '.zip') { |
| 390 | + console.log('uploadReleaseAsset', file); |
| 391 | + await github.repos.uploadReleaseAsset({ |
| 392 | + owner: context.repo.owner, |
| 393 | + repo: context.repo.repo, |
| 394 | + release_id: release_id, |
| 395 | + name: file, |
| 396 | + data: await fs.readFileSync(`./artifact/${file}`) |
| 397 | + }); |
| 398 | + } |
| 399 | + } |
0 commit comments