TransWikia.com

Are inconsistent results between different VQE runs justified?

Quantum Computing Asked by DaDiRa on July 4, 2021

I made this post a while ago, where I learned I could use qiskit’s VQE to calculate (or approximate) the Transverse Field Ising Hamiltonian and other similar Hamiltonians. After working with my code for a while, I managed to write the "functional programming version" that I wanted, and I started testing it.

My concern comes from the fact that every time I run the VQE, I may get very different results, despite not messing with the ansatz, the optimizer, the initial point or the Hamiltonian. Upon searching about it, I found this thread saying that if you don’t set an initial point, it may be chosen at random. I tried to set the seed myself as suggested there, or setting a zero initial point list to pass as the parameter, but neither seemed to change the inconsistency. Is this somehow justified? Can it be fixed or is it something that I’m going to have to deal with? I’ve tried researching this myself, but there don’t seem to be any good sources online that don’t require a high-level understanding of the papers they are based on.

Below I’m showing you an example, and how different the results I’m getting can be.
Let’s say that I have the following 3-site Ising chain Hamiltonian.

from qiskit.opflow import Z, X, I, Zero
h = 0
H = -(Z^Z^I)-(I^Z^Z)-h*((X^I^I)+(I^X^I)+(I^I^X)) #3-site Hamiltonian

For h=0 (as specified here with great detail) you should expect results that show every spin in the -z direction, that is |000> in this case. So I set up the VQE like so

from qiskit.providers.aer import QasmSimulator  
from qiskit.algorithms import VQE
from qiskit.algorithms.optimizers import COBYLA 
from qiskit.circuit.library import EfficientSU2
from qiskit.visualization import plot_histogram

backend = QasmSimulator()


optimizer = COBYLA(maxiter=1000)
ansatz = EfficientSU2(3)
vqe = VQE(ansatz, optimizer, quantum_instance=backend)
result = vqe.compute_minimum_eigenvalue(H)  

groundstates = probability_calculator(result)
#this is a function that I wrote to take
#VQE results and output probabilities with qiskit's histogram functions. It doesn't
#matter here since I've tested it and know it's not the reason for the
#inconsistencies
#(or you can just ignore this if you don't trust me and check the "raw" VQE results
#provided in the screenshots below).
plot_histogram(groundstates)

Now I run this snippet of code 6-7 times. First and second time, I get the following result (with a bit of a difference in probabilities, obviously)

enter image description here

The third time, I get the following result, which is a completely "flipped" version of the one I’m expecting

enter image description here

The last time I run it, I get the following results

enter image description here

It really makes no sense with my knowledge why this happens. I obviously chose a very simple case to demonstrate here, just to prove my point without having to mess with the math. You can do the same for h=100 where you would expect an equal superposition. The results look overall better (statistically speaking), but you will occasionally get a result that makes no sense.

To clarify my question once again: The VQE runs a minimum of 1000 times. What I don’t get is how it can yield such different results without messing with the code at all, just because you rerun it. I can’t find myself if this inconsistency is expected, or if I’m missing something I should have taken into account.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP