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

Setting shots in execute no longer works #6741

Closed
nonhermitian opened this issue Jul 14, 2021 · 4 comments · Fixed by #6743
Closed

Setting shots in execute no longer works #6741

nonhermitian opened this issue Jul 14, 2021 · 4 comments · Fixed by #6743
Labels
bug Something isn't working stable backport potential The bug might be minimal and/or import enough to be port to stable
Milestone

Comments

@nonhermitian
Copy link
Contributor

Information

  • Qiskit Terra version: 0.28
  • Python version:
  • Operating system:

What is the current behavior?

Setting the shots kwarg in execute is no longer obeyed:

from qiskit import *
from qiskit.test.mock import FakeMontreal
backend = FakeMontreal()

qubits = [1, 4, 7, 10, 12, 13]

N = 6
qc = QuantumCircuit(N)
qc.x(range(0, N))
qc.h(range(0, N))
for kk in range(N//2, 0, -1):
    qc.ch(kk, kk-1)
for kk in range(N//2, N-1):
    qc.ch(kk, kk+1)
qc.measure_all()

raw_counts = execute(qc, backend, shots=1000,
                    initial_layout=qubits).result().get_counts()

sum(raw_counts.values())

gives 1024

Steps to reproduce the problem

What is the expected behavior?

Suggested solutions

@nonhermitian nonhermitian added the bug Something isn't working label Jul 14, 2021
@nonhermitian
Copy link
Contributor Author

Perhaps it is not execute as this also does not work:

trans_qc = transpile(qc, backend, initial_layout=qubits)

backend.run(trans_qc, shots=1000).result().get_counts()

sum(raw_counts.values())

also gives 1024.

@mtreinish
Copy link
Member

It's a bug (a pretty obvious one) in the base fake backend class: https://github.com/Qiskit/qiskit-terra/blob/main/qiskit/test/mock/fake_backend.py#L151 is missing a **kwargs so none of the runtime options are getting passed through.

@nonhermitian
Copy link
Contributor Author

Hmm, this also does not work:

sim = Aer.aer.get_backend('qasm_simulator')

trans_qc = transpile(qc, sim)

sim.run(trans_qc, shots=1000).result().get_counts()

sum(raw_counts.values())

gives 1024.

Perhaps a second bug?

@nonhermitian
Copy link
Contributor Author

nonhermitian commented Jul 14, 2021

Ahh scratch the above, not setting the variable of raw_counts. Was thinking it was an Aer issue because of that.

@mtreinish mtreinish added the stable backport potential The bug might be minimal and/or import enough to be port to stable label Jul 14, 2021
@mergify mergify bot closed this as completed in #6743 Jul 14, 2021
@kdk kdk added this to the 0.19 milestone Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants