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
mdl.minimize(objective)
# 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)
np.random.seed(10)
initial_point = np.random.random(ESU2_circuit.num_parameters)
# Information purposes
intermediate_info = {
'nfev': [],
'parameters': [],
'energy': [],
'stddev': []
}
def callback(nfev, parameters, energy, stddev):
intermediate_info['nfev'].append(nfev)
intermediate_info['parameters'].append(parameters)
intermediate_info['energy'].append(energy)
intermediate_info['stddev'].append(stddev)
# IBMQ things
IBMQ.load_account()
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!