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 returns incorrect duplicate results #9093

Closed
kevinsung opened this issue Nov 7, 2022 · 1 comment
Closed

Sampler returns incorrect duplicate results #9093

kevinsung opened this issue Nov 7, 2022 · 1 comment
Assignees
Labels
bug Something isn't working mod: primitives Related to the Primitives module

Comments

@kevinsung
Copy link
Contributor

kevinsung commented Nov 7, 2022

Environment

  • Qiskit Terra version: 3ce1737
  • Python version: 3.10.7
  • Operating system: Fedora 36

What is happening?

I pass 8 different circuits to Sampler. Using the old deprecated syntax, the sampler correctly returns 8 unique distributions. Using the new syntax, only 2 unique distributions are returned, which is obviously wrong.

How can we reproduce the issue?

circuits.zip

from qiskit import qpy
from qiskit.primitives import Sampler


def unique(items):
    unique_items = []
    for item in items:
        if not any(item == x for x in unique_items):
            unique_items.append(item)
    return unique_items


with open("circuits.qpy", "rb") as f:
    circuits = qpy.load(f)

# deprecated syntax
with Sampler(circuits=circuits) as sampler:
    sampler_result = sampler(circuits=range(len(circuits)))
    quasi_dists_1 = sampler_result.quasi_dists

# updated syntax
sampler = Sampler()
sampler_result = sampler.run(circuits).result()
quasi_dists_2 = sampler_result.quasi_dists

# results differ
print(len(unique(quasi_dists_1)))  # prints 8
print(len(unique(quasi_dists_2)))  # prints 2

What should happen?

The sampler should return the correct results.

Any suggestions?

No response

@kevinsung kevinsung added the bug Something isn't working label Nov 7, 2022
@kevinsung kevinsung changed the title Sampler returns results in incorrect order Sampler returns incorrect duplicate results Nov 8, 2022
@woodsp-ibm woodsp-ibm added the mod: primitives Related to the Primitives module label Nov 8, 2022
@t-imamichi
Copy link
Member

I close this because Primitives V1 is deprecated #12575

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mod: primitives Related to the Primitives module
Projects
None yet
Development

No branches or pull requests

4 participants