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..c2f060de 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -4,6 +4,10 @@ # Changelog +## unreleased + +- AerBackend now reject circuits with too many qubits + ## 0.61.0 (December 2024) - Restrict qiskit version to ~= 1.2.4, to avoid breaking changes in 1.3.0 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( diff --git a/tests/qiskit_backend_test.py b/tests/qiskit_backend_test.py index 0fe745e3..0dc65a3c 100644 --- a/tests/qiskit_backend_test.py +++ b/tests/qiskit_backend_test.py @@ -22,6 +22,7 @@ from qiskit_aer import Aer # type: ignore from pytket.architecture import Architecture, FullyConnected +from pytket.circuit import Circuit from pytket.extensions.qiskit import ( AerBackend, AerStateBackend, @@ -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()