ollama/.github/workflows/test.yaml

309 lines
10 KiB
YAML
Raw Normal View History

2023-12-15 19:33:52 +00:00
name: test
on:
pull_request:
2024-03-07 18:43:39 +00:00
paths:
2024-03-07 19:33:49 +00:00
- '**/*'
2024-03-07 18:43:39 +00:00
- '!docs/**'
- '!README.md'
2023-12-15 19:33:52 +00:00
jobs:
changes:
runs-on: ubuntu-latest
outputs:
2024-04-01 20:47:34 +00:00
GENERATE: ${{ steps.changes.outputs.GENERATE }}
GENERATE_CUDA: ${{ steps.changes.outputs.GENERATE_CUDA }}
GENERATE_ROCM: ${{ steps.changes.outputs.GENERATE_ROCM }}
steps:
2024-03-27 23:14:20 +00:00
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: changes
run: |
changed() {
2024-03-27 23:14:20 +00:00
git diff-tree -r --no-commit-id --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} \
| xargs python3 -c "import sys; print(any([x.startswith('$1') for x in sys.argv[1:]]))"
}
{
echo GENERATE=$(changed llm/)
echo GENERATE_CUDA=$(changed llm/)
echo GENERATE_ROCM=$(changed llm/)
} >>$GITHUB_OUTPUT
2023-12-15 19:33:52 +00:00
generate:
needs: [changes]
if: ${{ needs.changes.outputs.GENERATE == 'True' }}
2023-12-15 19:33:52 +00:00
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-2019]
2024-01-14 17:19:45 +00:00
arch: [amd64, arm64]
exclude:
- os: ubuntu-latest
arch: arm64
- os: windows-2019
2024-01-14 17:19:45 +00:00
arch: arm64
2023-12-15 19:33:52 +00:00
runs-on: ${{ matrix.os }}
2024-01-14 17:19:45 +00:00
env:
GOARCH: ${{ matrix.arch }}
2023-12-15 19:33:52 +00:00
steps:
- uses: actions/checkout@v4
2024-01-12 17:03:06 +00:00
- uses: actions/setup-go@v5
2023-12-15 19:33:52 +00:00
with:
2024-04-09 16:50:12 +00:00
go-version-file: go.mod
2023-12-15 19:33:52 +00:00
cache: true
- run: go get ./...
- run: |
$gopath=(get-command go).source | split-path -parent
$gccpath=(get-command gcc).source | split-path -parent
& "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\Launch-VsDevShell.ps1"
cd $env:GITHUB_WORKSPACE
$env:CMAKE_SYSTEM_VERSION="10.0.22621.0"
$env:PATH="$gopath;$gccpath;$env:PATH"
echo $env:PATH
go generate -x ./...
if: ${{ startsWith(matrix.os, 'windows-') }}
2024-04-03 17:45:54 +00:00
name: 'Windows Go Generate'
- run: go generate -x ./...
if: ${{ ! startsWith(matrix.os, 'windows-') }}
2024-04-03 17:45:54 +00:00
name: 'Unix Go Generate'
2023-12-15 19:33:52 +00:00
- uses: actions/upload-artifact@v4
with:
2024-01-14 17:19:45 +00:00
name: ${{ matrix.os }}-${{ matrix.arch }}-libraries
path: |
llm/build/**/bin/*
llm/build/**/*.a
2023-12-22 20:17:37 +00:00
generate-cuda:
needs: [changes]
if: ${{ needs.changes.outputs.GENERATE_CUDA == 'True' }}
2023-12-22 20:17:37 +00:00
strategy:
matrix:
cuda-version:
- '11.8.0'
2024-02-06 21:35:54 +00:00
runs-on: linux
2023-12-22 20:17:37 +00:00
container: nvidia/cuda:${{ matrix.cuda-version }}-devel-ubuntu20.04
steps:
- run: |
apt-get update && apt-get install -y git build-essential curl
curl -fsSL https://github.com/Kitware/CMake/releases/download/v3.28.1/cmake-3.28.1-linux-x86_64.tar.gz \
| tar -zx -C /usr --strip-components 1
env:
DEBIAN_FRONTEND: noninteractive
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
2024-04-09 16:50:12 +00:00
go-version-file: go.mod
2023-12-22 20:17:37 +00:00
cache: true
- run: go get ./...
- run: |
git config --global --add safe.directory /__w/ollama/ollama
go generate -x ./...
2023-12-22 20:17:37 +00:00
env:
OLLAMA_SKIP_CPU_GENERATE: '1'
- uses: actions/upload-artifact@v4
with:
name: cuda-${{ matrix.cuda-version }}-libraries
path: |
llm/build/**/bin/*
dist/windows-amd64/**
2023-12-22 20:17:37 +00:00
generate-rocm:
needs: [changes]
if: ${{ needs.changes.outputs.GENERATE_ROCM == 'True' }}
2023-12-22 20:17:37 +00:00
strategy:
matrix:
rocm-version:
2024-03-27 21:15:47 +00:00
- '6.0.2'
2024-02-06 21:35:54 +00:00
runs-on: linux
2023-12-22 20:17:37 +00:00
container: rocm/dev-ubuntu-20.04:${{ matrix.rocm-version }}
steps:
- run: |
apt-get update && apt-get install -y git build-essential curl rocm-libs
curl -fsSL https://github.com/Kitware/CMake/releases/download/v3.28.1/cmake-3.28.1-linux-x86_64.tar.gz \
| tar -zx -C /usr --strip-components 1
env:
DEBIAN_FRONTEND: noninteractive
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
2024-04-09 16:50:12 +00:00
go-version-file: go.mod
2023-12-22 20:17:37 +00:00
cache: true
- run: go get ./...
- run: |
git config --global --add safe.directory /__w/ollama/ollama
go generate -x ./...
2023-12-22 20:17:37 +00:00
env:
OLLAMA_SKIP_CPU_GENERATE: '1'
- uses: actions/upload-artifact@v4
with:
name: rocm-${{ matrix.rocm-version }}-libraries
path: |
llm/build/**/bin/*
dist/windows-amd64/**
# ROCm generation step
generate-windows-rocm:
needs: [changes]
if: ${{ needs.changes.outputs.GENERATE_ROCM == 'True' }}
runs-on: windows
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
2024-04-09 16:50:12 +00:00
go-version-file: go.mod
cache: true
2024-04-03 17:45:54 +00:00
- name: 'Install ROCm'
run: |
$ErrorActionPreference = "Stop"
write-host "downloading AMD HIP Installer"
Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-23.Q4-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe"
write-host "Installing AMD HIP"
Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
write-host "Completed AMD HIP"
2024-04-03 17:45:54 +00:00
- name: 'Verify ROCm'
run: |
& 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
- run: go get ./...
- run: |
$gopath=(get-command go).source | split-path -parent
& "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\Launch-VsDevShell.ps1"
cd $env:GITHUB_WORKSPACE
$env:CMAKE_SYSTEM_VERSION="10.0.22621.0"
$env:PATH="$gopath;$env:PATH"
$env:OLLAMA_SKIP_CPU_GENERATE="1"
$env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
go generate -x ./...
name: go generate
env:
OLLAMA_SKIP_CPU_GENERATE: '1'
# TODO - do we need any artifacts?
# CUDA generation step
generate-windows-cuda:
needs: [changes]
if: ${{ needs.changes.outputs.GENERATE_CUDA == 'True' }}
runs-on: windows
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
2024-04-09 16:50:12 +00:00
go-version-file: go.mod
cache: true
2024-04-03 17:45:54 +00:00
- name: 'Install CUDA'
run: |
$ErrorActionPreference = "Stop"
write-host "downloading CUDA Installer"
Invoke-WebRequest -Uri "https://developer.download.nvidia.com/compute/cuda/11.3.1/local_installers/cuda_11.3.1_465.89_win10.exe" -OutFile "${env:RUNNER_TEMP}\cuda-install.exe"
write-host "Installing CUDA"
Start-Process "${env:RUNNER_TEMP}\cuda-install.exe" -ArgumentList '-s' -NoNewWindow -Wait
write-host "Completed CUDA"
$cudaPath=((resolve-path "c:\Program Files\NVIDIA*\CUDA\v*\bin\nvcc.exe")[0].path | split-path | split-path)
$cudaVer=($cudaPath | split-path -leaf ) -replace 'v(\d+).(\d+)', '$1_$2'
echo "$cudaPath\bin" >> $env:GITHUB_PATH
echo "CUDA_PATH=$cudaPath" >> $env:GITHUB_ENV
echo "CUDA_PATH_V${cudaVer}=$cudaPath" >> $env:GITHUB_ENV
echo "CUDA_PATH_VX_Y=CUDA_PATH_V${cudaVer}" >> $env:GITHUB_ENV
2024-04-03 17:45:54 +00:00
- name: 'Verify CUDA'
run: nvcc -V
- run: go get ./...
- name: go generate
run: |
$gopath=(get-command go).source | split-path -parent
$cudabin=(get-command nvcc).source | split-path
& "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\Launch-VsDevShell.ps1"
cd $env:GITHUB_WORKSPACE
$env:CMAKE_SYSTEM_VERSION="10.0.22621.0"
$env:PATH="$gopath;$cudabin;$env:PATH"
$env:OLLAMA_SKIP_CPU_GENERATE="1"
go generate -x ./...
env:
OLLAMA_SKIP_CPU_GENERATE: '1'
# TODO - do we need any artifacts?
2023-12-15 19:33:52 +00:00
lint:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-2019]
2024-01-14 17:19:45 +00:00
arch: [amd64, arm64]
exclude:
- os: ubuntu-latest
arch: arm64
- os: windows-2019
2024-01-14 17:19:45 +00:00
arch: arm64
- os: macos-latest
arch: amd64
2023-12-15 19:33:52 +00:00
runs-on: ${{ matrix.os }}
2024-01-14 17:19:45 +00:00
env:
GOARCH: ${{ matrix.arch }}
CGO_ENABLED: '1'
2023-12-15 19:33:52 +00:00
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
2024-01-12 17:03:06 +00:00
- uses: actions/setup-go@v5
2023-12-15 19:33:52 +00:00
with:
2024-04-09 16:50:12 +00:00
go-version-file: go.mod
2023-12-15 19:33:52 +00:00
cache: false
2024-01-25 01:29:47 +00:00
- run: |
2024-03-27 19:57:06 +00:00
case ${{ matrix.arch }} in
amd64) echo ARCH=x86_64 ;;
arm64) echo ARCH=arm64 ;;
esac >>$GITHUB_ENV
shell: bash
- run: |
2024-04-03 17:45:54 +00:00
mkdir -p llm/build/linux/$ARCH/stub/bin
touch llm/build/linux/$ARCH/stub/bin/ollama_llama_server
2024-01-25 01:29:47 +00:00
if: ${{ startsWith(matrix.os, 'ubuntu-') }}
- run: |
2024-04-03 17:45:54 +00:00
mkdir -p llm/build/darwin/$ARCH/stub/bin
touch llm/build/darwin/$ARCH/stub/bin/ollama_llama_server
2024-01-25 01:29:47 +00:00
if: ${{ startsWith(matrix.os, 'macos-') }}
2024-04-02 19:22:16 +00:00
- uses: golangci/golangci-lint-action@v4
with:
2024-04-23 17:17:42 +00:00
args: --timeout 8m0s -v
2023-12-15 19:33:52 +00:00
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-2019]
arch: [amd64]
2024-01-14 17:19:45 +00:00
exclude:
- os: ubuntu-latest
arch: arm64
- os: windows-2019
2024-01-14 17:19:45 +00:00
arch: arm64
2023-12-15 19:33:52 +00:00
runs-on: ${{ matrix.os }}
env:
GOARCH: ${{ matrix.arch }}
CGO_ENABLED: '1'
2024-04-03 17:45:54 +00:00
OLLAMA_CPU_TARGET: 'static'
2023-12-15 19:33:52 +00:00
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
2024-01-12 17:03:06 +00:00
- uses: actions/setup-go@v5
2023-12-15 19:33:52 +00:00
with:
2024-04-09 16:50:12 +00:00
go-version-file: go.mod
2023-12-15 19:33:52 +00:00
cache: true
- run: go get
- run: |
2024-03-27 19:57:06 +00:00
case ${{ matrix.arch }} in
amd64) echo ARCH=x86_64 ;;
arm64) echo ARCH=arm64 ;;
esac >>$GITHUB_ENV
shell: bash
- run: |
2024-04-03 17:45:54 +00:00
mkdir -p llm/build/linux/$ARCH/stub/bin
touch llm/build/linux/$ARCH/stub/bin/ollama_llama_server
if: ${{ startsWith(matrix.os, 'ubuntu-') }}
- run: |
2024-04-03 17:45:54 +00:00
mkdir -p llm/build/darwin/$ARCH/stub/bin
touch llm/build/darwin/$ARCH/stub/bin/ollama_llama_server
if: ${{ startsWith(matrix.os, 'macos-') }}
2024-04-03 17:45:54 +00:00
shell: bash
- run: go generate ./...
- run: go build
- run: go test -v ./...
2023-12-23 00:06:35 +00:00
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-binaries
path: ollama