|View source on GitHub|
Device object representing Google devices with a grid qubit layout.
cirq_google.devices.GridDevice( metadata: cirq.GridDeviceMetadata )
For end users, instances of this class are typically accessed via
This class is compliant with the core
cirq.Device abstraction. In particular:
* Device information is captured in the `metadata` property. * An instance of `GridDevice` can be used to validate circuits, moments, and operations.
Example use cases
Get an instance of a Google grid device.
Print the grid layout of the device.
Determine whether a circuit can be run on the device.
Determine whether an operation can be run on the device.
Determine whether a gate is available on the device.
Notes about CompilationTargetGatesets:
- If a device contains gates which yield multiple compilation target gatesets, the user can only choose one target gateset to compile to. For example, a device may contain both SYC and SQRT_ISWAP gates which yield two separate target gatesets, but a circuit can only be compiled to either SYC or SQRT_ISWAP for its two-qubit gates, not both.
- For a given compilation target gateset, gates which are part of the device's gateset but not the target gateset are not decomposed. However, they may still be merged with other gates in the circuit.
- A circuit which contains
cirq.WaitGates will be dropped if it is transformed using CompilationTargetGatesets generated by GridDevice. To better control circuit timing, insert WaitGates after the circuit has been transformed.
Notes for cirq_google internal implementation:
For Google devices, the
is the main specification for device information surfaced by the Quantum Computing Service.
Thus, this class is should be instantiated using a
DeviceSpecification proto via the
from_proto() class method.
||Get metadata information for the device.|
cirq_google.api.v2.device_pb2.DeviceSpecification) -> 'GridDevice'
GridDevice from a
If the given
validate_circuit( circuit: 'cirq.AbstractCircuit' ) -> None
Raises an exception if a circuit is not valid.
||The circuit to validate.|
||The circuit isn't valid for this device.|
validate_moment( moment: 'cirq.Moment' ) -> None
Raises an exception if a moment is not valid.
||The moment to validate.|
||The moment isn't valid for this device.|
validate_operation( operation: cirq.Operation ) -> None
Raises an exception if an operation is not valid.
An operation is valid if
* The operation is in the device gateset. * The operation targets a valid qubit * The operation targets a valid qubit pair, if it is a two-qubit operation.
||The operation to validate.|
||The operation isn't valid for this device.|
__eq__( other: _SupportsValueEquality ) -> bool
__ne__( other: _SupportsValueEquality ) -> bool