So I wrote an algorithm for a quadratic problem (qubo) and try to solve it. My question is why I don't get the correct results when running my algorithm on a quantum computer like IBM_manila. In the histogram that I get in the web interface when the job is done, everything seems completely random. For example the correct result would use the binary variables x_1: 1, x_2: 0, x_3: 1, x_4: 0 but in the histogram 1010 has only very few counts and 0111 which isn't even a legal result has the highest counts. Am I interpreting this correctly?

Running the algorithm locally with an exact eigensolver produces the right result.

I already read the following things:

  • COBYLA optimization doesn't seem to run very well with VQE
  • Iterations are important

But that alone doesn't do the trick for me. Maybe I'm doing something fundamentally wrong, so here is what I'm trying:

# I initialize the model:
mdl = Model()

# Then I set my goal, constraints, etc. and save them in 3 sums: s1, s2, s3
objective = s1 + s2 + s3

# Produce the quadratic program
quadratic_program = from_docplex_mp(mdl)
qubo = QuadraticProgramToQubo().convert(quadratic_program)
operator, offset = QuadraticProgramToQubo().convert(quadratic_program).to_ising()

# I set up the circuit
ESU2_circuit = EfficientSU2(num_qubits = operator.num_qubits, entanglement = 'linear', reps = 3)

# Optimizer and initial parameters:
optimizer = SPSA(maxiter=10)
initial_point = np.random.random(ESU2_circuit.num_parameters)

# Information purposes
intermediate_info = {
    'nfev': [],
    'parameters': [],
    'energy': [],
    'stddev': []

def callback(nfev, parameters, energy, stddev):

# IBMQ things
provider = IBMQ.get_provider(hub = 'ibm-q', group = 'open', project = 'main')
device = provider.get_backend('ibmq_manila')

# Parameters for the algorithm
optimizer = SPSA(maxiter=10)
vqe_solver = MinimumEigenOptimizer(VQE(quantum_instance = device, optimizer = optimizer))
vqe_results = vqe_solver.solve(qubo)

These questions come to my mind:

  • How many reps should one use when it comes to the circuit?
  • Is EfficientSU2 the way to go or are there better possibilities for circuit generation?
  • What's with the SPSA optimizer? How many iterations are preferable?
  • Is there generally something wrong with my approach?

So, what do you think? Thanks in advance!

  • 1
    $\begingroup$ Before running on a real device you might like to run on a local simulator to see how things behave. You can use a statevector one to start with, for an ideal result, then go to the counts based qasm simulator which will incur shot noise due to the sampling. On a real device you have other sources of noise that will affect things even more. You may find COBYLA works ok,. For SPSA 10 iterations is pretty small in trying to find a minimum. Trying with a local simulator should give you some insight into the iterations needed and the ansatz etc. $\endgroup$
    – Steve Wood
    Apr 4, 2022 at 20:25
  • $\begingroup$ Ah ok, thanks for your input, I will try out cobyla and increase the iterations. But am I reading the graph right? The histogram that I get in the web view of IBM quantum lab seems to be completely random. Is there a possibility to get the data with a certain method inside the qiskit code? $\endgroup$
    – Hirschi
    Apr 20, 2022 at 19:55


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.