![]() |
A device whose properties are represented by an edge-labelled graph.
Inherits From: Device
cirq.contrib.graph_device.UndirectedGraphDevice(
device_graph: Optional[cirq.contrib.graph_device.UndirectedHypergraph
] = None,
crosstalk_graph: Optional[cirq.contrib.graph_device.UndirectedHypergraph
] = None
) -> None
Each (undirected) edge of the device graph is labelled by an UndirectedGraphDeviceEdge or None. None indicates that any operation is allowed and has zero duration.
Each (undirected) edge of the constraint graph is labelled either by a function or None. The function takes as arguments operations on the adjacent device edges and raises an error if they are not simultaneously executable. If None, no such operations are allowed.
Note that
* the crosstalk graph is allowed to have vertices (i.e. device edges)
that do not exist in the graph device.
* duration_of does not check that operation is valid.
Args | |
---|---|
device_graph
|
An undirected hypergraph whose vertices correspond to qubits and whose edges determine allowable operations and their durations. |
crosstalk_graph
|
An undirected hypergraph whose vertices are edges of device_graph and whose edges give simultaneity constraints thereon. |
Raises | |
---|---|
TypeError
|
If the crosstalk graph is not a valid crosstalk graph. |
Attributes | |
---|---|
edges
|
|
labelled_edges
|
|
metadata
|
Returns the associated Metadata with the device if applicable. |
qubits
|
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.ops.Operation
) -> cirq.value.Duration
get_device_edge_from_op
get_device_edge_from_op(
operation: cirq.ops.Operation
) -> cirq.contrib.graph_device.graph_device.UndirectedGraphDeviceEdge
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.nx_graph if provided.
qubit_set
qubit_set() -> FrozenSet['cirq.Qid']
THIS FUNCTION IS DEPRECATED.
IT WILL BE REMOVED IN cirq v0.15
.
Please use UndirectedGraphDevice.qubits
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_crosstalk
validate_crosstalk(
operation: cirq.ops.Operation
,
other_operations: Iterable[cirq.ops.Operation
]
) -> None
validate_moment
validate_moment(
moment: 'cirq.Moment'
)
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.ops.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. |
__add__
__add__(
other
)
__eq__
__eq__(
other
)
Return self==value.