Skip to content

Transformers (eg: optimized_for_sycamore) unroll circuit operations by default.  #5039

@95-martin-orion

Description

@95-martin-orion

Description of the issue

Calling cirq.optimized_for_sycamore on a circuit with a CircuitOperation is expected to optimize only the contents of the CircuitOperation while preserving the structure, but the circuit is instead flattened.

How to reproduce the issue

import cirq_google

q0, q1 = cirq.LineQubit.range(2)
cop = cirq.CircuitOperation(
    cirq.FrozenCircuit(
      cirq.H(q0),
      cirq.CX(q0, q1),
      cirq.measure(q0, key='r1a'),
      cirq.measure(q1, key='r1b'),
    )
)
circuit = cirq.Circuit(cop.repeat(3))
syc_circuit = cirq_google.optimized_for_sycamore(circuit)
# circuitops have been flattened
print(syc_circuit)

Cirq version
0.14.0.dev20220228000741

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions