Quantum code executed multiple times automatically
Thevendran opened this issue · 1 comments
Thevendran commented
Steps to reproduce the problem
from qiskit_optimization import QuadraticProgram
from qiskit_optimization.algorithms import MinimumEigenOptimizer
from qiskit.algorithms import QAOA
from qiskit.utils import QuantumInstance
from qiskit_braket_provider import AWSBraketProvider
qubo = QuadraticProgram('two-different')
qubo.binary_var('x')
qubo.binary_var('y')
qubo.minimize(linear=[-1, -1], quadratic={('x', 'y'): 2}, constant=1)
print(qubo.prettyprint())
quantum_instance = QuantumInstance(
backend=AWSBraketProvider().get_backend('dm1'),
shots=1
)
qaoa_instance = QAOA(quantum_instance=quantum_instance)
qaoa_solver = MinimumEigenOptimizer(qaoa_instance)
result = qaoa_solver.solve(qubo)
print(result.prettyprint())
What is the current behavior?
Code gets executed multiple times (as back-to-back tasks in Braket), before the result returned back to local development environment.
What is the expected behavior?
Expecting the code to be executed just once.
jcjaskula-aws commented
Your code uses an optimizer to minimize a cost function (see the line MinimumEigenOptimizer(qaoa_instance)
). The solver will execute your circuit and subsequently update parameters to return the final result. You could use print(result.min_eigen_solver_result)
to read the number of circuit evaluations. As it is, this looks to work as intended, which means that indeed many tasks will be executed.