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

Mapping Error in BasicAer #1583

Closed
dcmckayibm opened this issue Dec 22, 2018 · 3 comments · Fixed by #1624
Closed

Mapping Error in BasicAer #1583

dcmckayibm opened this issue Dec 22, 2018 · 3 comments · Fixed by #1624
Assignees
Labels
bug Something isn't working

Comments

@dcmckayibm
Copy link
Member

'OPENQASM 2.0;\ninclude "qelib1.inc";\nqreg q0[5];\ncreg c0[3];\nx q0[4];\nmeasure q0[1] -> c0[0];\nmeasure q0[3] -> c0[1];\nmeasure q0[4] -> c0[2];\n'

The above qasm should give all shots in 100, but they are all in 000. Only happens in BasicAer, not in Aer.

Informations

  • Qiskit Terra version: 0.7
  • Python version: 3.6
  • Operating system:

What is the current behavior?

Steps to reproduce the problem

What is the expected behavior?

Suggested solutions

@dcmckayibm dcmckayibm changed the title Mapping Error in BasicQasm Mapping Error in BasicAer Dec 22, 2018
@jaygambetta
Copy link
Member

jaygambetta commented Dec 22, 2018

I confirm there is a bug

qr = QuantumRegister(5)
cr = ClassicalRegister(3)
circuit = QuantumCircuit(qr, cr)
circuit.x(qr[4])
circuit.measure(qr[1], cr[0])
circuit.measure(qr[3], cr[1])
circuit.measure(qr[4], cr[2])

backend = BasicAer.get_backend('qasm_simulator')
job = execute(circuit, backend)
result = job.result()
counts1 = result.get_counts()
print(counts1)

backend = Aer.get_backend('qasm_simulator')
job = execute(circuit, backend)
result = job.result()
counts2 = result.get_counts()
print(counts2)

gives the outcome david is saying.

{'000': 1024}
{'100': 1024}

@jaygambetta
Copy link
Member

@chriseclectic can you have a look at this.

@jaygambetta jaygambetta added the bug Something isn't working label Dec 22, 2018
@ajavadia
Copy link
Member

The bug is in the BasicAer python simulator. Specifically it is occurring in the _add_sample_measure function, which is responsible for finding a probability distribution from the statevector and sampling from that. This function cannot handle the case where only a subset of the total qubits are measured.

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

Successfully merging a pull request may close this issue.

4 participants