Skip to content

Commit

Permalink
Fix qibotf tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stavros11 committed Apr 21, 2022
1 parent 1735fa3 commit b6ebbad
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/qibo/tests/test_core_fusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ def test_fuse_circuit_three_qubit_gate(backend, max_qubits):
c.add(gates.CNOT(0, 1))
c.add(gates.CZ(2, 3))
fused_c = c.fuse(max_qubits=max_qubits)
K.assert_allclose(fused_c(), c(), atol=1e-12)
if K.name == "qibotf" and max_qubits > 2:
# qibotf does not support multi-qubit kernel
with pytest.raises(NotImplementedError):
_ = fused_c()
else:
K.assert_allclose(fused_c(), c(), atol=1e-12)


@pytest.mark.parametrize("nqubits", [4, 5, 10, 11])
Expand All @@ -96,7 +101,10 @@ def test_variational_layer_fusion(backend, nqubits, nlayers, max_qubits):
c.add(gates.CZ(0, nqubits - 1))

fused_c = c.fuse(max_qubits=max_qubits)
K.assert_allclose(fused_c(), c())
if K.name == "qibotf" and max_qubits > 2:
pytest.skip("qibotf does not support multi-qubit kernel")
else:
K.assert_allclose(fused_c(), c())


@pytest.mark.parametrize("nqubits", [4, 5])
Expand All @@ -118,7 +126,10 @@ def test_random_circuit_fusion(backend, nqubits, ngates, max_qubits):
q0, q1 = np.random.randint(0, nqubits, (2,))
c.add(gate(q0, q1))
fused_c = c.fuse(max_qubits=max_qubits)
K.assert_allclose(fused_c(), c(), atol=1e-7)
if K.name == "qibotf" and max_qubits > 2:
pytest.skip("qibotf does not support multi-qubit kernel")
else:
K.assert_allclose(fused_c(), c(), atol=1e-7)


def test_controlled_by_gates_fusion(backend):
Expand Down

0 comments on commit b6ebbad

Please sign in to comment.