View source on GitHub |
cirq.CZTargetGateset
implementation tailored to Google devices.
cirq_google.transformers.GoogleCZTargetGateset(
atol: float = 1e-08,
eject_paulis: bool = False,
additional_gates: Sequence[Union[Type[cirq.Gate], cirq.Gate, cirq.GateFamily]] = ()
)
In addition to features available from cirq.CZTargetGateset
, GoogleCZTargetGateset
contains
a flag, eject_paulis
, to enable the postprocess transformers cirq.eject_phased_paulis
and
cirq.eject_z
, which will push X, Y, Z, PhasedX, and certain PhasedXZ gates to the end of the
circuit.
Args | |
---|---|
atol
|
A limit on the amount of absolute error introduced by the transformation. |
eject_paulis
|
Whether to enable postprocess transformers cirq.eject_z and
cirq.eject_phased_paulis . If enabled, these transformers will remove tags (e.g.
cirq_google.PhysicalZTag ) from single-qubit Pauli operations. Defaults to False.
|
additional_gates
|
Sequence of additional gates / gate families which should also be "accepted" by this gateset. This is empty by default. |
Attributes | |
---|---|
gates
|
|
name
|
|
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.
If |
preprocess_transformers
|
List of transformers which should be run before decomposing individual operations. |
Methods
decompose_to_target_gateset
decompose_to_target_gateset(
op: 'cirq.Operation', moment_idx: int
) -> cirq_google.transformers.target_gatesets.sycamore_gateset.DecomposeResult
Method to rewrite the given operation using gates from this gateset.
Args | |
---|---|
op
|
cirq.Operation to be rewritten using gates from this gateset.
|
moment_idx
|
Moment index where the given operation op occurs in a circuit.
|
Returns | |
---|---|
|
validate
validate(
circuit_or_optree: Union['cirq.AbstractCircuit', op_tree.OP_TREE]
) -> bool
Validates gates forming circuit_or_optree
should be contained in Gateset.
Args | |
---|---|
circuit_or_optree
|
The cirq.Circuit or cirq.OP_TREE to validate.
|
with_params
with_params(
*, name: Optional[str] = None, unroll_circuit_op: Optional[bool] = None
) -> 'Gateset'
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.
Args | |
---|---|
name
|
New name for the Gateset. |
unroll_circuit_op
|
If True, new Gateset will recursively validate
cirq.CircuitOperation by validating the underlying cirq.Circuit .
|
Returns | |
---|---|
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.
|
__contains__
__contains__(
item: Union[raw_types.Gate, raw_types.Operation]
) -> bool
Check for containment of a given Gate/Operation in this Gateset.
Containment checks are handled as follows:
- For Gates or Operations that have an underlying gate (i.e. op.gate is not None):
- Forwards the containment check to the underlying
cirq.GateFamily
objects. - Examples of such operations include
cirq.GateOperation
s and their controlled and tagged variants (i.e. instances ofcirq.TaggedOperation
,cirq.ControlledOperation
whereop.gate
is not None) etc.
- Forwards the containment check to the underlying
- For Operations that do not have an underlying gate:
- Forwards the containment check to
self._validate_operation(item)
. - Examples of such operations include
cirq.CircuitOperation
s and their controlled and tagged variants (i.e. instances ofcirq.TaggedOperation
,cirq.ControlledOperation
whereop.gate
is None) etc.
- Forwards the containment check to
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.
Args | |
---|---|
item
|
The cirq.Gate or cirq.Operation instance to check containment for.
|
__eq__
__eq__(
other: _SupportsValueEquality
) -> bool
__ne__
__ne__(
other: _SupportsValueEquality
) -> bool