Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/max n qubits predicate #94

Merged
merged 13 commits into from
Mar 28, 2023
2 changes: 2 additions & 0 deletions pytket/extensions/qiskit/backends/ibm.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
GateSetPredicate,
NoClassicalControlPredicate,
NoFastFeedforwardPredicate,
MaxNQubitsPredicate,
Predicate,
)
from pytket.extensions.qiskit.qiskit_convert import tk_to_qiskit, _tk_gate_set
Expand Down Expand Up @@ -323,6 +324,7 @@ def available_devices(cls, **kwargs: Any) -> List[BackendInfo]:
def required_predicates(self) -> List[Predicate]:
predicates = [
NoSymbolsPredicate(),
MaxNQubitsPredicate(self._backend_info.n_nodes),
GateSetPredicate(
self._backend_info.gate_set.union(
{
Expand Down
15 changes: 15 additions & 0 deletions tests/backend_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1198,3 +1198,18 @@ def test_sim_qubit_order() -> None:
circ.X(Qubit("a", 0))
s = backend.run_circuit(circ).get_state()
assert np.isclose(abs(s[2]), 1.0)


@pytest.mark.skipif(skip_remote_tests, reason=REASON)
def test_requrired_predicates(manila_emulator_backend: IBMQEmulatorBackend) -> None:
# https://github.com/CQCL/pytket-qiskit/issues/93
circ = Circuit(7) # 7 qubit circuit in IBMQ gateset
circ.X(0).CX(0, 1).CX(0, 2).CX(0, 3).CX(0, 4).CX(0, 5).CX(0, 6).measure_all()
with pytest.raises(CircuitNotValidError) as errorinfo:
manila_emulator_backend.run_circuit(circ, n_shots=100)
assert (
"pytket.backends.backend_exceptions.CircuitNotValidError:"
+ "Circuit with index 0 in submitted does"
+ "not satisfy MaxNQubitsPredicate(5)"
in str(errorinfo)
)