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

✨ Statevector after partial measurement #286

Open
mhinkie opened this issue Aug 30, 2023 · 2 comments
Open

✨ Statevector after partial measurement #286

mhinkie opened this issue Aug 30, 2023 · 2 comments
Milestone

Comments

@mhinkie
Copy link

mhinkie commented Aug 30, 2023

What's the problem this feature will solve?

Add the possibility to extract the statevector after a partial measurement of the quantum circuit.

Context:
Qiskit's Aer simulator allows extracting the statevector after measuring a subset of the qubits in the quantum circuit. Since the measurement outcome is random, it will pick one possible outcome of the partial measurement at random and return the resulting statevector after the measurement.

Small example that illustrates this behavior:

from qiskit import *
from mqt import ddsim

reg = QuantumRegister(2)
clreg = ClassicalRegister(2)

circ = QuantumCircuit(reg, clreg)
circ.h(reg[0])
circ.cx(reg[0], reg[1])
circ.measure(reg[0], clreg[0])

print(circ.draw(fold=-1))

backend = ddsim.DDSIMProvider().get_backend("statevector_simulator")

job = execute(circ, backend, shots=1000)
counts = job.result().get_counts(circ)
sv = job.result().get_statevector(circ)
print("DDSIM Statevector", sv)
print("DDSIM Counts", counts)

backend_aer = Aer.get_backend("aer_simulator")
tcirc = transpile(circ, backend_aer)
tcirc.save_statevector()
job = execute(tcirc, backend_aer, shots=1000)
counts = job.result().get_counts(tcirc)
sv = job.result().get_statevector(tcirc)
print("Aer Statevector", sv)
print("Aer Counts", counts)

The output DDSIM Statevector will always be $1/\sqrt{2} (|00\rangle + |11\rangle)$. The output Aer Statevector will alternate between $|00\rangle$ and $|11\rangle$ since these are the possible statevectors after the first qubit was measured.

Describe the solution you'd like

Since there is no one and only "correct" way, how the statevector should look like in the above scenario, I'd propose allowing both possbilities s.t. users can chose depending on their application area. So it might be possible to add a flag (maybe at the time of initializiation of the backend) that chooses the behavior.

@mhinkie
Copy link
Author

mhinkie commented Aug 30, 2023

One thing that is also not quite clear is how Qiskit chooses which statevector to return: Either by the measurement probability or with equal probability.

Or maybe it is possible to return all of them?

@burgholzer
Copy link
Member

Thanks for the feature request. It should certainly be possible to get that working.
I'll get back to you on that 👍🏻

@burgholzer burgholzer added this to the DDSIM 2.0 milestone Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Status: Todo
Development

No branches or pull requests

2 participants