Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
db49834
modify release-build for linux and macosx
May 20, 2025
4173ff4
change to pipx for macos setup
May 20, 2025
bd3eeac
change macosx to use pypa/cibuildwheel action and add --no-cache-dir …
PabloCarmona May 20, 2025
bf034ba
fix vars for macos build
PabloCarmona May 20, 2025
287ce56
fix and add proper x86 arch
PabloCarmona May 20, 2025
f92ccbf
put proper torch version
PabloCarmona May 20, 2025
0837600
remove unnecessary matrix
PabloCarmona May 20, 2025
e9c4582
add step for setup openblas on macos build
PabloCarmona May 20, 2025
0f3311d
change manylinux build
PabloCarmona May 20, 2025
396f830
add clean, prune and cache tasks to help optimize disk space on runnners
PabloCarmona May 20, 2025
55ead00
clean some jobs not necessary
PabloCarmona May 20, 2025
14d5460
add compatible macosx version
PabloCarmona May 20, 2025
075cd23
disk optimization
PabloCarmona May 20, 2025
2933d28
update pyproject.toml and modify release-build
PabloCarmona May 21, 2025
dbb5389
change versions for build
PabloCarmona May 22, 2025
29f20d2
move from aws to ibmcloud cos publish
PabloCarmona May 23, 2025
7846641
fix pyproject.toml syntax error
PabloCarmona May 23, 2025
db4d584
fix pyproject.toml syntax error
PabloCarmona May 23, 2025
4bbbc2f
remove backend path
PabloCarmona May 23, 2025
0dd5a58
fix pyproject.toml syntax error
PabloCarmona May 23, 2025
3125e45
bump macosx target version from 10.9 to 10.13
PabloCarmona May 23, 2025
c71c8fd
fix pyproject.toml typo errpr
PabloCarmona May 23, 2025
b76da3f
add multiple python version
PabloCarmona May 23, 2025
3697142
fix naming version for macosx builds
PabloCarmona May 23, 2025
11b76a7
add cicd status badge to README
PabloCarmona May 23, 2025
beb9cd0
fix problem with Pytorch versions
May 28, 2025
f77f7ef
add fix to release-build workflow
PabloCarmona May 28, 2025
a324766
fix lint for naming
PabloCarmona May 28, 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
295 changes: 94 additions & 201 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,233 +2,126 @@ name: release-build

on:
workflow_dispatch:
create:
tags: 'v**'

permissions:
id-token: write
contents: read

env:
COS_ACCESS_KEY_ID: ${{ secrets.COS_ACCESS_KEY_ID }}
COS_SECRET_ACCESS_KEY: ${{ secrets.COS_SECRET_ACCESS_KEY }}
COS_BUCKET: ${{ secrets.COS_BUCKET }}
COS_ENDPOINT: ${{ secrets.COS_ENDPOINT }}
IBM_CLOUD_REGION: ${{ secrets.IBM_CLOUD_REGION }}
IBM_CLOUD_API_KEY: ${{ secrets.IBM_CLOUD_API_KEY }}
IBM_CLOUD_RESOURCE_GROUP: ${{ secrets.IBM_CLOUD_RESOURCE_GROUP }}
COS_BUCKET: ${{ secrets.COS_BUCKET }}

jobs:
# ────────────────────────────
# Test on Python 3.10
# Stage: Build & Deploy Wheels
# ────────────────────────────
test-py310:
name: Test (Python 3.10)
build-and-deploy-linux:
name: Build & Deploy wheels (manylinux)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python 3.10
uses: actions/setup-python@v5
- uses: actions/cache@v4
with:
python-version: 3.10.17

- name: Install system dependencies
run: |
sudo apt-get -qq update
sudo apt-get install -y ca-certificates libopenblas-dev gcc-9 g++-9
sudo update-alternatives \
--install /usr/bin/gcc gcc /usr/bin/gcc-9 60 \
--slave /usr/bin/g++ g++ /usr/bin/g++-9
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}

