Ansatz#

This section covers the API reference for various chemistry ansatzes.

Hardware-efficient#

qibochem.ansatz.hardware_efficient.hea(n_layers, n_qubits, parameter_gates=['RY', 'RZ'], 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_layers – Number of layers of rotation and entangling gates

  • n_qubits – Number of qubits in the quantum circuit

  • parameter_gates – List 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:

Gates corresponding to the hardware-efficient ansatz

Return type:

list

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, coeffs=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).

  • coeffs – List to hold the coefficients for the rotation parameter in each Pauli string. May be useful in running the VQE. WARNING: Will be modified in this function

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.br_circuit(n_qubits, parameters, n_occ)#

Google’s basis rotation circuit, applied between the occupied/virtual orbitals. Forms the exp(kappa) matrix, decomposes it into Givens rotations, and sets the circuit parameters based on the Givens rotation decomposition. Note: Supposed to be used with the JW fermion-to-qubit mapping

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

  • parameters – Rotation parameters for exp(kappa); Must have (n_occ * n_virt) parameters

  • n_occ – Number of occupied orbitals

Returns:

Circuit corresponding to the basis rotation ansatz between the occupied and virtual orbitals

Return type:

Qibo Circuit