7

I have implemented a VQE based on Qiskit's VQE function and want to run that on an actual quantum computer. My understanding was, that an IBMQ backend can be passed into the function as a Quantum Instance. But this doesn't seem to work.

Here is the code that I am using:

from qiskit.algorithms import VQE
from qiskit.algorithms.optimizers import COBYLA
from qiskit.opflow import Z, X, I
from qiskit.circuit.library import TwoLocal
from qiskit import IBMQ

IBMQ.save_account('token') # Insert token here IBMQ.load_account()

Define hamiltonian

H = -(Z ^ Z) - 0.2 * ((X ^ I) + (I ^ X))

Define backend

provider = IBMQ.get_provider(hub='ibm-q') backend = provider.get_backend('ibmq_bogota')

Define optimizer

optimizer = COBYLA(maxiter=200)

Define ansatz

ansatz = TwoLocal(2, 'ry','cz', reps=1)

Set up VQE and run on backend

vqe = VQE(ansatz=ansatz, optimizer=optimizer, quantum_instance=backend) result = vqe.compute_minimum_eigenvalue(operator=H)

print the result

print(result)

The Hamiltonian used in this code is just a dummy, not my actual one. I just want to figure out how to properly run the code on IBMQ, before I try it out with my actual one. I have already tried several approaches, including this one: How to run VQE experiments on IBMQ Backends? But they all did not work either.

Can someone please help me out?

narip
  • 3,169
  • 2
  • 10
  • 36
Tom
  • 71
  • 2

1 Answers1

1

Your code looks fine - I am afraid you just were out of luck - Bogota appears to have some problems today (24th Oct 2021 as of 11 PM EST). Try switching to a different backend, like ibmq-manila or ibmq-santiago. You can check a list of all backends available to you here.

On a related note, I would sincerely recommend also playing with simpler circuits at first. This way you can get better understanding of the technical aspects of working with IBM Quantum machines and be able to debug more complex code (like VQE) better. Qiskit Textbook is a fantastic resource to learn some theory with working code, but qiskit-tutorials in IBM Quantum Lab (visible on the left-side of the workbook when you first load the page) may be a perfect place for a quick starter

3yakuya
  • 672
  • 3
  • 10