- name: Build and install aihwkit wheel
- name: Cleanup runner
run: |
pip install -r requirements.txt
make build_inplace
pip cache purge
sudo apt-get clean
sudo rm -rf /var/lib/apt/lists/*

- name: Run pytest
run: |
pip install -r requirements-dev.txt
make pytest
- name: Build wheels
uses: pypa/[email protected]
env:
TEST_DATASET: true

# ────────────────────────────
# Lint on Python 3.10
# ────────────────────────────
lint-py310:
name: Lint (Python 3.10)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v5
CIBW_ENVIRONMENT: "TORCH_VERSION_SPECIFIER='==2.3.1' MAKEFLAGS='-j4'"
CIBW_BEFORE_BUILD: "pip install torch==2.3.1 torchvision -f https://download.pytorch.org/whl/torch_stable.html && pip install -r requirements.txt"
CIBW_MANYLINUX_X86_64_IMAGE: "aihwkit/manylinux2014_x86_64_aihwkit"
CIBW_REPAIR_WHEEL_COMMAND: "auditwheel repair -w {dest_dir} {wheel} --exclude libtorch_python.so"
CIBW_BUILD: "cp38-manylinux_x86_64 cp39-manylinux_x86_64 cp310-manylinux_x86_64"
with:
python-version: 3.10.17

- name: Install system dependencies
run: |
sudo apt-get -qq update
sudo apt-get install -y ca-certificates libopenblas-dev gcc-9 g++-9
sudo update-alternatives \
--install /usr/bin/gcc gcc /usr/bin/gcc-9 60 \
--slave /usr/bin/g++ g++ /usr/bin/g++-9
output-dir: wheelhouse

- name: Build and install aihwkit wheel
- name: Sync wheels to IBM COS
env:
IBM_CLOUD_REGION: ${{ secrets.IBM_CLOUD_REGION }}
IBM_CLOUD_API_KEY: ${{ secrets.IBM_CLOUD_API_KEY }}
IBM_CLOUD_RESOURCE_GROUP: ${{ secrets.IBM_CLOUD_RESOURCE_GROUP }}
COS_BUCKET: ${{ secrets.COS_BUCKET }}
run: |
pip install -r requirements.txt
make build_inplace

- name: Run lint checks
curl -fsSL https://clis.cloud.ibm.com/install/linux | sh
ibmcloud plugin install cos
ibmcloud login --apikey "$IBM_CLOUD_API_KEY" -r "$IBM_CLOUD_REGION" -g "$IBM_CLOUD_RESOURCE_GROUP"
Comment on lines +51 to +53
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily for this PR, but we have an official github action for setting up the CLI, logging in and installing plugins.

find "wheelhouse" -type f | while read filepath; do
relpath="${filepath#wheelhouse/}"
dest="$relpath"
echo "Uploading $filepath to $dest"
ibmcloud cos upload \
--bucket "$COS_BUCKET" \
--key "$dest" \
--file "$filepath" \
--region "$IBM_CLOUD_REGION"
done

- name: Cleanup runner
if: always()
run: |
pip install -r requirements-dev.txt
pip install -r requirements-examples.txt
make pycodestyle
make pylint
make mypy
# ────────────────────────────────────────
# Stage: Test multiple Python versions
# ────────────────────────────────────────
test-matrix:
name: Tests (3.8 & 3.9)
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9]
pip cache purge
sudo apt-get clean
sudo rm -rf /var/lib/apt/lists/* /var/cache/apt/*
rm -rf wheelhouse build dist *.egg-info

build-and-deploy-macos:
name: Build & Deploy wheels (macOS)
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- uses: actions/cache@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install system deps
run: |
sudo apt-get -qq update
sudo apt-get install -y ca-certificates libopenblas-dev gcc-9 g++-9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 \
--slave /usr/bin/g++ g++ /usr/bin/g++-9

- name: Build and install aihwkit wheel
run: |
pip install -r requirements.txt
make build_inplace
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}

- name: Run pytest
- name: Set up Environment
run: |
pip install -r requirements-dev.txt
make pytest

# ────────────────────────────
# Stage: Build & Deploy Wheels
# ────────────────────────────
build-and-deploy-linux:
name: Build & Deploy wheels (manylinux)
runs-on: ubuntu-latest
services:
docker:
image: docker:20.10.16
options: --privileged
env:
CIBW_ENVIRONMENT: "TORCH_VERSION_SPECIFIER='==2.3.1+cu121'"
CIBW_BEFORE_BUILD: "pip install torch==2.3.1+cu121 torchvision -f https://download.pytorch.org/whl/torch_stable.html && pip install -r requirements.txt"
CIBW_MANYLINUX_X86_64_IMAGE: "aihwkit/manylinux2014_x86_64_aihwkit_cuda"
CIBW_REPAIR_WHEEL_COMMAND: "auditwheel repair -w {dest_dir} {wheel} --exclude libtorch_python.so"
CIBW_BUILD: "cp39-manylinux_x86_64 cp310-manylinux_x86_64"
AIHWKIT_VERSION_SUFFIX: "+cuda121"
steps:
- uses: actions/checkout@v3

- name: Pull manylinux image
run: docker pull $CIBW_MANYLINUX_X86_64_IMAGE

- name: Install cibuildwheel
run: python3 -m pip install cibuildwheel==2.23.3
brew install openblas
brew link --force openblas
git clone -b aihwkit https://github.com/aihwkit-bot/delocate.git

- name: Build wheels
run: python3 -m cibuildwheel --output-dir wheelhouse
uses: pypa/[email protected]
env:
CIBW_ENVIRONMENT: "TORCH_VERSION_SPECIFIER='==2.3.1'"
CIBW_BEFORE_BUILD: "pip install torch==2.3.1 torchvision -f https://download.pytorch.org/whl/torch_stable.html && pip install ./delocate && pip install -r requirements.txt"
CIBW_ARCHS: "x86_64"
CIBW_BUILD: "cp38-macosx_x86_64 cp39-macosx_x86_64 cp310-macosx_x86_64"
MACOSX_DEPLOYMENT_TARGET: "10.13"
with:
output-dir: wheelhouse

- name: Sync wheels to IBM COS
env:
AWS_ACCESS_KEY_ID: ${{ secrets.COS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.COS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-south-1
IBM_CLOUD_REGION: ${{ secrets.IBM_CLOUD_REGION }}
IBM_CLOUD_API_KEY: ${{ secrets.IBM_CLOUD_API_KEY }}
IBM_CLOUD_RESOURCE_GROUP: ${{ secrets.IBM_CLOUD_RESOURCE_GROUP }}
COS_BUCKET: ${{ secrets.COS_BUCKET }}
run: |
which aws || pip install awscli --upgrade
aws s3 sync wheelhouse/ s3://${{ env.COS_BUCKET }}/ \
--acl public-read \
--delete \
--endpoint-url https://${{ env.COS_ENDPOINT }}

# build-and-deploy-macos:
# name: Build & Deploy wheels (macOS)
# runs-on: macos-latest
# env:
# CIBW_ENVIRONMENT: "TORCH_VERSION_SPECIFIER='==2.0.1'"
# CIBW_BEFORE_BUILD: "pip install torch==2.0.1 torchvision && pip install ./delocate && pip install -r requirements.txt"
# CIBW_BUILD: "cp38-macosx_x86_64 cp39-macosx_x86_64"
# steps:
# - uses: actions/checkout@v3

# - name: Install Homebrew deps
# run: |
# brew update
# brew install openblas

# - name: Clone delocate
# run: git clone -b aihwkit https://github.com/aihwkit-bot/delocate.git

# - name: Install cibuildwheel
# run: python3 -m pip install cibuildwheel==2.8.1

# - name: Build wheels
# run: python3 -m cibuildwheel --output-dir wheelhouse --platform macos

# - name: Sync wheels to IBM COS
# env:
# AWS_ACCESS_KEY_ID: ${{ secrets.COS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.COS_SECRET_ACCESS_KEY }}
# AWS_DEFAULT_REGION: us-south-1
# run: |
# which aws || pip install awscli --upgrade
# aws s3 sync wheelhouse/ s3://${{ env.COS_BUCKET }}/ \
# --acl public-read \
# --delete \
# --endpoint-url https://${{ env.COS_ENDPOINT }}

# build-and-deploy-windows:
# name: Build & Deploy wheels (Windows)
# runs-on: windows-latest
# env:
# CIBW_ENVIRONMENT: "TORCH_VERSION_SPECIFIER='==2.4.1'"
# CIBW_BEFORE_BUILD: "pip install torch==2.4.1 && pip install -r requirements.txt"
# CIBW_BUILD: "cp38-win_amd64 cp39-win_amd64 cp310-win_amd64"
# OPENBLAS_ROOT: C:\\BLAS
# OPENBLAS_ROOT_DIR: C:\\BLAS
# steps:
# - uses: actions/checkout@v3

# - name: Install Python & BLAS
# run: |
# choco install python --version=3.8.6 -y
# SET PATH=C:\Python38;C:\Python38\Scripts;%PATH%
# mkdir C:\BLAS
# Invoke-WebRequest -Uri https://github.com/xianyi/OpenBLAS/releases/download/v0.3.12/OpenBLAS-0.3.12-x64.zip -OutFile openblas.zip
# Expand-Archive openblas.zip -DestinationPath C:\BLAS

# - name: Install cibuildwheel
# run: python -m pip install cibuildwheel==2.8.1

# - name: Build wheels
# run: python -m cibuildwheel --output-dir wheelhouse

# - name: Sync wheels to IBM COS
# env:
# AWS_ACCESS_KEY_ID: ${{ secrets.COS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.COS_SECRET_ACCESS_KEY }}
# AWS_DEFAULT_REGION: us-south-1
# run: |
# which aws || pip install awscli --upgrade
# aws s3 sync wheelhouse/ s3://${{ env.COS_BUCKET }}/ \
# --acl public-read \
# --delete \
# --endpoint-url https://${{ env.COS_ENDPOINT }}
curl -fsSL https://clis.cloud.ibm.com/install/osx | sh
ibmcloud plugin install cos
ibmcloud login --apikey "$IBM_CLOUD_API_KEY" -r "$IBM_CLOUD_REGION" -g "$IBM_CLOUD_RESOURCE_GROUP"
find "wheelhouse" -type f | while read filepath; do
relpath="${filepath#wheelhouse/}"
dest="$relpath"
echo "Uploading $filepath to $dest"
ibmcloud cos upload \
--bucket "$COS_BUCKET" \
--key "$dest" \
--file "$filepath" \
--region "$IBM_CLOUD_REGION"
done
- name: Cleanup runner
if: always()
run: |
pip cache purge
brew cleanup --prune=all
rm -rf ~/Library/Caches/Homebrew/*
rm -rf wheelhouse build dist *.egg-info
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# IBM Analog Hardware Acceleration Kit

![PyPI](https://img.shields.io/pypi/v/aihwkit)
[![test-and-lint](https://github.com/IBM/aihwkit/actions/workflows/test-and-lint.yml/badge.svg)](https://github.com/IBM/aihwkit/actions/workflows/test-and-lint.yml)
[![release-build](https://github.com/IBM/aihwkit/actions/workflows/release-build.yml/badge.svg)](https://github.com/IBM/aihwkit/actions/workflows/release-build.yml)
[![Documentation Status](https://readthedocs.org/projects/aihwkit/badge/?version=latest)](https://aihwkit.readthedocs.io/en/latest/?badge=latest)
![PyPI - License](https://img.shields.io/pypi/l/aihwkit)
[![arXiv](https://img.shields.io/badge/arXiv-2104.02184-green.svg)](https://arxiv.org/abs/2104.02184)
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ requires = [
"numpy>=1.22,<2",
"protobuf>=4.21.6",
"tqdm",
"mypy==0.991"
"mypy==0.991",
"ninja; platform_system!='Windows'",
]
build-backend = "setuptools.build_meta"
9 changes: 4 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,20 @@
from skbuild import setup

INSTALL_REQUIRES = [
"torch{}".format(os.getenv("TORCH_VERSION_SPECIFIER", ">=1.9")),
"torch{}".format(os.getenv("TORCH_VERSION_SPECIFIER", ">=1.9,<2.7")),
"torchvision",
"scipy",
"requests>=2.25,<3",
"numpy>=1.22",
"protobuf>=4.21.6",
]


def get_version() -> str:
"""Get the package version."""
"""Get the package version for CUDA enabled wheels."""
version_path = os.path.join(os.path.dirname(__file__), "src", "aihwkit", "VERSION.txt")
with open(version_path, encoding="utf-8") as version_file:
return version_file.read().strip()

version_number = version_file.read().strip()
return f"{version_number}{os.getenv('AIHWKIT_VERSION_SUFFIX', '')}"

def get_long_description() -> str:
"""Get the package long description."""
Expand Down