# EstimatorV2.\_\_init\_\_() got an unexpected keyword argument 'session'

**URL:** <https://discuss.pennylane.ai/t/estimatorv2-init-got-an-unexpected-keyword-argument-session/5236>\
**Category:** PennyLane Qiskit\
**Created:** [September 24, 2024, 7:41pm UTC](https://discuss.pennylane.ai/t/estimatorv2-init-got-an-unexpected-keyword-argument-session/5236 "2024-09-24T19:41:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christophe\_Pere](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/christophe_pere/32/2417_2.png) [@Christophe\_Pere](https://discuss.pennylane.ai/u/Christophe_Pere)\
**Post date:** [September 24, 2024, 7:41pm UTC](https://discuss.pennylane.ai/t/estimatorv2-init-got-an-unexpected-keyword-argument-session/5236/1 "2024-09-24T19:41:52Z")

</div>

Hello,

I want to upgrade my code and use the 0.38 version of the Qiskit plugin. I ran the code from [The Remote device — PennyLane-Qiskit 0.38.0 documentation](https://docs.pennylane.ai/projects/qiskit/en/stable/devices/remote.html)

Code:

```auto
from qiskit_ibm_runtime import QiskitRuntimeService
from qiskit_ibm_runtime.fake_provider import FakeManilaV2
backend = FakeManilaV2()
dev = qml.device(
    "qiskit.remote",
    wires=5,
    backend=backend,
    resilience_level=1,
    optimization_level=1,
    seed_transpiler=42
)
@qml.qnode(dev)
def circuit(x, y, z):
    qml.RZ(z, wires=[0])
    qml.RY(y, wires=[0])
    qml.RX(x, wires=[0])
    qml.CNOT(wires=[0, 1])
    return qml.expval(qml.PauliZ(wires=1))
circuit(0.2, 0.1, 0.3)

```

And I got the error:

```auto
File ~/pennylane-qiskit/lib/python3.12/site-packages/pennylane_qiskit/qiskit_device.py:646, in QiskitDevice._execute_estimator(self, circuit, session)
    643 # the Estimator primitive takes care of diagonalization and measurements itself,
    644 # so diagonalizing gates and measurements are not included in the circuit
    645 qcirc = [circuit_to_qiskit(circuit, self.num_wires, diagonalize=False, measure=False)]
--> 646 estimator = Estimator(session=session)
    648 pauli_observables = [mp_to_pauli(mp, self.num_wires) for mp in circuit.measurements]
    649 compiled_circuits = self.compile_circuits(qcirc)

TypeError: EstimatorV2. __init__ () got an unexpected keyword argument 'session'

```

It’s from the documentation so I don’t know what to do…

About qml.about():

```auto
Name: PennyLane
Version: 0.38.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: https://github.com/PennyLaneAI/pennylane
Author:
Author-email:
License: Apache License 2.0
Location: /Users/christophe_pere/pennylane-qiskit/lib/python3.12/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, packaging, pennylane-lightning, requests, rustworkx, scipy, toml, typing-extensions
Required-by: PennyLane-qiskit, PennyLane_Lightning

Platform info: macOS-15.0-arm64-arm-64bit
Python version: 3.12.6
Numpy version: 1.26.4
Scipy version: 1.14.1
Installed devices:
- qiskit.aer (PennyLane-qiskit-0.38.0)
- qiskit.basicaer (PennyLane-qiskit-0.38.0)
- qiskit.basicsim (PennyLane-qiskit-0.38.0)
- qiskit.remote (PennyLane-qiskit-0.38.0)
- lightning.qubit (PennyLane_Lightning-0.38.0)
- default.clifford (PennyLane-0.38.0)
- default.gaussian (PennyLane-0.38.0)
- default.mixed (PennyLane-0.38.0)
- default.qubit (PennyLane-0.38.0)
- default.qubit.autograd (PennyLane-0.38.0)
- default.qubit.jax (PennyLane-0.38.0)
- default.qubit.legacy (PennyLane-0.38.0)
- default.qubit.tf (PennyLane-0.38.0)
- default.qubit.torch (PennyLane-0.38.0)
- default.qutrit (PennyLane-0.38.0)
- default.qutrit.mixed (PennyLane-0.38.0)
- default.tensor (PennyLane-0.38.0)
- null.qubit (PennyLane-0.38.0)

```

---

<div class="post-metadata">

**Author:** ![Christophe\_Pere](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/christophe_pere/32/2417_2.png) [@Christophe\_Pere](https://discuss.pennylane.ai/u/Christophe_Pere)\
**Post date:** [September 24, 2024, 8:02pm UTC](https://discuss.pennylane.ai/t/estimatorv2-init-got-an-unexpected-keyword-argument-session/5236/2 "2024-09-24T20:02:41Z")

</div>

I also tried with my own code and I obtained the same error

```auto
  File "/Users/christophe_pere/pennylane-qiskit/lib/python3.12/site-packages/pennylane_qiskit/qiskit_device.py", line 646, in _execute_estimator
    estimator = Estimator(session=session)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: EstimatorV2. __init__ () got an unexpected keyword argument 'session'

```

I can observe the creation of a session in the IBM Quantum Interface:

 ![Screenshot 2024-09-24 at 4.01.44 PM](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/2X/1/11d9dc32bcf8fdabf2f75cb24be7b98eba2796c1.png)

But the message is:

```auto
Status details
Status
Completed
completed icon
Session marked as not accepting new jobs and all jobs already in a terminal state.

```

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [September 25, 2024, 12:06am UTC](https://discuss.pennylane.ai/t/estimatorv2-init-got-an-unexpected-keyword-argument-session/5236/3 "2024-09-25T00:06:33Z")

</div>

Hi @Christophe_Pere ,

My colleague Austin helped me find the source of this issue.

It seems like it’s due to a difference in the version of `qiskit_ibm_runtime` . The latest 0.30.0 dev release seems to have broken this keyword. [The documentation](https://docs.quantum.ibm.com/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.EstimatorV2) suggests that the keyword should still be useable but they may have broken it accidentally. You can switch to the stable release of qiskit\_ibm\_runtime using `pip install qiskit_ibm_runtime==0.29.0` and the issue should resolve itself.

Let me know if this works for you!

---

<div class="post-metadata">

**Author:** ![Christophe\_Pere](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/christophe_pere/32/2417_2.png) [@Christophe\_Pere](https://discuss.pennylane.ai/u/Christophe_Pere)\
**Post date:** [September 26, 2024, 8:05pm UTC](https://discuss.pennylane.ai/t/estimatorv2-init-got-an-unexpected-keyword-argument-session/5236/4 "2024-09-26T20:05:54Z")

</div>

Hi @CatalinaAlbornoz

Thanks, it’s working when downgrading to 0.29.
