fix: link PyTorch libraries in wheel builds #13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Test | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| workflow_dispatch: | |
| jobs: | |
| # Build the distributable CPU wheel on a standard hosted runner. | |
| build: | |
| name: Build (CPU, Ubuntu 22.04, Python 3.11) | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake build-essential | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build wheel "setuptools>=64" "cmake>=3.14" "pybind11>=2.10.0" | |
| pip install torch==2.5.1 --index-url https://download.pytorch.org/whl/cpu | |
| pip install "numpy>=1.20.0" | |
| pip install pytest pytest-cov | |
| - name: Build package | |
| run: | | |
| python -m build --wheel --no-isolation | |
| env: | |
| AMMS_ENABLE_CUDA: "0" | |
| - name: Install package | |
| run: | | |
| pip install dist/*.whl | |
| - name: Run tests | |
| run: | | |
| pytest tests/ -v --cov=sage.libs.amms --cov-report=xml | |
| - name: Upload coverage | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| file: ./coverage.xml | |
| flags: unittests | |
| name: codecov-umbrella | |
| - name: Upload wheel | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheel-cpu-ubuntu22.04-py311 | |
| path: dist/*.whl | |
| cuda-contract: | |
| name: CUDA build contract | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Validate explicit CUDA switch | |
| run: | | |
| pip install pytest numpy | |
| pytest \ | |
| tests/test_issue5_cuda_cpu_switch_cleanup.py \ | |
| tests/test_issue6_build_matrix_and_perf_baseline.py::test_issue6_setup_has_explicit_cuda_cpu_switch_contract | |
| # Code quality checks | |
| lint: | |
| name: Code Quality | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install black ruff mypy numpy torch | |
| - name: Check formatting with Black | |
| run: | | |
| black --check sage/ tests/ | |
| - name: Lint with Ruff | |
| run: | | |
| ruff check sage/ tests/ | |
| - name: Type check with mypy | |
| run: | | |
| mypy sage/libs/amms/ --ignore-missing-imports || true |