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 (int) – Number of qubits in the quantum circuit

  • n_layers (int) – Number of layers of rotation and entangling gates

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

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

Returns:

Circuit corresponding to the hardware-efficient ansatz

Return type:

qibo.models.circuit.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 (int) – Number of qubits in the quantum circuit

  • n_electrons (int) – Number of electrons in the molecular system

  • ferm_qubit_map (str) – 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.models.circuit.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 (int) – Number of qubits in the quantum circuit

  • excitation (list) – 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 (float) – UCC parameter. Defaults to 0.0

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

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

Returns:

Circuit corresponding to a single UCC excitation

Return type:

qibo.models.circuit.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 qibochem.driver.Molecule. If no excitations are given, it defaults to returning the full UCCSD circuit ansatz.

Parameters:
  • molecule (qibochem.driver.Molecule) – The molecule of interest.

  • excitation_level (str) – 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) – 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 (list) – Parameters for the excitations. Default value depends on the use_mp2_guess argument.

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

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

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

  • use_mp2_guess (bool) – Whether to use MP2 amplitudes or a numpy zero array as the initial guess parameter. Default: True, will use the MP2 amplitudes as the initial guess parameters

Returns:

Circuit corresponding to an UCC ansatz

Return type:

qibo.models.circuit.Circuit

qibochem.ansatz.qeb.qeb_circuit(n_qubits, excitation, theta=0.0) Circuit

Qubit-excitation-based (QEB) circuit corresponding to the unitary coupled-cluster ansatz for a single excitation. This circuit ansatz is only valid for the Jordan-Wigner fermion to qubit mapping.

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

  • excitation (list) – 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 (float) – UCC parameter. Defaults to 0.0

  • trotter_steps (int) – Number of Trotter steps; i.e. number of times this ansatz is applied with \(\theta = \theta\) / trotter_steps. Default: 1

Returns:

Circuit corresponding to a single UCC excitation

Return type:

qibo.models.circuit.Circuit

References

1. I. Magoulas and F. A. Evangelista, CNOT-Efficient Circuits for Arbitrary Rank Many-Body Fermionic and Qubit Excitations, Journal of Chemical Theory and Computation, 2023, 19(3), 822-836. (links: here or on arXiv)

Basis rotation

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

Obtains the basis rotation gates in the order of the Clements scheme QR decomposition

Parameters:
  • A (ndarray) – Matrix with dimensions \((N, N)\), 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 transformation that rotate the basis

  • z_array (ndarray) – Array of Givens rotation angles in order of traversal from the QR decomposition

  • parameters (ndarray) – Array of parameters in order of traversal from the QR decomposition

Returns:

Two separate lists of single excitation gates and their corresponding parameters to implement the basis rotation using the Clements scheme QR decomposition

Return type:

(list, list)

Givens Excitation

qibochem.ansatz.givens_excitation.givens_excitation_circuit(n_qubits, excitation, theta=None)

Circuit ansatz corresponding to the Givens rotation excitation from Arrazola et al.

Parameters:
  • n_qubits (int) – Number of qubits in the circuit

  • excitation (list) – 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 (float) – Rotation angle. Default: 0.0

Returns:

Circuit ansatz for a single Givens excitation

Return type:

qibo.models.circuit.Circuit

References

1. J. M. Arrazola, O. D. Matteo, N. Quesada, S. Jahangiri, A. Delgado, and Nathan Killoran, Universal quantum circuits for quantum chemistry, Quantum, 2022, 6, 742. (link)

qibochem.ansatz.givens_excitation.givens_excitation_ansatz(molecule, excitations=None, include_hf=True, use_mp2_guess=True)

Convenience function for buildng a circuit corresponding to the Givens excitation ansatz with multiple excitations for a given qibochem.driver.Molecule. If no excitations are given, it defaults to including all possible spin-allowed excitations (up to doubles).

Parameters:
  • molecule (qibochem.driver.Molecule) – Molecule of interest

  • excitations (list) – List of excitations (e.g. [[0, 1, 2, 3], [0, 1, 4, 5]]) used to build the Givens excitation circuit

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

  • use_mp2_guess (bool) – Whether to use MP2 amplitudes or a numpy zero array as the initial guess parameter. Default: True, uses the MP2 amplitudes as the initial guess parameters

Returns:

Circuit corresponding to a Givens excitation circuit ansatz

Return type:

qibo.models.Circuit

Symmetry-Preserving

qibochem.ansatz.symmetry.symm_preserving_circuit(n_qubits, n_electrons)

Symmetry-preserving circuit ansatz from Gard et al.

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

  • n_electrons (int) – Number of electrons in the molecular system

Returns:

Circuit corresponding to the symmetry-preserving ansatz

Return type:

qibo.models.circuit.Circuit

References

1. B. T. Gard, L. Zhu, G. S. Barron, N. J. Mayhall, S. E. Economou, and E. Barnes, Efficient symmetry-preserving state preparation circuits for the variational quantum eigensolver algorithm, npj Quantum Information, 2020, 6, 10. (link)