Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary PyPI wheels #364

Merged
merged 78 commits into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
66d356a
support for building CUDA PyPI wheels
stefdoerr Mar 27, 2025
fa786b0
accidental commit
stefdoerr Mar 27, 2025
f9a098e
keep wheels and source packages clean
stefdoerr Mar 28, 2025
aa2c4d5
fix for skpping source file
stefdoerr Mar 28, 2025
d5ab932
Windows setup update for 12.4
stefdoerr Mar 28, 2025
b6344d2
new releasing to allow separate docs updates
stefdoerr Mar 28, 2025
0a82e3f
add windows section for cibuildwheel and fix issues with previous config
stefdoerr Mar 28, 2025
1930ad6
updated CI
stefdoerr Mar 28, 2025
4ad4222
only use cibw_archs on ubuntu jobs
stefdoerr Mar 28, 2025
7985eb4
no pytorch for old Mac. make if condition work on Windows
stefdoerr Mar 28, 2025
6f05a8c
repair-wheel fixed for OSX
stefdoerr Mar 28, 2025
36aec7b
typo
stefdoerr Mar 28, 2025
760a6ea
typo
stefdoerr Mar 28, 2025
10a8eff
merged old CI into new
stefdoerr Mar 28, 2025
404d87d
don't repair osx wheels
stefdoerr Mar 28, 2025
d67058a
ignore missing
stefdoerr Mar 28, 2025
34ac209
run a test that includes the compiled extension
stefdoerr Mar 28, 2025
d951642
rename yaml extension
stefdoerr Mar 28, 2025
84bce4f
enable full CI again
stefdoerr Mar 28, 2025
4457c89
fixing compilation issue in OSX
stefdoerr Mar 28, 2025
0b606eb
restore CI
stefdoerr Mar 31, 2025
b2beb73
reduce large test so it doesn't crash on laptop
stefdoerr Mar 31, 2025
e634790
try building different cuda versions
stefdoerr Mar 31, 2025
02a9eef
correct 11.8 URL
stefdoerr Mar 31, 2025
22774cc
don't pass GPUs on CI, there are none
stefdoerr Mar 31, 2025
a8dcc65
fix for mac
stefdoerr Mar 31, 2025
927cede
missing file
stefdoerr Mar 31, 2025
b2ab930
execute permissions
stefdoerr Mar 31, 2025
d285e44
install llvm and pybind11 for OSX so that the tests pass
stefdoerr Mar 31, 2025
b8e2e76
learning some stuff about brew
stefdoerr Mar 31, 2025
00f0eb8
envvar for osx tests
stefdoerr Mar 31, 2025
24c6f54
try again for mac
stefdoerr Mar 31, 2025
ef979ca
somehow didn't work
stefdoerr Mar 31, 2025
4137c30
try different approach
stefdoerr Mar 31, 2025
c7eb213
no need for the OSX script
stefdoerr Mar 31, 2025
28c1cda
free space on Linux, remove old step
stefdoerr Mar 31, 2025
9aa9809
install visual studio compiler on Windows
stefdoerr Mar 31, 2025
2398421
older windows
stefdoerr Mar 31, 2025
4f19e95
add the envvar
stefdoerr Mar 31, 2025
4e3cfee
move envvars to yaml file
stefdoerr Mar 31, 2025
d07993e
changed plan
stefdoerr Mar 31, 2025
86e2c34
try to fix Windows builds
stefdoerr Apr 1, 2025
766b6ec
use MSVC
stefdoerr Apr 1, 2025
d020ceb
used CMD for windows
stefdoerr Apr 1, 2025
94b4e10
increase verbosity on windows buildsg
stefdoerr Apr 1, 2025
1f8cf0d
add numpy to build and run dependencies
stefdoerr Apr 1, 2025
505860c
pip config not being picked up correctly
stefdoerr Apr 1, 2025
280d2d3
create folder
stefdoerr Apr 1, 2025
3794db0
MSVC toolset 17
stefdoerr Apr 1, 2025
393e393
22maybe?
stefdoerr Apr 1, 2025
971f87b
windows latest
stefdoerr Apr 1, 2025
9e0fd17
default toolset for windows 2022
stefdoerr Apr 1, 2025
66a41d0
older windows
stefdoerr Apr 1, 2025
c410ab3
missing thrust
stefdoerr Apr 1, 2025
b596942
thrust for cuda 12.4
stefdoerr Apr 1, 2025
cbc7660
debugging 12.4 issues
stefdoerr Apr 1, 2025
a92f3e7
add nvcc to PATH on cuda 12.4 Windows
stefdoerr Apr 1, 2025
2ec5454
manually specify arch lists for CUDA builds
stefdoerr Apr 1, 2025
3ec46e0
different approach for arch list
stefdoerr Apr 1, 2025
01ce937
run in bash
stefdoerr Apr 1, 2025
12ab6b2
try again
stefdoerr Apr 1, 2025
13398e6
try again
stefdoerr Apr 1, 2025
117da9f
try again
stefdoerr Apr 1, 2025
60d5b81
correctly export envvars for Windows
stefdoerr Apr 1, 2025
b900774
undo changes. issue is in pytorch package
stefdoerr Apr 1, 2025
b8a39ac
I do need extra index for Windows 12.4 after all
stefdoerr Apr 1, 2025
f386047
skip unstable aarch64 test. relax forward_multiple test which occasio…
stefdoerr Apr 1, 2025
290d943
print platform
stefdoerr Apr 1, 2025
8630dc7
run from inside container
stefdoerr Apr 1, 2025
e53f0b4
capitalization issue
stefdoerr Apr 1, 2025
bb75125
try pushing to GCP pypi
stefdoerr Apr 3, 2025
69e56da
fix issue with twine complaining about metadata
stefdoerr Apr 3, 2025
78b9486
try again with checkout
stefdoerr Apr 3, 2025
8f6a0a7
correct project ID
stefdoerr Apr 4, 2025
2b377fc
updated installation instructions. upload also to public PyPI
stefdoerr Apr 4, 2025
baa6b22
complete the PR
stefdoerr Apr 4, 2025
e15c1ae
fixed CI
stefdoerr Apr 4, 2025
7af0619
typo
stefdoerr Apr 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
name: Build Documentation

