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

Sampler with shots=None does not calculate resets exactly #1811

Open
garrison opened this issue May 14, 2023 · 1 comment
Open

Sampler with shots=None does not calculate resets exactly #1811

garrison opened this issue May 14, 2023 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@garrison
Copy link
Member

garrison commented May 14, 2023

Informations

  • Qiskit Aer version:
  • Python version:
  • Operating system:

What is the current behavior?

A circuit with reset operation(s) is not guaranteed to be deterministic when shots=None, a setting which is supposed to cause probabilities to be calculated exactly.

Steps to reproduce the problem

from qiskit_aer.primitives import Sampler as AerSampler
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.reset(0)
qc.measure(0, 0)
qc.measure(1, 1)
AerSampler().run(qc, shots=None).result().quasi_dists

is not deterministic. The last line evaluates to (on successive runs):

  • [{0: 0.5166015625, 2: 0.4833984375}]
  • [{0: 0.4833984375, 2: 0.5166015625}]
  • [{0: 0.505859375, 2: 0.494140625}]

What is the expected behavior?

Should evaluate to [{0: 0.5, 2: 0.5}]

Suggested solutions

[none]

Similar to #1810, I have created my own Sampler implementation based on Qiskit Terra's Statevector that supports resets exactly: https://github.com/Qiskit-Extensions/circuit-knitting-toolbox/blob/main/circuit_knitting_toolbox/utils/simulation.py

@hhorii
Copy link
Collaborator

hhorii commented May 22, 2023

I roughly read simulation.py. Here is my understanding:

  • If measure or reset come, a Statevector is coped to two Statevector to simulate two cases when 0 and 1 are measured,
  • c_if is not supported

This is very similar to #1766 (and #1766 supports c_if and other control-flow operations). We would like to re-think this issue after merging #1766.

@hhorii hhorii added this to the Aer 0.13.0 milestone May 25, 2023
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

3 participants