Skip to content

Commit e14b7ac

Browse files
Allow parallelize to have nonunitary gate operations for measurement and error gates.
1 parent 2173906 commit e14b7ac

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/bloqade/cirq_utils/parallelize.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ def auto_similarity(
119119
flattened_circuit: list[GateOperation] = list(cirq.flatten_op_tree(circuit))
120120
weights = {}
121121
for i in range(len(flattened_circuit)):
122+
if not cirq.has_unitary(flattened_circuit[i]):
123+
continue
122124
for j in range(i + 1, len(flattened_circuit)):
125+
if not cirq.has_unitary(flattened_circuit[j]):
126+
continue
123127
op1 = flattened_circuit[i]
124128
op2 = flattened_circuit[j]
125129
if can_be_parallel(op1, op2):
@@ -297,14 +301,20 @@ def colorize(
297301
for epoch in epochs:
298302
oneq_gates = []
299303
twoq_gates = []
304+
nonunitary_gates = []
300305
for gate in epoch:
301-
if len(gate.val.qubits) == 1:
306+
if not cirq.has_unitary(gate.val):
307+
nonunitary_gates.append(gate.val)
308+
elif len(gate.val.qubits) == 1:
302309
oneq_gates.append(gate.val)
303310
elif len(gate.val.qubits) == 2:
304311
twoq_gates.append(gate.val)
305312
else:
306313
raise RuntimeError("Unsupported gate type")
307314

315+
if len(nonunitary_gates) > 0:
316+
yield nonunitary_gates
317+
308318
if len(oneq_gates) > 0:
309319
yield oneq_gates
310320

0 commit comments

Comments
 (0)