From e1a35699f6c3b5ae6665d4aa21596a6c1e2521eb Mon Sep 17 00:00:00 2001 From: CalMacCQ <93673602+CalMacCQ@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:04:26 +0000 Subject: [PATCH 1/7] remove implicit qubit permutation warning in tk_to_qiskit --- pytket/extensions/qiskit/qiskit_convert.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/pytket/extensions/qiskit/qiskit_convert.py b/pytket/extensions/qiskit/qiskit_convert.py index a214e381..76ab16a7 100644 --- a/pytket/extensions/qiskit/qiskit_convert.py +++ b/pytket/extensions/qiskit/qiskit_convert.py @@ -862,10 +862,6 @@ def append_tk_command_to_qiskit( supported_gate_rebase = AutoRebase(_protected_tket_gates) -def _has_implicit_permutation(circ: Circuit) -> bool: - return any(q0 != q1 for q0, q1 in circ.implicit_qubit_permutation().items()) - - def tk_to_qiskit( tkcirc: Circuit, replace_implicit_swaps: bool = False ) -> QuantumCircuit: @@ -885,14 +881,6 @@ def tk_to_qiskit( if replace_implicit_swaps: tkc.replace_implicit_wire_swaps() - if _has_implicit_permutation(tkcirc) and not replace_implicit_swaps: - warnings.warn( - "The pytket Circuit contains implicit qubit permutations" - + " which aren't handled by default." - + " Consider using the replace_implicit_swaps flag in tk_to_qiskit or" - + " replacing them using Circuit.replace_implicit_swaps()." - ) - qcirc = QuantumCircuit(name=tkc.name) qreg_sizes: dict[str, int] = {} for qb in tkc.qubits: From 18f803efc9a13c32b9d6c0ba71bdd76d417dff43 Mon Sep 17 00:00:00 2001 From: CalMacCQ <93673602+CalMacCQ@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:21:36 +0000 Subject: [PATCH 2/7] remove test --- tests/qiskit_convert_test.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/qiskit_convert_test.py b/tests/qiskit_convert_test.py index 631f8ee0..cdde50d3 100644 --- a/tests/qiskit_convert_test.py +++ b/tests/qiskit_convert_test.py @@ -1172,10 +1172,3 @@ def test_nonregister_bits() -> None: c.rename_units({Bit(0): Bit(1)}) with pytest.raises(NotImplementedError): tk_to_qiskit(c) - - -def test_implicit_swap_warning() -> None: - c = Circuit(2).H(0).SWAP(0, 1) - c.replace_SWAPs() - with pytest.warns(UserWarning, match="The pytket Circuit contains implicit qubit"): - tk_to_qiskit(c) From 9ff88c49f522fbfc9c6a1a6e740931586da126e7 Mon Sep 17 00:00:00 2001 From: CalMacCQ <93673602+CalMacCQ@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:21:54 +0000 Subject: [PATCH 3/7] update changelog --- docs/changelog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 7defb804..4adf0ac5 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -4,6 +4,10 @@ # Changelog +## 0.60.0 (Unreleased) + +- Revert a change made in release v0.59.0 where users are warned about implicit qubit permutations in {py:func}`tk_to_qiskit`. This avoids spamming the user with unhelpful warnings when using pytket-qiskit backends. These backends handle implicit permutations automatically. + ## 0.59.0 (November 2024) - Updated pytket version requirement to 1.34.0. From 8eec1f6b87f1e6d4f23b410416b602ffc452593e Mon Sep 17 00:00:00 2001 From: CalMacCQ <93673602+CalMacCQ@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:46:01 +0000 Subject: [PATCH 4/7] fix note in the docs about 'compilation' to AerBackend --- docs/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index 846f6fb6..884112ab 100644 --- a/docs/index.md +++ b/docs/index.md @@ -230,7 +230,7 @@ Every {py:class}`~pytket.backends.backend.Backend` in pytket has its own {py:met - \[2\] {py:class}`~pytket._tket.passes.AutoRebase` is a conversion to the gateset supported by the backend. For IBM quantum devices and emulators the supported gate set is either $\{X, SX, Rz, CX\}$, $\{X, SX, Rz, ECR\}$, or $\{X, SX, Rz, CZ\}$. The more idealised Aer simulators have a much broader range of supported gates. - \[3\] This is imported from qiskit and corresponds to the method in "LightSABRE: A Lightweight and Enhanced SABRE Algorithm", Henry Zou, Matthew Treinish, Kevin Hartman, Alexander Ivrii, Jake Lishman, arXiv:2409.08368. -**Note:** The {py:meth}`~AerBackend.default_compilation_pass` for {py:class}`AerBackend` is the same as above. +**Note:** The {py:meth}`~AerBackend.default_compilation_pass` for {py:class}`AerBackend` is the same as above if a {py:class}`NoiseModel` is used. A {py:class}`NoiseModel` implicitly defines connectivity constraints via edge errors. If no {py:class}`NoiseModel` is used then then any passes related to connectivity constraints are omitted from the {py:meth}`~AerBackend.default_compilation_pass` for {py:class}`AerBackend`. ## Noise Modelling From 49b3b9372860b0e3bf9d8ee886328166ed5a6f3a Mon Sep 17 00:00:00 2001 From: CalMacCQ <93673602+CalMacCQ@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:48:40 +0000 Subject: [PATCH 5/7] fix import --- pytket/extensions/qiskit/qiskit_convert.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pytket/extensions/qiskit/qiskit_convert.py b/pytket/extensions/qiskit/qiskit_convert.py index 76ab16a7..a1d5dd6a 100644 --- a/pytket/extensions/qiskit/qiskit_convert.py +++ b/pytket/extensions/qiskit/qiskit_convert.py @@ -15,7 +15,6 @@ """Methods to allow conversion between Qiskit and pytket circuit classes """ -import warnings from collections import defaultdict from collections.abc import Iterable from inspect import signature From fe3cb507f042913105b0a83a6795e824292b2f96 Mon Sep 17 00:00:00 2001 From: CalMacCQ <93673602+CalMacCQ@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:56:54 +0000 Subject: [PATCH 6/7] expand docstring --- pytket/extensions/qiskit/qiskit_convert.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pytket/extensions/qiskit/qiskit_convert.py b/pytket/extensions/qiskit/qiskit_convert.py index a1d5dd6a..141f826c 100644 --- a/pytket/extensions/qiskit/qiskit_convert.py +++ b/pytket/extensions/qiskit/qiskit_convert.py @@ -871,6 +871,10 @@ def tk_to_qiskit( If no exact replacement can be found for a part of the circuit then an equivalent circuit will be returned using the tket gates which are supported in qiskit. + Please note that implicit swaps in a pytket Circuit are not handled by default. + Consider using the replace_implicit_swaps to replace these implicit swaps with + SWAP gates. + :param tkcirc: A :py:class:`Circuit` to be converted :param replace_implicit_swaps: Implement implicit permutation by adding SWAPs to the end of the circuit. From 23afa8933ae94623356d0157c44c6692f44799e2 Mon Sep 17 00:00:00 2001 From: CalMacCQ <93673602+CalMacCQ@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:57:36 +0000 Subject: [PATCH 7/7] minor fix --- pytket/extensions/qiskit/qiskit_convert.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytket/extensions/qiskit/qiskit_convert.py b/pytket/extensions/qiskit/qiskit_convert.py index 141f826c..cd2660e4 100644 --- a/pytket/extensions/qiskit/qiskit_convert.py +++ b/pytket/extensions/qiskit/qiskit_convert.py @@ -872,7 +872,7 @@ def tk_to_qiskit( circuit will be returned using the tket gates which are supported in qiskit. Please note that implicit swaps in a pytket Circuit are not handled by default. - Consider using the replace_implicit_swaps to replace these implicit swaps with + Consider using the replace_implicit_swaps flag to replace these implicit swaps with SWAP gates. :param tkcirc: A :py:class:`Circuit` to be converted