cirq.stratified_circuit(circuit: cirq.Circuit, *, categories: Iterable[Union[cirq.Gate, cirq.Operation, Type[cirq.Gate], Type[cirq.Operation], Callable[cirq.Operation, bool]]])cirq.Circuit[source]

Repacks avoiding simultaneous operations with different classes.

Sometimes, certain operations should not be done at the same time. For
example, the physical hardware may not be capable of doing certain
operations at the same time. Or it may have worse noise characteristics
when certain operations are done at the same time. In these cases, it
would be good to rearrange the circuit so that these operations always
occur in different moments.

(As a secondary effect, this may make the circuit easier to read.)

This methods takes a series of classifiers identifying categories of
operations and then ensures operations from each category only overlap
with operations from the same category. There is no guarantee that the
resulting circuit will be optimally packed under this constraint.
  • circuit – The circuit whose operations should be re-arranged.

  • categories – A list of classifiers picking out certain operations. There are several ways to specify a classifier. You can pass in a gate instance (e.g. cirq.X), a gate type (e.g. cirq.XPowGate), an operation instance (e.g. cirq.X(cirq.LineQubit(0))), an operation type (e.g. cirq.GlobalPhaseOperation), or an arbitrary operation predicate (e.g. lambda op: len(op.qubits) == 2).


A copy of the original circuit, but with re-arranged operations.