cirq_ionq.ionq_native_target_gateset.IonqNativeGatesetBase

Abstract base class to create two-qubit target gatesets.

This base class can be used to create two-qubit compilation target gatesets. It automatically implements the logic to

1. Apply `self.preprocess_transformers` to the input circuit, which by default will:
    a) Expand composite gates acting on > 2 qubits using <a href="https://quantumai.google/reference/python/cirq/expand_composite"><code>cirq.expand_composite</code></a>.
    b) Merge connected components of 1 & 2 qubit unitaries into tagged
        <a href="https://quantumai.google/reference/python/cirq/CircuitOperation"><code>cirq.CircuitOperation</code></a> using <a href="https://quantumai.google/reference/python/cirq/merge_k_qubit_unitaries"><code>cirq.merge_k_qubit_unitaries</code></a>.

2. Apply `self.decompose_to_target_gateset` to rewrite each operation (including merged
connected components from 1b) using gates from this gateset.
    a) Uses `self._decompose_single_qubit_operation`, `self._decompose_two_qubit_operation`
       and `self._decompose_multi_qubit_operation` to figure out how to rewrite (merged
       connected components of) operations using only gates from this gateset.
    b) A merged connected component containing only 1 & 2q gates from this gateset is
       replaced with a more efficient rewrite using `self._decompose_two_qubit_operation`
       iff the rewritten op-tree is lesser number of 2q interactions.

    Replace connected components with inefficient implementations (higher number of 2q
       interactions) with efficient rewrites to minimize total number of 2q interactions.

3. Apply `self.postprocess_transformers` to the transformed circuit, which by default will:
    a) Apply <a href="https://quantumai.google/reference/python/cirq/merge_single_qubit_moments_to_phxz"><code>cirq.merge_single_qubit_moments_to_phxz</code></a> to preserve moment structure (eg:
       alternating layers of single/two qubit gates).
    b) Apply <a href="https://quantumai.google/reference/python/cirq/drop_negligible_operations"><code>cirq.drop_negligible_operations</code></a> and <a href="https://quantumai.google/reference/python/cirq/drop_empty_moments"><code>cirq.drop_empty_moments</code></a> to minimize
       circuit depth.

Derived classes should simply implement self._decompose_two_qubit_operation abstract method and provide analytical decomposition of any 2q unitary using gates from the target gateset.

*gates A list of cirq.Gate subclasses / cirq.Gate instances / cirq.GateFamily instances.
atol A limit on the amount of absolute error introduced by the decomposition.

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.
preprocess_transformers List of transformers which should be run before decomposing individual operations.

Decompose to three qubit gates because three qubit gates have different decomposition for all-to-all connectivity between qubits.

Methods

decompose_all_to_all_connect_ccz_gate

View source

Decomposition of all-to-all connected qubits are different from line qubits or grid qubits, ckeckout IonQTargetGateset.

For example, for qubits in the same ion trap, the decomposition of CCZ gate will be:

0: ──────────────@──────────────────@───@───p──────@─── │ │ │ │ 1: ───@──────────┼───────@───p──────┼───X───p^-1───X─── │ │ │ │ 2: ───X───p^-1───X───p───X───p^-1───X───p──────────────

where p = T**ccz_gate._exponent

decompose_to_target_gateset

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

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

single_qubit_matrix_to_native_gates

View source

validate

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

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__

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.

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

__eq__

__ne__