cirq.ionq.IonQAPIDevice

A device that uses the gates exposed by the IonQ API.

Inherits From: Device

When using this device in constructing a circuit, it will convert one and two qubit gates that are not supported by the API into those supported by the API if they have a unitary matrix (support the unitary protocol).

Note that this device does not do any compression of the resulting circuit, i.e. it may result in a series of single qubit gates that could be executed using far fewer elements.

The gates supported by the API are

* <a href="../../cirq/ops/XPowGate"><code>cirq.XPowGate</code></a>, <a href="../../cirq/ops/YPowGate"><code>cirq.YPowGate</code></a>, <a href="../../cirq/ops/ZPowGate"><code>cirq.ZPowGate</code></a>
* <a href="../../cirq/ops/XXPowGate"><code>cirq.XXPowGate</code></a>, <a href="../../cirq/ops/YYPowGate"><code>cirq.YYPowGate</code></a>, <a href="../../cirq/ops/ZZPowGate"><code>cirq.ZZPowGate</code></a>
* <a href="../../cirq/ops/CNOT"><code>cirq.CNOT</code></a>, <a href="../../cirq/ops/H"><code>cirq.H</code></a>, <a href="../../cirq/ops/SWAP"><code>cirq.SWAP</code></a>
* <a href="../../cirq/ops/MeasurementGate"><code>cirq.MeasurementGate</code></a>

qubits The qubits upon which this device acts or the number of qubits. If the number of qubits, then the qubits will be cirq.LineQubits from 0 to this number minus one.
atol The absolute tolerance used for gate calculations and decompositions.

Methods

can_add_operation_into_moment

View source

Determines if it's possible to add an operation into a moment.

For example, on the XmonDevice two CZs shouldn't be placed in the same moment if they are on adjacent qubits.

Args
operation The operation being added.
moment The moment being transformed.

Returns
Whether or not the moment will validate after adding the operation.

decompose_operation

View source

Returns a device-valid decomposition for the given operation.

This method is used when adding operations into circuits with a device specified, to avoid spurious failures due to e.g. using a Hadamard gate that must be decomposed into native gates.

is_api_gate

View source

qubit_set

View source

Returns a set or frozenset of qubits on the device, if possible.

Returns
If the device has a finite set of qubits, then a set or frozen set of all qubits on the device is returned.

If the device has no well defined finite set of qubits (e.g. cirq.UnconstrainedDevice has this property), then None is returned.

validate_circuit

View source

Raises an exception if a circuit is not valid.

Args
circuit The circuit to validate.

Raises
ValueError The circuit isn't valid for this device.

validate_moment

View source

Raises an exception if a moment is not valid.

Args
moment The moment to validate.

Raises
ValueError The moment isn't valid for this device.

validate_operation

View source

Raises an exception if an operation is not valid.

Args
operation The operation to validate.

Raises
ValueError The operation isn't valid for this device.