Skip to content

Commit 1930fa1

Browse files
committed
Upload version-agnostic workflows
1 parent 0fd7926 commit 1930fa1

File tree

3 files changed

+234
-0
lines changed

3 files changed

+234
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Batch Build Wheels
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
versions:
7+
description: 'Comma-seperated version tags of llama-cpp-python to build'
8+
default: 'v0.1.77,v0.1.76'
9+
required: true
10+
type: string
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
define_matrix:
17+
name: Define Workflow Matrix
18+
runs-on: ubuntu-latest
19+
outputs:
20+
matrix: ${{ steps.set-matrix.outputs.matrix }}
21+
defaults:
22+
run:
23+
shell: pwsh
24+
env:
25+
PCKGVERS: ${{ inputs.versions }}
26+
27+
steps:
28+
- uses: actions/checkout@v3
29+
30+
- name: Define Job Output
31+
id: set-matrix
32+
run: |
33+
$x = $env:PCKGVERS.Split(',').Trim() -Join ', '
34+
Write-Output "matrix={`"node`":[$x]}" >> $env:GITHUB_OUTPUT
35+
36+
run_workflows:
37+
name: Build ${{ matrix.version }} Wheels
38+
needs: define_matrix
39+
strategy:
40+
max-parallel: 1
41+
matrix:
42+
version: ${{ fromJSON(needs.define_matrix.outputs.matrix) }}
43+
uses: ./.github/workflows/build-wheels.yml
44+
with:
45+
version: ${{ matrix.version }}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Build CPU-only Wheels
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version tag of llama-cpp-python to build: v0.1.77'
8+
default: 'v0.1.77'
9+
required: false
10+
type: string
11+
workflow_call:
12+
inputs:
13+
version:
14+
description: 'Version tag of llama-cpp-python to build: v0.1.77'
15+
default: 'v0.1.77'
16+
required: false
17+
type: string
18+
19+
permissions:
20+
contents: write
21+
22+
jobs:
23+
build_wheels:
24+
name: ${{ matrix.os }} ${{ matrix.pyver }} CPU ${{ matrix.avx }}
25+
runs-on: ${{ matrix.os }}
26+
strategy:
27+
matrix:
28+
os: [ubuntu-20.04, windows-latest]
29+
pyver: ["3.7", "3.8", "3.9", "3.10", "3.11"]
30+
avx: ["AVX","AVX2","AVX512","basic"]
31+
defaults:
32+
run:
33+
shell: pwsh
34+
env:
35+
AVXVER: ${{ matrix.avx }}
36+
PCKGVER: ${{ inputs.version }}
37+
38+
steps:
39+
- uses: actions/checkout@v3
40+
with:
41+
repository: 'abetlen/llama-cpp-python'
42+
ref: ${{ inputs.version }}
43+
submodules: 'recursive'
44+
45+
- uses: actions/setup-python@v3
46+
with:
47+
python-version: ${{ matrix.pyver }}
48+
49+
- name: Install Dependencies
50+
run: |
51+
python -m pip install build wheel
52+
53+
- name: Build Wheel
54+
run: |
55+
$env:VERBOSE = '1'
56+
$env:FORCE_CMAKE = '1'
57+
if ($env:AVXVER -eq 'AVX') {$env:CMAKE_ARGS = '-DLLAMA_AVX2=off'}
58+
if ($env:AVXVER -eq 'AVX512') {$env:CMAKE_ARGS = '-DLLAMA_AVX512=on'}
59+
if ($env:AVXVER -eq 'basic') {$env:CMAKE_ARGS = '-DLLAMA_AVX=off -DLLAMA_AVX2=off -DLLAMA_FMA=off -DLLAMA_F16C=off'}
60+
python -m build --wheel -C--build-option=egg_info "-C--build-option=--tag-build=+cpu$env:AVXVER"
61+
62+
- name: Upload files to a GitHub release
63+
id: upload-release
64+
uses: svenstaro/upload-release-action@2.6.1
65+
continue-on-error: true
66+
with:
67+
file: ./dist/*.whl
68+
tag: 'cpu'
69+
file_glob: true
70+
make_latest: false
71+
overwrite: true
72+
73+
- uses: actions/upload-artifact@v3
74+
if: steps.upload-release.outcome == 'failure'
75+
with:
76+
name: cpu
77+
path: ./dist/*.whl

.github/workflows/build-wheels.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Build Wheels
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version tag of llama-cpp-python to build: v0.1.77'
8+
default: 'v0.1.77'
9+
required: false
10+
type: string
11+
workflow_call:
12+
inputs:
13+
version:
14+
description: 'Version tag of llama-cpp-python to build: v0.1.77'
15+
default: 'v0.1.77'
16+
required: false
17+
type: string
18+
19+
permissions:
20+
contents: write
21+
22+
jobs:
23+
build_wheels:
24+
name: ${{ matrix.os }} ${{ matrix.pyver }} ${{ matrix.cuda }} ${{ matrix.releasetag == 'wheels' && 'AVX2' || matrix.releasetag }}
25+
runs-on: ${{ matrix.os }}
26+
strategy:
27+
matrix:
28+
os: [ubuntu-20.04, windows-latest]
29+
pyver: ["3.7", "3.8", "3.9", "3.10", "3.11"]
30+
cuda: ["11.6.2", "11.7.1", "11.8.0", "12.0.1", "12.1.1", "12.2.0"]
31+
releasetag: ["AVX","wheels","AVX512","basic"]
32+
defaults:
33+
run:
34+
shell: pwsh
35+
env:
36+
CUDAVER: ${{ matrix.cuda }}
37+
AVXVER: ${{ matrix.releasetag }}
38+
PCKGVER: ${{ inputs.version }}
39+
40+
steps:
41+
- uses: actions/checkout@v3
42+
with:
43+
repository: 'abetlen/llama-cpp-python'
44+
ref: ${{ inputs.version }}
45+
submodules: 'recursive'
46+
47+
- uses: actions/setup-python@v3
48+
with:
49+
python-version: ${{ matrix.pyver }}
50+
51+
- name: Setup Mamba
52+
uses: conda-incubator/setup-miniconda@v2.2.0
53+
with:
54+
activate-environment: "build"
55+
python-version: ${{ matrix.pyver }}
56+
miniforge-variant: Mambaforge
57+
miniforge-version: latest
58+
use-mamba: true
59+
add-pip-as-python-dependency: true
60+
auto-activate-base: false
61+
62+
- name: Install Dependencies
63+
run: |
64+
$cudaVersion = $env:CUDAVER
65+
$cudaChannels = ''
66+
$cudaNum = [int]$cudaVersion.substring($cudaVersion.LastIndexOf('.')+1)
67+
while ($cudaNum -ge 0) { $cudaChannels += '-c nvidia/label/cuda-' + $cudaVersion.Remove($cudaVersion.LastIndexOf('.')+1) + $cudaNum + ' '; $cudaNum-- }
68+
mamba install -y 'cuda' $cudaChannels.TrimEnd().Split()
69+
python -m pip install build wheel
70+
71+
- name: Build Wheel
72+
run: |
73+
$packageVersion = [version]$env:PCKGVER.TrimStart('v')
74+
$cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','')
75+
$env:CUDA_PATH = $env:CONDA_PREFIX
76+
$env:CUDA_HOME = $env:CONDA_PREFIX
77+
if ($IsLinux) {$env:LD_LIBRARY_PATH = $env:CONDA_PREFIX + '/lib:' + $env:LD_LIBRARY_PATH}
78+
$env:VERBOSE = '1'
79+
$env:FORCE_CMAKE = '1'
80+
$env:CMAKE_ARGS = '-DLLAMA_CUBLAS=on -DCMAKE_CUDA_ARCHITECTURES=all'
81+
if ($packageVersion -gt [version]'0.1.68' -and $packageVersion -lt [version]'0.1.70') {$env:CMAKE_ARGS = '-DLLAMA_CUBLAS=on -DCMAKE_CUDA_ARCHITECTURES=35-real;37-real;52;61-real;70-real;72-real;75-real;80-real;86-real;89-real;90'}
82+
if ($packageVersion -gt [version]'0.1.68' -and $packageVersion -lt [version]'0.1.70' -and [version]$env:CUDAVER -ge [version]'12.0') {$env:CMAKE_ARGS = '-DLLAMA_CUBLAS=on -DCMAKE_CUDA_ARCHITECTURES=52;61-real;70-real;72-real;75-real;80-real;86-real;89-real;90'}
83+
if ($packageVersion -gt [version]'0.1.68' -and $packageVersion -lt [version]'0.1.70' -and [version]$env:CUDAVER -lt [version]'11.8') {$env:CMAKE_ARGS = '-DLLAMA_CUBLAS=on -DCMAKE_CUDA_ARCHITECTURES=35-real;37-real;52;61-real;70-real;72-real;75-real;80-real;86'}
84+
if ($packageVersion -lt [version]'0.1.66') {$env:CUDAFLAGS = '-arch=all'}
85+
if ($env:AVXVER -eq 'AVX') {$env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DLLAMA_AVX2=off'}
86+
if ($env:AVXVER -eq 'AVX512') {$env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DLLAMA_AVX512=on'}
87+
if ($env:AVXVER -eq 'basic') {$env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DLLAMA_AVX=off -DLLAMA_AVX2=off -DLLAMA_FMA=off -DLLAMA_F16C=off'}
88+
python -m build --wheel -C--build-option=egg_info "-C--build-option=--tag-build=+cu$cudaVersion"
89+
90+
- name: Upload files to a GitHub release
91+
id: upload-release
92+
uses: svenstaro/upload-release-action@2.6.1
93+
continue-on-error: true
94+
with:
95+
file: ./dist/*.whl
96+
tag: ${{ matrix.releasetag }}
97+
file_glob: true
98+
make_latest: false
99+
overwrite: true
100+
101+
- uses: actions/upload-artifact@v3
102+
if: steps.upload-release.outcome == 'failure'
103+
with:
104+
name: ${{ matrix.releasetag == 'wheels' && 'AVX2' || matrix.releasetag }}
105+
path: ./dist/*.whl
106+
107+
build_cpu:
108+
name: Build CPU-only Wheels
109+
needs: build_wheels
110+
uses: ./.github/workflows/build-wheels-cpu.yml
111+
with:
112+
version: ${{ inputs.version }}

0 commit comments

Comments
 (0)