diff --git a/glue/cirq/stimcirq/_cirq_to_stim.py b/glue/cirq/stimcirq/_cirq_to_stim.py index 2cbb3fdf1..248dcd53d 100644 --- a/glue/cirq/stimcirq/_cirq_to_stim.py +++ b/glue/cirq/stimcirq/_cirq_to_stim.py @@ -409,7 +409,9 @@ def __init__(self): def process_circuit_operation_into_repeat_block(self, op: cirq.CircuitOperation) -> None: if self.flatten or op.repetitions == 1: - self.process_operations(cirq.decompose_once(op)) + moments = cirq.unroll_circuit_op(cirq.Circuit(op), deep=False, tags_to_check=None).moments + self.process_moments(moments) + self.out = self.out[:-1] # Remove a trailing TICK (to avoid double TICK) return child = CirqToStimHelper() diff --git a/glue/cirq/stimcirq/_cirq_to_stim_test.py b/glue/cirq/stimcirq/_cirq_to_stim_test.py index 21456dfae..65f3f1d2c 100644 --- a/glue/cirq/stimcirq/_cirq_to_stim_test.py +++ b/glue/cirq/stimcirq/_cirq_to_stim_test.py @@ -339,6 +339,31 @@ def test_on_loop(): result = stimcirq.StimSampler().run(c) assert result.measurements.keys() == {'0:a', '0:b', '1:a', '1:b', '2:a', '2:b'} + +def test_multi_moment_circuit_operation(): + q0 = cirq.LineQubit(0) + cc = cirq.Circuit( + cirq.CircuitOperation( + cirq.FrozenCircuit( + cirq.Moment(cirq.H(q0)), + cirq.Moment(cirq.H(q0)), + cirq.Moment(cirq.H(q0)), + cirq.Moment(cirq.H(q0)), + ) + ) + ) + assert stimcirq.cirq_circuit_to_stim_circuit(cc) == stim.Circuit(""" + H 0 + TICK + H 0 + TICK + H 0 + TICK + H 0 + TICK + """) + + def test_on_tagged_loop(): a, b = cirq.LineQubit.range(2) c = cirq.Circuit(