Skip to content

✨ Statevector after partial measurement  #286

@mhinkie

Description

@mhinkie

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions