IQMDevice#

Module: iqm.cirq_iqm.devices.iqm_device

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

metadata

Returns metadata for the device.

Methods

check_qubit_connectivity

Raises a ValueError if operation acts on qubits that are not connected.

decompose_circuit

Decomposes the given circuit to the native gate set of the device.

decompose_operation

Decompose a single quantum operation into the native operation set.

get_qubit

The device qubit corresponding to the given numeric index.

get_qubit_index

The numeric index of the given qubit on the device.

has_valid_operation_targets

Predicate, True iff the given operation is native and its targets are valid.

is_native_operation

Predicate, True iff the given operation is considered native for the architecture.

operation_decomposer

Decomposes operations into the native operation set.

route_circuit

Routes the given circuit to the device connectivity and qubit names.

validate_circuit

Raise an error if circuit is not compatible with this device.

validate_move

Validate whether the IQMMoveGate is between qubit and resonator registers.

validate_moves

Validate whether the IQMMoveGates are correctly applied in the circuit.

validate_operation

Raise an error if operation is not supported on this device.

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:

int

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:

bool

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:

bool

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: cirq.Operation) cirq.OP_TREE#

Decompose a single quantum operation into the native operation set.

Parameters:

operation (cirq.Operation)

Return type:

cirq.OP_TREE

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 from self.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 (see cirq.RouterCQC.route_circuit())

Raises:

ValueError – routing is impossible

Return type:

tuple[Circuit, dict[Qid, Qid], dict[Qid, Qid]]

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 from self.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#

Raise an error if circuit is not compatible with this device.

Parameters:

circuit (AbstractCircuit)

Return type:

None

validate_operation(operation: Operation) None#

Raise an error if operation is not supported on this device.

Parameters:

operation (Operation)

Return type:

None

validate_move(operation: Operation) None#

Validate 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#

Validate 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

Inheritance

Inheritance diagram of iqm.cirq_iqm.devices.iqm_device.IQMDevice