From 9ebc45a527c99a0b45203e806c9f2762bac625f8 Mon Sep 17 00:00:00 2001 From: cqc-melf <70640934+cqc-melf@users.noreply.github.com> Date: Tue, 7 Nov 2023 18:27:15 +0000 Subject: [PATCH 1/7] update gateset (#37) * update gateset, add test, update changelog * requested changes * remove line from test < 10 --- docs/changelog.rst | 5 ++ pytket/extensions/pyquil/backends/forest.py | 9 +++- tests/pyquil_convert_test.py | 2 + tests/qvm_backend_test.py | 54 +++++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 8268fb7..b8e9bf8 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,11 @@ Changelog ~~~~~~~~~ +0.31.0 (unreleased) +------------------- + +* add pyquil.gates.XY to the native gateset + 0.30.0 (October 2023) --------------------- diff --git a/pytket/extensions/pyquil/backends/forest.py b/pytket/extensions/pyquil/backends/forest.py index 884f87c..76b5eb5 100644 --- a/pytket/extensions/pyquil/backends/forest.py +++ b/pytket/extensions/pyquil/backends/forest.py @@ -108,7 +108,14 @@ class ForestBackend(Backend): _supports_counts = True _supports_contextual_optimisation = True _persistent_handles = True - _GATE_SET = {OpType.CZ, OpType.Rx, OpType.Rz, OpType.Measure, OpType.Barrier} + _GATE_SET = { + OpType.CZ, + OpType.Rx, + OpType.Rz, + OpType.Measure, + OpType.Barrier, + OpType.ISWAP, + } def __init__(self, qc: QuantumComputer): """Backend for running circuits with the Rigetti QVM. diff --git a/tests/pyquil_convert_test.py b/tests/pyquil_convert_test.py index dd8ac6e..1870b6e 100644 --- a/tests/pyquil_convert_test.py +++ b/tests/pyquil_convert_test.py @@ -37,6 +37,7 @@ CPHASE, SWAP, MEASURE, + XY, ) from pyquil.quilbase import Measurement from sympy import pi, Symbol @@ -78,6 +79,7 @@ def get_test_program(measure: bool = False) -> Program: p += CCNOT(0, 1, 2) p += CPHASE(PI / 4, 2, 1) p += SWAP(0, 3) + p += XY(PI / 3, 2, 1) if measure: ro = p.declare("ro", "BIT", 4) p += MEASURE(0, ro[0]) diff --git a/tests/qvm_backend_test.py b/tests/qvm_backend_test.py index 6b80f4b..f487b4c 100644 --- a/tests/qvm_backend_test.py +++ b/tests/qvm_backend_test.py @@ -390,6 +390,60 @@ def test_shots_bits_edgecases(qvm: None, quilc: None) -> None: assert res.get_counts() == correct_counts +@pytest.mark.skipif( + skip_qvm_tests, reason="Can only run Rigetti QVM if docker is installed" +) +def test_gateset(qvm: None, quilc: None) -> None: + qc = get_qc("9q-square", as_qvm=True) + forest_backend = ForestBackend(qc) + a = [Qubit("node", i) for i in range(6)] + + c = Circuit(0, 6) + for q in a: + c.add_qubit(q) + c.ISWAP(1, a[5], a[4]) + c.ISWAP(2, a[5], a[4]) + c.ISWAP(3, a[5], a[4]) + + c.measure_all() + + h = forest_backend.process_circuit(c, 10) + res = forest_backend.get_result(h) + + correct_shots = np.zeros((10, 6), dtype=int) # type: ignore + correct_counts = Counter({(0,) * 6: 10}) + + assert np.array_equal(res.get_shots(), correct_shots) + assert res.get_shots().shape == (10, 6) + assert res.get_counts() == correct_counts + + +@pytest.mark.skipif( + skip_qvm_tests, reason="Can only run Rigetti QVM if docker is installed" +) +def test_gateset_ii(qvm: None, quilc: None) -> None: + qc = get_qc("9q-square", as_qvm=True) + forest_backend = ForestBackend(qc) + + a = [Qubit("node", i) for i in range(6)] + c = Circuit(0, 6) + for q in a: + c.add_qubit(q) + c.Rx(1.0, a[5]) + c.ISWAP(0.5, a[5], a[4]) + c.Rx(1.0, a[4]) + c.ISWAP(0.5, a[5], a[4]) + c.measure_all() + + h = forest_backend.process_circuit(c, 10) + res = forest_backend.get_result(h) + + assert res.get_shots().shape == (10, 6) + assert ( + res.get_counts()[(0, 0, 0, 0, 0, 0)] + res.get_counts()[(0, 0, 0, 0, 1, 1)] + ) == 10 + + @pytest.mark.skipif( skip_qvm_tests, reason="Can only run Rigetti QVM if docker is installed" ) From 121626133b3d26ee3d7cf6c6023594193af9b1af Mon Sep 17 00:00:00 2001 From: cqc-melf <70640934+cqc-melf@users.noreply.github.com> Date: Tue, 21 Nov 2023 17:14:58 +0000 Subject: [PATCH 2/7] Update/dependabot docs (#38) * addtketwebsite * updateextlink * updatedependabot * updatereadme * updatereadmeII * replaceallgithublinks --- .github/dependabot.yml | 10 +++++++++- .github/workflows/docs/build-docs | 6 ++++-- .github/workflows/docs/conf.py | 2 +- .github/workflows/docs/intro.txt | 2 +- README.md | 9 ++------- setup.py | 2 +- 6 files changed, 18 insertions(+), 13 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index ac1560a..f384d36 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,4 +5,12 @@ updates: - package-ecosystem: "github-actions" directory: "/" schedule: - interval: "weekly" + interval: "daily" + - package-ecosystem: pip + directory: "/" + schedule: + interval: "daily" + groups: + python-packages: + patterns: + - "*" diff --git a/.github/workflows/docs/build-docs b/.github/workflows/docs/build-docs index cade78b..d3651bd 100755 --- a/.github/workflows/docs/build-docs +++ b/.github/workflows/docs/build-docs @@ -10,8 +10,9 @@ import sys DOCS_DIR = Path(sys.argv[0]).absolute().parent MODULES_DIR = DOCS_DIR.parent.parent.parent -PYTKET_DOCS_LINK = "https://cqcl.github.io/tket/pytket/api/index.html" -PYTKET_EX_DOCS_LINK = "https://cqcl.github.io/pytket-extensions/api/index.html" +TKET_WEBSITE_LINK = "https://tket.quantinuum.com/" +PYTKET_DOCS_LINK = "https://tket.quantinuum.com/api-docs/" +PYTKET_EX_DOCS_LINK = "https://tket.quantinuum.com/api-docs/extensions.html" PYTKET_PYQUIL_PYPI_LINK = "https://pypi.org/project/pytket-pyquil/" PYTKET_PYQUIL_GITHUB = "https://github.com/CQCL/pytket-pyquil" MODULE = "pyquil" @@ -51,6 +52,7 @@ def build_module_docs(): content.append( "\n.. toctree::\n\t:caption: More documentation:\n\t:maxdepth: 1\n\n" ) + content.append(f"\tTKET website <{TKET_WEBSITE_LINK}>\n") content.append(f"\tpytket <{PYTKET_DOCS_LINK}>\n") content.append(f"\tpytket extensions <{PYTKET_EX_DOCS_LINK}>\n") content.append( diff --git a/.github/workflows/docs/conf.py b/.github/workflows/docs/conf.py index 7394fb2..28c40bb 100644 --- a/.github/workflows/docs/conf.py +++ b/.github/workflows/docs/conf.py @@ -33,7 +33,7 @@ # -- Extension configuration ------------------------------------------------- -pytketdoc_base = "https://cqcl.github.io/tket/pytket/api/" +pytketdoc_base = "https://tket.quantinuum.com/api-docs/" intersphinx_mapping = { "https://docs.python.org/3/": None, diff --git a/.github/workflows/docs/intro.txt b/.github/workflows/docs/intro.txt index 85d4a2c..ce587b0 100644 --- a/.github/workflows/docs/intro.txt +++ b/.github/workflows/docs/intro.txt @@ -6,5 +6,5 @@ platforms. Each extension adds either new methods to the ``pytket`` package to convert between circuit representations, or new backends to which ``pytket`` circuits can be submitted. -.. _pytket: https://cqcl.github.io/tket/pytket/api/ +.. _pytket: https://tket.quantinuum.com/api-docs/ .. _Quantinuum: https://www.quantinuum.com/ diff --git a/README.md b/README.md index 3b08deb..19deb6d 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,7 @@ -# Pytket Extensions - -This repository contains the pytket-pyquil extension, using Quantinuum's -[pytket](https://cqcl.github.io/tket/pytket/api/index.html) quantum SDK. - # pytket-pyquil -[Pytket](https://cqcl.github.io/tket/pytket/api/index.html) is a python module for interfacing -with tket, a quantum computing toolkit and optimisation compiler developed by Quantinuum. +[Pytket](https://tket.quantinuum.com/api-docs/index.html) is a python module for interfacing +with tket, a quantum computing toolkit and optimising compiler developed by Quantinuum. `pytket-pyquil` is an extension to `pytket` that allows `pytket` circuits to be run on Rigetti backends and simulators, as well as conversion to and from pyQuil diff --git a/setup.py b/setup.py index d7df69c..49a84ed 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ author_email="tket-support@cambridgequantum.com", python_requires=">=3.8", project_urls={ - "Documentation": "https://cqcl.github.io/pytket-pyquil/api/index.html", + "Documentation": "https://tket.quantinuum.com/extensions/pytket-pyquil/api/index.html", "Source": "https://github.com/CQCL/pytket-pyquil", "Tracker": "https://github.com/CQCL/pytket-pyquil/issues", }, From 3f9883519d329ed23ed199d1482c90dbe8372dd0 Mon Sep 17 00:00:00 2001 From: cqc-melf <70640934+cqc-melf@users.noreply.github.com> Date: Wed, 22 Nov 2023 15:47:31 +0000 Subject: [PATCH 3/7] updatetestrequirements (#40) --- tests/test-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-requirements.txt b/tests/test-requirements.txt index a91759d..6330b88 100644 --- a/tests/test-requirements.txt +++ b/tests/test-requirements.txt @@ -1,5 +1,5 @@ pytest -pytest-timeout ~= 1.4.2 +pytest-timeout ~= 2.2.0 hypothesis requests_mock docker From 772601ebff3bee5e8d795ccb379fac6e9dfd959e Mon Sep 17 00:00:00 2001 From: cqc-melf <70640934+cqc-melf@users.noreply.github.com> Date: Wed, 22 Nov 2023 18:11:42 +0000 Subject: [PATCH 4/7] update links in documentation (#42) * update links in documentation * update readme --- .github/workflows/docs/build-docs | 10 +++++++--- README.md | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docs/build-docs b/.github/workflows/docs/build-docs index d3651bd..e2b4cbd 100755 --- a/.github/workflows/docs/build-docs +++ b/.github/workflows/docs/build-docs @@ -10,6 +10,8 @@ import sys DOCS_DIR = Path(sys.argv[0]).absolute().parent MODULES_DIR = DOCS_DIR.parent.parent.parent +TKET_EXAMPLES_LINK = "https://tket.quantinuum.com/examples/" +TKET_MANUAL_LINK = "https://tket.quantinuum.com/user-manual/" TKET_WEBSITE_LINK = "https://tket.quantinuum.com/" PYTKET_DOCS_LINK = "https://tket.quantinuum.com/api-docs/" PYTKET_EX_DOCS_LINK = "https://tket.quantinuum.com/api-docs/extensions.html" @@ -50,11 +52,13 @@ def build_module_docs(): with open(mod_docs / "intro.txt", "r") as f: content = f.readlines() content.append( - "\n.. toctree::\n\t:caption: More documentation:\n\t:maxdepth: 1\n\n" + "\n.. toctree::\n\t:caption: pytket documentation:\n\t:maxdepth: 1\n\n" ) - content.append(f"\tTKET website <{TKET_WEBSITE_LINK}>\n") - content.append(f"\tpytket <{PYTKET_DOCS_LINK}>\n") + content.append(f"\tpytket API docs <{PYTKET_DOCS_LINK}>\n") content.append(f"\tpytket extensions <{PYTKET_EX_DOCS_LINK}>\n") + content.append(f"\tManual <{TKET_MANUAL_LINK}>\n") + content.append(f"\tExample notebooks <{TKET_EXAMPLES_LINK}>\n") + content.append(f"\tTKET website <{TKET_WEBSITE_LINK}>\n") content.append( "\n.. toctree::\n\t:caption: Links:\n\t:maxdepth: 1\n\n" ) diff --git a/README.md b/README.md index 19deb6d..192a28c 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,9 @@ representations. `pytket-pyquil` is available for Python 3.9, 3.10 and 3.11, on Linux, MacOS and Windows. To install, run: -```pip install pytket-pyquil``` +```shell +pip install pytket-pyquil +``` This will install `pytket` if it isn't already installed, and add new classes and methods into the `pytket.extensions` namespace. From db0b4e49f82fe51955b3d8fcf7cec223e3d66b44 Mon Sep 17 00:00:00 2001 From: Melf Date: Thu, 23 Nov 2023 18:16:58 +0000 Subject: [PATCH 5/7] update pytket version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 49a84ed..0386ed1 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,7 @@ packages=find_namespace_packages(include=["pytket.*"]), include_package_data=True, install_requires=[ - "pytket ~= 1.21", + "pytket ~= 1.22", "pyquil ~= 3.5", "typing-extensions ~= 4.2", ], From b68afdb9c5f9f4c78db15bef549e8b5e0b9e4e1c Mon Sep 17 00:00:00 2001 From: Melf Date: Thu, 23 Nov 2023 18:17:19 +0000 Subject: [PATCH 6/7] update changelog --- docs/changelog.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index b8e9bf8..043990a 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,9 +1,10 @@ Changelog ~~~~~~~~~ -0.31.0 (unreleased) -------------------- +0.31.0 (November 2023) +---------------------- +* Updated pytket version requirement to 1.22. * add pyquil.gates.XY to the native gateset 0.30.0 (October 2023) From b93e1dcdba3efc67f93e403fd55a3d0944cc92be Mon Sep 17 00:00:00 2001 From: Melf Date: Thu, 23 Nov 2023 18:26:13 +0000 Subject: [PATCH 7/7] update extension version --- _metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_metadata.py b/_metadata.py index 28a3cc7..18add0d 100644 --- a/_metadata.py +++ b/_metadata.py @@ -1,2 +1,2 @@ -__extension_version__ = "0.30.0" +__extension_version__ = "0.31.0" __extension_name__ = "pytket-pyquil"