Giter VIP home page Giter VIP logo

vqe's Introduction

Ansätze for noisy variational quantum eigensolvers

Mafalda Ramôa

This repository contains the code I developed for my thesis, submitted for the degree of Master of Science in the Engineering Physics course at University of Minho (Physics of Information branch).

You can access the thesis on arXiv.

Files

CIRQ_AdaptVQE

Implementation of Adapt VQE ([1][2]), using the CIRQ simulator for the evaluation of both the energy and the gradient, and OpenFermion, PySCF and their plug-in for the chemistry part. Includes:

  • A noise free, matrix algebra based version of the algorithm.
  • The possibility of removing terms or growing the ansatz conservatively (multiple optimization attempts per iteration).
  • Multiple pool options (the ones used in Qubit Adapt [1] and Fermionic Adapt [2], and others).
  • Functions to estimate the required numer of CNOTs.
  • Functions to examine the Slater determinants in the state.
  • Plots for the evolution of the energy, comparing runs, etc.

CIRQ_AdaptVQE_Basic

Simpler, function-based version of Adapt VQE using the CIRQ simulator for the evaluation of both the energy and the gradient, and OpenFermion, PySCF and their plug-in for the chemistry part. Includes:

  • A noise free, matrix algebra based version of the algorithm.
  • Multiple pool options (the ones used in Fermionic Adapt and Qubit Adapt, and others).
  • Energy calculation functions, with and without sampling noise, and tests to check their performance, as well as the impact of trotterization and sampling noise on the energy evaluation.
  • Gradient calculation functions, with and without sampling noise, and tests to check their performance, as well as the impact of the number of shots on the precision.
  • Basic energy plots.

CIRQ_Openfermion

Exploring simple functionalities of Openfermion along with CIRQ.

CIRQ_UCCSD_VQE

Implementation of VQE with the unitary coupled cluster singles and doubles ansatz, using the CIRQ simulator for the energy expectation, and Openfermion, PySCF and their plug-in for the chemistry part. Includes:

  • A noise free, matrix algebra based version of the algorithm.
  • Analysis of the number of operators in the UCCSD ansatz.
  • Tests on the expectation estimation, with and without trotterization, and with or without sampling noise.
  • Multiple methods for trotterizing operators, and tests on their application to Hamiltonians and the UCCSD operator.
  • Analysis of the effect of the starting point, trotterization, sampling noise, and choice of optimizer.

CIRQ_VQE

Implementation of the original VQE algorithm [3] using the CIRQ simulator for the energy expectation. The algorithm is applied to HeH+, using the Hamiltonian from that paper, and the same ansatz (spanning the whole 2-qubit Hilbert space). Includes:

  • A noise free, matrix algebra based version of the algorithm.
  • Functions to create a circuit to prepare an arbitrary two qubit state from its parameterization, based on Schmidt decomposition.
  • Plot comparing the median and average of the energy.
  • Plot with the median of the energy, with interquartile ranges as error bars.
  • Tests on the energy expectation and state preparation.

CIRQ_VQE_Hyperparameters

Attempts to minimize the hyperparameters for the Nelder Mead optimization: tolerance (fatol, xatol) and the initial simplex size (through a single parameter delta). Current values were result of using a cost function penalizing overlaps with the ground state under 90%, and the number of failed attempts until converging.

Qiskit_AdaptVQE

Implementation of the Adapt VQE algorithm, using Qiskit for evaluation of the energy, and OpenFermion, PySCF and their plug-in for the chemistry part.

  • A noise free, matrix algebra based version of the algorithm..
  • Noise models for thermal relaxation, SPAM noise,...
  • Qubit Adapt [1] and Fermionic Adapt [2] pools.
  • Plot for the evolution of the energy
  • Trotterization of OpenFermion's QubitOperator into Qiskit circuits.
  • Transformation of OpenFermion's Hamiltonian into Qiskit Aqua observables.

Qiskit_UCCSD_VQE

Implementation of VQE with the unitary coupled cluster singles and doubles ansatz, using Qiskit for the energy expectation, and PySCF and its Qiskit Driver for the chemistry part. Includes:

  • A noise free, matrix algebra based version of the algorithm..
  • Noise models for thermal relaxation, SPAM noise,...
  • Numerical results.
  • A plot of the evolution of the energy along the optimization.

Qiskit_VQE

Implementation of the original VQE algorithm [3] using Qiskit for the energy expectation. The algorithm is applied to HeH+, using the Hamiltonian from that paper, and the same ansatz (spanning the whole 2-qubit Hilbert space). Includes:

  • A noise free, matrix algebra based version of the algorithm.
  • Plot of the evolution of the energy and overlap with the ground state along the optimization.

References

[1] Ho Lun Tang, V. O. Shkolnikov, George S. Barron, Harper R. Grimsley, Nicholas J. Mayhall, Edwin Barnes, and Sophia E. Economou. qubit-ADAPT-VQE: An adaptive algorithm for constructing hardware-efficient ansatze on a quantum processor. Preprint arXiv arXiv:1911.10205 [quant-ph].

[2] Harper R. Grimsley, Sophia E. Economou, Edwin Barnes, and Nicholas J. Mayhall. An adaptive variational algorithm for exact molecular simulations on a quantum computer. Nature Communications, 10(1), 3007 (2019).

[3] Alberto Peruzzo, Jarrod McClean, Peter Shadbolt, Man-Hong Yung, Xiao-Qi Zhou, Peter J. Love, Al ́an Aspuru-Guzik, and Jeremy L. O’Brien. A variational eigenvalue solver on a photonic quantum processor. Nature Communications 5 (1), 4213 (2014).

vqe's People

Contributors

mafaldaramoa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vqe's Issues

Changes in how cirq handles results.data

Hi,
I don't know if you still care about this project, given that it seems you have finished your masters (congrats!). If you don't care about keeping it up to date, that is perfectly reasonable, but do still please let me know how I can cite this if I end up publishing anything based on this.

If you would like to keep things up to date, I've found the following bug in CIRQ_UCCSD_VQE.ipynb:

Using the newest versions of OF and cirq, a KeyError occurs in the measureString function, which I believe is caused because cirq no longer saves the columns from identity Paulis in the results.data after this section:

if (pauliString != "I"*len(qubits)):
    s = cirq.Simulator()
    results = s.run(circuit,repetitions = repetitions)

It can be fixed by changing the for loop over range(repetitions) to the following:

for j in range(repetitions):
        meas = 1
        non_identities = 0
        for i in range(len(qubits)):
            if (pauliString[i] != "I"):
              
              meas = meas*(1-2*np.array(results.data)[j][non_identities]) # was meas = meas*(1-2*results.data[i][j]), but that failed. I guess Cirq changed how they save results.data
              non_identities += 1 # This was not here, but is necessary because Cirq no longer adds identity matrices to the results.data
        total += meas

Again, you are obviously under no obligation to keep this up to date, and I would love to credit you properly because this has been a great starting point for me in OF and Cirq, so really the main reason I'm posting this is so I can cite this in the future.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.