munich-quantum-toolkit / munich-quantum-toolkit/ddsim
✨ Statevector after partial measurement
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 162
- Forks
- 40
- Avg merge
- 4h 49m
- Merged PRs (30d)
- 40
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the statevector_simulator backend behavior around execute(), get_statevector(), and backend initialization. Compare the described DDSIM and Aer outcomes, then determine how an option for partial-measurement statevectors should be exposed and what result behavior should confirm the feature.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100