Skip to content

Commit ce6dc20

Browse files
authored
Merge pull request #1549 from carlos-luque/fixsubgraph
Minor fix to qibo.transpiler.placer.Subgraph
2 parents b8266f4 + 9bb2c2b commit ce6dc20

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/qibo/transpiler/placer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def __call__(self, circuit: Circuit):
126126
"""
127127
assert_placement(circuit, self.connectivity)
128128
gates_qubits_pairs = _find_gates_qubits_pairs(circuit)
129-
if len(gates_qubits_pairs) < 3:
129+
if len(gates_qubits_pairs) < 2:
130130
raise_error(
131131
ValueError,
132132
"Circuit must contain at least two two-qubit gates "

tests/test_transpiler_placer.py

+10
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ def test_subgraph_restricted(star_connectivity):
9393
assert_placement(circuit, restricted_connectivity)
9494

9595

96+
def test_subgraph_leasttwoqubitgates(star_connectivity):
97+
circuit = Circuit(5)
98+
circuit.add(gates.CNOT(0, 3))
99+
circuit.add(gates.CNOT(1, 2))
100+
connectivity = star_connectivity()
101+
placer = Subgraph(connectivity=connectivity)
102+
placer(circuit)
103+
assert_placement(circuit, connectivity)
104+
105+
96106
@pytest.mark.parametrize("reps", [1, 10, 100])
97107
@pytest.mark.parametrize("names", [["A", "B", "C", "D", "E"], [0, 1, 2, 3, 4]])
98108
def test_random(reps, names, star_connectivity):

0 commit comments

Comments
 (0)