Target gateset accepting CZ + single qubit rotations + measurement gates.

Inherits From: TwoQubitCompilationTargetGateset, CompilationTargetGateset, Gateset

Used in the notebooks

Used in the tutorials

By default, cirq.CZTargetGateset will accept and compile unknown gates to the following universal target gateset:

Optionally, users can also specify additional gates / gate families which should be accepted by this gateset via the additional_gates argument.

When compiling a circuit, any unknown gate, i.e. a gate which is not accepted by this gateset, will be compiled to the default gateset (i.e. cirq.CZ/cirq.CZPowGate, cirq.PhasedXZGate, cirq.MeasurementGate).

atol A limit on the amount of absolute error introduced by the decomposition.
allow_partial_czs If set, all powers of the form cirq.CZ**t, and not just cirq.CZ, are part of this gateset.
additional_gates Sequence of additional gates / gate families which should also be "accepted" by this gateset. This is empty by default.
preserve_moment_structure Whether to preserve the moment structure of the circuit during compilation or not.



num_qubits Maximum number of qubits on which a gate from this gateset can act upon.
postprocess_transformers List of transformers which should be run after decomposing individual operations.
preprocess_transformers List of transformers which should be run before decomposing individual operations.



View source

Method to rewrite the given operation using gates from this gateset.

op cirq.Operation to be rewritten using gates from this gateset.
moment_idx Moment index where the given operation op occurs in a circuit.


  • An equivalent cirq.OP_TREE implementing op using gates from this gateset.
  • None or NotImplemented if does not know how to decompose op.


View source

Validates gates forming circuit_or_optree should be contained in Gateset.

circuit_or_optree The cirq.Circuit or cirq.OP_TREE to validate.


View source

Returns a copy of this Gateset with identical gates and new values for named arguments.

If a named argument is None then corresponding value of this Gateset is used instead.

name New name for the Gateset.
unroll_circuit_op If True, new Gateset will recursively validate cirq.CircuitOperation by validating the underlying cirq.Circuit.

self if all new values are None or identical to the values of current Gateset. else a new Gateset with identical gates and new values for named arguments.


View source

Check for containment of a given Gate/Operation in this Gateset.

Containment checks are handled as follows:

The complexity of the method in terms of the number of gates, n, is

  • O(1) when any default cirq.GateFamily instance accepts the given item, except for an Instance GateFamily trying to match an item with a different global phase.
  • O(n) for all other cases: matching against custom gate families, matching across global phase for the default Instance GateFamily, no match against any underlying gate family.

item The cirq.Gate or cirq.Operation instance to check containment for.


View source


View source