Quantum Codebook is an amazing resource. I really feel now I am learning things well.
I have copied the below example codes (which are amazing) from the Codebook I.2. Please guide me how to modify these code so that I can run it on IBMQ real hardware. I have a account on IBMQ. It would be great if someone can guide me how to run it on some free hardware.
# This creates a device with three wires on which PennyLane can run computations
dev = qml.device("default.qubit", wires=3)
def my_circuit(theta, phi, omega):
# IMPLEMENT THE CIRCUIT BY ADDING THE GATES
# Here are two examples, so you can see the format:
qml.RX(theta, wires =0)
qml.RY(phi, wires= 1)
qml.RZ(omega, wires=2)
qml.CNOT(wires = [0,1])
qml.CNOT(wires =[1,2])
qml.CNOT(wires= [2,0])
return qml.probs(wires=[0, 1, 2])
# This creates a QNode, binding the function and device
my_qnode = qml.QNode(my_circuit, dev)
# We set up some values for the input parameters
theta, phi, omega = 0.1, 0.2, 0.3
# Now we can execute the QNode by calling it like we would a regular function
my_qnode(theta, phi, omega)
dev = qml.device("default.qubit", wires=3)
##################
# YOUR CODE HERE #
##################
# DECORATE THE FUNCTION BELOW TO TURN IT INTO A QNODE
@qml.qnode(dev)
def my_circuit(theta, phi, omega):
qml.RX(theta, wires=0)
qml.RY(phi, wires=1)
qml.RZ(omega, wires=2)
qml.CNOT(wires=[0, 1])
qml.CNOT(wires=[1, 2])
qml.CNOT(wires=[2, 0])
return qml.probs(wires=[0, 1, 2])
theta, phi, omega = 0.1, 0.2, 0.3
my_circuit(theta, phi, omega)