make Gibbs MPS trace tag-wise #443
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: CI | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| jobs: | |
| test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - python-version: "3.10" | |
| profile: core | |
| extras: dev | |
| - python-version: "3.11" | |
| profile: core | |
| extras: dev | |
| - python-version: "3.12" | |
| profile: core | |
| extras: dev | |
| - python-version: "3.12" | |
| profile: extended | |
| extras: dev,test-extended,contraction | |
| - python-version: "3.12" | |
| profile: vmc | |
| extras: dev,vmc | |
| runs-on: ubuntu-latest | |
| env: | |
| NUMBA_CACHE_DIR: /tmp/numba_cache_pepsy | |
| NUMBA_DISABLE_CACHING: "1" | |
| PYTHONPYCACHEPREFIX: /tmp/pycache_pepsy | |
| MPLCONFIGDIR: /tmp/mplconfig_pepsy | |
| MPLBACKEND: Agg | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install package (${{ matrix.profile }}) | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[${{ matrix.extras }}]" | |
| - name: Validate source syntax | |
| run: python -m compileall -q -f src tests | |
| - name: Check Python lint | |
| # Ruff's F rules cover the Pyflakes checks and honor noqa markers for | |
| # intentional lazy, type-only, and compatibility exports. | |
| run: python -m ruff check src/pepsy tests | |
| - name: Run tests with coverage | |
| if: matrix.python-version == '3.12' && matrix.profile == 'core' | |
| run: pytest -q --cov=pepsy --cov-report=term-missing | |
| - name: Run extended tests with coverage | |
| if: matrix.profile == 'extended' | |
| run: pytest -q -o addopts="" --cov=pepsy --cov-report=term-missing --cov-fail-under=60 | |
| - name: Run tests | |
| if: matrix.profile == 'vmc' || (matrix.profile == 'core' && matrix.python-version != '3.12') | |
| run: pytest -q -o addopts="" | |
| typecheck: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install type-check dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[dev]" | |
| - name: Run focused type checks | |
| run: python -m mypy src/pepsy/tensors/validation.py src/pepsy/vmc/api.py | |
| mpi: | |
| name: MPI (${{ matrix.ranks }} ranks) | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| ranks: [2, 3] | |
| runs-on: ubuntu-latest | |
| env: | |
| NUMBA_CACHE_DIR: /tmp/numba_cache_pepsy | |
| NUMBA_DISABLE_CACHING: "1" | |
| PYTHONPYCACHEPREFIX: /tmp/pycache_pepsy | |
| MPLCONFIGDIR: /tmp/mplconfig_pepsy | |
| MPLBACKEND: Agg | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install MPI runtime | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y openmpi-bin libopenmpi-dev | |
| - name: Install MPI test profile | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[dev,mpi]" | |
| - name: Run MPI unit-contract tests | |
| run: pytest -q -o addopts="" tests/test_mpi.py | |
| - name: Run multi-process MPI integration tests | |
| run: | | |
| mpiexec --oversubscribe --bind-to none -n ${{ matrix.ranks }} \ | |
| python -m pytest -q -o addopts="" \ | |
| tests/test_mpi_integration.py | |
| - name: Run MPI benchmark smoke test | |
| run: | | |
| mpiexec --oversubscribe --bind-to none -n ${{ matrix.ranks }} \ | |
| python benchmarks/mpi_shots.py \ | |
| --shots 8 --qubits 2 --depth 1 --chi 4 --workers auto | |
| package: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Build distributions | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[dev]" | |
| python -m build --sdist --wheel | |
| python -m twine check dist/* | |
| version="$(python -c "import pathlib, tomllib; print(tomllib.loads(pathlib.Path('pyproject.toml').read_text())['project']['version'])")" | |
| echo "Built Pepsy version: ${version}" | |
| - name: Smoke test wheel installation | |
| run: | | |
| smoke_dir="$(mktemp -d)" | |
| python -m venv "$smoke_dir/no-deps-venv" | |
| expected_version="$(python -c "import pathlib, tomllib; print(tomllib.loads(pathlib.Path('pyproject.toml').read_text())['project']['version'])")" | |
| "$smoke_dir/no-deps-venv/bin/pip" install --no-deps dist/*.whl | |
| EXPECTED_VERSION="$expected_version" "$smoke_dir/no-deps-venv/bin/python" -c \ | |
| "import importlib.metadata as md, os, pepsy; expected=os.environ['EXPECTED_VERSION']; actual=md.version('pepsy'); assert pepsy.__version__ == actual == expected; assert hasattr(pepsy, 'experimental')" | |
| - name: Smoke test base dependency installation | |
| run: | | |
| smoke_dir="$(mktemp -d)" | |
| python -m venv "$smoke_dir/venv" | |
| "$smoke_dir/venv/bin/pip" install dist/*.whl | |
| "$smoke_dir/venv/bin/python" -c \ | |
| "import pepsy; import pepsy.backends, pepsy.boundary, pepsy.fitting, pepsy.interop, pepsy.solvers, pepsy.tensors" | |
| "$smoke_dir/venv/bin/python" -X importtime -c "import pepsy" 2> "$smoke_dir/importtime.txt" | |
| tail -n 1 "$smoke_dir/importtime.txt" | |
| docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install documentation profile | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[docs]" | |
| - name: Build documentation | |
| run: python -m sphinx -q -b html docs docs/_build/html |