paddle_quantum.ansatz.layer

The source file of the class for quantum circuit templates.

class paddle_quantum.ansatz.layer.Layer(qubits_idx, num_qubits, depth=1)

Bases: Sequential

Base class for Layers.

Parameters:
  • qubits_idx (Iterable[int] | str) – Indices of the qubits on which this layer is applied.

  • num_qubits (int) – Total number of qubits.

  • depth (int) – Number of layers.

Note

A Circuit instance needs to extend this Layer instance to be used in a circuit.

property gate_history

list of gates information of this layer

Returns:

history of quantum gates

class paddle_quantum.ansatz.layer.SuperpositionLayer(qubits_idx=None, num_qubits=None, depth=1)

Bases: Layer

Layers of Hadamard gates.

Parameters:
  • qubits_idx (Iterable[int] | str) – Indices of the qubits on which the layer is applied.

  • qubits. (Defaults to None i.e. applied on all) –

  • num_qubits (int) – Total number of qubits. Defaults to None.

  • depth (int) – Number of layers. Defaults to 1.

class paddle_quantum.ansatz.layer.LinearEntangledLayer(qubits_idx=None, num_qubits=None, depth=1)

Bases: Layer

Linear entangled layers consisting of Ry gates, Rz gates, and CNOT gates.

Parameters:
  • qubits_idx (Iterable[int] | str) – Indices of the qubits on which the layer is applied.

  • qubits. (Defaults to None i.e. applied on all) –

  • num_qubits (int) – Total number of qubits. Defaults to None.

  • depth (int) – Number of layers. Defaults to 1.

class paddle_quantum.ansatz.layer.RealEntangledLayer(qubits_idx=None, num_qubits=None, depth=1)

Bases: Layer

Strongly entangled layers consisting of Ry gates and CNOT gates.

Note

The mathematical representation of this layer of quantum gates is a real unitary matrix. This ansatz is from the following paper: https://arxiv.org/pdf/1905.10876.pdf.

Parameters:
  • qubits_idx (Iterable[int] | str) – Indices of the qubits on which the layer is applied.

  • qubits. (Defaults to None i.e. applied on all) –

  • num_qubits (int) – Total number of qubits. Defaults to None.

  • depth (int) – Number of layers. Defaults to 1.

class paddle_quantum.ansatz.layer.ComplexEntangledLayer(qubits_idx=None, num_qubits=None, depth=1)

Bases: Layer

Strongly entangled layers consisting of single-qubit rotation gates and CNOT gates.

Note

The mathematical representation of this layer of quantum gates is a complex unitary matrix. This ansatz is from the following paper: https://arxiv.org/abs/1804.00633.

Parameters:
  • qubits_idx (Iterable[int] | str) – Indices of the qubits on which the layer is applied.

  • qubits. (Defaults to None i.e. applied on all) –

  • num_qubits (int) – Total number of qubits. Defaults to None.

  • depth (int) – Number of layers. Defaults to 1.

class paddle_quantum.ansatz.layer.RealBlockLayer(qubits_idx=None, num_qubits=None, depth=1)

Bases: Layer

Weakly entangled layers consisting of Ry gates and CNOT gates.

Note

The mathematical representation of this layer of quantum gates is a real unitary matrix.

Parameters:
  • qubits_idx (Iterable[int] | str) – Indices of the qubits on which the layer is applied.

  • qubits. (Defaults to None i.e. applied on all) –

  • num_qubits (int) – Total number of qubits. Defaults to None.

  • depth (int) – Number of layers. Defaults to 1.

class paddle_quantum.ansatz.layer.QAOALayer(edges, nodes, depth=1)

Bases: Layer

QAOA driving layers

Note

this layer only works for MAXCUT problem

Parameters:
  • edges (Iterable) – edges of the graph

  • nodes (Iterable) – nodes of the graph

  • depth (int) – depth of layer

class paddle_quantum.ansatz.layer.QAOALayerWeighted(edges, nodes, depth=1)

Bases: Layer

QAOA driving layers with weights

Parameters:
  • edges (Dict[Tuple[int, int], float]) – edges of the graph with weights

  • nodes (Dict[int, float]) – nodes of the graph with weights

  • depth (int) – depth of layer