From 66917908be06660307fcb8deb49d5f3b0705bf88 Mon Sep 17 00:00:00 2001 From: Melf Date: Thu, 12 Dec 2024 17:13:12 +0000 Subject: [PATCH 1/5] fix max qubit predicate --- pytket/extensions/qiskit/backends/aer.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pytket/extensions/qiskit/backends/aer.py b/pytket/extensions/qiskit/backends/aer.py index 652f537b..a6a879f4 100644 --- a/pytket/extensions/qiskit/backends/aer.py +++ b/pytket/extensions/qiskit/backends/aer.py @@ -48,6 +48,7 @@ ConnectivityPredicate, DefaultRegisterPredicate, GateSetPredicate, + MaxNQubitsPredicate, NoBarriersPredicate, NoClassicalControlPredicate, NoFastFeedforwardPredicate, @@ -695,6 +696,7 @@ def __init__( self._required_predicates = [ NoSymbolsPredicate(), GateSetPredicate(self._backend_info.gate_set), + MaxNQubitsPredicate(n_qubits), ] if self._crosstalk_params is not None: self._required_predicates.extend( From f40bfaa0907feaac17c2fbb0c51491efd1aa5b8b Mon Sep 17 00:00:00 2001 From: Melf Date: Fri, 13 Dec 2024 12:24:12 +0000 Subject: [PATCH 2/5] update changelog and version --- _metadata.py | 2 +- docs/changelog.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/_metadata.py b/_metadata.py index 5a144f83..44194cbb 100644 --- a/_metadata.py +++ b/_metadata.py @@ -1,2 +1,2 @@ -__extension_version__ = "0.61.0" +__extension_version__ = "0.62.0" __extension_name__ = "pytket-qiskit" diff --git a/docs/changelog.md b/docs/changelog.md index fe378fbf..b0bfd826 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -4,6 +4,10 @@ # Changelog +## unreleased + +- AerBackend now reject circuits with too qubits + ## 0.61.0 (December 2024) - Restrict qiskit version to ~= 1.2.4, to avoid breaking changes in 1.3.0 From e341a4acfadc2d2ff71a373e38ce5ab176bdfe60 Mon Sep 17 00:00:00 2001 From: Melf Date: Fri, 13 Dec 2024 12:34:13 +0000 Subject: [PATCH 3/5] add test --- tests/qiskit_backend_test.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/qiskit_backend_test.py b/tests/qiskit_backend_test.py index 0fe745e3..4aaba138 100644 --- a/tests/qiskit_backend_test.py +++ b/tests/qiskit_backend_test.py @@ -21,6 +21,7 @@ from qiskit.providers import JobStatus # type: ignore from qiskit_aer import Aer # type: ignore +from pytket import Circuit from pytket.architecture import Architecture, FullyConnected from pytket.extensions.qiskit import ( AerBackend, @@ -59,6 +60,15 @@ def test_samples() -> None: assert all((r[0] == "1" and r[1] == r[2]) for r in counts) +def test_maxnqubits() -> None: + backend = AerBackend(n_qubits=1) + with pytest.raises(Exception): + backend.run_circuit( + circuit=Circuit(2).CX(0, 1).measure_all(), + n_shots=1, + ) + + def test_state() -> None: qc = circuit_gen() b = AerStateBackend() From 357bbd0c866926cabd7fab110e73248d2552554c Mon Sep 17 00:00:00 2001 From: cqc-melf <70640934+cqc-melf@users.noreply.github.com> Date: Fri, 13 Dec 2024 12:41:13 +0000 Subject: [PATCH 4/5] Update docs/changelog.md Co-authored-by: Callum Macpherson <93673602+CalMacCQ@users.noreply.github.com> --- docs/changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.md b/docs/changelog.md index b0bfd826..c2f060de 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -6,7 +6,7 @@ ## unreleased -- AerBackend now reject circuits with too qubits +- AerBackend now reject circuits with too many qubits ## 0.61.0 (December 2024) From 9a9574adc89491ea3f0ec442b02f8954273f0fa7 Mon Sep 17 00:00:00 2001 From: Melf Date: Fri, 13 Dec 2024 12:43:51 +0000 Subject: [PATCH 5/5] fix mypy --- tests/qiskit_backend_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qiskit_backend_test.py b/tests/qiskit_backend_test.py index 4aaba138..0dc65a3c 100644 --- a/tests/qiskit_backend_test.py +++ b/tests/qiskit_backend_test.py @@ -21,8 +21,8 @@ from qiskit.providers import JobStatus # type: ignore from qiskit_aer import Aer # type: ignore -from pytket import Circuit from pytket.architecture import Architecture, FullyConnected +from pytket.circuit import Circuit from pytket.extensions.qiskit import ( AerBackend, AerStateBackend,