![]() |
Device object generated from a device specification proto.
cirq_google.devices.SerializableDevice(
qubits: List[cirq.Qid],
gate_definitions: Dict[Type[cirq.Gate], List[_GateDefinition]]
)
Given a device specification proto and a gate_set to translate the serialized gate_ids to cirq Gates, this will generate a Device that can verify operations and circuits for the hardware specified by the device.
Expected usage is through constructing this class through a proto using the static function call from_proto().
This class only supports GridQubits and NamedQubits. NamedQubits with names that conflict (such as "4_3") may be converted to GridQubits on deserialization.
Args | |
---|---|
qubits
|
A list of valid Qid for the device. |
gate_definitions
|
Maps cirq gates to device properties for that gate. |
Attributes | |
---|---|
metadata
|
Get metadata information for device. |
Methods
can_add_operation_into_moment
can_add_operation_into_moment(
operation: 'cirq.Operation', moment: 'cirq.Moment'
) -> bool
THIS FUNCTION IS DEPRECATED.
IT WILL BE REMOVED IN cirq v0.15
.
can_add_operation_into_moment will be removed in the future. Consider using device.validate_circuit instead.
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
decompose_operation(
operation: 'cirq.Operation'
) -> 'cirq.OP_TREE'
THIS FUNCTION IS DEPRECATED.
IT WILL BE REMOVED IN cirq v0.15
.
Devices will no longer decompose operations.
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.
duration_of
duration_of(
operation: cirq.Operation
) -> cirq.Duration
from_proto
@classmethod
from_proto( proto:
cirq_google.api.v2.device_pb2.DeviceSpecification
, gate_sets: Iterable[cirq_google.serialization.SerializableGateSet
] ) -> 'SerializableDevice'
Create a SerializableDevice
from a proto.
Args | |
---|---|
proto
|
A proto describing the qubits on the device, as well as the supported gates and timing information. |
gate_sets
|
SerializableGateSets that can translate the gate_ids into cirq Gates. |
Raises | |
---|---|
NotImplementedError
|
If the target ordering mixes SUBSET_PERMUTATION
and other types of ordering.
|
ValueError
|
If the serializable gate set does not have a serialized id that matches that in the device specification. |
qid_pairs
qid_pairs() -> FrozenSet['cirq.SymmetricalQidPair']
THIS FUNCTION IS DEPRECATED.
IT WILL BE REMOVED IN cirq v0.15
.
qubit coupling data can now be found in device.metadata if provided.
Returns a list of qubit edges on the device, defined by the gate definitions.
Returns:
The list of qubit edges on the device.
qubit_set
qubit_set() -> FrozenSet[cirq.Qid]
THIS FUNCTION IS DEPRECATED.
IT WILL BE REMOVED IN cirq v0.15
.
Please use metadata.qubit_set if applicable.
validate_circuit
validate_circuit(
circuit: 'cirq.AbstractCircuit'
) -> None
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
validate_moment(
moment: 'cirq.Moment'
) -> None
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
validate_operation(
operation: cirq.Operation
) -> None
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. |