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

Different default shot numbers for qiskit Sampler and BraketLocalBackend. #183

Open
maolinml opened this issue Jul 1, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@maolinml
Copy link
Collaborator

maolinml commented Jul 1, 2024

What is the expected enhancement?

The default shot number for qiskit’s Sampler is 0, whereas that for BraketLocalBackend is 1000, see the code example below. This could cause some confusion. Ideally, the default shot values should be the same.

from qiskit import QuantumCircuit
from qiskit_braket_provider import BraketLocalBackend
from qiskit.primitives import Sampler

circuit = QuantumCircuit(1)
circuit.h(0)
circuit.measure_all()

# Run with qiskit backend
Sampler().run(circuit).result().quasi_dists[0]

# Qiskit local backend return probability calculated 
# from state vector, which has no shot noise and the
# result is fixed for different runs
# {0: 0.5, 1: 0.5}

# Run with braket backend
BraketLocalBackend().run(circuit).result().results[0].data.counts

# Braket local backend return sampled probability with shot noise
# and the result vary from run to run
# {'1': 537, '0': 487}
@speller26
Copy link
Collaborator

I'm actually surprised that the sampler accepts 0 shots, and returns probabilities as the counts. In any case, the Braket provider doesn't have a native sampler, but just a classic Qiskit backend, which is a different interface. However, it might be worth considering writing native primitives in this package.

@maolinml
Copy link
Collaborator Author

I don't think we need a native sampler to resolve the discrepancy shown above. We can simply set the default shot to zero for "BraketLocalBackend().run(...)" and use the state vector simulator, right?

@shpface shpface added the enhancement New feature or request label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants