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

feat: PortDiff for StaticSizeCircuit #561

Draft
wants to merge 57 commits into
base: feat/badgerv2
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
dd083ee
feat: Add StaticSizeCircuit
lmondada Aug 19, 2024
67d6d90
Add linked_op method
lmondada Aug 20, 2024
c710541
feat: Fast hashing for StaticSizeCircuit
lmondada Aug 20, 2024
e3f773d
chore: Move `pyproject.toml` to `tket2-py` (#546)
aborgna-q Aug 22, 2024
58a5015
Implement portmatching
lmondada Aug 23, 2024
dd29e3a
chore: Use portmatching pre-release
lmondada Aug 26, 2024
5038474
chore(deps-py): bump the dev group across 1 directory with 3 updates …
dependabot[bot] Aug 27, 2024
c1210cc
feat: PortDiff support
lmondada Aug 27, 2024
685b4f7
chore: Replace `poetry` with `uv` (#557)
aborgna-q Aug 27, 2024
3d32130
chore(deps-rs): bump the patch group with 2 updates (#558)
dependabot[bot] Aug 27, 2024
486fd29
Finish PortDiff impl
lmondada Aug 27, 2024
7c83ba8
feat: Extend Command::optype lifetime (#562)
lmondada Aug 28, 2024
17644ef
chore(deps-rs): bump bytemuck from 1.17.0 to 1.17.1 in the patch grou…
dependabot[bot] Sep 2, 2024
258a7c5
feat!: Update rust hugr dependency to `0.12.0`, and python hugr to `0…
aborgna-q Sep 2, 2024
8503cc9
feat: Badger on PortDiff
lmondada Sep 3, 2024
42cc82f
feat!: remove Tk2Op::AngleAdd (#567)
ss2165 Sep 3, 2024
fb2e4e0
fix: Deactivate Sentinels, check owner in SameOp predicate
lmondada Sep 3, 2024
ee4dc88
docs: Add static_circ docs
lmondada Sep 3, 2024
0147a35
chore: Upgarde to portmatching rc2
lmondada Sep 3, 2024
9d7ef43
feat: Support empty wire
lmondada Sep 3, 2024
1a617aa
feat: Update search strategy
lmondada Sep 3, 2024
a231905
feat(badger): Fix qubit order
lmondada Sep 3, 2024
62351fb
feat!: angle type no longer parametric. (#577)
ss2165 Sep 4, 2024
e6acc88
feat!: HSeries ops (#573)
ss2165 Sep 4, 2024
cc41081
feat: Better cost heuristic
lmondada Sep 4, 2024
d14631f
feat!: replace f64 with angle type for tk2 ops (#578)
ss2165 Sep 4, 2024
bf73511
feat: more angle ops (construct, deconstruct, radians, equality) (#581)
ss2165 Sep 4, 2024
06a6838
fix!: quantum extension name wrong way round (#582)
ss2165 Sep 4, 2024
6fe8807
chore: Update to portdiff v0.3 and activate salient squashing
lmondada Sep 4, 2024
eb833a4
chore: release v0.2.0 (#553)
hugrbot Sep 4, 2024
d9538d3
chore(py): release tket2-py 0.3.0 (#570)
hugrbot Sep 4, 2024
e3f9da1
ci: Fix incorrect wheels name on publish (#587)
aborgna-q Sep 5, 2024
f0884cc
feat!: move angle types + and ops to new "tket2.angle" extension (#591)
ss2165 Sep 5, 2024
09a7b8b
ci: Fix wheels upload on different dir (#590)
aborgna-q Sep 5, 2024
7591c08
fix: extension ops checking against incorrect name (#593)
ss2165 Sep 5, 2024
5ca29af
fix!: remove TryFrom for extension ops use `cast` (#592)
ss2165 Sep 5, 2024
dd9592f
fix: don't load angle extensions on to quantum (#597)
ss2165 Sep 5, 2024
dcc562d
feat: dataflow builder methods for angle ops (#596)
ss2165 Sep 6, 2024
cd27d46
fix: badger-optimiser produces Diff json output
lmondada Sep 6, 2024
7ac0206
feat: lowering tk2ops -> hseriesops (#579)
ss2165 Sep 6, 2024
304471b
feat: Store rewrite value in serialised format
lmondada Sep 9, 2024
9358142
feat: Enable compile-rewriter
lmondada Sep 9, 2024
9ed57c1
chore: Upgrade portdiff to v0.3.1
lmondada Sep 9, 2024
58e1626
chore(deps-rs): bump the minor group with 2 updates (#600)
dependabot[bot] Sep 9, 2024
d9deacb
chore(deps-rs): bump the patch group with 3 updates (#599)
dependabot[bot] Sep 9, 2024
191c86f
WIP Python bindings for StaticSizeCircuit
lmondada Sep 10, 2024
aed9d73
Merge branch 'main' into feat/portdiff
ABorgna Sep 10, 2024
f537bb5
Solve some warnings
lmondada Sep 10, 2024
7c5de17
Use portdiff's MergeStrategy
lmondada Sep 9, 2024
4ba3e8c
just fix
ABorgna Sep 10, 2024
3b61397
Wrap PortDiffGraph
ABorgna Sep 10, 2024
34c70da
Add python all_edges
lmondada Sep 11, 2024
469a5f2
Working badgerv2 prototype
lmondada Sep 20, 2024
1cee039
Update portdiff
lmondada Sep 20, 2024
970e782
feat: PortDiff rendering in jupyter
lmondada Sep 20, 2024
b99fa90
docs: Add badger v2 demo
lmondada Sep 20, 2024
52d33b2
Use https
lmondada Sep 23, 2024
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
2 changes: 1 addition & 1 deletion .github/change-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ python:
- "tket2-py/**"
- "tket2-eccs/**"
- "pyproject.toml"
- "poetry.lock"
- "uv.lock"
5 changes: 4 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ updates:
# Major updates still generate individual PRs

- package-ecosystem: "pip"
directory: "/" # Location of package manifests
directories: # Location of package manifests
- "/"
- "/tket2-py"
- "/tket2-eccs"
schedule:
interval: "weekly"
commit-message:
Expand Down
8 changes: 8 additions & 0 deletions .github/script/install-uv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

# Installs a fixed UV version
#
# This reads the `UV_CACHE_DIR` environment variable if it is set,
# and stores the downloaded dependencies in that directory.

curl -LsSf https://astral.sh/uv/0.3.4/install.sh | sh
58 changes: 36 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ env:
CI: true # insta snapshots behave differently on ci
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
UV_CACHE_DIR: /tmp/.uv-cache

jobs:
# Check if changes were made to the relevant files.
Expand Down Expand Up @@ -82,23 +83,29 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: mozilla-actions/[email protected]
- name: Install poetry
run: pipx install poetry
- name: Set up Python
- name: Set up uv
run: .github/script/install-uv.sh
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: "poetry"
- name: Install the project libraries
# Note: We do not need to compile with maturin here,
# as we are only checking the Python code.
run: poetry install
python-version: '3.12'
- name: Restore uv cache
uses: actions/cache@v4
with:
path: ${{ env.UV_CACHE_DIR }}
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}
- name: Setup dependencies
run: uv sync --locked
- name: Type check with mypy
run: poetry run mypy .
run: uv run mypy .
- name: Check formatting with ruff
run: poetry run ruff format --check
run: uv run ruff format --check
- name: Lint with ruff
run: poetry run ruff check
run: uv run ruff check
- name: Minimize uv cache
run: uv cache prune --ci

benches:
name: Build benchmarks 🏋️
Expand Down Expand Up @@ -226,23 +233,30 @@ jobs:
- uses: mozilla-actions/[email protected]
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
- name: Set up uv
run: .github/script/install-uv.sh
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'poetry'
- name: Build pyo3 bindings
run: |
poetry install
poetry run maturin develop
python-version: '3.10'
- name: Restore uv cache
uses: actions/cache@v4
with:
path: ${{ env.UV_CACHE_DIR }}
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}
- name: Setup dependencies
run: uv sync --locked
- name: Run python tests with coverage instrumentation
run: poetry run pytest --cov=./ --cov-report=xml
run: uv run pytest --cov=./ --cov-report=xml
- name: Upload coverage output artifact
uses: actions/upload-artifact@v4
with:
name: py-coverage
path: coverage.xml
- name: Minimize uv cache
run: uv cache prune --ci

coverage-py:
name: Upload Python coverage 🐍
Expand Down
43 changes: 29 additions & 14 deletions .github/workflows/python-pure-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
matrix:
target:
- { name: tket2-eccs, key_secret: PYPI_PUBLISH_TKET2_ECCS }
- { dir: tket2-eccs, name: tket2_eccs, key_secret: PYPI_PUBLISH_TKET2_ECCS }
steps:
# Check the release tag against the package name
#
Expand All @@ -35,41 +35,56 @@ jobs:
run: |
echo "run=$SHOULD_RUN" >> $GITHUB_OUTPUT
env:
SHOULD_RUN: ${{ github.event_name != 'release' || ( github.ref_type == 'tag' && startsWith(github.ref, format('refs/tags/{0}-v', matrix.target.name)) ) }}
SHOULD_RUN: ${{ github.event_name != 'release' || ( github.ref_type == 'tag' && startsWith(github.ref, format('refs/tags/{0}-v', matrix.target.dir)) ) }}

- uses: actions/checkout@v4
if: ${{ steps.check-tag.outputs.run == 'true' }}
- name: Run sccache-cache
if: ${{ steps.check-tag.outputs.run == 'true' }}
uses: mozilla-actions/[email protected]
- name: Install poetry


- name: Set up uv
if: ${{ steps.check-tag.outputs.run == 'true' }}
run: pipx install poetry
- name: Set up Python '3.10'
run: .github/script/install-uv.sh
- name: Set up Python
if: ${{ steps.check-tag.outputs.run == 'true' }}
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: "poetry"
python-version: '3.12'

- name: Build sdist and wheels
if: ${{ steps.check-tag.outputs.run == 'true' }}
run: |
cd ${{ matrix.target.name }}
poetry build -o ../dist
cd ${{ matrix.target.dir }}
uvx --from build pyproject-build --installer uv --outdir ../dist

- name: Upload the built packages as artifacts
if: ${{ steps.check-tag.outputs.run == 'true' }}
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.target.name }}-sdist
name: build-${{ matrix.target.dir }}-sdist
path: |
dist/*.tar.gz
dist/*.whl

- name: Test installing the built wheels
if: ${{ steps.check-tag.outputs.run == 'true' }}
run: |
echo "Testing the newly built ${{ matrix.target.name }} wheels..."
uv run -f dist --with ${{ matrix.target.name }} --refresh-package ${{ matrix.target.name }} --no-project -- python -c "import ${{ matrix.target.name }}"
uvx twine check --strict dist/*

- name: Publish to PyPI
if: ${{ (github.event_name == 'release' && github.ref_type == 'tag' && startsWith(github.ref, format('refs/tags/{0}-v', matrix.target.name)) ) || (github.event_name == 'workflow_dispatch' && github.ref_type == 'tag' && startsWith(github.ref, format('refs/tags/{0}-v', matrix.target.name)) ) }}
if: ${{ (github.event_name == 'release' && github.ref_type == 'tag' && startsWith(github.ref, format('refs/tags/{0}-v', matrix.target.dir)) ) || (github.event_name == 'workflow_dispatch' && github.ref_type == 'tag' && startsWith(github.ref, format('refs/tags/{0}-v', matrix.target.dir)) ) }}
run: |
cd ${{ matrix.target.name }}
poetry config pypi-token.pypi ${{ secrets[matrix.target.key_secret] }}
poetry publish --dist-dir ../dist --skip-existing
echo "Publishing to PyPI..."
echo "Based on the following workflow variables, this is a new version tag push:"
echo " - event_name: ${{ github.event_name }}"
echo " - ref_type: ${{ github.ref_type }}"
echo " - ref: ${{ github.ref }}"
uvx twine upload --skip-existing --verbose dist/*
env:
TWINE_NON_INTERACTIVE: 1
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets[matrix.target.key_secret] }}
18 changes: 13 additions & 5 deletions .github/workflows/python-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ on:
permissions:
contents: read

env:
MODULE_DIR: tket2-py

jobs:
# Check if the tag matches the package name,
# or if the workflow is running on a non-release event.
Expand Down Expand Up @@ -64,9 +67,10 @@ jobs:
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
args: --release --out ../dist --find-interpreter
sccache: 'true'
manylinux: auto
working-directory: ${{ env.MODULE_DIR }}
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -97,9 +101,10 @@ jobs:
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
args: --release --out ../dist --find-interpreter
sccache: 'true'
manylinux: musllinux_1_2
working-directory: ${{ env.MODULE_DIR }}
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -127,8 +132,9 @@ jobs:
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
args: --release --out ../dist --find-interpreter
sccache: 'true'
working-directory: ${{ env.MODULE_DIR }}
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
Expand All @@ -155,8 +161,9 @@ jobs:
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter
args: --release --out ../dist --find-interpreter
sccache: 'true'
working-directory: ${{ env.MODULE_DIR }}
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
Expand All @@ -173,7 +180,8 @@ jobs:
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
args: --out ../dist
working-directory: ${{ env.MODULE_DIR }}
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
Expand Down
25 changes: 9 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,74 +34,67 @@ repos:

- repo: local
hooks:
- id: poetry-install
name: sync poetry deps
description: Ensure development tools are installed.
entry: poetry install --sync
language: system
files: poetry.lock
pass_filenames: false
- id: ruff-format
name: ruff format
description: Format python code with `ruff`.
entry: poetry run ruff format
entry: uv run ruff format
language: system
files: \.py$
pass_filenames: false
- id: ruff-check
name: ruff
description: Check python code with `ruff`.
entry: poetry run ruff check --fix --exit-non-zero-on-fix
entry: uv run ruff check --fix --exit-non-zero-on-fix
language: system
files: \.py$
pass_filenames: false
- id: mypy-check
name: mypy
description: Check python code with `mypy`.
entry: poetry run mypy .
entry: uv run mypy .
language: system
files: \.py$
pass_filenames: false
- id: cargo-fmt
name: cargo format
description: Format rust code with `cargo fmt`.
entry: poetry run -- cargo fmt --all -- --check
entry: uv run -- cargo fmt --all -- --check
language: system
files: \.rs$
pass_filenames: false
- id: cargo-check
name: cargo check
description: Check rust code with `cargo check`.
entry: poetry run -- cargo check --all --all-features --workspace
entry: uv run -- cargo check --all --all-features --workspace
language: system
files: \.rs$
pass_filenames: false
- id: cargo-test
name: cargo test
description: Run tests with `cargo test`.
entry: poetry run -- cargo test --all-features --workspace
entry: uv run -- cargo test --all-features
language: system
files: \.rs$
pass_filenames: false
- id: cargo-clippy
name: cargo clippy
description: Run clippy lints with `cargo clippy`.
entry: poetry run -- cargo clippy --all-features --all-targets --workspace -- -D warnings
entry: uv run -- cargo clippy --all-features --all-targets --workspace -- -D warnings
language: system
files: \.rs$
pass_filenames: false
- id: cargo-doc
name: cargo doc
description: Generate documentation with `cargo doc`.
entry: poetry run -- cargo doc --no-deps --all-features --workspace
entry: uv run -- cargo doc --no-deps --all-features --workspace
language: system
files: \.rs$
pass_filenames: false
- id: py-test
name: pytest
description: Run python tests
# Ensure that we are using the local version of `tket2-eccs` and not the one from PyPI
entry: poetry run -- sh -c "poetry install -C tket2-eccs && maturin develop && pytest --cov=./ --cov-report=html"
entry: uv run -- sh -c "maturin develop && pytest --cov=./ --cov-report=html"
language: system
files: \.py$
pass_filenames: false
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"tket2-py": "0.2.1",
"tket2-py": "0.3.0",
"tket2-eccs": "0.1.0"
}
Loading