cirq.optimizers.ConvertToCzAndSingleGates

Attempts to convert strange multi-qubit gates into CZ and single qubit

Inherits From: PointOptimizer

gates.

First, checks if the operation has a unitary effect. If so, and the gate is a 1-qubit or 2-qubit gate, then performs circuit synthesis of the operation.

Second, attempts to cirq.decompose to the operation.

Third, if ignore_failures is set, gives up and returns the gate unchanged. Otherwise raises a TypeError.

ignore_failures If set, gates that fail to convert are forwarded unchanged. If not set, conversion failures raise a TypeError.
allow_partial_czs If set, the decomposition is permitted to use gates of the form cirq.CZ**t, instead of only cirq.CZ.

Methods

optimization_at

View source

Describes how to change operations near the given location.

For example, this method could realize that the given operation is an X gate and that in the very next moment there is a Z gate. It would indicate that they should be combined into a Y gate by returning PointOptimizationSummary(clear_span=2, clear_qubits=op.qubits, new_operations=cirq.Y(op.qubits[0]))

Args
circuit The circuit to improve.
index The index of the moment with the operation to focus on.
op The operation to focus improvements upon.

Returns
A description of the optimization to perform, or else None if no change should be made.

optimize_circuit

View source

__call__

View source

Call self as a function.