mindquantum.algorithm.nisq.HardwareEfficientAnsatz

View Source On Gitee
class mindquantum.algorithm.nisq.HardwareEfficientAnsatz(n_qubits, single_rot_gate_seq, entangle_gate=X, entangle_mapping='linear', depth=1, prefix: str = '', suffix: str = '')[source]

HardwareEfficientAnsatz is a kind of ansatz that can be easily implement on quantum chip.

The hardware efficient is constructed by a layer of single qubit rotation gate and a layer of two qubits entanglement gate. The single qubit rotation gate layer is constructed by one or several rotation gate that act on every qubit. The two qubits entanglement gate layer is constructed by CNOT, CZ, Rxx, Ryy, Rzz, etc. acting on entangle_mapping. For more detail, please refers Hardware-efficient variational quantum eigensolver for small molecules and quantum magnets.

Parameters
  • n_qubits (int) – number of qubit that this ansatz act on.

  • single_rot_gate_seq (list[BasicGate]) – A list of parameterized rotation gate that act on each qubit.

  • entangle_gate (BasicGate) – The non parameterized entanglement gate. If it is a single qubit gate, than the control version will be used. Default: XGate.

  • entangle_mapping (Union[str, list[tuple[int]]]) – The entanglement mapping of entanglement gate. 'linear' means the entanglement gate will be act on every neighboring qubits. 'all' means the entanglement gate will be act on any two qubits. Besides, you can specific which two qubits you want to do entanglement by setting the entangle_mapping to a list of two qubits tuple. Default: "linear".

  • depth (int) – The depth of ansatz. Default: 1.

  • prefix (str) – The prefix of parameters. Default: ''.

  • suffix (str) – The suffix of parameters. Default: ''.

Examples

>>> from mindquantum.algorithm.nisq import HardwareEfficientAnsatz
>>> from mindquantum.core.gates import RY, RZ, Z
>>> hea = HardwareEfficientAnsatz(3, [RY, RZ], Z, [(0, 1), (0, 2)])
>>> hea.circuit
      ┏━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━┓             ┏━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━┓
q0: ──┨ RY(d0_n0_0) ┠─┨ RZ(d0_n0_1) ┠───■─────■───┨ RY(d1_n0_0) ┠─┨ RZ(d1_n0_1) ┠───
      ┗━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━┛   ┃     ┃   ┗━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━┛
      ┏━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━┓ ┏━┻━┓   ┃   ┏━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━┓
q1: ──┨ RY(d0_n1_0) ┠─┨ RZ(d0_n1_1) ┠─┨ Z ┠───╂───┨ RY(d1_n1_0) ┠─┨ RZ(d1_n1_1) ┠───
      ┗━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━┛ ┗━━━┛   ┃   ┗━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━┛
      ┏━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━┓       ┏━┻━┓ ┏━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━┓
q2: ──┨ RY(d0_n2_0) ┠─┨ RZ(d0_n2_1) ┠───────┨ Z ┠─┨ RY(d1_n2_0) ┠─┨ RZ(d1_n2_1) ┠───
      ┗━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━┛       ┗━━━┛ ┗━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━┛