qat.fermion.phase_estimation.perform_phase_estimation

class qat.fermion.phase_estimation.perform_phase_estimation(H_el: ElectronicStructureHamiltonian, n_phase_bits: int, n_trotter_steps: int, init_vec: Optional[str] = None, n_adiab_steps: Optional[int] = 0, E_target: Optional[float] = 0, size_interval: Optional[float] = 2.0, basis_transform: Optional[str] = 'jordan-wigner', qpu=None, n_shots: Optional[int] = 0, verbose: Optional[bool] = False)

Perform quantum phase estimation (QPE) on an ElectronicStructureHamiltonian. This Hamiltonian is transformed to the computational basis via a Jordan-Wigner transformation and approximated via first order trotterization. Other transformations like parity and Bravyi-Kitaev are also possible.

When providing an initial state one can specify it either as a string composed of zeros and ones, or as a QRoutine which will produce it. The QPE is meant to start from an eigenstate of the Hamiltonian, however, knowing apriori even one eigenstate of the system may be challenging. Therefore, this function comes with adiabatic state preparation - an optional preliminary step to create an eigenstate of the Hamiltonian \(H\). This step consists in performing QPE n_adiab_steps number of times, but not to read the phase bits (it is set to only one), but rather to collapse the system to an eigenstate (read from the data bits). The first of the series of QPE executions starts from the lowest energy eigenstate of the Hamiltonian composed of \(h_{pq}\). Then, \(h_{pq}\) is linearly transformed to \(H\) and at each new step we start from the eigenstate of the Hamiltonian of the previous step. This guarantees that when the main QPE routine starts, it will do so from an eigenstate of the full \(H\).

Usually, energies lie outside the range \((-\frac{2\pi}{t}, 0)\). However, this range can be adjusted by searching inside the window \((E_{target} - \frac{\Delta}{2}, E_{target} + \frac{\Delta}{2})\) with \(E_{target}\) and \(\Delta\) specified by E_target and size_interval, respectively. It is suggested to always start from a large size interval and unbiased target energy like \(0\) thus enclosing many of the eigenenergies including the desired one. One can then narrow the window around an already found eigenenergy for a better precision. Working with a window not enclosing an eigenenergy would still evaluate to a result, but it may be misleading.

Warning

  • Regarding the adiabatic state preparation, if the lowest energy eigenstate of the first-step Hamiltonian \(h_{pq}\) is also an eigenstate of the whole \(H\), the system will remain in it until the end of the whole adiabatic stage. Hence, this eigenstate may not be the one of the lowest energy anymore.

  • As a rule of thumb, if small changes to the interval cause considerable deviations in the energy, that’s a sign that the window is too small or a different target energy may be better.

Parameters
  • H_el (ElectronicStructureHamiltonian) – An electronic-structure Hamiltonian.

  • n_phase_bits (int) – Number of qubits for the phase evaluation. The larger it is, the more accurate is the result.

  • n_trotter_steps (int) – Number of first order trotterization steps. For good phase estimation it should also increase if n_phase_bits is increased.

  • init_vec (Optional[str]) – Initial vector specified in the computational basis as a string - ‘01101’ for example. Starting from |0..0> an X will be applied to the respective qubits so as to produce the provided vector. This vector will enter the adiabatic state preparation routine if n_adiab_steps is not 0 or will be given straight to the main QPE routine.

  • n_adiab_steps (Optional[int]) – Number of steps to pass from the part of the Hamiltonian containing only c_p^dagger * c_p terms (which is diagonal and fast to deal with) to the Hamiltonian of interest.

  • E_target (Optional[float]) – Expected energy. If unknown, set to 0.

  • size_interval (Optional[float]) – Size \(\Delta\) of the interval one thinks the value of the energy is in: \(E \in [E_\mathrm{target}-\Delta/2, E_\mathrm{target}+\Delta/2]\) If no idea take \(\Delta =2 E_\mathrm{max}\), with \(E_\mathrm{max}\) an upper bound of the energy.

  • basis_transform (Optional[str]) – Transformation to go from qat.fermion.hamiltonians.ElectronicStructureHamiltonian into a qat.fermion.hamiltonians.SpinHamiltonian: one can use the “jordan-wigner” (default), “bravyi-kitaev” or “parity” transformations.

  • qpu (Optional[QPU]) – QPU to use for computation. Will use by default the default installed QPU.

Returns

  • Energy found,

  • associated probability.

Return type

Tuple[float, float]

Note

Usually, energies lie outside the range \((-\frac{2\pi}{t}, 0)\). However, this range can be adjusted by specifying the arguments E_target and size_interval thus searching inside the window \((E_{t} - \frac{\Delta}{2}, E_{target} + \frac{size\_interval}{2})\), where \(E_{t}\) and \(\Delta\) stand for. We suggest to always start from a large size interval and unbiased target energy like 0 thus enclosing many of the eigenenergies including the desired one. One can then narrow the window around an already found eigenenergy for a better precision. Experience shows that working with a window not enclosing an eigenenergy makes the QPE still output a result, but it is misleading.