LineMappingPTN#

Module: iqm.qaoa.transpiler.ptn.ptn

class iqm.qaoa.transpiler.ptn.ptn.LineMappingPTN(*args, **kwargs)[source]#

Bases: BaseMapping

The mapping class for line PTN routing algorithm.

The mapping instance for line PTN routing has the responsibility to keep track of two important attributes: hard2line and line_of_parities. The former keeps track of mapping hardware qubits on the QPU into LineQubits of the PTN. The latter keeps track what parity is mapped onto which LineQubit.

Parameters:
  • qpu (QPU) – The QPU onto which we do the routing.

  • problem_bqm (BinaryQuadraticModel) – The BQM of the problem, only necessary to extract variable names.

  • line_of_hw_qubits (list[HardQubit] | None) – A chain of HW qubits on the qpu. If not provided, it is found with a greedy algorithm.

Raises:
  • ValueError – If the provided line_of_hw_qubits contains duplicates.

  • ValueError – If the provided line_of_hw_qubits is too short.

  • ValueError – If the provided line_of_hw_qubits is not a chain on the QPU (i.e., two consecutive HW qubits are not connected on the QPU).

Warning

UserWarning: If the provided line_of_hw_qubits is longer than the number of problem variables. In that case

it is truncated.

Attributes

hard2line

The mapping from hardware qubits to line qubits in the PTN circuit.

line_of_parities

The line of parity information carried by the qubits of the PTN circuit.

Methods

cnot

Applies the CNOT gate to the mapping at line qubits qb0 and qb1.

dcnot

Applies the DCNOT gate to the mapping at line qubits qb0 and qb1.

update

Update the mapping from the input layer.

property hard2line: dict[HardQubit, int | None]#

The mapping from hardware qubits to line qubits in the PTN circuit.

property line_of_parities: list[set[int]]#

The line of parity information carried by the qubits of the PTN circuit.

update(layer)[source]#

Update the mapping from the input layer.

Goes through the layer and applies each DCNOT therein. The layer represents a Parity Twine Chain, i.e., one chain of DCNOTs going through the line qubits.

Parameters:

layer (list[tuple[int, int]]) – The layer to be applied to the mapping, referred to as PTC (Parity Twine Chain).

Return type:

None

cnot(qb0, qb1)[source]#

Applies the CNOT gate to the mapping at line qubits qb0 and qb1.

The gate acts on qb1, controlled by qb0. This modifies self._line_of_parities in-place.

Parameters:
Return type:

None

dcnot(qb0, qb1)[source]#

Applies the DCNOT gate to the mapping at line qubits qb0 and qb1.

A DCNOT gate is made up of two CNOT gates. Note that the first CNOT gate acts on qb0, controlled by qb1. The second CNOT gate acts on qb1, controlled by qb0.

Parameters:
  • qb0 (int) – The first LineQubit on which the DCNOT gate acts.

  • qb1 (int) – The second LineQubit on which the DCNOT gate acts.

Return type:

None

Inheritance

Inheritance diagram of iqm.qaoa.transpiler.ptn.ptn.LineMappingPTN