Skip to content

Qiskit implementation of classical shadow formalism with VQE for calculating ground state energies of molecules

License

Notifications You must be signed in to change notification settings

renatawong/classical-shadow-vqe

Repository files navigation

Electronic structure problem (estimating ground state energy) with VQE and classical shadows

The notebooks implement the idea in [1] (see the experiments therein) and extend the application of classical shadows to each iteration of VQE.

Status

The notebooks are complete.

How to use the notebooks

Requires the package predicting-quantum-properties from [2].

There are a total of six files that calculate the electronic structure problem:

  1. electronic_structure_problem_dcs.ipynb : Electronic structure problem with shadow (derandomized) applied on the optimal set of angles only. This is the original idea in [1].
  2. electronic_structure_problem_rcs.ipynb : Electronic structure problem with shadow (randomized) applied on the optimal set of angles only.

The below files on the other hand apply classical shadow in each cost function evaluation of VQE:

  1. vqe_rcs_qiskit.ipynb : Electronic structure problem using VQE with the vanilla classical shadow (i.e. randomised basis change).
  2. vqe_rcs_qiskit_optimized.ipynb: As above but with optimization.
  3. vqe_dcs_qiskit.ipynb : Electronic structure problem using VQE with ``derandomised'' classical shadow (i.e. derandomised Hamiltonian used for basis change).
  4. vqe_dcs_qiskit_optimized.ipynb : As above but with time optimization.

Calculations using the optimized versions take significantly less time than with the non-optimised versions.

File modified_derandomization.py contains a modified version of the file 'data_acquisition_shadow.py' in the package 'predicting-quantum-properties' [2]. This modification allows the user to specify the number of derandomised operators to be generated. In the original version [2], the user had to specify the number of evaluations per observable, which did not allow for control over the total number of generated operators.

The folder experimental-results contains the experimental results for the molecules $H_2$, $LiH$, $BeH_2$, $H_2O$, and $NH_3$. Note that [1] doesn't specify how to obtain a required number of derandomized operators, instead it one must pass a number of evaluations per observable. This results in the number of required operators being either unergenerated or overgenerated. Hence, in order to be able to verify the results of [1], we do a postprocessing on the method for generating derandomized operators from [2]. Essentially, we pass the parameter '50' to 'derandomized_classical_shadow.py' as the number of evaluations per observable, and then we either add operators to the output or decrease the number of operators in the output, depending on how many operators are needed for each test. Our method works for the tested molecules, but no guarantee is given for the general case.

Acknowledgements

The notebooks are based on the theory described in [1].

The code was written by Renata Wong (https://renatawong.github.io/).

This work benefited greatly from discussions with Prof. Hsi-Sheng Goan (National Taiwan University), Prof. Hao-Chung Cheng (National Taiwan University), Prof. Jyh-Pin Chou (National Changhua University of Education), Michał Stęchły (PsiQuantum), and Hsin Yuan (Robert) Huang (California Institute of Technology). All remaining deficiencies are my own.

References

[1] Hsin-Yuan Huang, Richard Kueng, and John Preskill, Efficient estimation of Pauli observables by derandomization, https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.127.030503

[2] Hsin-Yuan Huang, Predicting quantum properties, https://github.com/hsinyuan-huang/predicting-quantum-properties

License Apache License 2.0