Hello! If applicable, put your complete code example down below. Make sure that your code:
- is 100% self-contained — someone can copy-paste exactly what is here and run it to
reproduce the behaviour you are observing - includes comments
Note: I have set the values for QISKIT_IBM_TOKEN and QISKIT_IBM_INSTANCE in the env and can connect and run code on IBMQ hardware
```
Put code here
import os
import pennylane as qml
from pennylane import numpy as np
from qiskit_ibm_runtime import QiskitRuntimeService
ibm_apikey=os.environ.get(“QISKIT_IBM_TOKEN”)
ibm_crn=os.environ.get(“QISKIT_IBM_INSTANCE”)
Obtain the backend
Load the Runtime primitive and session
from qiskit_ibm_runtime import SamplerV2 as Sampler
service = QiskitRuntimeService(channel=“ibm_quantum_platform”)
Use the least busy backend
backend = service.least_busy(operational=True, simulator=False, min_num_qubits = 127)
print(backend.name)
print(f"\n qml.about(): {qml.about()}")
Connect to IBM Quantum hardware backend
try:
dev = qml.device(
“qiskit.ibmq”,
wires=2,
shots=1024, # Number of times to run the circuit on hardware
backend=“backend_name”,
ibmqx_token=ibm_apikey,
instance=ibm_crn
)
print(f"\ninitialized PennyLane device for {backend.name}“)
except Exception as e:
print(f”\nError connecting to : {backend.name}")
print(“Connecting to local simulator”)
dev = qml.device(“default.qubit”, wires=2, shots=1024) # Fallback to local ideal simulator
If you want help with diagnosing an error, please put the full error message below:
Put full error message here
python .\pennylane-on-IBMQ.py
ibm_torino
Error connecting to : ibm_torino
Connecting to local simulator
And, finally, make sure to include the versions of your packages. Specifically, show us the output of `qml.about()`.
Name: pennylane
Version: 0.42.0
Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Home-page:
Author:
Author-email:
License-Expression: Apache-2.0
Location: C:\Users\user1\AppData\Local\Programs\Python\Python313\Lib\site-packages
Requires: appdirs, autograd, autoray, cachetools, diastatic-malt, networkx, numpy, packaging, pennylane-lightning, requests, rustworkx, scipy, tomlkit, typing_extensions
Required-by: pennylane_lightning
Platform info: Windows-11-10.0.26100-SP0
Python version: 3.13.5
Numpy version: 2.2.6
Scipy version: 1.16.0
Installed devices:
- default.clifford (pennylane-0.42.0)
- default.gaussian (pennylane-0.42.0)
- default.mixed (pennylane-0.42.0)
- default.qubit (pennylane-0.42.0)
- default.qutrit (pennylane-0.42.0)
- default.qutrit.mixed (pennylane-0.42.0)
- default.tensor (pennylane-0.42.0)
- null.qubit (pennylane-0.42.0)
- reference.qubit (pennylane-0.42.0)
- lightning.qubit (pennylane_lightning-0.42.0)
qml.about(): None