From 1c0c3d5fefccd98c1f24ddaa6f2fcae26da127a3 Mon Sep 17 00:00:00 2001 From: rmoyard Date: Tue, 24 Jan 2023 12:25:43 -0500 Subject: [PATCH 1/4] Fix --- pennylane_qiskit/qiskit_device.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pennylane_qiskit/qiskit_device.py b/pennylane_qiskit/qiskit_device.py index b5b0da6c2..67c760737 100644 --- a/pennylane_qiskit/qiskit_device.py +++ b/pennylane_qiskit/qiskit_device.py @@ -448,6 +448,9 @@ def batch_execute(self, circuits): self._current_job = self.backend.run(compiled_circuits, shots=self.shots, **self.run_args) result = self._current_job.result() + # increment counter for number of executions of qubit device + self._num_executions += 1 + # Compute statistics using the state and/or samples results = [] for circuit, circuit_obj in zip(circuits, compiled_circuits): @@ -468,9 +471,6 @@ def batch_execute(self, circuits): res = np.asarray(res) results.append(res) - # increment counter for number of executions of qubit device - self._num_executions += 1 - if self.tracker.active: self.tracker.update(batches=1, batch_len=len(circuits)) self.tracker.record() From d8d47ea6b0797c7206c0cf5901576ec1232294dc Mon Sep 17 00:00:00 2001 From: rmoyard Date: Tue, 24 Jan 2023 15:52:35 -0500 Subject: [PATCH 2/4] Fix tests --- tests/test_qiskit_device.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_qiskit_device.py b/tests/test_qiskit_device.py index 066100cfd..bd4755196 100644 --- a/tests/test_qiskit_device.py +++ b/tests/test_qiskit_device.py @@ -177,8 +177,8 @@ def test_result_empty_tape(self, device, tol): assert np.allclose(res[0], dev.execute(empty_tape), atol=0) def test_num_executions_recorded(self, device): - """Tests that the number of exeuctions are recorded correctly..""" + """Tests that the number of executions are recorded correctly..""" dev = device(2) tapes = [self.tape1, self.tape2] res = dev.batch_execute(tapes) - assert dev.num_executions == 2 + assert dev.num_executions == 1 From 1747d286f4c6520dfed251c601f778acebe50c9a Mon Sep 17 00:00:00 2001 From: rmoyard Date: Tue, 24 Jan 2023 15:54:30 -0500 Subject: [PATCH 3/4] Add changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb85d67ff..92651e3dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ ### Bug fixes +* The number of executions of the device is now correct. + [(#261)](https://github.com/PennyLaneAI/pennylane-qiskit/pull/261) + ### Contributors This release contains contributions from (in alphabetical order): From c0d442c92e4ff239b345409246b00aa7327da460 Mon Sep 17 00:00:00 2001 From: rmoyard Date: Tue, 24 Jan 2023 15:56:02 -0500 Subject: [PATCH 4/4] Wrong PR number --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92651e3dc..b48705be9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ ### Bug fixes * The number of executions of the device is now correct. - [(#261)](https://github.com/PennyLaneAI/pennylane-qiskit/pull/261) + [(#259)](https://github.com/PennyLaneAI/pennylane-qiskit/pull/259) ### Contributors