1
$\begingroup$

The VQE.run method only takes a quantum_instance of type QuantumInstance or BaseBackend and NOT IBMQBackend. How then can I run VQE experiments on actual IBMQ Backends rather than just locally using a qasm_simulator with the NoiseModel of an IBMQBackend.

$\endgroup$
1
$\begingroup$

BaseBackend is the abstract base class all backend classes inherit from, so IBMQBackend is actually a BaseBackend.

$\endgroup$
1
  • $\begingroup$ I re-accepted another answer, as using VQE.run on an actual backend isn't optimum, as I think it submits the VQE experiment in individual optimizer iterations, rather than having the backend handle it independently. $\endgroup$ – MShakeG Sep 30 '20 at 9:17
0
$\begingroup$

Please find here a code for using IBM Q backend for VQE.

Note that the code was tested in IBM Quatum Lab at IBM Q website.

provider = IBMQ.load_account() #your IBM Q account
backend = provider.backends(name = 'ibmq_ourense')[0] #getting IBM Q Backend

#connect IBM backend to VQE
vqe_solver = MinimumEigenOptimizer(VQE(quantum_instance = backend))

#solve a problem (qubo is variable with QUBO problem which construction is not a part of this code)
vqe_results = vqe_solver.solve(qubo) 
$\endgroup$
5
  • $\begingroup$ thank you for the answer, how would I specify the qubo QuadraticProgram parameter for VQE. I've adapted your code as follows: vqe_solver = MinimumEigenOptimizer(VQE(qubitOp, var_form, optimizer=optimizer, backend = device)). Also I am trying to obtain the eigenvalue which is relatively simple using VQE.run which returns a dictionary with an eigenvalue key. $\endgroup$ – MShakeG Sep 30 '20 at 13:16
  • $\begingroup$ My code is structured much like the VQE section in the Qiskit Textbook, however I'm trying to execute it on an actual IBMQ Backend rather than a local noisy qasm_simulator, however when using VQE.run it seems execute the experiment by submitting each experiment from local to IBMQ iteratively with the number optimizer iterations, instead of having the IBMQ Backend handle it entirely for all optimizer iterations. $\endgroup$ – MShakeG Sep 30 '20 at 13:21
  • $\begingroup$ @MShakeG: VQE is a hybrid algorithm which means that it combines classical and quantum approach. A simulation of Hamiltonian is done on a quantum computer but a function describing an energy is optimized classicaly. Hence quantum backend cannot handle whole computation. The result is what you see: iteration is sent to a quantum processor, results are measured and some steps are done classically and then it repeats and so on and so on. $\endgroup$ – Martin Vesely Oct 1 '20 at 8:24
  • $\begingroup$ I would imagine that it would simple to have the backend handle both the classical component of the computation in tandem with the quantum, rather than rely on a back and forth communication between my device and the IBMQ Backend. It would also add convenience as you can disconnect, and reconnect later and retrieve the final results with a job_id. I guess that's something for the dev team at IBM to work on if they haven't already. $\endgroup$ – MShakeG Oct 1 '20 at 11:59
  • $\begingroup$ @MShakeG: Yes, more or less all quantum algorithms need also classical part for measurement and communication with a quantum computer. However, VQE is hybrid by nature. To have purely quantum VQE, I think we would need quantum RAM (qRAM) which is currently highly experimental device. $\endgroup$ – Martin Vesely Oct 2 '20 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.