Transforms the given circuit into an equivalent circuit using gates accepted by gateset.

Used in the notebooks

Used in the tutorials

Repeat max_num_passes times or when max_num_passes=None until no further changes can be done

  1. Run all gateset.preprocess_transformers
  2. Convert operations using built-in cirq decompose + gateset.decompose_to_target_gateset.
  3. Run all gateset.postprocess_transformers

The optimizer is a heuristic and may not produce optimal results even with max_num_passes=None. The preprocessors and postprocessors of the gate set as well as their order yield different results.

circuit Input circuit to transform. It will not be modified.
context cirq.TransformerContext storing common configurable options for transformers.
gateset Target gateset, which should be an instance of cirq.CompilationTargetGateset.
ignore_failures If set, operations that fail to convert are left unchanged. If not set, conversion failures raise a ValueError.
max_num_passes The maximum number of passes to do. A value of None means to keep iterating until no more changes happen to the number of moments or operations.

An equivalent circuit containing gates accepted by gateset.

ValueError If any input operation fails to convert and ignore_failures is False.