2
$\begingroup$

When simulating a circuit using qasm simulator, if there is a depolarizing channel in the noise model, then the results could be mixed states. How can I calculate the density matrix of the mixed states?

$\endgroup$

1 Answer 1

3
$\begingroup$

The easiest way to do this would be to probably use the density matrix snapshot instruction: https://qiskit.org/documentation/stubs/qiskit.providers.aer.extensions.SnapshotDensityMatrix.html#qiskit.providers.aer.extensions.SnapshotDensityMatrix basically just add circuit.snapshot_density_matrix('density_matrix') to your circuit where you want to get the density matrix. That will store the density matrix in the output results. Here is an example script:

from qiskit.test.mock import FakeVigo
from qiskit import QuantumCircuit
from qiskit.providers.aer import extensions  # import aer snapshot instructions
from qiskit import execute


qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.snapshot_density_matrix('density_matrix')
result = execute(qc, FakeVigo()).result()
# Extract density matrix snapshot from result object:
density_matrix = result.data()['snapshots']['density_matrix']['density_matrix'][0]['value']
print(density_matrix)

In that script FakeVigo is just running Aer under the covers with a noise model taken from a snapshot of the backend properties from the IBMQ vigo device.

$\endgroup$
4
  • $\begingroup$ nice answer +1. I am sure the OP appreciate your input/answer. Can you elaborate a bit more on the built in noise model? Is it being changed from time to time or is it just a fixed model based off from the hardware calibration of some sort? $\endgroup$
    – KAJ226
    Commented Feb 7, 2021 at 4:51
  • $\begingroup$ In that example script? The noise model there is built from a snapshot of the calibration properties returned via the IBMQ api. It just uses Aer's NoiseModel.from_backend method to build the noise model which includes 1 and 2 qubit gate depolarization and thermal relaxation errors, and readout errors: qiskit.org/documentation/stubs/… $\endgroup$ Commented Feb 7, 2021 at 15:36
  • $\begingroup$ If you're using a real backend with the qiskit-ibmq-provider then the noise model built with NoiseModel.from_backend with that backend will be using the latest calibration data (it's updated once a day iirc) returned by backend.properties() (unless you manually build it from a previous calibration). I only used the fake backend in the example because the fake backends are always available, even without credentials, and just contain a fixed snapshot that was committed to the qiskit repo. $\endgroup$ Commented Feb 7, 2021 at 15:41
  • $\begingroup$ Thanks! Got it. Yes, I was preferring to when using real backend with qiskit-ibmq-provider. I asked because I think the noise in these devices fluctuates and wondering how often you guys changes the noise model to keep up with it. $\endgroup$
    – KAJ226
    Commented Feb 7, 2021 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.