on:
push:
branches:
- "main"
pull_request:
branches:
- "main"
workflow_dispatch:
workflow_call:

jobs:
build-docs:
Expand Down
186 changes: 186 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
name: Build wheels and publish

on:
workflow_dispatch:
workflow_call:

jobs:
build:
name: Build wheels on ${{ matrix.os }}-${{ matrix.cuda }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, windows-2019, macos-latest]
cuda: [cpu, cu118, cu124]
exclude:
- os: ubuntu-24.04-arm
cuda: cu118
- os: ubuntu-24.04-arm
cuda: cu124
- os: macos-latest
cuda: cu118
- os: macos-latest
cuda: cu124

steps:
- name: Free space of Github Runner (otherwise it will fail by running out of disk)
if: matrix.os == 'ubuntu-latest'
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "/usr/local/.ghcup"
sudo rm -rf "/usr/local/julia1.9.2"
sudo rm -rf "/usr/local/lib/android"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"

- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.23.0

- name: Activate MSVC
uses: ilammy/msvc-dev-cmd@v1
if: matrix.os == 'windows-2019'

- name: Build wheels
if: matrix.os != 'windows-2019'
shell: bash -l {0}
run: |
if [[ "${{ runner.os }}" == "Linux" ]]; then
export CIBW_ARCHS="${{ matrix.os == 'ubuntu-24.04-arm' && 'aarch64' || 'auto64' }}"
fi
python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BEFORE_ALL_LINUX: "cibuildwheel_support/prepare_build_environment_linux_${{ matrix.cuda }}.sh"
CIBW_BEFORE_ALL_MACOS: "cibuildwheel_support/prepare_build_environment_osx.sh"
CPU_TRAIN: ${{ runner.os == 'macOS' && 'true' || 'false' }}
WITH_CUDA: ${{ matrix.cuda != 'cpu' && '1' || '0' }}

