Skip to content

Commit 17762c1

Browse files
committed
Merge remote-tracking branch 'origin/dev' into dev
2 parents 6f7623f + eaf8ad1 commit 17762c1

File tree

4 files changed

+318
-80
lines changed

4 files changed

+318
-80
lines changed
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
name: Build Wheels & Release ROCm62
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release:
7+
description: 'Release? 1 = yes, 0 = no'
8+
default: '0'
9+
required: true
10+
type: string
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
build_wheels:
17+
name: ${{ matrix.os }} P${{ matrix.pyver }} C${{ matrix.cuda }} R${{ matrix.rocm }} T${{ matrix.torch }}
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
matrix:
21+
include:
22+
23+
# Ubuntu 20.04 CUDA
24+
25+
# ROCm 6.2
26+
- { artname: 'wheel', os: ubuntu-20.04-l, pyver: '3.10', cuda: '', rocm: '6.2', torch: '2.5.0', cudaarch: '' }
27+
- { artname: 'wheel', os: ubuntu-20.04-l, pyver: '3.11', cuda: '', rocm: '6.2', torch: '2.5.0', cudaarch: '' }
28+
- { artname: 'wheel', os: ubuntu-20.04-l, pyver: '3.12', cuda: '', rocm: '6.2', torch: '2.5.0', cudaarch: '' }
29+
30+
# ROCm 6.2.4
31+
- { artname: 'wheel', os: ubuntu-20.04-l, pyver: '3.10', cuda: '', rocm: '6.2.4', torch: '2.6.0', cudaarch: '' }
32+
- { artname: 'wheel', os: ubuntu-20.04-l, pyver: '3.11', cuda: '', rocm: '6.2.4', torch: '2.6.0', cudaarch: '' }
33+
- { artname: 'wheel', os: ubuntu-20.04-l, pyver: '3.12', cuda: '', rocm: '6.2.4', torch: '2.6.0', cudaarch: '' }
34+
- { artname: 'wheel', os: ubuntu-20.04-l, pyver: '3.13', cuda: '', rocm: '6.2.4', torch: '2.6.0', cudaarch: '' }
35+
36+
fail-fast: false
37+
38+
defaults:
39+
run:
40+
shell: pwsh
41+
42+
steps:
43+
# Free disk space
44+
45+
- name: Free Disk Space
46+
uses: jlumbroso/[email protected]
47+
if: runner.os == 'Linux'
48+
with:
49+
tool-cache: true
50+
android: true
51+
dotnet: true
52+
haskell: true
53+
large-packages: false
54+
swap-storage: true
55+
56+
# Setup Python
57+
58+
- uses: actions/checkout@v4
59+
60+
- uses: actions/[email protected]
61+
with:
62+
python-version: ${{ matrix.pyver }}
63+
64+
# Get version string from package
65+
66+
- name: Get version string
67+
id: package_version
68+
run: |
69+
$versionString = Get-Content $(Join-Path 'exllamav2' 'version.py') -raw
70+
if ($versionString -match '__version__ = "(\d+\.(?:\d+\.?(?:dev\d+)?)*)"')
71+
{
72+
Write-Output $('::notice file=build-wheels-release.yml,line=200,title=Package Version::Detected package version is: {0}' -f $Matches[1])
73+
Write-Output "PACKAGE_VERSION=$($Matches[1])" >> "$env:GITHUB_OUTPUT"
74+
}
75+
else
76+
{
77+
Write-Output '::error file=build-wheels-release.yml,line=203::Could not parse version from exllamav2/version.py! You must upload wheels manually!'
78+
Write-Output "PACKAGE_VERSION=None" >> "$env:GITHUB_OUTPUT"
79+
}
80+
81+
# Pin VS build tools to 17.9 so builds won't fail
82+
83+
- name: Install VS2022 BuildTools 17.9.7
84+
run: choco install -y visualstudio2022buildtools --version=117.9.7.0 --params "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --installChannelUri https://aka.ms/vs/17/release/180911598_-255012421/channel"
85+
if: runner.os == 'Windows'
86+
87+
# Install ROCm SDK, apparently needs to happen before setting up Python
88+
89+
- name: Build for ROCm
90+
if: matrix.rocm != ''
91+
shell: bash
92+
run: |
93+
# --- Install ROCm SDK
94+
95+
export ROCM_VERSION=${{ matrix.rocm }}
96+
export TORCH_VERSION=${{ matrix.torch }}
97+
98+
[ ! -d /etc/apt/keyrings ] && sudo mkdir --parents --mode=0755 /etc/apt/keyrings
99+
wget https://repo.radeon.com/rocm/rocm.gpg.key -O - | gpg --dearmor | sudo tee /etc/apt/keyrings/rocm.gpg > /dev/null
100+
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/$ROCM_VERSION focal main" | sudo tee --append /etc/apt/sources.list.d/rocm.list
101+
echo -e 'Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600' | sudo tee /etc/apt/preferences.d/rocm-pin-600
102+
103+
sudo apt update
104+
sudo apt install rocm-hip-sdk -y
105+
sudo apt clean -y
106+
107+
echo "/opt/rocm/bin" >> $GITHUB_PATH
108+
echo "ROCM_PATH=/opt/rocm" >> $GITHUB_ENV
109+
echo "ROCM_VERSION=$ROCM_VERSION" >> $GITHUB_ENV
110+
echo "USE_ROCM=1" >> $GITHUB_ENV
111+
112+
# --- Install dependencies
113+
114+
python3 -m ensurepip --upgrade
115+
pip3 install torch==${{ matrix.torch }} --index-url="https://download.pytorch.org/whl/rocm$ROCM_VERSION"
116+
pip3 install --upgrade setuptools==69.5.1 build wheel safetensors sentencepiece ninja
117+
pip3 cache purge
118+
119+
# --- Build wheel
120+
121+
python3 -m build -n --wheel -C--build-option=egg_info "-C--build-option=--tag-build=+rocm${{ matrix.rocm }}-torch${{ matrix.torch }}"
122+
123+
# Build for CUDA
124+
125+
- name: Setup Mamba
126+
if: matrix.cuda != ''
127+
uses: conda-incubator/[email protected]
128+
with:
129+
activate-environment: "exllama"
130+
python-version: ${{ matrix.pyver }}
131+
# miniforge-variant: Mambaforge
132+
miniforge-version: latest
133+
# use-mamba: true
134+
add-pip-as-python-dependency: true
135+
auto-activate-base: false
136+
137+
- name: Build for CUDA
138+
if: matrix.cuda != ''
139+
run: |
140+
# --- Spawn the VS shell
141+
if ($IsWindows) {
142+
Import-Module 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll'
143+
Enter-VsDevShell -VsInstallPath 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools' -DevCmdArguments '-arch=x64 -host_arch=x64'
144+
$env:DISTUTILS_USE_SDK=1
145+
}
146+
147+
# --- Install CUDA using Conda
148+
$cudaVersion = '${{ matrix.cuda }}'
149+
$cudaVersionPytorch = '${{ matrix.cuda }}'.Remove('${{ matrix.cuda }}'.LastIndexOf('.')).Replace('.','')
150+
151+
$env:MAMBA_NO_LOW_SPEED_LIMIT = 1
152+
mamba install -y -c nvidia/label/cuda-$cudaVersion cuda-toolkit cuda-runtime
153+
154+
if (!(mamba list cuda)[-1].contains('cuda')) {sleep -s 10; mamba install -y 'cuda' $cudaVersion}
155+
if (!(mamba list cuda)[-1].contains('cuda')) {throw 'CUDA Toolkit failed to install!'}
156+
157+
$env:CUDA_PATH = $env:CONDA_PREFIX
158+
$env:CUDA_HOME = $env:CONDA_PREFIX
159+
if ($IsLinux) {$env:LD_LIBRARY_PATH = $env:CONDA_PREFIX + '/lib:' + $env:LD_LIBRARY_PATH}
160+
161+
# --- Install dependencies
162+
163+
python -m ensurepip --upgrade
164+
python -m pip install torch==${{ matrix.torch }} --index-url https://download.pytorch.org/whl/cu$cudaVersionPytorch
165+
python -m pip install --upgrade setuptools==69.5.1 build wheel safetensors sentencepiece ninja
166+
167+
# --- Build wheel
168+
169+
$BUILDTAG = "+cu$cudaVersionPytorch-torch${{ matrix.torch }}"
170+
$env:TORCH_CUDA_ARCH_LIST = '${{ matrix.cudaarch }}'
171+
python -m build -n --wheel -C--build-option=egg_info "-C--build-option=--tag-build=$BUILDTAG"
172+
173+
# Build sdist
174+
175+
- name: Build sdist
176+
if: matrix.cuda == '' && matrix.rocm == ''
177+
run: |
178+
# --- Spawn the VS shell
179+
if ($IsWindows) {
180+
Import-Module 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll'
181+
Enter-VsDevShell -VsInstallPath 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools' -DevCmdArguments '-arch=x64 -host_arch=x64'
182+
$env:DISTUTILS_USE_SDK=1
183+
}
184+
185+
# --- Install dependencies
186+
187+
python -m pip install torch==${{ matrix.torch }} --index-url https://download.pytorch.org/whl/cpu
188+
python -m pip install build wheel ninja
189+
190+
# --- Build wheel
191+
192+
$env:EXLLAMA_NOCOMPILE=1
193+
python -m build -n
194+
195+
# Upload files
196+
197+
- uses: actions/upload-artifact@v4
198+
if: matrix.artname == 'wheel'
199+
with:
200+
name: wheel-${{ matrix.os }}-py${{ matrix.pyver }}-cuda${{ matrix.cuda }}-torch${{ matrix.torch }}
201+
path: ./dist/*
202+
203+
- uses: actions/upload-artifact@v4
204+
if: matrix.artname == 'sdist'
205+
with:
206+
name: 'sdist'
207+
path: ./dist/*
208+
209+
- name: Upload files to GitHub release
210+
if: steps.package_version.outputs.PACKAGE_VERSION != 'None' && inputs.release == '1'
211+
uses: svenstaro/[email protected]
212+
with:
213+
file: ./dist/*.whl
214+
tag: ${{ format('v{0}', steps.package_version.outputs.PACKAGE_VERSION) }}
215+
file_glob: true
216+
overwrite: true
217+
release_name: ${{ steps.package_version.outputs.PACKAGE_VERSION }}

0 commit comments

Comments
 (0)