Skip to content

Commit

Permalink
Melf/fix max n qubits (#434)
Browse files Browse the repository at this point in the history
* fix max qubit predicate

* update changelog and version

* add test

* Update docs/changelog.md

Co-authored-by: Callum Macpherson <[email protected]>

* fix mypy

---------

Co-authored-by: Callum Macpherson <[email protected]>
  • Loading branch information
cqc-melf and CalMacCQ authored Dec 13, 2024
1 parent 46bdddf commit d0cee1c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion _metadata.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__extension_version__ = "0.61.0"
__extension_version__ = "0.62.0"
__extension_name__ = "pytket-qiskit"
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pytket/extensions/qiskit/backends/aer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
ConnectivityPredicate,
DefaultRegisterPredicate,
GateSetPredicate,
MaxNQubitsPredicate,
NoBarriersPredicate,
NoClassicalControlPredicate,
NoFastFeedforwardPredicate,
Expand Down Expand Up @@ -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(
Expand Down
10 changes: 10 additions & 0 deletions tests/qiskit_backend_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit d0cee1c

Please sign in to comment.