From 94c751bfcd35e7309d391b94ffe81d6b4b5858f9 Mon Sep 17 00:00:00 2001 From: Philip Loche Date: Tue, 18 Feb 2025 13:49:57 +0100 Subject: [PATCH] Test and build wheels with Torch 2.6 --- .github/workflows/build-wheels.yml | 42 ++++++++++++------- .github/workflows/coverage.yml | 2 +- .github/workflows/docs.yml | 2 +- .github/workflows/python-tests.yml | 8 ++-- .github/workflows/rust-tests.yml | 2 +- .github/workflows/torch-tests.yml | 19 ++++----- featomic-torch/tests/utils/mod.rs | 2 +- featomic-torch/tests/valgrind.supp | 1 + .../rustc-manylinux_2_28_aarch64/Dockerfile | 11 +++++ 9 files changed, 57 insertions(+), 32 deletions(-) create mode 100644 python/scripts/rustc-manylinux_2_28_aarch64/Dockerfile diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index 31a136306..79c0e13e7 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -65,7 +65,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.13" - name: install dependencies run: python -m pip install cibuildwheel twine @@ -99,7 +99,7 @@ jobs: name: ${{ matrix.name }} (torch v${{ matrix.torch-version }}) strategy: matrix: - torch-version: ['2.1', '2.2', '2.3', '2.4', '2.5'] + torch-version: ['2.1', '2.2', '2.3', '2.4', '2.5', '2.6'] arch: ['arm64', 'x86_64'] os: ['ubuntu-22.04', 'ubuntu-22.04-arm', 'macos-13', 'macos-14', 'windows-2022'] exclude: @@ -113,6 +113,7 @@ jobs: - {os: macos-13, arch: x86_64, torch-version: '2.3'} - {os: macos-13, arch: x86_64, torch-version: '2.4'} - {os: macos-13, arch: x86_64, torch-version: '2.5'} + - {os: macos-13, arch: x86_64, torch-version: '2.6'} include: # add `cibw-arch` and `rust-target` to the different configurations - name: x86_64 Linux @@ -140,12 +141,22 @@ jobs: arch: x86_64 rust-target: x86_64-pc-windows-msvc cibw-arch: AMD64 - # add the right python version for each torch version - - {torch-version: '2.1', python-version: '3.11', cibw-python: 'cp311-*'} - - {torch-version: '2.2', python-version: '3.12', cibw-python: 'cp312-*'} - - {torch-version: '2.3', python-version: '3.12', cibw-python: 'cp312-*'} - - {torch-version: '2.4', python-version: '3.12', cibw-python: 'cp312-*'} - - {torch-version: '2.5', python-version: '3.12', cibw-python: 'cp312-*'} + # add the right python version image for each torch version + - {torch-version: '2.1', cibw-python: 'cp311-*'} + - {torch-version: '2.2', cibw-python: 'cp312-*'} + - {torch-version: '2.3', cibw-python: 'cp312-*'} + - {torch-version: '2.4', cibw-python: 'cp312-*'} + - {torch-version: '2.5', cibw-python: 'cp312-*'} + - {torch-version: '2.6', cibw-python: 'cp312-*'} + # set the right manylinux image to use + - {torch-version: '2.1', manylinux-version: "2014"} + - {torch-version: '2.2', manylinux-version: "2014"} + - {torch-version: '2.3', manylinux-version: "2014"} + - {torch-version: '2.4', manylinux-version: "2014"} + - {torch-version: '2.5', manylinux-version: "2014"} + # only torch >+ 2.6 on arm64-linux needs the newer manylinux + - {torch-version: '2.6', arch: arm64, manylinux-version: "_2_28"} + - {torch-version: '2.6', arch: x86_64, manylinux-version: "2014"} steps: - uses: actions/checkout@v4 with: @@ -160,14 +171,17 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} + python-version: "3.13" - name: install dependencies run: python -m pip install cibuildwheel - name: build manylinux with rust docker image if: matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-22.04-arm' - run: docker buildx build -t rustc-manylinux2014_${{ matrix.cibw-arch }} python/scripts/rustc-manylinux2014_${{ matrix.cibw-arch }} + run: | + docker buildx build \ + -t rustc-manylinux${{ matrix.manylinux-version }}_${{ matrix.cibw-arch }} \ + python/scripts/rustc-manylinux${{ matrix.manylinux-version }}_${{ matrix.cibw-arch }} - name: build featomic-torch wheel run: python -m cibuildwheel python/featomic_torch @@ -176,8 +190,8 @@ jobs: CIBW_SKIP: "*musllinux*" CIBW_ARCHS: ${{ matrix.cibw-arch }} CIBW_BUILD_VERBOSITY: 1 - CIBW_MANYLINUX_X86_64_IMAGE: rustc-manylinux2014_x86_64 - CIBW_MANYLINUX_AARCH64_IMAGE: rustc-manylinux2014_aarch64 + CIBW_MANYLINUX_X86_64_IMAGE: rustc-manylinux${{ matrix.manylinux-version }}_x86_64 + CIBW_MANYLINUX_AARCH64_IMAGE: rustc-manylinux${{ matrix.manylinux-version }}_aarch64 # FEATOMIC_NO_LOCAL_DEPS is set to 1 when building a tag of # featomic-torch, which will force to use the version of featomic # already released on PyPI. Otherwise, this will use the version of @@ -245,7 +259,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.13" - name: install dependencies run: python -m pip install twine wheel @@ -294,7 +308,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.13" - name: build featomic sdist run: | diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 7fe703f8d..a91a4de8f 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: - name: setup Python uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.13" - name: setup rust uses: dtolnay/rust-toolchain@master diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 54eb46260..6ca6195d9 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -31,7 +31,7 @@ jobs: - name: setup Python uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.13" - name: install dependencies run: | diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 3ca206b49..ead0ba368 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -21,11 +21,11 @@ jobs: - os: ubuntu-22.04 python-version: "3.9" - os: ubuntu-22.04 - python-version: "3.12" + python-version: "3.13" - os: macos-14 - python-version: "3.12" + python-version: "3.13" - os: windows-2022 - python-version: "3.12" + python-version: "3.13" steps: - uses: actions/checkout@v4 @@ -68,7 +68,7 @@ jobs: name: Python ${{ matrix.python-version }} / check build strategy: matrix: - python-version: ['3.9', '3.12'] + python-version: ['3.9', '3.13'] os: [ubuntu-22.04] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/rust-tests.yml b/.github/workflows/rust-tests.yml index e825f0c1f..2b2f5eb9f 100644 --- a/.github/workflows/rust-tests.yml +++ b/.github/workflows/rust-tests.yml @@ -90,7 +90,7 @@ jobs: uses: actions/setup-python@v5 if: "!matrix.container" with: - python-version: "3.12" + python-version: "3.13" - name: setup rust uses: dtolnay/rust-toolchain@master diff --git a/.github/workflows/torch-tests.yml b/.github/workflows/torch-tests.yml index a06423e1e..344dd2a0d 100644 --- a/.github/workflows/torch-tests.yml +++ b/.github/workflows/torch-tests.yml @@ -19,33 +19,32 @@ jobs: matrix: include: - os: ubuntu-22.04 - torch-version: 1.12.* + torch-version: "1.12" python-version: "3.9" cargo-test-flags: --release - os: ubuntu-22.04 - torch-version: 2.3.* - python-version: "3.12" + torch-version: "2.6" + python-version: "3.13" cargo-test-flags: --release do-valgrind: true - os: ubuntu-20.04 container: ubuntu:20.04 extra-name: ", cmake 3.16" - torch-version: 2.5.* - python-version: "3.12" + torch-version: "2.6" + python-version: "3.13" cargo-test-flags: "" cxx-flags: -fsanitize=undefined -fsanitize=address -fno-omit-frame-pointer -g - os: macos-14 - torch-version: 2.3.* - python-version: "3.12" + torch-version: "2.6" + python-version: "3.13" cargo-test-flags: --release - os: windows-2022 - # Torch 2.3.0 is broken on Windows, and 2.2 has https://github.com/pytorch/pytorch/issues/118862 - torch-version: 2.1.* - python-version: "3.11" + torch-version: "2.6" + python-version: "3.13" cargo-test-flags: --release steps: diff --git a/featomic-torch/tests/utils/mod.rs b/featomic-torch/tests/utils/mod.rs index 8924e3b3e..60ac0951a 100644 --- a/featomic-torch/tests/utils/mod.rs +++ b/featomic-torch/tests/utils/mod.rs @@ -84,7 +84,7 @@ pub fn setup_pytorch(build_dir: PathBuf) -> PathBuf { .expect("failed to run python"); assert!(status.success(), "failed to run `python -m pip install --upgrade pip`"); - let torch_version = std::env::var("FEATOMIC_TORCH_TEST_VERSION").unwrap_or("2.3.*".into()); + let torch_version = std::env::var("FEATOMIC_TORCH_TEST_VERSION").unwrap_or("2.6.*".into()); let status = Command::new(&python) .arg("-m") .arg("pip") diff --git a/featomic-torch/tests/valgrind.supp b/featomic-torch/tests/valgrind.supp index fda067afc..84939826f 100644 --- a/featomic-torch/tests/valgrind.supp +++ b/featomic-torch/tests/valgrind.supp @@ -22,6 +22,7 @@ fun:malloc ... fun:mkl_serv_malloc + ... fun:mkl_serv_domain_get_max_threads ... } diff --git a/python/scripts/rustc-manylinux_2_28_aarch64/Dockerfile b/python/scripts/rustc-manylinux_2_28_aarch64/Dockerfile new file mode 100644 index 000000000..16c10ada4 --- /dev/null +++ b/python/scripts/rustc-manylinux_2_28_aarch64/Dockerfile @@ -0,0 +1,11 @@ +# Use manylinux docker image as a base +FROM quay.io/pypa/manylinux_2_28_aarch64 + +RUN yum install git -y +RUN git config --global --add safe.directory /code + +# Download rustup-init asn install +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain 1.75 + +ENV PATH="/root/.cargo/bin:${PATH}" +ENV RUST_BUILD_TARGET="aarch64-unknown-linux-gnu"