-
-
Notifications
You must be signed in to change notification settings - Fork 279
216 lines (185 loc) · 7.73 KB
/
build-wheels-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
name: Build Wheels & Release
on:
workflow_dispatch:
inputs:
pypi:
description: 'Upload wheels to PyPI? 1 = yes, 0 = no'
default: '0'
required: true
type: string
permissions:
contents: write
jobs:
build_wheels:
name: ${{ matrix.os }} Python ${{ matrix.pyver }} CUDA ${{ matrix.cuda }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-latest]
pyver: ["3.8", "3.9", "3.10", "3.11"]
cuda: ["11.7.0", "11.8.0", "12.1.1"]
defaults:
run:
shell: pwsh
env:
CUDAVER: ${{ matrix.cuda }}
PYVER: ${{ matrix.pyver }}
steps:
- name: Free Disk Space
uses: jlumbroso/[email protected]
if: runner.os == 'Linux'
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
swap-storage: false
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: ${{ matrix.pyver }}
- name: Setup Mamba
uses: conda-incubator/[email protected]
with:
activate-environment: "build"
python-version: ${{ matrix.pyver }}
miniforge-variant: Mambaforge
miniforge-version: latest
use-mamba: true
add-pip-as-python-dependency: true
auto-activate-base: false
- name: Install Dependencies
run: |
$cudaVersion = $env:CUDAVER
$cudaVersionPytorch = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','')
$cudaChannels = ''
$cudaNum = [int]$cudaVersion.substring($cudaVersion.LastIndexOf('.')+1)
while ($cudaNum -ge 0) { $cudaChannels += '-c nvidia/label/cuda-' + $cudaVersion.Remove($cudaVersion.LastIndexOf('.')+1) + $cudaNum + ' '; $cudaNum-- }
mamba install -y 'cuda' $cudaChannels.TrimEnd().Split()
if (!(mamba list cuda)[-1].contains('cuda')) {sleep -s 10; mamba install -y 'cuda' $cudaChannels.TrimEnd().Split()}
if (!(mamba list cuda)[-1].contains('cuda')) {throw 'CUDA Toolkit failed to install!'}
if ([version]$env:CUDAVER -lt [version]'11.8.0') {$torchver = "torch==2.0.1"} else {$torchver = "torch==2.1.0"}
python -m pip install $torchver --index-url https://download.pytorch.org/whl/cu$cudaVersionPytorch
python -m pip3 install --upgrade setuptools==65.5.1
python -m pip3 install --upgrade build wheel safetensors sentencepiece ninja
- name: Build Wheel
id: build-wheel
run: |
$versionString = Get-Content $(Join-Path 'exllamav2' 'version.py') -raw
if ($versionString -match '__version__ = "(\d+\.(?:\d+\.?(?:dev\d+)?)*)"')
{
Write-Output $('::notice file=build-wheels-release.yml,line=83,title=Package Version::Detected package version is: {0}' -f $Matches[1])
Write-Output "PACKAGE_VERSION=$($Matches[1])" >> "$env:GITHUB_OUTPUT"
} else {
Write-Output '::error file=build-wheels-release.yml,line=86::Could not parse version from exllamav2/version.py! You must upload wheels manually!'
Write-Output "PACKAGE_VERSION=None" >> "$env:GITHUB_OUTPUT"
}
$env:CUDA_PATH = $env:CONDA_PREFIX
$env:CUDA_HOME = $env:CONDA_PREFIX
if ($IsLinux) {$env:LD_LIBRARY_PATH = $env:CONDA_PREFIX + '/lib:' + $env:LD_LIBRARY_PATH}
$cudaVersion = $env:CUDAVER
$cudaVersionPytorch = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','')
$BUILDTAG = "+cu$cudaVersionPytorch"
$env:TORCH_CUDA_ARCH_LIST = if ([version]$env:CUDAVER -lt [version]'11.8') {'6.0 6.1 7.0 7.5 8.0 8.6+PTX'} else {'6.0 6.1 7.0 7.5 8.0 8.6 8.9 9.0+PTX'}
python -m build -n --wheel -C--build-option=egg_info "-C--build-option=--tag-build=$BUILDTAG"
- uses: actions/upload-artifact@v3
with:
name: 'wheels'
path: ./dist/*
- name: Upload files to a GitHub release
if: steps.build-wheel.outputs.PACKAGE_VERSION != 'None'
uses: svenstaro/[email protected]
with:
file: ./dist/*.whl
tag: ${{ format('v{0}', steps.build-wheel.outputs.PACKAGE_VERSION) }}
file_glob: true
overwrite: true
release_name: ${{ steps.build-wheel.outputs.PACKAGE_VERSION }}
build_rocm:
name: Build ROCm Wheels & Release
needs: build_wheels
uses: ./.github/workflows/build-wheels-release-rocm.yml
with:
pypi: '0'
# publish-wheels-to-pypi:
# name: Publish Python distribution to PyPI
# if: inputs.pypi == '1'
# needs: ['build_wheels','build_rocm']
# runs-on: ubuntu-latest
#
# environment:
# name: pypi
# url: https://pypi.org/p/exllamav2
# permissions:
# id-token: write # IMPORTANT: mandatory for trusted publishing
#
# steps:
# - name: Download all the wheels
# uses: actions/download-artifact@v3
# with:
# name: wheels
# path: dist/
# - name: Publish distribution to PyPI
# uses: pypa/[email protected]
build_sdist:
name: Build sdist
needs: ['build_wheels','build_rocm'] # publish-wheels-to-pypi
runs-on: ubuntu-20.04
defaults:
run:
shell: pwsh
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install Dependencies
run: |
python -m pip install torch==2.1.0 --index-url https://download.pytorch.org/whl/cpu
python -m pip install build wheel ninja
- name: Build Wheel
id: build-wheel-sdist
run: |
$versionString = Get-Content $(Join-Path 'exllamav2' 'version.py') -raw
if ($versionString -match '__version__ = "(\d+\.(?:\d+\.?(?:dev\d+)?)*)"')
{
Write-Output $('::notice file=build-wheels-release.yml,line=166,title=Package Version::Detected package version is: {0}' -f $Matches[1])
Write-Output "PACKAGE_VERSION=$($Matches[1])" >> "$env:GITHUB_OUTPUT"
} else {
Write-Output '::error file=build-wheels-release.yml,line=169::Could not parse version from exllamav2/version.py! You must upload wheels manually!'
Write-Output "PACKAGE_VERSION=None" >> "$env:GITHUB_OUTPUT"
}
$env:EXLLAMA_NOCOMPILE=1
python -m build -n
- uses: actions/upload-artifact@v3
with:
name: 'sdist'
path: ./dist/* # Use ./dist/*.whl to only upload the JIT compile wheel
- name: Upload files to a GitHub release
if: steps.build-wheel-sdist.outputs.PACKAGE_VERSION != 'None'
uses: svenstaro/[email protected]
with:
file: ./dist/*.whl
tag: ${{ format('v{0}', steps.build-wheel-sdist.outputs.PACKAGE_VERSION) }}
file_glob: true
overwrite: true
release_name: ${{ steps.build-wheel-sdist.outputs.PACKAGE_VERSION }}
publish-sdist-to-pypi:
name: Publish Python distribution to PyPI
if: inputs.pypi == '1'
needs: build_sdist
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/exllamav2
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download the sdist
uses: actions/download-artifact@v3
with:
name: sdist
path: dist/
- name: Publish distribution to PyPI
uses: pypa/[email protected]