stratified_circuit(circuit: cirq.Circuit, *, categories: Iterable[Union[cirq.Gate, cirq.Operation, Type[cirq.Gate], Type[cirq.Operation], Callable[cirq.Operation, bool]]]) → cirq.Circuit¶
Repacks avoiding simultaneous operations with different classes.Sometimes, certain operations should not be done at the same time. Forexample, the physical hardware may not be capable of doing certainoperations at the same time. Or it may have worse noise characteristicswhen certain operations are done at the same time. In these cases, itwould be good to rearrange the circuit so that these operations alwaysoccur in different moments.
(As a secondary effect, this may make the circuit easier to read.)This methods takes a series of classifiers identifying categories ofoperations and then ensures operations from each category only overlapwith operations from the same category. There is no guarantee that theresulting 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.