From 283957acbe4fed3e8f57c28670b0e8b888599db1 Mon Sep 17 00:00:00 2001 From: jllllll <3887729+jllllll@users.noreply.github.com> Date: Fri, 13 Oct 2023 16:26:26 -0500 Subject: [PATCH] Use Pytorch 2.1 for CUDA 11.8+ and ROCm builds --- .../workflows/build-wheels-release-rocm.yml | 16 +++-- .github/workflows/build-wheels-release.yml | 70 ++++++++++++------- .github/workflows/build-wheels-rocm.yml | 4 +- .github/workflows/build-wheels.yml | 7 +- 4 files changed, 63 insertions(+), 34 deletions(-) diff --git a/.github/workflows/build-wheels-release-rocm.yml b/.github/workflows/build-wheels-release-rocm.yml index 6e22ec6..ee28202 100644 --- a/.github/workflows/build-wheels-release-rocm.yml +++ b/.github/workflows/build-wheels-release-rocm.yml @@ -1,11 +1,11 @@ -name: Build ROCm 5.4.2 Wheels & Release +name: Build ROCm 5.6 Wheels & Release on: workflow_dispatch: inputs: pypi: description: 'Upload wheels to PyPI? 1 = yes, 0 = no' - default: '1' + default: '0' required: true type: string workflow_call: @@ -61,13 +61,21 @@ jobs: - name: Install Dependencies run: | - pip3 install torch==2.1.0.dev20230903 --pre --index-url="https://download.pytorch.org/whl/rocm$ROCM_VERSION" --extra-index-url="https://download.pytorch.org/whl/nightly/rocm$ROCM_VERSION" + pip3 install torch==2.1.0 --index-url="https://download.pytorch.org/whl/rocm$ROCM_VERSION" pip3 install build wheel safetensors sentencepiece ninja - name: Build Wheel id: build-wheel run: | - if ($(Get-Content 'setup.py' -raw) -match 'version = "(\d+\.(?:\d+\.?)*)" \+ \(') {Write-Output $('::notice file=build-wheels-release-rocm.yml,line=54,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=41::Could not parse version from setup.py! You must upload wheels manually!'; Write-Output "PACKAGE_VERSION=None" >> "$env:GITHUB_OUTPUT"} + if ($(Get-Content 'setup.py' -raw) -match 'version = "(\d+\.(?:\d+\.?)*)" \+ \(') + { + Write-Output $('::notice file=build-wheels-release-rocm.yml,line=72,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=75::Could not parse version from setup.py! You must upload wheels manually!' + Write-Output "PACKAGE_VERSION=None" >> "$env:GITHUB_OUTPUT" + } + $BUILDTAG = "+rocm$env:ROCM_VERSION" python3 -m build -n --wheel -C--build-option=egg_info "-C--build-option=--tag-build=$BUILDTAG" shell: pwsh diff --git a/.github/workflows/build-wheels-release.yml b/.github/workflows/build-wheels-release.yml index db0104e..bd41311 100644 --- a/.github/workflows/build-wheels-release.yml +++ b/.github/workflows/build-wheels-release.yml @@ -66,15 +66,25 @@ jobs: while ($cudaNum -ge 0) { $cudaChannels += '-c nvidia/label/cuda-' + $cudaVersion.Remove($cudaVersion.LastIndexOf('.')+1) + $cudaNum + ' '; $cudaNum-- } mamba install -y 'cuda' $cudaChannels.TrimEnd().Split() - if ([version]$env:CUDAVER -gt [version]'11.8.0') {$torchver = "torch==2.1.0.* --pre --index-url https://download.pytorch.org/whl/nightly/cu$cudaVersionPytorch"} else {$torchver = "torch --index-url https://download.pytorch.org/whl/cu$cudaVersionPytorch"} - python -m pip install $torchver.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 pip install build wheel safetensors sentencepiece ninja - name: Build Wheel id: build-wheel run: | - if ($(Get-Content 'setup.py' -raw) -match 'version = "(\d+\.(?:\d+\.?)*)" \+ \(') {Write-Output $('::notice file=build-wheels-release.yml,line=53,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=41::Could not parse version from setup.py! You must upload wheels manually!'; Write-Output "PACKAGE_VERSION=None" >> "$env:GITHUB_OUTPUT"} + if ($(Get-Content 'setup.py' -raw) -match 'version = "(\d+\.(?:\d+\.?)*)" \+ \(') + { + Write-Output $('::notice file=build-wheels-release.yml,line=82,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=85::Could not parse version from setup.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 @@ -109,30 +119,30 @@ jobs: 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/gh-action-pypi-publish@v1.8.10 + # 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/gh-action-pypi-publish@v1.8.10 build_sdist: name: Build sdist - needs: publish-wheels-to-pypi + needs: ['build_wheels','build_rocm'] # publish-wheels-to-pypi runs-on: ubuntu-20.04 defaults: run: @@ -151,14 +161,22 @@ jobs: - name: Build Wheel id: build-wheel-sdist run: | - if ($(Get-Content 'setup.py' -raw) -match 'version = "(\d+\.(?:\d+\.?)*)" \+ \(') {Write-Output $('::notice file=build-wheels-release.yml,line=53,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=41::Could not parse version from setup.py! You must upload wheels manually!'; Write-Output "PACKAGE_VERSION=None" >> "$env:GITHUB_OUTPUT"} + if ($(Get-Content 'setup.py' -raw) -match 'version = "(\d+\.(?:\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 setup.py! You must upload wheels manually!' + Write-Output "PACKAGE_VERSION=None" >> "$env:GITHUB_OUTPUT" + } + $env:EXLLAMA_NOCOMPILE=1 python -m build - uses: actions/upload-artifact@v3 with: name: 'sdist' - path: ./dist/* + 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' diff --git a/.github/workflows/build-wheels-rocm.yml b/.github/workflows/build-wheels-rocm.yml index 7189c47..de925d4 100644 --- a/.github/workflows/build-wheels-rocm.yml +++ b/.github/workflows/build-wheels-rocm.yml @@ -1,4 +1,4 @@ -name: Build ROCm 5.4.2 Wheels +name: Build ROCm 5.6 Wheels on: workflow_dispatch: @@ -46,7 +46,7 @@ jobs: - name: Install Dependencies run: | - pip3 install torch==2.1.0.dev20230903 --pre --index-url="https://download.pytorch.org/whl/rocm$ROCM_VERSION" --extra-index-url="https://download.pytorch.org/whl/nightly/rocm$ROCM_VERSION" + pip3 install torch==2.1.0 --index-url="https://download.pytorch.org/whl/rocm$ROCM_VERSION" pip3 install build wheel safetensors sentencepiece ninja - name: Build Wheel diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index fa262be..5e7cb6a 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -56,8 +56,11 @@ jobs: while ($cudaNum -ge 0) { $cudaChannels += '-c nvidia/label/cuda-' + $cudaVersion.Remove($cudaVersion.LastIndexOf('.')+1) + $cudaNum + ' '; $cudaNum-- } mamba install -y 'cuda' $cudaChannels.TrimEnd().Split() - if ([version]$env:CUDAVER -gt [version]'11.8.0') {$torchver = "torch==2.1.0.* --pre --index-url https://download.pytorch.org/whl/nightly/cu$cudaVersionPytorch"} else {$torchver = "torch --index-url https://download.pytorch.org/whl/cu$cudaVersionPytorch"} - python -m pip install $torchver.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 pip install build wheel safetensors sentencepiece ninja