Skip to content

Commit

Permalink
Fix premature session closure error (#608)
Browse files Browse the repository at this point in the history
* Fix premature session closure error

* fix too-many-positional-arguments

* changelog

* Reformat to comply with black

* Apply suggestions from code review

---------

Co-authored-by: Tak Hur <[email protected]>
Co-authored-by: Austin Huang <[email protected]>
  • Loading branch information
3 people authored Jan 7, 2025
1 parent 40a4d24 commit f775205
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@

### Documentation 📝

### Bug fixes 🐛
### Bug fixes 🐛
* Fixed premature session closure when using `qiskit_session`.
[(#608)](https://github.com/PennyLaneAI/pennylane-qiskit/pull/608)

### Contributors ✍️

This release contains contributions from (in alphabetical order):

Andrija Paurevic
Tak Hur

---
# Release 0.39.1
Expand Down
1 change: 0 additions & 1 deletion pennylane_qiskit/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,6 @@ def _function(*args, params: dict = None, wires: list = None, **kwargs):
mid_circ_regs[carg] = mid_circ_meas[-1]

else:

try:
if not isinstance(instruction, (ControlFlowOp,)):
operation_args = [instruction.to_matrix()]
Expand Down
6 changes: 3 additions & 3 deletions pennylane_qiskit/qiskit_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
This module contains a prototype base class for constructing Qiskit devices
for PennyLane with the new device API.
"""
# pylint: disable=too-many-instance-attributes,attribute-defined-outside-init
# pylint: disable=too-many-instance-attributes,attribute-defined-outside-init,too-many-positional-arguments


import warnings
Expand Down Expand Up @@ -325,7 +325,6 @@ def __init__(
compile_backend=None,
**kwargs,
):

if shots is None:
warnings.warn(
"Expected an integer number of shots, but received shots=None. Defaulting "
Expand Down Expand Up @@ -592,7 +591,8 @@ def execute_circuits(session):
results.append(execute_fn(circ, session))
yield results
finally:
session.close()
if self._session is None:
session.close()

with execute_circuits(session) as results:
return results
Expand Down
1 change: 0 additions & 1 deletion pennylane_qiskit/qiskit_device_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ class QiskitDeviceLegacy(QubitDevice, abc.ABC):
_eigs = {}

def __init__(self, wires, provider, backend, shots=1024, **kwargs):

super().__init__(wires=wires, shots=shots)

self.provider = provider
Expand Down

0 comments on commit f775205

Please sign in to comment.