QPU#

class iqm.qaoa.transpiler.quantum_hardware.QPU(hardware_graph, hardware_layout=None)[source]#

Bases: object

A parent class for all QPU architectures.

The main purpose of the QPU class is to store the hardware_graph and the shortest_path/s in there. The method draw() can be used independently to plot the graph (using the hardware_layout), but it’s meant to be used by the draw() method of the class Layer.

Parameters:
  • hardware_graph (nx.Graph) – A Graph representing the topology of the QPU, i.e., the connections between the HardQubits.

  • hardware_layout (dict[HardQubit, tuple[Any, Any]] | None) – A layout of the QPU, i.e., the coordinates of the qubits in the 2D plane.

Attributes

hardware_graph

The connectivity graph of the QPU.

hardware_layout

The layout of the hardware qubits (in the 2D plane).

qubits

The set of all HardQubits of the QPU.

shortest_path

The dictionary of dictionaries of shortest paths.

Methods

draw([mapping, ax, gate_lists, show])

A method for drawing the QPU.

has_edge(gate)

Is there an edge between the qubits involved in gate?

property qubits: set[HardQubit]#

The set of all HardQubits of the QPU.

has_edge(gate)[source]#

Is there an edge between the qubits involved in gate?

Parameters:

gate (HardEdge) – A HardEdge between two HardQubits.

Returns:

True if there is an edge between the two HardQubits on the QPU graph and False otherwise.

Return type:

bool

property hardware_graph: Graph#

The connectivity graph of the QPU.

property hardware_layout: dict[HardQubit, tuple[float, float]]#

The layout of the hardware qubits (in the 2D plane).

property shortest_path: dict[HardQubit, dict[HardQubit, list[HardQubit]]]#

The dictionary of dictionaries of shortest paths.

It’s defined so that shortest_path[source][target] is the list of nodes lying on the/a shortest path between the source and target nodes.

draw(mapping=None, ax=None, gate_lists=None, show=True, **kwargs)[source]#

A method for drawing the QPU.

It displays the picture of the QPU in a pop-up window, with edges colored based on gate_lists.

Parameters:
  • mapping (Mapping | None) – The mapping between the logical and hardware qubits, for labels of the graph nodes.

  • ax (Axes | None) – An instance of matplotlib.axes.Axes object, to define the plotting area.

  • gate_lists (dict[str, list[tuple[HardQubit]]] | None) – A dictionary whose keys are colors (as single-letter strings) and values are lists of edges which should be colored that color.

  • show (bool) – Boolean which decides if the graph will be shown in a pop-up window.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

None