|
| 1 | +name: Build Wheels & Release |
| 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 | + defaults: |
| 20 | + run: |
| 21 | + shell: pwsh |
| 22 | + strategy: |
| 23 | + matrix: |
| 24 | + include: |
| 25 | + |
| 26 | + # Ubuntu 20.04 CUDA |
| 27 | + |
| 28 | + # Python 3.10 |
| 29 | + - { artname: 'wheel', os: ubuntu-22.04, pyver: '3.10', cuda: '12.8.1', rocm: '', torch: '2.7.0', cudaarch: '8.0 8.6 8.9 9.0 10.0 12.0+PTX' } |
| 30 | + |
| 31 | + # Python 3.11 |
| 32 | + - { artname: 'wheel', os: ubuntu-22.04, pyver: '3.11', cuda: '12.8.1', rocm: '', torch: '2.7.0', cudaarch: '8.0 8.6 8.9 9.0 10.0 12.0+PTX' } |
| 33 | + |
| 34 | + # Python 3.12 |
| 35 | + - { artname: 'wheel', os: ubuntu-22.04, pyver: '3.12', cuda: '12.8.1', rocm: '', torch: '2.7.0', cudaarch: '8.0 8.6 8.9 9.0 10.0 12.0+PTX' } |
| 36 | + |
| 37 | + # Python 3.13 |
| 38 | + - { artname: 'wheel', os: ubuntu-22.04, pyver: '3.13', cuda: '12.8.1', rocm: '', torch: '2.7.0', cudaarch: '8.0 8.6 8.9 9.0 10.0 12.0+PTX' } |
| 39 | + |
| 40 | + # Windows 2022 CUDA |
| 41 | + |
| 42 | + # Python 3.10 |
| 43 | + - { artname: 'wheel', os: windows-2022, pyver: '3.10', cuda: '12.8.1', rocm: '', torch: '2.7.0', cudaarch: '8.0 8.6 8.9 9.0 10.0 12.0+PTX' } |
| 44 | + |
| 45 | + # Python 3.11 |
| 46 | + - { artname: 'wheel', os: windows-2022, pyver: '3.11', cuda: '12.8.1', rocm: '', torch: '2.7.0', cudaarch: '8.0 8.6 8.9 9.0 10.0 12.0+PTX' } |
| 47 | + |
| 48 | + # Python 3.12 |
| 49 | + - { artname: 'wheel', os: windows-2022, pyver: '3.12', cuda: '12.8.1', rocm: '', torch: '2.7.0', cudaarch: '8.0 8.6 8.9 9.0 10.0 12.0+PTX' } |
| 50 | + |
| 51 | + # Python 3.13 |
| 52 | + - { artname: 'wheel', os: windows-2022, pyver: '3.13', cuda: '12.8.1', rocm: '', torch: '2.7.0', cudaarch: '8.0 8.6 8.9 9.0 10.0 12.0+PTX' } |
| 53 | + |
| 54 | + # sdist |
| 55 | + - { artname: 'sdist', os: ubuntu-22.04, pyver: '3.11', cuda: '', rocm: '', torch: '2.7.0', cudaarch: '' } |
| 56 | + |
| 57 | + fail-fast: false |
| 58 | + |
| 59 | + steps: |
| 60 | + #Free disk space |
| 61 | + |
| 62 | + - name: Free Disk Space |
| 63 | + |
| 64 | + if: runner.os == 'Linux' |
| 65 | + with: |
| 66 | + tool-cache: true |
| 67 | + android: true |
| 68 | + dotnet: true |
| 69 | + haskell: true |
| 70 | + large-packages: false |
| 71 | + swap-storage: true |
| 72 | + |
| 73 | + # Setup Python |
| 74 | + |
| 75 | + - uses: actions/checkout@v4 |
| 76 | + |
| 77 | + # Get version string from package |
| 78 | + |
| 79 | + - name: Get version string |
| 80 | + id: package_version |
| 81 | + run: | |
| 82 | + $versionString = Get-Content $(Join-Path 'exllamav3' 'version.py') -raw |
| 83 | + if ($versionString -match '__version__ = "(\d+\.(?:\d+\.?(?:dev\d+)?)*)"') |
| 84 | + { |
| 85 | + Write-Output $('::notice file=build-wheels-release.yml,line=200,title=Package Version::Detected package version is: {0}' -f $Matches[1]) |
| 86 | + Write-Output "PACKAGE_VERSION=$($Matches[1])" >> "$env:GITHUB_OUTPUT" |
| 87 | + } |
| 88 | + else |
| 89 | + { |
| 90 | + Write-Output '::error file=build-wheels-release.yml,line=203::Could not parse version from exllamav2/version.py! You must upload wheels manually!' |
| 91 | + Write-Output "PACKAGE_VERSION=None" >> "$env:GITHUB_OUTPUT" |
| 92 | + } |
| 93 | +
|
| 94 | + # Pin VS build tools to 17.9 for wider compat |
| 95 | + |
| 96 | + - name: Install VS2022 BuildTools 17.9.7 |
| 97 | + 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" |
| 98 | + if: runner.os == 'Windows' |
| 99 | + |
| 100 | + # Install uv for easier python setup |
| 101 | + - name: Install the latest version of uv and set the python version |
| 102 | + uses: astral-sh/setup-uv@v5 |
| 103 | + with: |
| 104 | + python-version: ${{ matrix.pyver }} |
| 105 | + |
| 106 | + - name: Install Windows CUDA 12.8 |
| 107 | + if: runner.os == 'Windows' && contains(matrix.cuda, '12.8') |
| 108 | + run: | |
| 109 | + mkdir -p "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" |
| 110 | + choco install unzip -y |
| 111 | + curl -fL -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_cudart/windows-x86_64/cuda_cudart-windows-x86_64-12.8.57-archive.zip" |
| 112 | + curl -fL -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvcc/windows-x86_64/cuda_nvcc-windows-x86_64-12.8.61-archive.zip" |
| 113 | + curl -fL -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvrtc/windows-x86_64/cuda_nvrtc-windows-x86_64-12.8.61-archive.zip" |
| 114 | + curl -fL -O "https://developer.download.nvidia.com/compute/cuda/redist/libcublas/windows-x86_64/libcublas-windows-x86_64-12.8.3.14-archive.zip" |
| 115 | + curl -fL -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvtx/windows-x86_64/cuda_nvtx-windows-x86_64-12.8.55-archive.zip" |
| 116 | + curl -fL -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_profiler_api/windows-x86_64/cuda_profiler_api-windows-x86_64-12.8.55-archive.zip" |
| 117 | + curl -fL -O "https://developer.download.nvidia.com/compute/cuda/redist/visual_studio_integration/windows-x86_64/visual_studio_integration-windows-x86_64-12.8.55-archive.zip" |
| 118 | + curl -fL -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvprof/windows-x86_64/cuda_nvprof-windows-x86_64-12.8.57-archive.zip" |
| 119 | + curl -fL -O "https://developer.download.nvidia.com/compute/cuda/redist/cuda_cccl/windows-x86_64/cuda_cccl-windows-x86_64-12.8.55-archive.zip" |
| 120 | + curl -fL -O "https://developer.download.nvidia.com/compute/cuda/redist/libcusparse/windows-x86_64/libcusparse-windows-x86_64-12.5.7.53-archive.zip" |
| 121 | + curl -fL -O "https://developer.download.nvidia.com/compute/cuda/redist/libcusolver/windows-x86_64/libcusolver-windows-x86_64-11.7.2.55-archive.zip" |
| 122 | + curl -fL -O "https://developer.download.nvidia.com/compute/cuda/redist/libcurand/windows-x86_64/libcurand-windows-x86_64-10.3.9.55-archive.zip" |
| 123 | + curl -fL -O "https://developer.download.nvidia.com/compute/cuda/redist/libcufft/windows-x86_64/libcufft-windows-x86_64-11.3.3.41-archive.zip" |
| 124 | + unzip '*.zip' -d "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" |
| 125 | + xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\cuda_cudart-windows-x86_64-12.8.57-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y |
| 126 | + xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\cuda_nvcc-windows-x86_64-12.8.61-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y |
| 127 | + xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\cuda_nvrtc-windows-x86_64-12.8.61-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y |
| 128 | + xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\libcublas-windows-x86_64-12.8.3.14-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y |
| 129 | + xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\cuda_nvtx-windows-x86_64-12.8.55-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y |
| 130 | + xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\cuda_profiler_api-windows-x86_64-12.8.55-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y |
| 131 | + xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\visual_studio_integration-windows-x86_64-12.8.55-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y |
| 132 | + xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\cuda_nvprof-windows-x86_64-12.8.57-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y |
| 133 | + xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\cuda_cccl-windows-x86_64-12.8.55-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y |
| 134 | + xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\libcusparse-windows-x86_64-12.5.7.53-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y |
| 135 | + xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\libcusolver-windows-x86_64-11.7.2.55-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y |
| 136 | + xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\libcurand-windows-x86_64-10.3.9.55-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y |
| 137 | + xcopy "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\libcufft-windows-x86_64-11.3.3.41-archive\*" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" /E /I /H /Y |
| 138 | + echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append |
| 139 | + echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8\libnvvp" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append |
| 140 | + echo "CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 |
| 141 | + echo "CUDA_PATH_V12_8=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 |
| 142 | + |
| 143 | + # TODO: Find specific sub-packages |
| 144 | + - name: Install Linux CUDA ${{ matrix.cuda }} |
| 145 | + |
| 146 | + id: cuda-toolkit-Linux |
| 147 | + with: |
| 148 | + cuda: "${{ matrix.cuda }}" |
| 149 | + linux-local-args: '["--toolkit"]' |
| 150 | + method: "network" |
| 151 | + if: runner.os != 'Windows' && matrix.cuda != '' |
| 152 | + |
| 153 | + - name: Install CUDA build Dependencies |
| 154 | + if: matrix.cuda != '' |
| 155 | + id: cuda_deps |
| 156 | + run: | |
| 157 | + git config --system core.longpaths true |
| 158 | + $cudaVersion = '${{ matrix.cuda }}' |
| 159 | + $cudaVersionPytorch = '${{ matrix.cuda }}'.Remove('${{ matrix.cuda }}'.LastIndexOf('.')).Replace('.','') |
| 160 | + Write-Output "CUDA_VERSION_PYTORCH=$cudaVersionPytorch" >> "$env:GITHUB_OUTPUT" |
| 161 | + $pytorchIndexUrl = "https://download.pytorch.org/whl/cu$cudaVersionPytorch" |
| 162 | +
|
| 163 | + uv pip install torch==${{ matrix.torch }} --index-url $pytorchIndexUrl |
| 164 | + uv pip install --upgrade build setuptools==69.5.1 wheel packaging ninja safetensors sentencepiece tokenizers numpy |
| 165 | +
|
| 166 | + - name: Build for CUDA |
| 167 | + if: matrix.cuda != '' |
| 168 | + run: | |
| 169 | + # --- Spawn the VS shell |
| 170 | + if ($IsWindows) { |
| 171 | + Import-Module 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll' |
| 172 | + Enter-VsDevShell -VsInstallPath 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools' -DevCmdArguments '-arch=x64 -host_arch=x64' |
| 173 | + $env:DISTUTILS_USE_SDK=1 |
| 174 | + } |
| 175 | +
|
| 176 | + # --- Build wheel |
| 177 | + $BUILDTAG = "+cu${{ steps.cuda_deps.outputs.CUDA_VERSION_PYTORCH }}-torch${{ matrix.torch }}" |
| 178 | + $env:BUILD_TARGET = "cuda" |
| 179 | + $env:TORCH_CUDA_ARCH_LIST = '${{ matrix.cudaarch }}' |
| 180 | + python -m build -n --wheel -C--build-option=egg_info "-C--build-option=--tag-build=$BUILDTAG" |
| 181 | +
|
| 182 | + # Build sdist |
| 183 | + |
| 184 | + - name: Build sdist |
| 185 | + if: matrix.cuda == '' && matrix.rocm == '' |
| 186 | + run: | |
| 187 | + # --- Install dependencies |
| 188 | +
|
| 189 | + uv pip install torch==${{ matrix.torch }} --index-url https://download.pytorch.org/whl/cpu |
| 190 | + uv pip install --upgrade build setuptools==69.5.1 wheel packaging ninja safetensors sentencepiece tokenizers numpy |
| 191 | +
|
| 192 | + # --- Build wheel |
| 193 | + |
| 194 | + $env:EXLLAMA_NOCOMPILE=1 |
| 195 | + python -m build -n |
| 196 | +
|
| 197 | + # Upload files |
| 198 | + |
| 199 | + - name: Upload files to GitHub release |
| 200 | + if: steps.package_version.outputs.PACKAGE_VERSION != 'None' && inputs.release == '1' |
| 201 | + |
| 202 | + with: |
| 203 | + file: ./dist/*.whl |
| 204 | + tag: ${{ format('v{0}', steps.package_version.outputs.PACKAGE_VERSION) }} |
| 205 | + file_glob: true |
| 206 | + overwrite: true |
| 207 | + release_name: ${{ steps.package_version.outputs.PACKAGE_VERSION }} |
0 commit comments