Skip to content

Commit

Permalink
FIX: #1546 class Subgraph, minimum two-qubit gates
Browse files Browse the repository at this point in the history
 The if statement that checks the number of two-qubit gates in the circuit
  • Loading branch information
carlos-luque committed Dec 18, 2024
1 parent 3713524 commit 866b969
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/qibo/transpiler/placer.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def __call__(self, circuit: Circuit):
"""
assert_placement(circuit, self.connectivity)
gates_qubits_pairs = _find_gates_qubits_pairs(circuit)
if len(gates_qubits_pairs) < 3:
if len(gates_qubits_pairs) < 2:
raise_error(
ValueError,
"Circuit must contain at least two two-qubit gates "
Expand Down
10 changes: 10 additions & 0 deletions tests/test_transpiler_placer.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ def test_subgraph_restricted(star_connectivity):
assert_placement(circuit, restricted_connectivity)


def test_subgraph_leasttwoqubitgates(star_connectivity):
circuit = Circuit(5)
circuit.add(gates.CNOT(0, 3))
circuit.add(gates.CNOT(1, 2))
connectivity = star_connectivity()
placer = Subgraph(connectivity=connectivity)
placer(circuit)
assert_placement(circuit, connectivity)


@pytest.mark.parametrize("reps", [1, 10, 100])
@pytest.mark.parametrize("names", [["A", "B", "C", "D", "E"], [0, 1, 2, 3, 4]])
def test_random(reps, names, star_connectivity):
Expand Down

0 comments on commit 866b969

Please sign in to comment.