Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the place of num_exec #259

Merged
merged 7 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

### Bug fixes

* The number of executions of the device is now correct.
[(#259)](https://github.com/PennyLaneAI/pennylane-qiskit/pull/259)

### Contributors

This release contains contributions from (in alphabetical order):
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 @@ -466,6 +466,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):
Expand All @@ -486,9 +489,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()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_qiskit_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅 yes retrospect this doesn't look right!

assert dev.num_executions == 1