- name: Build wheels
if: matrix.os == 'windows-2019'
shell: cmd # Use cmd on Windows to avoid bash environment taking priority over MSVC variables
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BEFORE_ALL_WINDOWS: "bash cibuildwheel_support/prepare_build_environment_windows_${{ matrix.cuda }}.sh"
WITH_CUDA: ${{ matrix.cuda != 'cpu' && '1' || '0' }}
DISTUTILS_USE_SDK: "1" # Windows requires this to use vc for building
SKIP_TORCH_COMPILE: "true"
CIBW_BUILD_VERBOSITY_WINDOWS: "1"

- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.cuda }}-cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

publish-to-accelera-pypi:
name: >-
Publish Python 🐍 distribution 📦 to Acellera PyPI
needs:
- build
runs-on: ubuntu-latest
permissions: # Needed for GCP authentication
contents: "read"
id-token: "write"
strategy:
fail-fast: false
matrix:
cuda: [cpu, cu118, cu124]

steps:
- uses: actions/checkout@v4 # Needed for GCP authentication for some reason

- name: Set up Cloud SDK
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_PYPI_SERVICE_ACCOUNT }}

- name: Download all the dists
uses: actions/download-artifact@v4
with:
pattern: "${{ matrix.cuda }}-cibw-wheels*"
path: dist/
merge-multiple: true

- name: Publish distribution 📦 to Acellera PyPI
run: |
pip install build twine keyring keyrings.google-artifactregistry-auth
pip install -U packaging
twine upload --repository-url https://us-central1-python.pkg.dev/pypi-packages-455608/${{ matrix.cuda }} dist/* --verbose --skip-existing

publish-to-official-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/torchmd-net
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
pattern: "cu124-cibw-wheels*"
path: dist/
merge-multiple: true

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TMDNET_PYPI_API_TOKEN }}
skip_existing: true

github-release:
name: >-
Sign the Python 🐍 distribution 📦 with Sigstore
and upload them to GitHub Release
needs:
- build
runs-on: ubuntu-latest

permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
path: dist/
merge-multiple: true

- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.whl

- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
"$GITHUB_REF_NAME"
--repo "$GITHUB_REPOSITORY"
--notes ""

- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
"$GITHUB_REF_NAME" dist/**
--repo "$GITHUB_REPOSITORY"
21 changes: 6 additions & 15 deletions .github/workflows/CI.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
name: CI
name: Test

on:
push:
branches:
- "main"
pull_request:
branches:
- "main"
workflow_dispatch:
workflow_call:
schedule:
- cron: "0 0 * * 0" # Run every Sunday at 0:00

Expand All @@ -17,13 +13,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [
"ubuntu-latest",
"ubuntu-22.04-arm",
"macos-latest",
# "macos-13",
"windows-2022",
]
os:
["ubuntu-latest", "ubuntu-22.04-arm", "macos-latest", "windows-2022"]
python-version: ["3.10"]

defaults: # Needed for conda
Expand Down Expand Up @@ -56,7 +47,7 @@ jobs:
elif [[ "${{ runner.os }}" == "Linux" ]]; then
conda install gxx --channel conda-forge --override-channels
elif [[ "${{ runner.os }}" == "macOS" ]]; then
conda install clangxx llvm-openmp pybind11 --channel conda-forge --override-channels
conda install "clangxx<20" "llvm-openmp<20" pybind11 --channel conda-forge --override-channels
elif [[ "${{ runner.os }}" == "Windows" ]]; then
conda install vc vc14_runtime vs2015_runtime --channel conda-forge --override-channels
fi
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Whole

on: [push]

jobs:
test:
uses: ./.github/workflows/test.yml
secrets: inherit

publish:
if: startsWith(github.event.ref, 'refs/tags/v')
needs: test
uses: ./.github/workflows/publish.yml
secrets: inherit

docs:
if: startsWith(github.event.ref, 'refs/tags/')
needs: publish
uses: ./.github/workflows/docs.yml
secrets: inherit

docs_update:
if: startsWith(github.event.ref, 'refs/tags/d')
uses: ./.github/workflows/docs.yml
secrets: inherit
9 changes: 9 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
prune benchmarks
prune cibuildwheel_support
prune docs
prune examples
prune scripts
prune tests
exclude .readthedocs.yaml
exclude environment.yml
exclude Makefile
30 changes: 22 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
ifndef version
$(error version variable is not set. Call with `make release version=XXX`)
endif
# Check that given variables are set and all have non-empty values,
# die with an error otherwise.
#
# Params:
# 1. Variable name(s) to test.
# 2. (optional) Error message to print.
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined variable: $1$(if $2, ($2))))

.PHONY: release docs

release:
git checkout main
git fetch
git pull
git tag -a $(version) -m "$(version) release"
git push --tags origin $(version)
@:$(call check_defined, version, The release version)
git tag -a v$(version) -m "v$(version) release"
git push --tags origin v$(version)

docs:
@:$(call check_defined, version, The release version)
git tag -fa d$(version) -m "$(version) docs"
git push -f --tags origin d$(version)
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,30 @@ Documentation is available at https://torchmd-net.readthedocs.io


## Installation
TorchMD-Net is available in [conda-forge](https://conda-forge.org/) and can be installed with:
TorchMD-Net is available as a pip installable wheel as well as in [conda-forge](https://conda-forge.org/)

TorchMD-Net provides builds for CPU-only, CUDA 11.8 and CUDA 12.4. CPU versions are only provided as reference,
as the performance will be extremely limited.
Depending on which variant you wish to install, you can install it with one of the following commands:

```sh
# The following will install the CUDA 12.4 version by default
pip install torchmd-net
# The following will install the CUDA 11.8 version
pip install torchmd-net --extra-index-url https://download.pytorch.org/whl/cu118 --extra-index-url https://us-central1-python.pkg.dev/pypi-packages-455608/cu118/simple
# The following will install the CUDA 12.4 version
pip install torchmd-net --extra-index-url https://download.pytorch.org/whl/cu124 --extra-index-url https://us-central1-python.pkg.dev/pypi-packages-455608/cu124/simple
# The following will install the CPU only version (not recommended)
pip install torchmd-net --extra-index-url https://download.pytorch.org/whl/cpu --extra-index-url https://us-central1-python.pkg.dev/pypi-packages-455608/cpu/simple
```

Alternatively it can be installed with conda or mamba with one of the following commands.
We recommend using [Miniforge](https://github.com/conda-forge/miniforge/) instead of anaconda.

```shell
mamba install torchmd-net
mamba install torchmd-net cuda-version=11.8
mamba install torchmd-net cuda-version=12.4
```
We recommend using [Mamba](https://github.com/conda-forge/miniforge/#mambaforge) instead of conda.

### Install from source

Expand Down
4 changes: 4 additions & 0 deletions cibuildwheel_support/prepare_build_environment_linux_cpu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Configure pip to use PyTorch extra-index-url for CPU
mkdir -p $HOME/.config/pip
echo "[global]
extra-index-url = https://download.pytorch.org/whl/cpu" > $HOME/.config/pip/pip.conf
37 changes: 37 additions & 0 deletions cibuildwheel_support/prepare_build_environment_linux_cu118.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#! /bin/bash

set -e
set -x


if [ "$CIBW_ARCHS" != "aarch64" ]; then

# Install CUDA 11.8:
dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo

dnf install --setopt=obsoletes=0 -y \
cuda-nvcc-11-8-11.8.89-1 \
cuda-cudart-devel-11-8-11.8.89-1 \
libcurand-devel-11-8-10.3.0.86-1 \
libcudnn9-devel-cuda-11-9.8.0.87-1 \
libcublas-devel-11-8-11.11.3.6-1 \
libnccl-devel-2.15.5-1+cuda11.8 \
libcusparse-devel-11-8-11.7.5.86-1 \
libcusolver-devel-11-8-11.4.1.48-1 \
gcc-toolset-11

ln -s cuda-11.8 /usr/local/cuda
ln -s /opt/rh/gcc-toolset-11/root/usr/bin/gcc /usr/local/cuda/bin/gcc
ln -s /opt/rh/gcc-toolset-11/root/usr/bin/g++ /usr/local/cuda/bin/g++

export CUDA_HOME="/usr/local/cuda"
export WITH_CUDA=1


# Configure pip to use PyTorch extra-index-url for CUDA 11.8
mkdir -p $HOME/.config/pip
echo "[global]
extra-index-url = https://download.pytorch.org/whl/cu118" > $HOME/.config/pip/pip.conf

fi

Loading
Loading