Skip to content

Commit

Permalink
Fix batch_execute output type for QNodes with multiple outputs (#163)
Browse files Browse the repository at this point in the history
* asarray

* check type

* changelog
  • Loading branch information
antalszava authored and rmoyard committed Jan 31, 2022
1 parent eb50beb commit af0fed6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

### New features since last release

* Defined the `QiskitDevice.batch_execute` method, to allow
Qiskit backends to run multiple quantum circuits at the same time. This
addition allows submitting batches of circuits to IBMQ e.g., when computing
gradients internally.
[(#156)](https://github.com/PennyLaneAI/pennylane-qiskit/pull/156)
[(#163)](https://github.com/PennyLaneAI/pennylane-qiskit/pull/163)

### Breaking changes

### Improvements
Expand All @@ -12,7 +19,8 @@
* Added support for the `qml.SX` operation to the Qiskit devices.
[(#158)](https://github.com/PennyLaneAI/pennylane-qiskit/pull/158)

* Added support for returning job execution times. [(#160)](https://github.com/PennyLaneAI/pennylane-qiskit/pull/160)
* Added support for returning job execution times.
[(#160)](https://github.com/PennyLaneAI/pennylane-qiskit/pull/160)

### Documentation

Expand Down
1 change: 1 addition & 0 deletions pennylane_qiskit/qiskit_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ def batch_execute(self, circuits):
self._samples = self.generate_samples(circuit_obj)

res = self.statistics(circuit.observables)
res = np.asarray(res)
results.append(res)

if self.tracker.active:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_qiskit_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ def test_result(self, device, tol):
tape2_expected = dev.execute(self.tape2)

assert len(res) == 2
assert isinstance(res[0], np.ndarray)
assert np.allclose(res[0], tape1_expected, atol=0)

assert isinstance(res[1], np.ndarray)
assert np.allclose(res[1], tape2_expected, atol=0)

def test_result_empty_tape(self, device, tol):
Expand Down

0 comments on commit af0fed6

Please sign in to comment.