Skip to content

Commit 49221a0

Browse files
authored
Lower cirq.ResetChannel to squin (#637)
This might have been lost during the refactor in v0.8. Or, it was always missing and only noticed in #583. FYI, @tcochran-quera.
1 parent 5b853b7 commit 49221a0

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/bloqade/cirq_utils/lowering.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,6 @@ def generic_visit(self, state: lowering.State[cirq.Circuit], node: CirqNode):
282282
)
283283
raise lowering.BuildError(f"Cannot lower {node}")
284284

285-
# return self.visit_Operation(state, node)
286-
287285
def lower_literal(self, state: lowering.State[cirq.Circuit], value) -> ir.SSAValue:
288286
raise lowering.BuildError("Literals not supported in cirq circuit")
289287

@@ -658,3 +656,10 @@ def visit_AsymmetricDepolarizingChannel(
658656
probabilities, controls=control_qarg, targets=target_qarg
659657
)
660658
)
659+
660+
def visit_ResetChannel(
661+
self, state: lowering.State[cirq.Circuit], node: cirq.ResetChannel
662+
):
663+
qubits = self.lower_qubit_getindices(state, node.qubits)
664+
stmt = qubit.stmts.Reset(qubits)
665+
return state.current_frame.push(stmt)

test/cirq_utils/test_cirq_to_squin.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ def phased_gates():
6464
)
6565

6666

67+
def reset_circuit():
68+
q = cirq.LineQubit.range(2)
69+
return cirq.Circuit(
70+
cirq.reset(q[0]), cirq.ResetChannel().on_each(*q), cirq.measure(*q)
71+
)
72+
73+
6774
def pow_gate_circuit():
6875
q0 = cirq.LineQubit(0)
6976
q1 = cirq.LineQubit(1)
@@ -188,6 +195,7 @@ def nested_circuit():
188195
nested_circuit,
189196
bit_flip,
190197
depolarizing_channels,
198+
reset_circuit,
191199
],
192200
)
193201
def test_circuit(circuit_f, run_sim: bool = False):

0 commit comments

Comments
 (0)