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
.
2 Answers
BaseBackend
is the abstract base class all backend classes inherit from, so IBMQBackend
is actually a BaseBackend
.
-
$\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$– MShakeGSep 30, 2020 at 9:17
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)
-
$\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 theeigenvalue
which is relatively simple usingVQE.run
which returns a dictionary with aneigenvalue
key. $\endgroup$– MShakeGSep 30, 2020 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$– MShakeGSep 30, 2020 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$ Oct 1, 2020 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$– MShakeGOct 1, 2020 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$ Oct 2, 2020 at 10:01