Using IBM quantum hardware with PennyLane

Hello,
Could you please tell how do I run my PennyLane circuit on IBM quantum hardware? Given the recent release of Qiskit 1.0 are there any changes to how to run the hardware?

I need to know ASAP to meet a project deadline.
Thank you so much.

Hi @a_vinil , welcome to the Forum!

We have a new demo coming out soon on how to do this.

You can see the PR here and the preview here.

Remember that you need to install PennyLane and the PennyLane-Qiskit plugin with: pip install pennylane pennylane-qiskit

Here’s a small code example that you can run on IBM hardware:

import warnings
warnings.filterwarnings('ignore')

# Add your IBM API token here
# token =

# Import the library that you need in order to use your IBM account
import qiskit_ibm_provider

# Import your favourite libraries
import pennylane as qml
import datetime as dt

# Get your IBM provider
try:
    provider = qiskit_ibm_provider.IBMProvider()
except:
    provider = qiskit_ibm_provider.IBMProvider.save_account(token=token, overwrite=True)

print(provider.backends())

# Define the backend that you will run on
b = "ibm_sherbrooke"

# Create your device
dev = qml.device(
    "qiskit.ibmq",
    wires=2,
    backend=b,
    shots = 1,
    ibmqx_token=token
)
#dev = qml.device('qiskit.aer', wires=2)

# Activate the device resource tracker
dev.tracker.active = True

# Create your qnode
@qml.qnode(dev)
def circuit():
    qml.Hadamard(wires=0)
    return qml.expval(qml.PauliZ(0))

# Run your circuit
circuit()

# Retrieve your current job
job = dev._current_job

# Print the summary of job time per step
print('Summary: \n',dev.tracker.history)

I hope this helps and good luck with your project!

1 Like

Thank you so much Catalina.

No problem @a_vinil !

Let us know if you have any issues with running on their hardware.