From c5979f0ba99bcd89d08bd3d95a85e3cea2f5b9fa Mon Sep 17 00:00:00 2001 From: Alec Edgington <54802828+cqc-alec@users.noreply.github.com> Date: Wed, 17 Jan 2024 16:03:54 +0000 Subject: [PATCH 01/17] [infra] Fix typo in build commands for scheduled run. (#1217) --- .github/workflows/build_and_test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index b78207d2a5..f8522c0719 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -282,7 +282,7 @@ jobs: if: github.event_name == 'schedule' # https://github.com/CQCL/tket/issues/1200 run: | cd pytket - pip install -e -v + pip install -e . -v - name: Run doctests run: | cd pytket @@ -395,7 +395,7 @@ jobs: if: github.event_name == 'schedule' # https://github.com/CQCL/tket/issues/1200 run: | cd pytket - python${{ matrix.python-version }} -m pip install -e -v + python${{ matrix.python-version }} -m pip install -e . -v - name: Run doctests run: | cd pytket @@ -522,7 +522,7 @@ jobs: if: github.event_name == 'schedule' # https://github.com/CQCL/tket/issues/1200 run: | cd pytket - pip install -e -v + pip install -e . -v - name: Run doctests run: | cd pytket From 5a924d65910f25e842c2f6769e68fc40bbba0c5d Mon Sep 17 00:00:00 2001 From: Alec Edgington <54802828+cqc-alec@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:36:30 +0000 Subject: [PATCH 02/17] Update to catch2 3.5.2 (#1223) --- .github/workflows/build-without-conan.yml | 6 +++--- build-without-conan.md | 6 +++--- libs/tkassert/test/conanfile.py | 2 +- libs/tklog/test/conanfile.py | 2 +- libs/tkrng/test/conanfile.py | 2 +- libs/tktokenswap/test/conanfile.py | 2 +- libs/tkwsm/test/conanfile.py | 2 +- pytket/conanfile.py | 2 +- tket/conanfile.py | 4 ++-- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-without-conan.yml b/.github/workflows/build-without-conan.yml index 4c60023946..edcfba3a3f 100644 --- a/.github/workflows/build-without-conan.yml +++ b/.github/workflows/build-without-conan.yml @@ -74,9 +74,9 @@ jobs: - name: Install catch2 run: | cd ${TMP_DIR} - wget https://github.com/catchorg/Catch2/archive/refs/tags/v3.5.1.tar.gz - tar xzvf v3.5.1.tar.gz - cd Catch2-3.5.1/ + wget https://github.com/catchorg/Catch2/archive/refs/tags/v3.5.2.tar.gz + tar xzvf v3.5.2.tar.gz + cd Catch2-3.5.2/ mkdir build cd build cmake -GNinja -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} .. diff --git a/build-without-conan.md b/build-without-conan.md index 5f9b4b5c62..3ea0a2908a 100644 --- a/build-without-conan.md +++ b/build-without-conan.md @@ -91,9 +91,9 @@ cmake --install . ``` cd ${TMP_DIR} -wget https://github.com/catchorg/Catch2/archive/refs/tags/v3.5.1.tar.gz -tar xzvf v3.5.1.tar.gz -cd Catch2-3.5.1/ +wget https://github.com/catchorg/Catch2/archive/refs/tags/v3.5.2.tar.gz +tar xzvf v3.5.2.tar.gz +cd Catch2-3.5.2/ mkdir build cd build cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} .. diff --git a/libs/tkassert/test/conanfile.py b/libs/tkassert/test/conanfile.py index 867a9e7861..498c921f81 100644 --- a/libs/tkassert/test/conanfile.py +++ b/libs/tkassert/test/conanfile.py @@ -60,4 +60,4 @@ def package(self): def requirements(self): self.requires("tkassert/0.3.4") - self.requires("catch2/3.5.1") + self.requires("catch2/3.5.2") diff --git a/libs/tklog/test/conanfile.py b/libs/tklog/test/conanfile.py index 7c5a7eff22..9d1596c24b 100644 --- a/libs/tklog/test/conanfile.py +++ b/libs/tklog/test/conanfile.py @@ -60,4 +60,4 @@ def package(self): def requirements(self): self.requires("tklog/0.3.3") - self.requires("catch2/3.5.1") + self.requires("catch2/3.5.2") diff --git a/libs/tkrng/test/conanfile.py b/libs/tkrng/test/conanfile.py index 9715a6840a..025d26376b 100644 --- a/libs/tkrng/test/conanfile.py +++ b/libs/tkrng/test/conanfile.py @@ -60,4 +60,4 @@ def package(self): def requirements(self): self.requires("tkrng/0.3.3") - self.requires("catch2/3.5.1") + self.requires("catch2/3.5.2") diff --git a/libs/tktokenswap/test/conanfile.py b/libs/tktokenswap/test/conanfile.py index a8d4b316a3..865e8080bd 100644 --- a/libs/tktokenswap/test/conanfile.py +++ b/libs/tktokenswap/test/conanfile.py @@ -61,4 +61,4 @@ def package(self): def requirements(self): self.requires("tktokenswap/0.3.6") self.requires("tkrng/0.3.3@tket/stable") - self.requires("catch2/3.5.1") + self.requires("catch2/3.5.2") diff --git a/libs/tkwsm/test/conanfile.py b/libs/tkwsm/test/conanfile.py index 84c60d0c90..da4850bf1a 100644 --- a/libs/tkwsm/test/conanfile.py +++ b/libs/tkwsm/test/conanfile.py @@ -62,4 +62,4 @@ def requirements(self): self.requires("tkwsm/0.3.6") self.requires("tkassert/0.3.4@tket/stable") self.requires("tkrng/0.3.3@tket/stable") - self.requires("catch2/3.5.1") + self.requires("catch2/3.5.2") diff --git a/pytket/conanfile.py b/pytket/conanfile.py index 352e0785b4..2c47955011 100644 --- a/pytket/conanfile.py +++ b/pytket/conanfile.py @@ -32,7 +32,7 @@ def package(self): cmake.install() def requirements(self): - self.requires("tket/1.2.86@tket/stable") + self.requires("tket/1.2.87@tket/stable") self.requires("tklog/0.3.3@tket/stable") self.requires("tkrng/0.3.3@tket/stable") self.requires("tkassert/0.3.4@tket/stable") diff --git a/tket/conanfile.py b/tket/conanfile.py index 98f4ac9285..9bc611d7ec 100644 --- a/tket/conanfile.py +++ b/tket/conanfile.py @@ -23,7 +23,7 @@ class TketConan(ConanFile): name = "tket" - version = "1.2.86" + version = "1.2.87" package_type = "library" license = "Apache 2" homepage = "https://github.com/CQCL/tket" @@ -121,7 +121,7 @@ def requirements(self): self.requires("tktokenswap/0.3.6@tket/stable") self.requires("tkwsm/0.3.6@tket/stable") if self.build_test(): - self.test_requires("catch2/3.5.1") + self.test_requires("catch2/3.5.2") if self.build_proptest(): self.test_requires("rapidcheck/cci.20230815") From d53061ca318de3034dee8576f8de75bb5a4aec13 Mon Sep 17 00:00:00 2001 From: Alec Edgington <54802828+cqc-alec@users.noreply.github.com> Date: Fri, 19 Jan 2024 12:28:09 +0000 Subject: [PATCH 03/17] Use ARM-Linux runners from buildjet instead of using docker on the self-hosted Mac. (#1225) --- .github/workflows/packages.yml | 11 +------- .github/workflows/release.yml | 49 +++++++++++++++------------------- 2 files changed, 22 insertions(+), 38 deletions(-) diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index 1254788bc3..35b72ef1bb 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -68,26 +68,17 @@ jobs: build_manylinux_aarch64: name: Build on manylinux (aarch64) - runs-on: ['self-hosted', 'macOS', 'ARM64'] + runs-on: 'buildjet-8vcpu-ubuntu-2204-arm' steps: - uses: actions/checkout@v4 - name: Set up container run: | - export DOCKER_HOST=unix://${HOME}/.docker/run/docker.sock - docker rm --force -v linux_build docker create --name linux_build -i -v /:/host quay.io/pypa/manylinux_2_28_aarch64:latest /bin/bash docker cp . linux_build:/tket/ - name: Install and upload packages run: | - export DOCKER_HOST=unix://${HOME}/.docker/run/docker.sock docker start linux_build docker exec -e JFROG_ARTIFACTORY_TOKEN_3="${{ secrets.JFROG_ARTIFACTORY_TOKEN_3 }}" -e JFROG_ARTIFACTORY_USER_3="${{ secrets.JFROG_ARTIFACTORY_USER_3 }}" -e CONAN_PROFILE=linux-armv8-gcc12 linux_build /bin/bash -c "/tket/.github/workflows/linuxbuildpackages" - - - name: Remove container - if: always() - run: | - export DOCKER_HOST=unix://${HOME}/.docker/run/docker.sock - docker rm --force -v linux_build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bd6f55e630..a02458d5cb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,7 +37,8 @@ jobs: build_Linux_aarch64_wheels: name: Build manylinux aarch64 - runs-on: ['self-hosted', 'macOS', 'ARM64'] + # We need the one with 12GB RAM to build pytket. + runs-on: 'buildjet-8vcpu-ubuntu-2204-arm' strategy: matrix: python3-version: ['10', '11', '12'] @@ -48,28 +49,18 @@ jobs: - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - name: Set up container run: | - export DOCKER_HOST=unix://${HOME}/.docker/run/docker.sock docker create --name linux_build -i -v /:/host quay.io/pypa/manylinux_2_28_aarch64:latest /bin/bash docker cp . linux_build:/tket/ - name: Run build run: | - export DOCKER_HOST=unix://${HOME}/.docker/run/docker.sock docker start linux_build docker exec -e PY_TAG="cp3${{ matrix.python3-version }}-cp3${{ matrix.python3-version }}" -e CONAN_PROFILE=linux-armv8-gcc12 linux_build /bin/bash -c "/tket/.github/workflows/linuxbuildwheel" mkdir wheelhouse docker cp linux_build:/tket/pytket/audited/. wheelhouse/ - - name: Remove container - if: always() - run: | - export DOCKER_HOST=unix://${HOME}/.docker/run/docker.sock - docker rm --force -v linux_build - uses: actions/upload-artifact@v4 with: name: Linux_aarch64_3.${{ matrix.python3-version }}_wheel path: wheelhouse/ - - name: Remove directory - if: always() - run: rm -rf wheelhouse build_macos_wheels: name: Build macos wheels @@ -227,7 +218,7 @@ jobs: test_Linux_aarch64_wheels: name: Test linux aarch64 wheels needs: build_Linux_aarch64_wheels - runs-on: ['self-hosted', 'macOS', 'ARM64'] + runs-on: 'buildjet-4vcpu-ubuntu-2204-arm' strategy: matrix: python3-version: ['10', '11', '12'] @@ -235,29 +226,31 @@ jobs: - uses: actions/checkout@v4 with: path: tket + - name: Set up Python 3.${{ matrix.python3-version }} + # Use deadsnakes/action because Python for Linux/ARM is not available with + # actions/setup-python. + # Python 3.10 is the default python on Ubuntu 22.04, so this combination + # is not available from deadsnakes: use the default python in this case. + if: matrix.python3-version != '10' + uses: deadsnakes/action@v3.1.0 + with: + python-version: "3.${{ matrix.python3-version }}" - name: Download wheel uses: actions/download-artifact@v4 with: name: Linux_aarch64_3.${{ matrix.python3-version }}_wheel path: wheelhouse/ - - name: Set up container + - name: Install wheel + run: pip install wheelhouse/pytket-*.whl + - uses: actions/checkout@v4 + with: + path: tket + - name: Setup tests run: | - export DOCKER_HOST=unix://${HOME}/.docker/run/docker.sock - docker create --name linux_build -i -v /:/host quay.io/pypa/manylinux_2_28_aarch64:latest /bin/bash - docker cp . linux_build:/tket/ + cd tket/pytket/tests + pip install -U -r requirements.txt - name: Run tests - run: | - export DOCKER_HOST=unix://${HOME}/.docker/run/docker.sock - docker start linux_build - docker exec -e PY_TAG="cp3${{ matrix.python3-version }}-cp3${{ matrix.python3-version }}" linux_build /bin/bash -c "/tket/.github/workflows/linuxtestwheel" - - name: Remove container - if: always() - run: | - export DOCKER_HOST=unix://${HOME}/.docker/run/docker.sock - docker rm --force -v linux_build - - name: Remove directory - if: always() - run: rm -rf wheelhouse + run: cd tket/pytket/tests && pytest --ignore=simulator/ test_macos_wheels: name: Test macos wheels From 4582602c2d33882daae08967de23dbad66dcebec Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 09:20:34 +0000 Subject: [PATCH 04/17] Bump actions/cache from 3 to 4 (#1226) Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build_and_test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index f8522c0719..efb15f79ec 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -194,7 +194,7 @@ jobs: with: format: YYYYMMDDHHmmss - name: ccache windows - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.ninja-ccache-setup.outputs.ccache_dir }} key: tket-static-${{ matrix.os }}-${{ steps.current_time.outputs.formattedTime }} @@ -467,7 +467,7 @@ jobs: with: format: YYYYMMDDHHmmss - name: ccache windows - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.ccache-setup.outputs.ccache_dir }} key: tket-dynamic-visual-studio-windows-2022-${{ steps.current_time.outputs.formattedTime }} From 6906704b0ad64d077dff5c71454652926f91ee12 Mon Sep 17 00:00:00 2001 From: Alec Edgington <54802828+cqc-alec@users.noreply.github.com> Date: Mon, 22 Jan 2024 12:24:48 +0000 Subject: [PATCH 05/17] Don't raise exception if zx is not installed (#1228) --- pytket/pytket/zx/tensor_eval.py | 7 +++---- pytket/tests/zx_diagram_test.py | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pytket/pytket/zx/tensor_eval.py b/pytket/pytket/zx/tensor_eval.py index bfc4ab790e..ba104b6ed6 100644 --- a/pytket/pytket/zx/tensor_eval.py +++ b/pytket/pytket/zx/tensor_eval.py @@ -16,6 +16,7 @@ numpy tensor features, in particular the einsum evaluation and optimisations.""" from typing import Dict, List, Any from math import floor, pi, sqrt, cos, sin +import warnings import sympy import numpy as np from pytket.zx import ( @@ -34,12 +35,10 @@ try: import quimb.tensor as qtn # type: ignore except ModuleNotFoundError as err: - err.msg = ( + warnings.warn( 'Missing package for tensor evaluation of ZX diagrams. Run "pip ' - "install 'pytket[ZX]'\" to install the optional dependencies and try " - "again." + "install 'pytket[ZX]'\" to install the optional dependencies." ) - raise err def _gen_to_tensor(gen: ZXGen, rank: int) -> np.ndarray: diff --git a/pytket/tests/zx_diagram_test.py b/pytket/tests/zx_diagram_test.py index fc24a52998..f123b008fa 100644 --- a/pytket/tests/zx_diagram_test.py +++ b/pytket/tests/zx_diagram_test.py @@ -37,6 +37,7 @@ have_quimb: bool = True try: + import quimb.tensor # type: ignore from pytket.zx.tensor_eval import ( unitary_from_quantum_diagram, fix_boundaries_to_binary_states, From d25b915604bdf4c9e0dd467b0a714c7a7c173f92 Mon Sep 17 00:00:00 2001 From: Alec Edgington <54802828+cqc-alec@users.noreply.github.com> Date: Wed, 24 Jan 2024 15:15:30 +0000 Subject: [PATCH 06/17] [infra] Export compile commands. (#1229) --- pytket/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pytket/CMakeLists.txt b/pytket/CMakeLists.txt index fd11218bcd..5c2e5360a1 100644 --- a/pytket/CMakeLists.txt +++ b/pytket/CMakeLists.txt @@ -48,6 +48,8 @@ endif() list(APPEND CMAKE_MODULE_PATH "${CMAKE_BINARY_DIR}") +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + set(Boost_NO_BOOST_CMAKE ON) if (WIN32) From 44f401ce50cf907f5a510523a08eb75da4e2a74d Mon Sep 17 00:00:00 2001 From: CalMacCQ <93673602+CalMacCQ@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:13:59 +0000 Subject: [PATCH 07/17] Add `CXConfigType` to API docs (#1230) * add missing CXConfigType to pytket.circuit docs * remove special members --- pytket/docs/circuit.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pytket/docs/circuit.rst b/pytket/docs/circuit.rst index 4cae8e2a11..3c2418ba97 100644 --- a/pytket/docs/circuit.rst +++ b/pytket/docs/circuit.rst @@ -20,6 +20,8 @@ pytket.circuit :members: .. autoclass:: pytket._tket.circuit.BasisOrder :members: +.. autoclass:: pytket._tket.circuit.CXConfigType + :members: .. autoclass:: pytket._tket.circuit.CircBox :special-members: :members: @@ -114,4 +116,4 @@ pytket.circuit :members: .. autoclass:: pytket._tket.circuit.DummyBox :special-members: - :members: + :members: \ No newline at end of file From 26b5f37bea982604011f37e4d43173ccd9f82d50 Mon Sep 17 00:00:00 2001 From: Alec Edgington <54802828+cqc-alec@users.noreply.github.com> Date: Fri, 26 Jan 2024 11:13:19 +0000 Subject: [PATCH 08/17] [infra]Use boost 1.84.0 in libs. (#1233) --- libs/tktokenswap/conanfile.py | 4 ++-- libs/tktokenswap/test/conanfile.py | 2 +- libs/tkwsm/conanfile.py | 4 ++-- libs/tkwsm/test/conanfile.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libs/tktokenswap/conanfile.py b/libs/tktokenswap/conanfile.py index 0bebcbd278..db0d5a6d1a 100644 --- a/libs/tktokenswap/conanfile.py +++ b/libs/tktokenswap/conanfile.py @@ -19,7 +19,7 @@ class TktokenswapConan(ConanFile): name = "tktokenswap" - version = "0.3.6" + version = "0.3.7" package_type = "library" license = "Apache 2" url = "https://github.com/CQCL/tket" @@ -73,4 +73,4 @@ def requirements(self): self.requires("tklog/0.3.3@tket/stable") self.requires("tkassert/0.3.4@tket/stable", transitive_headers=True) self.requires("tkrng/0.3.3@tket/stable") - self.requires("boost/1.83.0", transitive_libs=False) + self.requires("boost/1.84.0", transitive_libs=False) diff --git a/libs/tktokenswap/test/conanfile.py b/libs/tktokenswap/test/conanfile.py index 865e8080bd..8923967b3f 100644 --- a/libs/tktokenswap/test/conanfile.py +++ b/libs/tktokenswap/test/conanfile.py @@ -59,6 +59,6 @@ def package(self): cmake.install() def requirements(self): - self.requires("tktokenswap/0.3.6") + self.requires("tktokenswap/0.3.7") self.requires("tkrng/0.3.3@tket/stable") self.requires("catch2/3.5.2") diff --git a/libs/tkwsm/conanfile.py b/libs/tkwsm/conanfile.py index 5d33f177c2..613655278d 100644 --- a/libs/tkwsm/conanfile.py +++ b/libs/tkwsm/conanfile.py @@ -19,7 +19,7 @@ class TkwsmConan(ConanFile): name = "tkwsm" - version = "0.3.6" + version = "0.3.7" package_type = "library" license = "Apache 2" url = "https://github.com/CQCL/tket" @@ -72,4 +72,4 @@ def package_info(self): def requirements(self): self.requires("tkassert/0.3.4@tket/stable") self.requires("tkrng/0.3.3@tket/stable") - self.requires("boost/1.83.0", transitive_headers=True, transitive_libs=False) + self.requires("boost/1.84.0", transitive_headers=True, transitive_libs=False) diff --git a/libs/tkwsm/test/conanfile.py b/libs/tkwsm/test/conanfile.py index da4850bf1a..ee1ae1c54f 100644 --- a/libs/tkwsm/test/conanfile.py +++ b/libs/tkwsm/test/conanfile.py @@ -59,7 +59,7 @@ def package(self): cmake.install() def requirements(self): - self.requires("tkwsm/0.3.6") + self.requires("tkwsm/0.3.7") self.requires("tkassert/0.3.4@tket/stable") self.requires("tkrng/0.3.3@tket/stable") self.requires("catch2/3.5.2") From 08d58f1ebc5572130b1020ed5e654445a4cd4427 Mon Sep 17 00:00:00 2001 From: Alec Edgington <54802828+cqc-alec@users.noreply.github.com> Date: Fri, 26 Jan 2024 11:59:27 +0000 Subject: [PATCH 09/17] [infra] Update to boost 1.84, tkwsm 0.3.7 and tktokenswap 0.3.7 (#1234) --- .github/workflows/build-without-conan.yml | 6 +++--- build-without-conan.md | 8 ++++---- pytket/conanfile.py | 6 +++--- tket/conanfile.py | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-without-conan.yml b/.github/workflows/build-without-conan.yml index edcfba3a3f..7807b620d8 100644 --- a/.github/workflows/build-without-conan.yml +++ b/.github/workflows/build-without-conan.yml @@ -30,9 +30,9 @@ jobs: - name: Install boost run: | cd ${TMP_DIR} - wget -O boost_1_83_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.83.0/boost_1_83_0.tar.gz/download - tar xzvf boost_1_83_0.tar.gz - cd boost_1_83_0/ + wget -O boost_1_84_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.84.0/boost_1_84_0.tar.gz/download + tar xzvf boost_1_84_0.tar.gz + cd boost_1_84_0/ ./bootstrap.sh --prefix=${INSTALL_DIR} ./b2 ./b2 install diff --git a/build-without-conan.md b/build-without-conan.md index 3ea0a2908a..e756bec4fb 100644 --- a/build-without-conan.md +++ b/build-without-conan.md @@ -22,9 +22,9 @@ The versions should match the current requirements as specified in the relevant ``` cd ${TMP_DIR} -wget -O boost_1_83_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.83.0/boost_1_83_0.tar.gz/download -tar xzvf boost_1_83_0.tar.gz -cd boost_1_83_0/ +wget -O boost_1_84_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.84.0/boost_1_84_0.tar.gz/download +tar xzvf boost_1_84_0.tar.gz +cd boost_1_84_0/ ./bootstrap.sh --prefix=${INSTALL_DIR} ./b2 ./b2 install @@ -258,4 +258,4 @@ NO_CONAN=1 pip install -v -e . (You can use the environment variable `PYTKET_CMAKE_N_THREADS` to restrict the number of threads used in the above command; otherwise one thread per CPU is -used.) \ No newline at end of file +used.) diff --git a/pytket/conanfile.py b/pytket/conanfile.py index 2c47955011..95728ed3a1 100644 --- a/pytket/conanfile.py +++ b/pytket/conanfile.py @@ -32,12 +32,12 @@ def package(self): cmake.install() def requirements(self): - self.requires("tket/1.2.87@tket/stable") + self.requires("tket/1.2.88@tket/stable") self.requires("tklog/0.3.3@tket/stable") self.requires("tkrng/0.3.3@tket/stable") self.requires("tkassert/0.3.4@tket/stable") - self.requires("tkwsm/0.3.6@tket/stable") - self.requires("tktokenswap/0.3.6@tket/stable") + self.requires("tkwsm/0.3.7@tket/stable") + self.requires("tktokenswap/0.3.7@tket/stable") self.requires("symengine/0.11.2") self.requires("gmp/6.3.0") self.requires("pybind11/2.11.1") diff --git a/tket/conanfile.py b/tket/conanfile.py index 9bc611d7ec..fcae34b554 100644 --- a/tket/conanfile.py +++ b/tket/conanfile.py @@ -23,7 +23,7 @@ class TketConan(ConanFile): name = "tket" - version = "1.2.87" + version = "1.2.88" package_type = "library" license = "Apache 2" homepage = "https://github.com/CQCL/tket" @@ -111,15 +111,15 @@ def package_info(self): def requirements(self): # libraries installed from remote: # https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs - self.requires("boost/1.83.0", transitive_headers=True) + self.requires("boost/1.84.0", transitive_headers=True) self.requires("symengine/0.11.2", transitive_headers=True) self.requires("eigen/3.4.0", transitive_headers=True) self.requires("nlohmann_json/3.11.3", transitive_headers=True) self.requires("tklog/0.3.3@tket/stable") self.requires("tkassert/0.3.4@tket/stable", transitive_headers=True) self.requires("tkrng/0.3.3@tket/stable") - self.requires("tktokenswap/0.3.6@tket/stable") - self.requires("tkwsm/0.3.6@tket/stable") + self.requires("tktokenswap/0.3.7@tket/stable") + self.requires("tkwsm/0.3.7@tket/stable") if self.build_test(): self.test_requires("catch2/3.5.2") if self.build_proptest(): From dfadf94b784f54d5779635b48b274e16bad126e0 Mon Sep 17 00:00:00 2001 From: Alec Edgington <54802828+cqc-alec@users.noreply.github.com> Date: Fri, 26 Jan 2024 13:39:11 +0000 Subject: [PATCH 10/17] [feature] Add method to get bytecode from a `WasmFileHandler` (#1235) --- pytket/docs/changelog.rst | 7 +++++++ pytket/pytket/wasm/wasm.py | 6 ++++-- pytket/tests/classical_test.py | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pytket/docs/changelog.rst b/pytket/docs/changelog.rst index cd269c455f..fa638f0e9c 100644 --- a/pytket/docs/changelog.rst +++ b/pytket/docs/changelog.rst @@ -1,6 +1,13 @@ Changelog ========= +Unreleased +---------- + +Features: + +* Add ``WasmFileHandler.bytecode()`` method to retrieve the WASM as bytecode. + 1.24.0 (January 2024) --------------------- diff --git a/pytket/pytket/wasm/wasm.py b/pytket/pytket/wasm/wasm.py index 45a651d4d1..bf4f57cd68 100644 --- a/pytket/pytket/wasm/wasm.py +++ b/pytket/pytket/wasm/wasm.py @@ -91,7 +91,6 @@ def __init__(self, filepath: str, check_file: bool = True, int_size: int = 32): self._unsupported_function = [] if self._check_file: - mod_iter = iter(decode_module(self._wasm_file)) _, _ = next(mod_iter) @@ -143,7 +142,6 @@ def __init__(self, filepath: str, check_file: bool = True, int_size: int = 32): self._function_types = cur_sec_data.payload.types for x in function_names: - # check for only integer type in parameters and return values supported_function = True idx = _func_lookup[x][1] @@ -214,6 +212,10 @@ def __repr__(self) -> str: wasm file was checked""" ) + def bytecode(self) -> bytes: + """The WASM content as bytecode""" + return self._wasm_file + def check_function( self, function_name: str, number_of_parameters: int, number_of_returns: int ) -> bool: diff --git a/pytket/tests/classical_test.py b/pytket/tests/classical_test.py index bf8ff4642a..9a6c24cf2f 100644 --- a/pytket/tests/classical_test.py +++ b/pytket/tests/classical_test.py @@ -178,6 +178,10 @@ def test_wasm_2() -> None: def test_wasm_3() -> None: w = wasm.WasmFileHandler("testfile.wasm") + with open("testfile.wasm", "rb") as f: + bytecode = f.read() + assert w.bytecode() == bytecode + c = Circuit(0, 6) c.add_wasm("add_one", w, [1], [1], [Bit(0), Bit(1)]) From 590f78d29b7a273fe61142f6101187a9e884cbe6 Mon Sep 17 00:00:00 2001 From: Alec Edgington <54802828+cqc-alec@users.noreply.github.com> Date: Mon, 29 Jan 2024 09:09:54 +0000 Subject: [PATCH 11/17] Only authenticate if necessary. (#1238) --- .github/workflows/build_libs.yml | 6 +++--- .github/workflows/linuxbuildlib | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_libs.yml b/.github/workflows/build_libs.yml index 21a430f26e..9cc92183f1 100644 --- a/.github/workflows/build_libs.yml +++ b/.github/workflows/build_libs.yml @@ -83,8 +83,6 @@ jobs: - name: build shared ${{ matrix.lib }} if: matrix.lib == 'tklog' run: conan create -s build_type=${{ matrix.build_type }} -o boost/*:header_only=True -o ${{ matrix.lib }}/*:shared=True libs/${{ matrix.lib }} --build=missing --user=tket --channel=stable - - name: authenticate to repository - run: conan remote login -p ${{ secrets.JFROG_ARTIFACTORY_TOKEN_3 }} tket-libs ${{ secrets.JFROG_ARTIFACTORY_USER_3 }} - name: get version shell: bash run: | @@ -92,7 +90,9 @@ jobs: echo "LIB_LABEL=${lib_label}" >> $GITHUB_ENV - name: upload package if: github.event_name == 'push' - run: conan upload ${{ env.LIB_LABEL }} -r=tket-libs + run: | + conan remote login -p ${{ secrets.JFROG_ARTIFACTORY_TOKEN_3 }} tket-libs ${{ secrets.JFROG_ARTIFACTORY_USER_3 }} + conan upload ${{ env.LIB_LABEL }} -r=tket-libs manylinux: name: build library (manylinux) needs: changes diff --git a/.github/workflows/linuxbuildlib b/.github/workflows/linuxbuildlib index b751530846..61475bb9fb 100755 --- a/.github/workflows/linuxbuildlib +++ b/.github/workflows/linuxbuildlib @@ -31,13 +31,12 @@ diff ${DEFAULT_PROFILE_PATH} ${PROFILE_PATH} || true cp ${PROFILE_PATH} ${DEFAULT_PROFILE_PATH} ${CONAN_CMD} remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0 -${CONAN_CMD} remote login -p ${JFROG_ARTIFACTORY_TOKEN_3} tket-libs ${JFROG_ARTIFACTORY_USER_3} - ${CONAN_CMD} create ${TKLIB} -o boost/*:header_only=True --build=missing --user=tket --channel=stable --format json > ${TKLIB}.json LIB_LABEL=$(${PYBIN}/python ./libver ${TKLIB}.json ${TKLIB}) if [ ${UPLOAD_PACKAGE} == "YES" ] then + ${CONAN_CMD} remote login -p ${JFROG_ARTIFACTORY_TOKEN_3} tket-libs ${JFROG_ARTIFACTORY_USER_3} ${CONAN_CMD} upload ${LIB_LABEL} -r=tket-libs fi From a8dd7963aaf89561f5c3b2409074e21d1515ea2a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 09:32:37 +0000 Subject: [PATCH 12/17] Bump dorny/paths-filter from 2.11.1 to 3.0.0 (#1236) Bumps [dorny/paths-filter](https://github.com/dorny/paths-filter) from 2.11.1 to 3.0.0. - [Release notes](https://github.com/dorny/paths-filter/releases) - [Changelog](https://github.com/dorny/paths-filter/blob/master/CHANGELOG.md) - [Commits](https://github.com/dorny/paths-filter/compare/v2.11.1...v3.0.0) --- updated-dependencies: - dependency-name: dorny/paths-filter dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build_and_test.yml | 2 +- .github/workflows/build_libs.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/test_libs.yml | 2 +- .github/workflows/valgrind.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index efb15f79ec..10a102eca9 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -33,7 +33,7 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3.12' - - uses: dorny/paths-filter@v2.11.1 + - uses: dorny/paths-filter@v3.0.0 id: filter with: base: ${{ github.ref }} diff --git a/.github/workflows/build_libs.yml b/.github/workflows/build_libs.yml index 9cc92183f1..3f0ce57d4b 100644 --- a/.github/workflows/build_libs.yml +++ b/.github/workflows/build_libs.yml @@ -20,7 +20,7 @@ jobs: libs: ${{ steps.filter.outputs.changes }} steps: - uses: actions/checkout@v4 - - uses: dorny/paths-filter@v2.11.1 + - uses: dorny/paths-filter@v3.0.0 id: filter with: base: ${{ github.ref }} diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ec4d2bc279..410f9105af 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -24,7 +24,7 @@ jobs: tket: ${{ steps.filter.outputs.tket }} steps: - uses: actions/checkout@v4 - - uses: dorny/paths-filter@v2.11.1 + - uses: dorny/paths-filter@v3.0.0 id: filter with: base: ${{ github.ref }} diff --git a/.github/workflows/test_libs.yml b/.github/workflows/test_libs.yml index 1317a89c0e..e2e2864f6e 100644 --- a/.github/workflows/test_libs.yml +++ b/.github/workflows/test_libs.yml @@ -20,7 +20,7 @@ jobs: libs: ${{ steps.filter.outputs.changes }} steps: - uses: actions/checkout@v4 - - uses: dorny/paths-filter@v2.11.1 + - uses: dorny/paths-filter@v3.0.0 id: filter with: base: ${{ github.ref }} diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index e6acc9a7aa..7d83830a8a 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -19,7 +19,7 @@ jobs: tket: ${{ steps.filter.outputs.tket }} steps: - uses: actions/checkout@v4 - - uses: dorny/paths-filter@v2.11.1 + - uses: dorny/paths-filter@v3.0.0 id: filter with: base: ${{ github.ref }} From 3e556dce5cb6defc473fb8d44607f81b71593491 Mon Sep 17 00:00:00 2001 From: CalMacCQ <93673602+CalMacCQ@users.noreply.github.com> Date: Mon, 29 Jan 2024 11:48:20 +0000 Subject: [PATCH 13/17] Tidy up `pytket.circuit` API docs (#1178) * don't clutter pytket.circuit docs by expanding submodules * change caption * use bysource order for autodoc * start using automethod for Circuit methods * fix typo * use autodoc typehints * Expand TOC for all pages * add some circuit properties * delete unused config settings * add another chunk of automethod boilerplate * finish adding circuit methods * add some notes on Circuit.add_gate * submodules -> classes * scrub ._tket from pytket.circuit docs source * remove more _tket * don't use sphinx_autodoc_typehints for now * remove non-existent Reset method * use submodules rather than classes * don't show binary info in pytket.circuit doc * remove typehints extension entirely * remove duplicate CV method * remove more duplicate methods * submodules -> classes * reorder circuit properties * remove duplicate properties * remove :special-members: and use automethod for __init__ etc * remove __hash__ * minor spacing edit * Revert "minor spacing edit" This reverts commit abe76a49c9186f2f202b85e4b5058977fb7e658a. * add missing methods found by python script * use autoproperty for created_qubits and discarded_qubits * add script to check circuit methods and properties * fix typo * remove comment * fix spaxing and heading * consistent headings * remove some dunder methods from API docs * add __rshift__ dunder method back into the docs * add explanatory comments * remove spaces --- pytket/docs/check_circuit_class_docs.py | 16 + pytket/docs/circuit.rst | 76 ++--- pytket/docs/circuit_class.rst | 374 +++++++++++++++++++++++- pytket/docs/conf.py | 73 +---- 4 files changed, 424 insertions(+), 115 deletions(-) create mode 100644 pytket/docs/check_circuit_class_docs.py diff --git a/pytket/docs/check_circuit_class_docs.py b/pytket/docs/check_circuit_class_docs.py new file mode 100644 index 0000000000..816bc4c35d --- /dev/null +++ b/pytket/docs/check_circuit_class_docs.py @@ -0,0 +1,16 @@ +import inspect +import re + +from pytket._tket.circuit import Circuit + +# This script is used to check that no methods or properties of +# the Circuit class are left out in the circuit_class.rst file. + +with open("circuit_class.rst", "r", encoding="utf-8") as file: + rst = file.read() + +in_methods = {p[0] for p in inspect.getmembers(Circuit)} +pattern = re.compile(r"(?:\bautomethod\b|\bautoproperty\b):: (\w+)\n") +in_docs = set(pattern.findall(rst)) +missing = in_methods - in_docs +print([s for s in missing if not s.startswith("_")]) diff --git a/pytket/docs/circuit.rst b/pytket/docs/circuit.rst index 3c2418ba97..6352657c5e 100644 --- a/pytket/docs/circuit.rst +++ b/pytket/docs/circuit.rst @@ -2,7 +2,7 @@ pytket.circuit ================================== .. toctree:: :caption: Classes: - :maxdepth: 2 + :maxdepth: 1 circuit_class.rst optype.rst @@ -14,106 +14,106 @@ pytket.circuit .. automodule:: pytket._tket.circuit :members: fresh_symbol -.. autoclass:: pytket._tket.circuit.Op +.. autoclass:: pytket.circuit.Op :members: -.. autoclass:: pytket._tket.circuit.Command +.. autoclass:: pytket.circuit.Command :members: -.. autoclass:: pytket._tket.circuit.BasisOrder +.. autoclass:: pytket.circuit.BasisOrder :members: -.. autoclass:: pytket._tket.circuit.CXConfigType +.. autoclass:: pytket.circuit.CXConfigType :members: -.. autoclass:: pytket._tket.circuit.CircBox +.. autoclass:: pytket.circuit.CircBox :special-members: :members: -.. autoclass:: pytket._tket.circuit.Unitary1qBox +.. autoclass:: pytket.circuit.Unitary1qBox :special-members: :members: -.. autoclass:: pytket._tket.circuit.Unitary2qBox +.. autoclass:: pytket.circuit.Unitary2qBox :special-members: :members: -.. autoclass:: pytket._tket.circuit.Unitary3qBox +.. autoclass:: pytket.circuit.Unitary3qBox :special-members: :members: -.. autoclass:: pytket._tket.circuit.ExpBox +.. autoclass:: pytket.circuit.ExpBox :special-members: :members: -.. autoclass:: pytket._tket.circuit.PauliExpBox +.. autoclass:: pytket.circuit.PauliExpBox :special-members: :members: -.. autoclass:: pytket._tket.circuit.PauliExpPairBox +.. autoclass:: pytket.circuit.PauliExpPairBox :special-members: :members: -.. autoclass:: pytket._tket.circuit.ToffoliBox +.. autoclass:: pytket.circuit.ToffoliBox :special-members: :members: -.. autoclass:: pytket._tket.circuit.QControlBox +.. autoclass:: pytket.circuit.QControlBox :special-members: :members: -.. autoclass:: pytket._tket.circuit.CustomGateDef +.. autoclass:: pytket.circuit.CustomGateDef :members: -.. autoclass:: pytket._tket.circuit.CustomGate +.. autoclass:: pytket.circuit.CustomGate :members: -.. autoclass:: pytket._tket.circuit.Conditional +.. autoclass:: pytket.circuit.Conditional :members: -.. autoclass:: pytket._tket.circuit.ClassicalExpBox +.. autoclass:: pytket.circuit.ClassicalExpBox :members: -.. autoclass:: pytket._tket.circuit.PhasePolyBox +.. autoclass:: pytket.circuit.PhasePolyBox :special-members: :members: -.. autoclass:: pytket._tket.circuit.ProjectorAssertionBox +.. autoclass:: pytket.circuit.ProjectorAssertionBox :special-members: :members: -.. autoclass:: pytket._tket.circuit.StabiliserAssertionBox +.. autoclass:: pytket.circuit.StabiliserAssertionBox :special-members: :members: -.. autoclass:: pytket._tket.circuit.WASMOp +.. autoclass:: pytket.circuit.WASMOp :special-members: :members: -.. autoclass:: pytket._tket.circuit.MultiBitOp +.. autoclass:: pytket.circuit.MultiBitOp :special-members: :members: -.. autoclass:: pytket._tket.circuit.SetBitsOp +.. autoclass:: pytket.circuit.SetBitsOp :special-members: :members: -.. autoclass:: pytket._tket.circuit.ClassicalEvalOp +.. autoclass:: pytket.circuit.ClassicalEvalOp :special-members: :members: -.. autoclass:: pytket._tket.circuit.ClassicalOp +.. autoclass:: pytket.circuit.ClassicalOp :special-members: :members: -.. autoclass:: pytket._tket.circuit.CopyBitsOp +.. autoclass:: pytket.circuit.CopyBitsOp :special-members: :members: -.. autoclass:: pytket._tket.circuit.RangePredicateOp +.. autoclass:: pytket.circuit.RangePredicateOp :special-members: :members: -.. autoclass:: pytket._tket.circuit.MultiplexorBox +.. autoclass:: pytket.circuit.MultiplexorBox :special-members: :members: -.. autoclass:: pytket._tket.circuit.MultiplexedRotationBox +.. autoclass:: pytket.circuit.MultiplexedRotationBox :special-members: :members: -.. autoclass:: pytket._tket.circuit.MultiplexedU2Box +.. autoclass:: pytket.circuit.MultiplexedU2Box :special-members: :members: -.. autoclass:: pytket._tket.circuit.MultiplexedTensoredU2Box +.. autoclass:: pytket.circuit.MultiplexedTensoredU2Box :special-members: :members: -.. autoclass:: pytket._tket.circuit.StatePreparationBox +.. autoclass:: pytket.circuit.StatePreparationBox :special-members: :members: -.. autoclass:: pytket._tket.circuit.DiagonalBox +.. autoclass:: pytket.circuit.DiagonalBox :special-members: :members: -.. autoclass:: pytket._tket.circuit.ConjugationBox +.. autoclass:: pytket.circuit.ConjugationBox :special-members: :members: -.. autoclass:: pytket._tket.circuit.ResourceBounds +.. autoclass:: pytket.circuit.ResourceBounds :special-members: :members: -.. autoclass:: pytket._tket.circuit.ResourceData +.. autoclass:: pytket.circuit.ResourceData :special-members: :members: -.. autoclass:: pytket._tket.circuit.DummyBox +.. autoclass:: pytket.circuit.DummyBox :special-members: :members: \ No newline at end of file diff --git a/pytket/docs/circuit_class.rst b/pytket/docs/circuit_class.rst index ea7da61904..d92aefe7e6 100644 --- a/pytket/docs/circuit_class.rst +++ b/pytket/docs/circuit_class.rst @@ -1,5 +1,5 @@ pytket.circuit.Circuit -================================== +====================== :py:class:`Circuit` objects provide an abstraction of quantum circuits. They consist of a set of qubits/quantum wires and a collection of operations applied to them in a given order. These wires have open inputs and outputs, rather than assuming any fixed input state. See the `pytket User Manual `_ for a step-by-step tutorial on constructing circuits. @@ -20,7 +20,371 @@ following keyword arguments are supported: ``condition``, or using the pair ``condition_bits`` and ``condition_value`` to condition on a specified set of bit values.) -.. currentmodule:: pytket._tket.circuit.Circuit -.. autoclass:: pytket._tket.circuit.Circuit - :special-members: - :members: +.. + Sphinx doesn't seem to offer much control over how the methods and properties are ordered in the docs + We list the methods and properties manually (for now) to ensure that the most important methods (e.g. Circuit.add_gate) + are closer to the top of the page. Some less important methods like Circuit.YYPhase + and Circuit.add_multiplexed_tensored_u2 are near the bottom. + Since the Circuit class is so big we use the check_circuit_class_docs.py script to check that we haven't missed anything. + +.. currentmodule:: pytket.circuit.Circuit +.. autoclass:: pytket.circuit.Circuit + + .. automethod:: __init__ + + .. automethod:: __iter__ + + .. automethod:: __rshift__ + + .. automethod:: add_gate + + .. automethod:: append + + .. automethod:: add_circuit + + .. automethod:: add_qubit + + .. automethod:: add_bit + + .. automethod:: add_phase + + .. autoproperty:: name + + .. autoproperty:: n_qubits + + .. autoproperty:: n_bits + + .. autoproperty:: phase + + .. autoproperty:: qubits + + .. autoproperty:: bits + + .. autoproperty:: n_gates + + .. autoproperty:: is_symbolic + + .. automethod:: add_q_register + + .. automethod:: get_q_register + + .. automethod:: add_c_register + + .. automethod:: get_c_register + + .. autoproperty:: q_registers + + .. autoproperty:: c_registers + + .. automethod:: rename_units + + .. automethod:: add_blank_wires + + .. automethod:: remove_blank_wires + + .. automethod:: flatten_registers + + .. autoproperty:: qubit_readout + + .. autoproperty:: bit_readout + + .. autoproperty:: opgroups + + .. autoproperty:: is_simple + + .. autoproperty:: qubit_to_bit_map + + .. automethod:: commands_of_type + + .. automethod:: ops_of_type + + .. automethod:: n_gates_of_type + + .. automethod:: n_1qb_gates + + .. automethod:: n_2qb_gates + + .. automethod:: n_nqb_gates + + .. automethod:: free_symbols + + .. automethod:: symbol_substitution + + .. automethod:: substitute_named + + .. automethod:: depth + + .. automethod:: depth_2q + + .. automethod:: depth_by_type + + .. automethod:: get_commands + + .. automethod:: add_barrier + + .. automethod:: add_conditional_barrier + + .. automethod:: add_wasm + + .. automethod:: add_wasm_to_reg + + .. automethod:: from_dict + + .. automethod:: to_dict + + .. automethod:: get_statevector + + .. automethod:: get_unitary + + .. automethod:: get_unitary_times_other + + .. automethod:: dagger + + .. automethod:: transpose + + .. automethod:: copy + + .. automethod:: get_resources + + .. automethod:: add_c_and + + .. automethod:: add_c_not + + .. automethod:: add_c_or + + .. automethod:: add_c_xor + + .. automethod:: add_c_range_predicate + + .. automethod:: add_c_and_to_registers + + .. automethod:: add_c_or_to_registers + + .. automethod:: add_c_xor_to_registers + + .. automethod:: add_c_not_to_registers + + .. automethod:: add_c_copybits + + .. automethod:: add_c_copyreg + + .. automethod:: add_c_setreg + + .. automethod:: add_c_setbits + + .. automethod:: add_c_transform + + .. automethod:: add_c_modifier + + .. automethod:: add_c_predicate + + .. automethod:: add_classicalexpbox_bit + + .. automethod:: add_classicalexpbox_register + + .. automethod:: qubit_create + + .. automethod:: qubit_create_all + + .. automethod:: qubit_discard + + .. automethod:: qubit_discard_all + + .. automethod:: qubit_is_created + + .. automethod:: qubit_is_discarded + + .. autoproperty:: created_qubits + + .. autoproperty:: discarded_qubits + + .. autoproperty:: valid_connectivity + + .. automethod:: replace_SWAPs + + .. automethod:: replace_implicit_wire_swaps + + .. automethod:: implicit_qubit_permutation + + .. automethod:: to_latex_file + + + Convenience methods for appending gates + --------------------------------------- + + .. Note:: For adding gates to a circuit the :py:meth:`Circuit.add_gate` method is sufficient to append any :py:class:`OpType` to a :py:class:`Circuit`. + Some gates can only be added with :py:meth:`Circuit.add_gate`. For other more commonly used operations these can be added to a :py:class:`Circuit` directly using the convenience methods below. + + .. automethod:: H + + .. automethod:: X + + .. automethod:: Y + + .. automethod:: Z + + .. automethod:: S + + .. automethod:: Sdg + + .. automethod:: SX + + .. automethod:: SXdg + + .. automethod:: T + + .. automethod:: Tdg + + .. automethod:: V + + .. automethod:: Vdg + + .. automethod:: Rx + + .. automethod:: Ry + + .. automethod:: Rz + + .. automethod:: PhasedX + + .. automethod:: TK1 + + .. automethod:: TK2 + + .. automethod:: U1 + + .. automethod:: U2 + + .. automethod:: U3 + + .. automethod:: CX + + .. automethod:: CY + + .. automethod:: CZ + + .. automethod:: CS + + .. automethod:: CSdg + + .. automethod:: CV + + .. automethod:: CVdg + + .. automethod:: CSX + + .. automethod:: CSXdg + + .. automethod:: CH + + .. automethod:: ECR + + .. automethod:: CRx + + .. automethod:: CRy + + .. automethod:: CRz + + .. automethod:: CU1 + + .. automethod:: CU3 + + .. automethod:: Measure + + .. automethod:: measure_all + + .. automethod:: measure_register + + .. automethod:: Reset + + .. automethod:: Phase + + .. automethod:: SWAP + + .. automethod:: CCX + + .. automethod:: CSWAP + + .. automethod:: ESWAP + + .. automethod:: ISWAP + + .. automethod:: ISWAPMax + + .. automethod:: PhasedISWAP + + .. automethod:: FSim + + .. automethod:: Sycamore + + .. automethod:: XXPhase + + .. automethod:: XXPhase3 + + .. automethod:: YYPhase + + .. automethod:: ZZPhase + + .. automethod:: ZZMax + + Methods for appending circuit boxes + ----------------------------------- + + .. Note:: For adding boxes to a circuit the :py:meth:`Circuit.add_gate` method is sufficient to append any :py:class:`OpType` to a :py:class:`Circuit`. + + .. jupyter-input:: + + from pytket.circuit import Circuit, CircBox + + sub_circ = Circuit(2).CX(0, 1).Rz(0.25, 1).CX(0, 1) + + box = CircBox(sub_circ) + + bigger_circ = Circuit(3) + + # Equivalent to bigger_circ.add_circbox(box, [0, 1, 2]) + bigger_circ.add_gate(box, [0, 1, 2]) + + .. automethod:: add_circbox + + .. automethod:: add_unitary1qbox + + .. automethod:: add_unitary2qbox + + .. automethod:: add_unitary3qbox + + .. automethod:: add_expbox + + .. automethod:: add_pauliexpbox + + .. automethod:: add_pauliexppairbox + + .. automethod:: add_pauliexpcommutingsetbox + + .. automethod:: add_phasepolybox + + .. automethod:: add_toffolibox + + .. automethod:: add_dummybox + + .. automethod:: add_qcontrolbox + + .. automethod:: add_custom_gate + + .. automethod:: add_assertion + + .. automethod:: add_multiplexor + + .. automethod:: add_multiplexedrotation + + .. automethod:: add_multiplexedu2 + + .. automethod:: add_multiplexed_tensored_u2 + + .. automethod:: add_state_preparation_box + + .. automethod:: add_diagonal_box + + .. automethod:: add_conjugation_box + + diff --git a/pytket/docs/conf.py b/pytket/docs/conf.py index d4f64dcd24..a0623689b1 100644 --- a/pytket/docs/conf.py +++ b/pytket/docs/conf.py @@ -99,6 +99,7 @@ # html_theme_options = { + "show_toc_level": 2, "repository_url": "https://github.com/CQCL/tket", "use_repository_button": True, "use_issues_button": True, @@ -132,78 +133,6 @@ # Output file base name for HTML help builder. htmlhelp_basename = "pytketdoc" - -# -- Options for LaTeX output ------------------------------------------------ - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - ( - master_doc, - "pytket.tex", - "pytket Documentation", - "Cambridge Quantum Computing Ltd", - "manual", - ), -] - - -# -- Options for manual page output ------------------------------------------ - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [(master_doc, "pytket", "pytket Documentation", [author], 1)] - - -# -- Options for Texinfo output ---------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ( - master_doc, - "pytket", - "pytket Documentation", - author, - "pytket", - "Python API for CQC's tket compiler", - "Miscellaneous", - ), -] - - -# -- Options for Epub output ------------------------------------------------- - -# Bibliographic Dublin Core info. -epub_title = project - -# The unique identifier of the text. This can be a ISBN number -# or the project homepage. -# -# epub_identifier = '' - -# A unique identification for the text. -# -# epub_uid = '' - -# A list of files that should not be packed into the epub file. epub_exclude_files = ["search.html"] autodoc_member_order = "groupwise" From 03860de0382caf6a2b6b9c3a566636c6306855f2 Mon Sep 17 00:00:00 2001 From: Alec Edgington <54802828+cqc-alec@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:19:44 +0000 Subject: [PATCH 14/17] Revert "Don't try to install ZX module with Python 3.12. (#1203)" (#1241) --- .github/workflows/build_and_test.yml | 30 +++++++++------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 10a102eca9..981a5a8945 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -279,7 +279,7 @@ jobs: cd pytket pip install -e .[ZX] -v - name: Build pytket - if: github.event_name == 'schedule' # https://github.com/CQCL/tket/issues/1200 + if: github.event_name == 'schedule' # https://github.com/CQCL/tket/issues/1242 run: | cd pytket pip install -e . -v @@ -387,34 +387,28 @@ jobs: with: python-version: '3.12' - name: Build pytket - if: github.event_name != 'schedule' run: | cd pytket - python${{ matrix.python-version }} -m pip install -e .[ZX] -v - - name: Build pytket - if: github.event_name == 'schedule' # https://github.com/CQCL/tket/issues/1200 - run: | - cd pytket - python${{ matrix.python-version }} -m pip install -e . -v + python -m pip install -e .[ZX] -v - name: Run doctests run: | cd pytket - python${{ matrix.python-version }} -m pip install pytest - python${{ matrix.python-version }} -m pytest --doctest-modules pytket + python -m pip install pytest + python -m pytest --doctest-modules pytket - name: Test pytket run: | cd pytket/tests - python${{ matrix.python-version }} -m pip install -r requirements.txt - python${{ matrix.python-version }} -m pytest --ignore=simulator/ + python -m pip install -r requirements.txt + python -m pytest --ignore=simulator/ - name: Check type stubs are up-to-date and run mypy if: matrix.os == 'macos-13-xlarge' && (github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch') run: | - python${{ matrix.python-version }} -m pip install -U mypy - python${{ matrix.python-version }} -m pip install pybind11-stubgen==2.3.6 # https://github.com/CQCL/tket/issues/1135 + python -m pip install -U mypy + python -m pip install pybind11-stubgen==2.3.6 # https://github.com/CQCL/tket/issues/1135 cd pytket ./stub_generation/regenerate_stubs git diff --quiet pytket/_tket && echo "Stubs are up-to-date" || exit 1 # fail if stubs change after regeneration - python${{ matrix.python-version }} -m mypy --config-file=mypy.ini --no-incremental -p pytket -p tests + python -m mypy --config-file=mypy.ini --no-incremental -p pytket -p tests - name: Upload package if: github.event_name == 'push' && github.ref == 'refs/heads/develop' && needs.check_changes.outputs.tket_changed == 'true' run: | @@ -514,15 +508,9 @@ jobs: with: python-version: '3.12' - name: Build pytket - if: github.event_name != 'schedule' run: | cd pytket pip install -e .[ZX] -v - - name: Build pytket - if: github.event_name == 'schedule' # https://github.com/CQCL/tket/issues/1200 - run: | - cd pytket - pip install -e . -v - name: Run doctests run: | cd pytket From c5a7106d60ca9c5e8b2a622b72619849291bcb72 Mon Sep 17 00:00:00 2001 From: Alec Edgington <54802828+cqc-alec@users.noreply.github.com> Date: Fri, 9 Feb 2024 11:25:00 +0000 Subject: [PATCH 15/17] [infra] Fix build command on Windows (#1247) --- .github/workflows/build_and_test.yml | 2 +- .github/workflows/release.yml | 2 +- pytket/conanfile.py | 2 +- tket/conanfile.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 981a5a8945..95530abafb 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -481,7 +481,7 @@ jobs: run: | $env:TKET_VSGEN_CCACHE_EXE = '${{ steps.ccache-path.outputs.ccache_path }}' conan build tket --user tket --channel stable -o boost/*:header_only=True -o tklog/*:shared=True -o tket/*:shared=True - conan export-pkg tket --user tket --channel stable -o boost/*:header_only=True -o tklog/*:shared=True -o tket/*:shared=True -tf `"`" + conan export-pkg tket --user tket --channel stable -o boost/*:header_only=True -o tklog/*:shared=True -o tket/*:shared=True -tf "" - name: Install tket if: needs.check_changes.outputs.tket_changed != 'true' run: conan install --requires tket/${{ needs.check_changes.outputs.tket_ver }}@tket/stable -o boost/*:header_only=True -o tklog/*:shared=True -o tket/*:shared=True diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a02458d5cb..d247b1f44b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -169,7 +169,7 @@ jobs: cp ${PROFILE_PATH} ${DEFAULT_PROFILE_PATH} conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0 - name: Build tket - run: conan create tket --user tket --channel stable --build=missing -o boost/*:header_only=True -o tklog/*:shared=True -o tket/*:shared=True -tf `"`" + run: conan create tket --user tket --channel stable --build=missing -o boost/*:header_only=True -o tklog/*:shared=True -o tket/*:shared=True -tf "" - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: diff --git a/pytket/conanfile.py b/pytket/conanfile.py index 95728ed3a1..cd8d59b8b3 100644 --- a/pytket/conanfile.py +++ b/pytket/conanfile.py @@ -32,7 +32,7 @@ def package(self): cmake.install() def requirements(self): - self.requires("tket/1.2.88@tket/stable") + self.requires("tket/1.2.89@tket/stable") self.requires("tklog/0.3.3@tket/stable") self.requires("tkrng/0.3.3@tket/stable") self.requires("tkassert/0.3.4@tket/stable") diff --git a/tket/conanfile.py b/tket/conanfile.py index fcae34b554..0864fe494b 100644 --- a/tket/conanfile.py +++ b/tket/conanfile.py @@ -23,7 +23,7 @@ class TketConan(ConanFile): name = "tket" - version = "1.2.88" + version = "1.2.89" package_type = "library" license = "Apache 2" homepage = "https://github.com/CQCL/tket" From fc89c70dc2c57f6617f6297946ab2935b9f07bbd Mon Sep 17 00:00:00 2001 From: Alec Edgington <54802828+cqc-alec@users.noreply.github.com> Date: Fri, 9 Feb 2024 16:19:44 +0000 Subject: [PATCH 16/17] [bugfix] Don't reuse "stale" Pauli stabilizers when generating Pauli graphs (#1245) --- pytket/conanfile.py | 2 +- pytket/docs/changelog.rst | 5 +++++ tket/conanfile.py | 2 +- tket/src/PauliGraph/PauliGraph.cpp | 5 +++-- tket/test/src/test_CompilerPass.cpp | 13 +++++++++++++ 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/pytket/conanfile.py b/pytket/conanfile.py index cd8d59b8b3..4a3873aa34 100644 --- a/pytket/conanfile.py +++ b/pytket/conanfile.py @@ -32,7 +32,7 @@ def package(self): cmake.install() def requirements(self): - self.requires("tket/1.2.89@tket/stable") + self.requires("tket/1.2.90@tket/stable") self.requires("tklog/0.3.3@tket/stable") self.requires("tkrng/0.3.3@tket/stable") self.requires("tkassert/0.3.4@tket/stable") diff --git a/pytket/docs/changelog.rst b/pytket/docs/changelog.rst index fa638f0e9c..e7e6e851b5 100644 --- a/pytket/docs/changelog.rst +++ b/pytket/docs/changelog.rst @@ -8,6 +8,11 @@ Features: * Add ``WasmFileHandler.bytecode()`` method to retrieve the WASM as bytecode. +Fixes: + +* Fix bug in ``PauliExponentials()`` pass affecting circuits containing + ``PhasedX`` gates containing Clifford angles. + 1.24.0 (January 2024) --------------------- diff --git a/tket/conanfile.py b/tket/conanfile.py index 0864fe494b..0c6e9481f5 100644 --- a/tket/conanfile.py +++ b/tket/conanfile.py @@ -23,7 +23,7 @@ class TketConan(ConanFile): name = "tket" - version = "1.2.89" + version = "1.2.90" package_type = "library" license = "Apache 2" homepage = "https://github.com/CQCL/tket" diff --git a/tket/src/PauliGraph/PauliGraph.cpp b/tket/src/PauliGraph/PauliGraph.cpp index a6ec0fcae6..abd2a8b42c 100644 --- a/tket/src/PauliGraph/PauliGraph.cpp +++ b/tket/src/PauliGraph/PauliGraph.cpp @@ -163,8 +163,6 @@ void PauliGraph::apply_gate_at_end( case OpType::PhasedX: { Expr alpha = gate.get_params().at(0); Expr beta = gate.get_params().at(1); - SpPauliStabiliser zpauli = cliff_.get_zrow(qbs.at(0)); - SpPauliStabiliser xpauli = cliff_.get_xrow(qbs.at(0)); std::optional cliff_alpha = equiv_Clifford(alpha); std::optional cliff_beta = equiv_Clifford(beta); // Rz(-b) @@ -173,6 +171,7 @@ void PauliGraph::apply_gate_at_end( cliff_.apply_gate_at_end(OpType::Sdg, qbs); } } else { + SpPauliStabiliser zpauli = cliff_.get_zrow(qbs.at(0)); apply_pauli_gadget_at_end(zpauli, -beta); } // Rx(a) @@ -181,6 +180,7 @@ void PauliGraph::apply_gate_at_end( cliff_.apply_gate_at_end(OpType::V, qbs); } } else { + SpPauliStabiliser xpauli = cliff_.get_xrow(qbs.at(0)); apply_pauli_gadget_at_end(xpauli, alpha); } // Rz(b) @@ -189,6 +189,7 @@ void PauliGraph::apply_gate_at_end( cliff_.apply_gate_at_end(OpType::S, qbs); } } else { + SpPauliStabiliser zpauli = cliff_.get_zrow(qbs.at(0)); apply_pauli_gadget_at_end(zpauli, beta); } break; diff --git a/tket/test/src/test_CompilerPass.cpp b/tket/test/src/test_CompilerPass.cpp index 5106e5cfc5..43ed4d4b46 100644 --- a/tket/test/src/test_CompilerPass.cpp +++ b/tket/test/src/test_CompilerPass.cpp @@ -2026,5 +2026,18 @@ SCENARIO( REQUIRE(cu.get_circ_ref().n_gates() == 1); } } + +SCENARIO("PauliExponentials") { + GIVEN("A PhasedX gate") { + // https://github.com/CQCL/tket/issues/1244 + Circuit c(1); + c.add_op(OpType::PhasedX, {0.5, 0.6}, {0}); + c.add_op(OpType::PhasedX, {0.6, 0.5}, {0}); + CompilationUnit cu(c); + CHECK(gen_pauli_exponentials(Transforms::PauliSynthStrat::Individual) + ->apply(cu)); + REQUIRE(test_unitary_comparison(c, cu.get_circ_ref(), true)); + } +} } // namespace test_CompilerPass } // namespace tket From f3edf410b804e7057901c18a30f07cf8ae650958 Mon Sep 17 00:00:00 2001 From: Alec Edgington Date: Fri, 9 Feb 2024 16:25:03 +0000 Subject: [PATCH 17/17] Update version and changelog. --- pytket/docs/changelog.rst | 4 ++-- pytket/docs/conf.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pytket/docs/changelog.rst b/pytket/docs/changelog.rst index e7e6e851b5..1b13d9c9cc 100644 --- a/pytket/docs/changelog.rst +++ b/pytket/docs/changelog.rst @@ -1,8 +1,8 @@ Changelog ========= -Unreleased ----------- +1.25.0 (February 2024) +---------------------- Features: diff --git a/pytket/docs/conf.py b/pytket/docs/conf.py index a0623689b1..b25bb0c302 100644 --- a/pytket/docs/conf.py +++ b/pytket/docs/conf.py @@ -38,9 +38,9 @@ author = "Quantinuum" # The short X.Y version -version = "1.24" +version = "1.25" # The full version, including alpha/beta/rc tags -release = "1.24.0" +release = "1.25.0" # -- General configuration ---------------------------------------------------