Qiskit.remote with the latest IBM plateform: https://quantum.cloud.ibm.com

Hi,

I would like to know if using backend: dev = qml.device(‘qiskit.remote’, wires=127, backend=backend) requires a paid plan on the new IBM Quantum platform (The Cloud version).

Indeed, I have the following error: errors":[{“code”:1352,“message”:“You are not authorized to run a session when using the open plan.”

By using directly, the IBM qiskit without Pennylane, the free “Open Plan” does not create any issue.

You should reproduce this message with this code using this example.
Please test with the new IBM Quantum Plateform: https://quantum.cloud.ibm.com/ and not the old classic one which is: https://quantum.ibm.com/

import pennylane as qml
import numpy as np
import matplotlib.pyplot as plt

service = QiskitRuntimeService()
backend = service.backend(name='ibm_sherbrooke')

dev = qml.device('qiskit.remote', wires=127, backend=backend)

@qml.qnode(dev)

def entanglement_circuit():
    qml.Hadamard(wires=0)  
    qml.CNOT(wires=[0, 1])
    return qml.probs(wires=[0, 1])

state = entanglement_circuit()

print(np.round(state, 3)).  

**Does Xanadu Cloud offer a free “Open plan”? **

if yes where can I register?

Thanks.

Hi @quantumel ,

Can you please share the output of qml.about() and the version of Qiskit and QiskitRuntime that you’re using?

My guess is that it’s an issue with the version being used.

Hi,

Here there are:

qml.about():
Name: PennyLane
Version: 0.41.1
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: GitHub - PennyLaneAI/pennylane: 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.
Author:
Author-email:
License: Apache License 2.0
Location: c:\perso\Logiciels\Vscode.pennylane_env\Lib\site-packages
Requires: appdirs, autograd, autoray, cachetools, diastatic-malt, networkx, numpy, packaging, pennylane-lightning, requests, rustworkx, scipy, tomlkit, typing-extensions
Required-by: PennyLane-qiskit, PennyLane-qsharp, PennyLane_Lightning

Platform info: Windows-11-10.0.26100-SP0
Python version: 3.13.2
Numpy version: 1.26.4
Scipy version: 1.15.3
Installed devices:

  • default.clifford (PennyLane-0.41.1)
  • default.gaussian (PennyLane-0.41.1)
  • default.mixed (PennyLane-0.41.1)
  • default.qubit (PennyLane-0.41.1)
  • default.qutrit (PennyLane-0.41.1)
  • default.qutrit.mixed (PennyLane-0.41.1)
  • default.tensor (PennyLane-0.41.1)
  • null.qubit (PennyLane-0.41.1)
  • reference.qubit (PennyLane-0.41.1)
  • lightning.qubit (PennyLane_Lightning-0.41.1)
  • qiskit.aer (PennyLane-qiskit-0.41.0.post0)
  • qiskit.basicaer (PennyLane-qiskit-0.41.0.post0)
  • qiskit.basicsim (PennyLane-qiskit-0.41.0.post0)
  • qiskit.remote (PennyLane-qiskit-0.41.0.post0)
  • microsoft.QuantumSimulator (PennyLane-qsharp-0.19.0)

Qiskit version:
print(“Qiskit version:”, qiskit.version):
Qiskit version: 1.2.4

Qiskit runtime version:
print(qiskit_runtime.version)
0.29.0

Thanks @quantumel .

Everything looks right except for the Python version. We support up to Python 3.12. However this doesn’t look to be causing the issue, it’s probably coming from somewhere else. I’ve forwarded your question internally to our team so that they can investigate this more. We’ll get back to you next week with our findings.

Hi @quantumel ,

It looks like Qiskit may have change the way they handle sessions. We’re looking into a workaround for this.

Thanks for your feeback.

Hi @quantumel ,

I have a quick update. We’ve created a GitHub issue for this and we’re prioritizing a fix. You can follow the issue to see the progress on the fix. I’ll still post here when I have more info or when it’s fixed.

Hi @quantumel ,

My colleague Austin has been working on a fix. You can see the PR here.

In the meantime, you can use this quick fix found by Austin:

service = QiskitRuntimeService() 
backend = service.backend(name='ibm_sherbrooke') 
dev = qml.device('qiskit.remote', wires=127, backend=backend, session=backend) # define the session to be your backend

This seemed to work with the fake backends. We’re waiting in the queue to see if this works on real qpus too. Let us know if this works for you too!

Hi,

Thanks, unable to test on IBM QPUs, unfortunately the IBM servers were busy all the time.
I will let you know if I manage to obtain some result.

Thanks for your feedback.
Regards

Hi,

The job is passed as you see in the screenshot of IBM Quantum Plateform.

I got the result:
[0.466 0.058 0.056 0.421]

Thanks.

Now I run a QML programme using the same process.
First run using this code with IBM simulator: qiskit.aer

# Exécuter un Code Pennylane en utilisant un Simulateur Qiskit
import pennylane as qml
from pennylane import numpy as np
import matplotlib.pyplot as plt

# Générer un jeu de données simple
np.random.seed(42)
X = np.array([[0, 0], [0, 1], [1, 0], [1, 1]])
y = np.array([0, 1, 1, 0])  # Classes binaires

# Création d'un simulateur quantique avec 2 qubits avec le simulateur Qiskit
**dev = qml.device('qiskit.aer', wires=2)**

@qml.qnode(dev)
def circuit(params, x):
    """Circuit quantique paramétré pour la classification."""
    qml.RX(x[0], wires=0)
    qml.RX(x[1], wires=1)
    qml.RY(params[0], wires=0)
    qml.RY(params[1], wires=1)
    qml.CNOT(wires=[0, 1])
    qml.RZ(params[2], wires=0)
    qml.RZ(params[3], wires=1)
    return qml.expval(qml.PauliZ(0))

# Fonction de coût
def cost(params):
    cost = 0
    for xi, yi in zip(X, y):
        output = circuit(params, xi)
        cost += (output - yi) ** 2
    return cost / len(X)

# Initialiser les paramètres
np.random.seed(42)
init_params = np.random.normal(size=(4,))

# Optimiseur
opt = qml.GradientDescentOptimizer(stepsize=0.1)

# Entraînement du circuit
params = init_params
for i in range(100):
    params = opt.step(cost, params)
    if (i + 1) % 10 == 0:
        print(f"Étape {i + 1}: Coût = {cost(params)}")

# Afficher les paramètres optimisés
print("Paramètres optimisés :", params)

# Tester le circuit avec les données d'entraînement
predictions = [circuit(params, xi) for xi in X]
print("Prédictions :", predictions)

# Afficher les résultats
plt.scatter(X[:, 0], X[:, 1], c=y, cmap='bwr', marker='o')
plt.title("Classification binaire avec un circuit quantique")
plt.xlabel("Feature 1")
plt.ylabel("Feature 2")
plt.show()

The result is correct with qiskit.aer.

Now I use the same code just changing the device using IBM QPU:

import pennylane as qml
from pennylane import numpy as np
import matplotlib.pyplot as plt

# Générer un jeu de données simple
np.random.seed(42)
X = np.array([[0, 0], [0, 1], [1, 0], [1, 1]])
y = np.array([0, 1, 1, 0])  # Classes binaires

# Pour accéder aux informations d'identification enregistrées pour le canal quantique IBM et sélectionner une instance
service = QiskitRuntimeService()

# Sélection explicite d'un backend compatible
backend = service.backend(name='ibm_sherbrooke')

# Afficher le backend utilisé
print(backend)  

# Utiliser ce backend avec PennyLane (par exemple pour Qiskit sur une machine à 127 qubits)
# Bug fix: ajouter session=backend pour la nouvelle version de IBM Quantum Plateform 1er juillet 2025 
#dev = qml.device('qiskit.remote', wires=127, backend=backend)
dev = qml.device('qiskit.remote', wires=127, backend=backend, session=backend) # définit la session pour tn backend

@qml.qnode(dev)
def circuit(params, x):
    """Circuit quantique paramétré pour la classification."""
    qml.RX(x[0], wires=0)
    qml.RX(x[1], wires=1)
    qml.RY(params[0], wires=0)
    qml.RY(params[1], wires=1)
    qml.CNOT(wires=[0, 1])
    qml.RZ(params[2], wires=0)
    qml.RZ(params[3], wires=1)
    return qml.expval(qml.PauliZ(0))

# Fonction de coût
def cost(params):
    cost = 0
    for xi, yi in zip(X, y):
        output = circuit(params, xi)
        cost += (output - yi) ** 2
    return cost / len(X)

# Initialiser les paramètres
np.random.seed(42)
init_params = np.random.normal(size=(4,))

# Optimiseur
opt = qml.GradientDescentOptimizer(stepsize=0.1)

# Entraînement du circuit
params = init_params
for i in range(100):
    params = opt.step(cost, params)
    if (i + 1) % 10 == 0:
        print(f"Étape {i + 1}: Coût = {cost(params)}")

# Afficher les paramètres optimisés
print("Paramètres optimisés :", params)

# Tester le circuit avec les données d'entraînement
predictions = [circuit(params, xi) for xi in X]
print("Prédictions :", predictions)

# Afficher les résultats
plt.scatter(X[:, 0], X[:, 1], c=y, cmap='bwr', marker='o')
plt.title("Classification binaire avec un circuit quantique")
plt.xlabel("Feature 1")
plt.ylabel("Feature 2")
plt.show()

The job is correctly ended.

This code got stuck, why?
image

Using the qiskit.aer, the code finished under 4 min.

What I did not understand: how Pennylane can run the circuit in my cost function without submit n times the circuit in the job?

If I have to change my code above in the case of using a simulator or a QPU, does this mean that Pennylane is not so interoperable or generic since I have to adapt the code according to the physical device of the provider or the simulator?

Do you have any idea on how to make the code generic so that only the supplier information can be modified regardless of the quantum resource?

Additional information about this use case, it works with Azure Quantum only changing the provider.

here is the change:

# Connection aux ressources Azure
workspace = Workspace ( 
    resource_id = "<resource_id>", 
    location = "westeurope"  
)

provider = AzureQuantumProvider(workspace)
backend = provider.get_backend("rigetti.sim.qvm")
# backend = provider.get_backend("rigetti.qpu.ankaa-3")

The question is why is not working with IBM QPU?

Hi @quantumel

@CatalinaAlbornoz is away and will be back on June 11th.

Just wanted to let you know that we merged the previously mentioned fix which should solve the initial issue.

As for your other questions, I would also expect the circuit to be sent to IBM multiple times with each optimizer update of the input values. If the code got stuck, I imagine that something is going wrong with the connection to IBM while handling the multiple jobs required.

Let me see if I can get you some more info on this.

@quantumel One question, do you see another job being queued when you run your code?
We saw that the first job is completed correctly. PennyLane should automatically queue another job after this. Do you see any pending jobs?

Thanks for your notice. It seems that the IBM plan run out of credits. That’s why the rest of the jobs got stuck. I need to check again asap. I will let you know if any issue will occur again. Thanks for giving some clues.

2 Likes