hi,
I am trying to rotate a qubit using the ibmq device.But it calculate so slow and about 3min per step. I check my IBMQ Experience result and found it seems like every step the optimization is performed, the qnode must revisit the device.
I am curious how to speed up the calculation and reduce the waiting time for the ibm device.
Code
import pennylane as qml
from pennylane import numpy as np
from qiskit import IBMQ
from qiskit.providers.ibmq import least_busy
provider = IBMQ.load_account()
print(“\n(IBMQ Backends)”)
for backend in provider.backends():
print(backend.status())
try:
least_busy_device = least_busy(provider.backends(simulator=False))
except:
print(“All devices are currently unavailable.”)
lbd = str(least_busy_device)
print("Running on current least busy device: ", lbd)
dev1 = qml.device(“qiskit.ibmq”, wires=1, backend=lbd)
@qml.qnode(dev1)
def circuit(params):
qml.RX(params[0],wires=0)
qml.RY(params[1],wires=0)
return qml.expval(qml.PauliZ(0))
def cost(var):
return circuit(var)
init_params = np.array([0.011,0.012])
print(cost(init_params))
opt = qml.GradientDescentOptimizer(stepsize=0.4)
steps = 100
params = init_params
for i in range(steps):
params = opt.step(cost, params)
if (i+1) % 5 == 0:
print(“Cost after step{:5d}:{:.7f}”.format(i+1, cost(params)))
print(“Optimizer rotation angles:{}”.format(params))
I delete my API_TOKEN in the code.
and the result show in IBMQ Experience
Time spent on one step.
In the end the spin quantum was not completed because it took too long time and did not seem to return an updated value.
Is my method of using the device wrong?
please help