From 6edd6a8370677d1644debb6ae90833ed5d1229e1 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Thu, 5 Jun 2025 10:47:36 +0800 Subject: [PATCH] support torch 2.7.0 (#118) --- .github/workflows/macos-cpu-wheels.yml | 3 +- .github/workflows/ubuntu-arm64-cpu-wheels.yml | 12 ++++---- .github/workflows/ubuntu-cpu-wheels.yml | 2 +- .github/workflows/ubuntu-cuda-wheels.yml | 9 +++--- .github/workflows/windows-x64-cpu-wheels.yml | 29 ++++++++++++------- CMakeLists.txt | 3 ++ .../github_actions/generate_build_matrix.py | 11 +++++-- scripts/github_actions/install_torch.sh | 17 +++++++++++ 8 files changed, 62 insertions(+), 24 deletions(-) diff --git a/.github/workflows/macos-cpu-wheels.yml b/.github/workflows/macos-cpu-wheels.yml index 50d8e7c..ed23d03 100644 --- a/.github/workflows/macos-cpu-wheels.yml +++ b/.github/workflows/macos-cpu-wheels.yml @@ -3,7 +3,8 @@ name: build-wheels-cpu-macos on: push: branches: - - fix-wheel-2 + - wheel + # - torch-2.7.0 tags: - '*' workflow_dispatch: diff --git a/.github/workflows/ubuntu-arm64-cpu-wheels.yml b/.github/workflows/ubuntu-arm64-cpu-wheels.yml index 48b8d83..494501f 100644 --- a/.github/workflows/ubuntu-arm64-cpu-wheels.yml +++ b/.github/workflows/ubuntu-arm64-cpu-wheels.yml @@ -3,8 +3,8 @@ name: build-wheels-cpu-arm64-ubuntu on: push: branches: - # - wheel - - fix-cuda-12.6 + - wheel + # - torch-2.7.0 tags: - '*' workflow_dispatch: @@ -27,11 +27,11 @@ jobs: id: set-matrix run: | # outputting for debugging purposes - python ./scripts/github_actions/generate_build_matrix.py --for-arm64 - MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --for-arm64) + # python ./scripts/github_actions/generate_build_matrix.py --for-arm64 + # MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --for-arm64) - # python ./scripts/github_actions/generate_build_matrix.py --test-only-latest-torch --for-arm64 - # MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --test-only-latest-torch --for-arm64) + python ./scripts/github_actions/generate_build_matrix.py --test-only-latest-torch --for-arm64 + MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --test-only-latest-torch --for-arm64) echo "::set-output name=matrix::${MATRIX}" build-manylinux-wheels: diff --git a/.github/workflows/ubuntu-cpu-wheels.yml b/.github/workflows/ubuntu-cpu-wheels.yml index 5fb9201..f8f366f 100644 --- a/.github/workflows/ubuntu-cpu-wheels.yml +++ b/.github/workflows/ubuntu-cpu-wheels.yml @@ -3,8 +3,8 @@ name: build-wheels-cpu-ubuntu on: push: branches: - # - fix-cuda-12.6 - wheel + # - torch-2.7.0 tags: - '*' workflow_dispatch: diff --git a/.github/workflows/ubuntu-cuda-wheels.yml b/.github/workflows/ubuntu-cuda-wheels.yml index a7f750c..269607c 100644 --- a/.github/workflows/ubuntu-cuda-wheels.yml +++ b/.github/workflows/ubuntu-cuda-wheels.yml @@ -4,6 +4,7 @@ on: push: branches: - wheel + - torch-2.7.0 tags: - '*' workflow_dispatch: @@ -26,11 +27,11 @@ jobs: id: set-matrix run: | # outputting for debugging purposes - python ./scripts/github_actions/generate_build_matrix.py --enable-cuda - MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --enable-cuda) + # python ./scripts/github_actions/generate_build_matrix.py --enable-cuda + # MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --enable-cuda) - # python ./scripts/github_actions/generate_build_matrix.py --enable-cuda --test-only-latest-torch - # MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --enable-cuda --test-only-latest-torch) + python ./scripts/github_actions/generate_build_matrix.py --enable-cuda --test-only-latest-torch + MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --enable-cuda --test-only-latest-torch) echo "::set-output name=matrix::${MATRIX}" build-manylinux-wheels: diff --git a/.github/workflows/windows-x64-cpu-wheels.yml b/.github/workflows/windows-x64-cpu-wheels.yml index e9b12e1..7a8f12e 100644 --- a/.github/workflows/windows-x64-cpu-wheels.yml +++ b/.github/workflows/windows-x64-cpu-wheels.yml @@ -3,7 +3,8 @@ name: build-wheels-cpu-win64 on: push: branches: - - fix-wheel-2 + - wheel + # - torch-2.7.0 tags: - '*' workflow_dispatch: @@ -47,15 +48,23 @@ jobs: with: fetch-depth: 0 - # see https://cibuildwheel.readthedocs.io/en/stable/changelog/ - # for a list of versions - - name: Build wheels - uses: pypa/cibuildwheel@v2.22.0 - env: - CIBW_BEFORE_BUILD: pip install torch==${{ matrix.torch}}+cpu -f https://download.pytorch.org/whl/torch_stable.html cmake numpy || pip install torch==${{ matrix.torch}}+cpu -f https://download.pytorch.org/whl/torch/ cmake numpy - CIBW_BUILD: ${{ matrix.python-version }}-win_amd64 - CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "" - CIBW_BUILD_VERBOSITY: 3 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + shell: bash + run: | + pip install -q torch==${{ matrix.torch}} cmake numpy wheel>=0.40.0 twine setuptools + pip install torch==${{ matrix.torch}}+cpu -f https://download.pytorch.org/whl/torch_stable.html cmake numpy || pip install torch==${{ matrix.torch}}+cpu -f https://download.pytorch.org/whl/torch/ cmake numpy + + - name: Build wheel + shell: bash + run: | + python3 setup.py bdist_wheel + mkdir wheelhouse + cp -v dist/* wheelhouse - name: Display wheels shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index d9acc3f..aa63e6c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,7 @@ # Copyright (c) 2021 Xiaomi Corporation (author: Fangjun Kuang) +if (CMAKE_VERSION VERSION_GREATER_EQUAL "4.0.0") + set(CMAKE_POLICY_VERSION_MINIMUM 3.5) +endif() cmake_minimum_required(VERSION 3.8 FATAL_ERROR) diff --git a/scripts/github_actions/generate_build_matrix.py b/scripts/github_actions/generate_build_matrix.py index 3892043..f1c025b 100755 --- a/scripts/github_actions/generate_build_matrix.py +++ b/scripts/github_actions/generate_build_matrix.py @@ -303,10 +303,18 @@ def generate_build_matrix( else ["11.8.0", "12.4.0", "12.6.0"] ), }, + "2.7.0": { + "python-version": ["3.9", "3.10", "3.11", "3.12", "3.13"], + "cuda": ( + ["11.8", "12.6", "12.8"] + if not for_windows + else ["11.8.0", "12.6.2", "12.8.1"] + ), + }, # https://github.com/Jimver/cuda-toolkit/blob/master/src/links/windows-links.ts } if test_only_latest_torch: - latest = "2.6.0" + latest = "2.7.0" matrix = {latest: matrix[latest]} if for_windows or for_macos: @@ -377,7 +385,6 @@ def generate_build_matrix( continue if for_windows: - p = "cp" + "".join(p.split(".")) ans.append({"torch": torch, "python-version": p}) elif for_macos: ans.append({"torch": torch, "python-version": p}) diff --git a/scripts/github_actions/install_torch.sh b/scripts/github_actions/install_torch.sh index b0cea34..faa9fed 100755 --- a/scripts/github_actions/install_torch.sh +++ b/scripts/github_actions/install_torch.sh @@ -264,6 +264,23 @@ case ${torch} in ;; esac ;; + 2.7.*) + case ${cuda} in + 11.8) + package="torch==${torch}+cu118" + # https://download.pytorch.org/whl/nightly/torch/ + url=https://download.pytorch.org/whl/torch/ + ;; + 12.6) + package="torch==${torch}+cu126" + url=https://download.pytorch.org/whl/torch/ + ;; + 12.8) + package="torch==${torch}+cu128" + url=https://download.pytorch.org/whl/torch/ + ;; + esac + ;; *) echo "Unsupported PyTorch version: ${torch}" exit 1