Skip to content

wip4

wip4 #108

Workflow file for this run

name: CI
on:
workflow_dispatch: # allows manual triggering
inputs:
create_release:
description: 'Create new release'
required: true
type: boolean
push:
branches:
- master
paths: ['.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal']
pull_request:
types: [opened, synchronize, reopened]
paths: ['.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal']
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
cancel-in-progress: true
# Fine-grant permission
# https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
permissions:
contents: write # for creating release
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
GGML_NLOOP: 3
GGML_N_THREADS: 1
LLAMA_LOG_COLORS: 1
LLAMA_LOG_PREFIX: 1
LLAMA_LOG_TIMESTAMPS: 1
jobs:
windows-msys2-cpu-x86_64:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
arch: [avx, avx2, avx512, amx]
include:
- { arch: avx, defines: '-DGGML_AVX=ON -DGGML_AVX2=OFF -DGGML_AVX512=OFF -DGGML_AMX_TILE=OFF -DGGML_AMX_INT8=OFF' }
- { arch: avx2, defines: '-DGGML_AVX=ON -DGGML_AVX2=ON -DGGML_AVX512=OFF -DGGML_AMX_TILE=OFF -DGGML_AMX_INT8=OFF' }
- { arch: avx512, defines: '-DGGML_AVX=ON -DGGML_AVX2=ON -DGGML_AVX512=ON -DGGML_AMX_TILE=OFF -DGGML_AMX_INT8=OFF' }
- { arch: amx, defines: '-DGGML_AVX=ON -DGGML_AVX2=ON -DGGML_AVX512=ON -DGGML_AMX_TILE=ON -DGGML_AMX_INT8=ON' }
steps:
- name: Clone
uses: actions/checkout@v4
- name: Install Ninja
run: |
choco install ninja
- name: Build using CMake
run: |
cmake -B build -G "Ninja Multi-Config" -DGGML_NATIVE=OFF -DBUILD_SHARED_LIBS=ON -DGGML_BACKEND_DL=ON ${{ matrix.defines }}
cmake --build build --config Release -t ggml-cpu
- name: Rename artifacts
run: mv build/bin/Release/ggml-cpu.dll ggml-cpu-${{ matrix.arch }}.dll
- name: Upload artifacts
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
uses: actions/upload-artifact@v4
with:
path: ggml-cpu-${{ matrix.arch }}.dll
name: ggml-cpu-${{ matrix.arch }}.dll
windows-msys2-x86_64:
runs-on: windows-latest
needs:
- windows-msys2-cpu-x86_64
steps:
- name: Clone
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Ninja
run: |
choco install ninja
- name: Install curl
run: |
choco install curl
- name: Build using CMake
run: |
cmake -B build -G "Ninja Multi-Config" -DLLAMA_CURL=ON -DLLAMA_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=ON -DGGML_BACKEND_DL=ON -DCURL_INCLUDE_DIR="C:/ProgramData/chocolatey/include" -DCURL_LIBRARY="C:/ProgramData/chocolatey/lib" -DCURL_STATICLIB=ON
cmake --build build --config Release
rm build/bin/Release/ggml-cpu.dll
- name: Download CPU backend artifacts
uses: actions/download-artifact@v4
with:
pattern: 'ggml-cpu-*.dll'
path: build/bin/Release
merge-multiple: true
- name: Determine tag name
id: tag
shell: bash
run: |
BUILD_NUMBER="$(git rev-list --count HEAD)"
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
else
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
fi
- name: Pack artifacts
id: pack_artifacts
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
run: |
Copy-Item LICENSE .\build\bin\Release\llama.cpp.txt
7z a llama-${{ steps.tag.outputs.name }}-bin-msys2-cpu.zip .\build\bin\Release\*
- name: Upload artifacts
id: upload_artifacts
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
uses: actions/upload-artifact@v4
with:
path: llama-${{ steps.tag.outputs.name }}-bin-msys2-cpu.zip
name: llama-${{ steps.tag.outputs.name }}-bin-msys2-cpu.zip
release:
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
runs-on: ubuntu-latest
needs:
- windows-msys2-x86_64
steps:
- name: Clone
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine tag name
id: tag
shell: bash
run: |
BUILD_NUMBER="$(git rev-list --count HEAD)"
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
else
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
fi
- name: Download artifacts
id: download-artifact
uses: actions/download-artifact@v4
with:
path: ./artifact
- name: Move artifacts
id: move_artifacts
run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release
- name: Create release
id: create_release
uses: anzz1/action-create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.name }}
- name: Upload release
id: upload_release
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const path = require('path');
const fs = require('fs');
const release_id = '${{ steps.create_release.outputs.id }}';
for (let file of await fs.readdirSync('./artifact/release')) {
if (path.extname(file) === '.zip') {
console.log('uploadReleaseAsset', file);
await github.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release_id,
name: file,
data: await fs.readFileSync(`./artifact/release/${file}`)
});
}
}