entropicalabs / openqaoa

Multi-backend SDK for quantum optimisation
MIT License
116 stars 58 forks source link

Issue with property "q.set_classical_optimizer(optimize=False)" #186

Closed krankgeflugel closed 1 year ago

krankgeflugel commented 1 year ago

Describe the bug

I was trying to use OpenQAOA to run only the optimised circuit of my QAOA instance. I have used the simulator to derive the optimal variational parameters, and I wanted to run only the final circuit on the IBMQ cloud.

I used the following command (where qsim_qiskit is my QAOA() object) qsim_qiskit.set_classical_optimizer(optimize=False)

While it worked on the local qiskit simulator, on the cloud it sent multiple jobs (I am not sure how many iterations it was considering, eventually I killed the jobs).

To Reproduce

Steps to reproduce the behavior:

# initialize model with default configurations
qsim_qiskit = QAOA()

# optionally configure the following properties of the model
# device
qiskit_cloud = create_device(location='ibmq', name='ibmq_qasm_simulator', **qpu_credentials)
qsim_qiskit.set_device(qiskit_cloud)

#qiskit_device = create_device(location='local', name='qiskit.statevector_simulator')
#qsim_qiskit.set_device(qiskit_device)

# circuit properties
qsim_qiskit.set_circuit_properties(p=2, param_type='standard', init_type='custom', mixer_hamiltonian='x',
                                variational_params_dict={
                                    "betas":variational_params.betas.tolist(),
                                    "gammas":variational_params.gammas.tolist()
                                    })

# backend properties (already set by default)
qsim_qiskit.set_backend_properties(prepend_state=None, append_state=None)

#qsim_qiskit.set_classical_optimizer(optimize=False) # **<--- This is the problematic line**

Expected behavior

I want to be able to run only one circuit on the IBMQ cloud

Note that the following command works (but it's not ideal) #qsim_qiskit.set_classical_optimizer(optimize=False) qsim_qiskit.set_classical_optimizer(method='cobyla', maxiter=0, cost_progress=True, parameter_log=True, optimization_progress=True)

Screenshot 2023-02-19 at 1 45 05 PM
vishal-ph commented 1 year ago

new method to execute the QAOA circuit at a specific value of parameters in #192 fixes the issue.