iqm.cirq_iqm.devices.iqm_device.IQMDevice#
- class iqm.cirq_iqm.devices.iqm_device.IQMDevice(metadata: IQMDeviceMetadata)#
Bases:
Device
ABC for the properties of a specific IQM quantum architecture.
Adds extra functionality on top of the basic
cirq.Device
class for decomposing gates, optimizing circuits and mapping qubits.- Parameters:
metadata (IQMDeviceMetadata) – device metadata which contains the qubits, their connectivity, and the native gateset
Attributes
Returns metadata for the device.
Methods
__eq__
(other)Return self==value.
check_qubit_connectivity
(operation)Raises a ValueError if operation acts on qubits that are not connected.
decompose_circuit
(circuit)Decomposes the given circuit to the native gate set of the device.
decompose_operation
(operation)Decompose a single quantum operation into the native operation set.
get_qubit
(index)The device qubit corresponding to the given numeric index.
get_qubit_index
(qubit)The numeric index of the given qubit on the device.
Predicate, True iff the given operation is native and its targets are valid.
Predicate, True iff the given operation is considered native for the architecture.
Decomposes operations into the native operation set.
route_circuit
(circuit, *[, initial_mapper, ...])Routes the given circuit to the device connectivity and qubit names.
validate_circuit
(circuit)Raises an exception if a circuit is not valid.
validate_move
(operation)Validates whether the IQMMoveGate is between qubit and resonator registers.
validate_moves
(circuit)Validates whether the IQMMoveGates are correctly applied in the circuit.
validate_operation
(operation)Raises an exception if an operation is not valid.
- property metadata: IQMDeviceMetadata#
Returns metadata for the device.
- classmethod get_qubit_index(qubit: NamedQubit) int #
The numeric index of the given qubit on the device.
- Parameters:
qubit (NamedQubit) –
- Return type:
- get_qubit(index: int) Qid #
The device qubit corresponding to the given numeric index.
- Parameters:
index (int) –
- Return type:
Qid
- check_qubit_connectivity(operation: Operation) None #
Raises a ValueError if operation acts on qubits that are not connected.
- Parameters:
operation (Operation) –
- Return type:
None
- is_native_operation(op: Operation) bool #
Predicate, True iff the given operation is considered native for the architecture.
- Parameters:
op (Operation) –
- Return type:
- has_valid_operation_targets(op: Operation) bool #
Predicate, True iff the given operation is native and its targets are valid.
- Parameters:
op (Operation) –
- Return type:
- operation_decomposer(op: Operation) list[Operation] | None #
Decomposes operations into the native operation set.
All the decompositions below keep track of global phase (required for decomposing controlled gates).
- Parameters:
op (Operation) – operation to decompose
- Returns:
decomposition, or None to pass
op
to the Cirq native decomposition machinery instead- Return type:
list[Operation] | None
- decompose_operation(operation: Operation) Operation | OpTree #
Decompose a single quantum operation into the native operation set.
- Parameters:
operation (Operation) –
- Return type:
Operation | OpTree
- route_circuit(circuit: Circuit, *, initial_mapper: AbstractInitialMapper | None = None, qubit_subset: Sequence[Qid] | None = None) tuple[Circuit, dict[Qid, Qid], dict[Qid, Qid]] #
Routes the given circuit to the device connectivity and qubit names.
The routed circuit uses the device qubits, and may have additional SWAP gates inserted to perform the qubit routing. The transformer
cirq.RouterCQC
is used for routing. Note that only gates of one or two qubits, and measurement operations of arbitrary size are supported.Adds the attribute
iqm_calibration_set_id
to the routed circuit, with value taken fromself.metadata.architecture.calibration_set_id
if available, otherwise None.- Parameters:
circuit (Circuit) – Circuit to route.
initial_mapper (AbstractInitialMapper | None) – Initial mapping from
circuit
qubits to device qubits, to serve as the starting point of the routing.None
means it will be generated automatically.qubit_subset (Sequence[Qid] | None) – Restrict the routing to this subset of the device qubits. If
None
, use the entire device.
- Returns:
routed circuit, initial mapping before inserting SWAP gates (see
cirq.RouterCQC.route_circuit()
), final mapping from physical qubits to physical qubits (seecirq.RouterCQC.route_circuit()
)- Raises:
ValueError – routing is impossible
- Return type:
- decompose_circuit(circuit: Circuit) Circuit #
Decomposes the given circuit to the native gate set of the device.
Adds the attribute
iqm_calibration_set_id
to the decomposed circuit, with value taken fromself.metadata.architecture.calibration_set_id
if available, otherwise None.- Parameters:
circuit (Circuit) – circuit to decompose
- Returns:
decomposed circuit
- Return type:
Circuit
- validate_circuit(circuit: AbstractCircuit) None #
Raises an exception if a circuit is not valid.
- Parameters:
circuit (AbstractCircuit) – The circuit to validate.
- Raises:
ValueError – The circuit isn’t valid for this device.
- Return type:
None
- validate_operation(operation: Operation) None #
Raises an exception if an operation is not valid.
- Parameters:
operation (Operation) – The operation to validate.
- Raises:
ValueError – The operation isn’t valid for this device.
- Return type:
None
- validate_move(operation: Operation) None #
Validates whether the IQMMoveGate is between qubit and resonator registers.
- Parameters:
operation (cirq.Operation) – Operation to check
- Raises:
ValueError – In case the the first argument of the IQMMoveGate is not a qubit, or if the second argument is not a resonator on this device.
- Returns:
None when the IQMMoveGate is used correctly.
- Return type:
None
- validate_moves(circuit: AbstractCircuit) None #
Validates whether the IQMMoveGates are correctly applied in the circuit.
- Parameters:
circuit (cirq.AbstractCircuit) – The circuit to validate.
- Raises:
ValueError – If the IQMMoveGate is applied incorrectly.
- Returns:
None if the IQMMoveGates are applied correctly.
- Return type:
None