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

StatevectorSampler reuses the same seed for all PUBs #13730

Open
tnemoz opened this issue Jan 24, 2025 · 0 comments
Open

StatevectorSampler reuses the same seed for all PUBs #13730

tnemoz opened this issue Jan 24, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@tnemoz
Copy link
Contributor

tnemoz commented Jan 24, 2025

Environment

  • Qiskit version:
    1.3.0
  • Python version:
    3.10.10
  • Operating system:
    Ubuntu

What is happening?

When initialized with a seed, StatevectorSampler will reuse the same seed for all PUBs instead of generating a RNG once using this seed and then sticking to it. This causes undesired behaviors when running (close to) identical PUBs.

How can we reproduce the issue?

from qiskit import QuantumCircuit
from qiskit.primitives import StatevectorSampler

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

sampler = StatevectorSampler(seed=42)
res = sampler.run([(qc, None, 1) for _ in range(10)]).result()

for r in res:
    print(r.data.meas.get_int_counts())

What should happen?

The code should instantiate a RNG once using the provided seed and then generate subsequent random numbers using this generator for all PUBs without re-instantiate it with the provided seed, so that the experiment is reproducible, but results between PUBs are not correlated.

Any suggestions?

It's definitely a niche problem, that I noticed because I had to run identical QuantumCircuits among different PUBs, so I'd understand if this isn't fixed.

@tnemoz tnemoz added the bug Something isn't working label Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant