Ansatz#

This section covers the API reference for various chemistry circuit ansatzes.

Hardware-efficient#

qibochem.ansatz.hardware_efficient.he_circuit(n_qubits, n_layers, parameter_gates=None, coupling_gates='CZ')#

Builds the generalized hardware-efficient ansatz, in which the rotation and entangling gates used can be chosen by the user

Parameters:
  • n_qubits – Number of qubits in the quantum circuit

  • n_layers – Number of layers of rotation and entangling gates

  • parameter_gates – Iterable of single-qubit rotation gates to be used in the ansatz. The gates should be given as strings representing valid Qibo one-qubit gates. Default: ["RY", "RZ"]

  • coupling_gates – String representing the two-qubit entangling gate to be used in the ansatz; should be a valid two-qubit Qibo gate. Default: "CZ"

Returns:

Circuit corresponding to the hardware-efficient ansatz

Return type:

Qibo Circuit

Hartree-Fock#

qibochem.ansatz.hf_reference.hf_circuit(n_qubits, n_electrons, ferm_qubit_map=None)#

Circuit to prepare a Hartree-Fock state

Parameters:
  • n_qubits – Number of qubits in the quantum circuit

  • n_electrons – Number of electrons in the molecular system

  • ferm_qubit_map – Fermion to qubit map. Must be either Jordan-Wigner (jw) or Brayvi-Kitaev (bk). Default value is jw.

Returns:

Circuit initialized in a HF reference state

Return type:

Qibo Circuit

Unitary Coupled Cluster#

qibochem.ansatz.ucc.ucc_circuit(n_qubits, excitation, theta=0.0, trotter_steps=1, ferm_qubit_map=None)#

Circuit corresponding to the unitary coupled-cluster ansatz for a single excitation

Parameters:
  • n_qubits – Number of qubits in the quantum circuit

  • excitation – Iterable of orbitals involved in the excitation; must have an even number of elements E.g. [0, 1, 2, 3] represents the excitation of electrons in orbitals (0, 1) to (2, 3)

  • theta – UCC parameter. Defaults to 0.0

  • trotter_steps – Number of Trotter steps; i.e. number of times the UCC ansatz is applied with theta = theta / trotter_steps. Default: 1

  • ferm_qubit_map – Fermion-to-qubit transformation. Default is Jordan-Wigner (jw).

Returns:

Circuit corresponding to a single UCC excitation

Return type:

Qibo Circuit

qibochem.ansatz.ucc.ucc_ansatz(molecule, excitation_level=None, excitations=None, thetas=None, trotter_steps=1, ferm_qubit_map=None, include_hf=True, use_mp2_guess=True)#

Convenience function for buildng a circuit corresponding to the UCC ansatz with multiple excitations for a given Molecule. If no excitations are given, it defaults to returning the full UCCSD circuit ansatz.

Parameters:
  • molecule – The Molecule of interest.

  • excitation_level – Include excitations up to how many electrons, i.e. "S" or "D". Ignored if excitations argument is given. Default: "D", i.e. double excitations

  • excitations – List of excitations (e.g. [[0, 1, 2, 3], [0, 1, 4, 5]]) used to build the UCC circuit. Overrides the excitation_level argument

  • thetas – Parameters for the excitations. Default value depends on the use_mp2_guess argument.

  • trotter_steps – number of Trotter steps; i.e. number of times the UCC ansatz is applied with theta = theta / trotter_steps. Default: 1

  • ferm_qubit_map – fermion-to-qubit transformation. Default: Jordan-Wigner ("jw")

  • include_hf – Whether or not to start the circuit with a Hartree-Fock circuit. Default: True

  • use_mp2_guess – Whether to use MP2 amplitudes or a numpy zero array as the initial guess parameter. Default: True; use the MP2 amplitudes as the default guess parameters

Returns:

Circuit corresponding to an UCC ansatz

Return type:

Qibo Circuit

Basis rotation#

qibochem.ansatz.basis_rotation.basis_rotation_gates(A, z_array, parameters)#

places the basis rotation gates on circuit in the order of Clements scheme QR decomposition

Parameters:
  • A – NxN matrix, with -1 being null, 0 is the control and integers 1 or greater being the index for angles in clements QR decomposition of the unitary matrix representing the unitary transforms that rotate the basis

  • z_array – array of givens rotation angles in order of traversal from QR decomposition

  • parameters – array of parameters in order of traversal from QR decomposition

Outputs:
gate_list:

list of gates which implement the basis rotation using Clements scheme QR decomposition

ordered_angles:

list of angles ordered by sequence of singles excitation gates added to circuit