I want to do a simulation involving:

  1. mid-circuit measurement (i.e. based on the measurement result of some qubits to append further gates on other qubits; e.g., Pauli error correction in entanglement swapping)
  2. initialize the circuit with a general density matrix (i.e., initialize a circuit with a mixed state)

I have tried three frameworks: Qiskit, Cirq, and QuTip. These are my observations (might be wrong)

  1. Qiskit: support mid-circuit measurement, but does not support initialization by density matrix

  2. Cirq: support both.

  3. QuTip: does not support mid-circuit measurement, but supports initialization by density matrix.

So, I used Cirq to do the simulation. However, I found that initialization by density matrix leads to results whose density matrix's trace < 1. I was wondering if I mistake something. As far as I know, initializing a circuit with a density matrix is quite complex, requiring ancilla qubits. It seems that having a line of code to do such a thing is too good to be true?

Besides these frameworks, do you know any frameworks that can do the above two things? Thanks very much for your time!

P.S. If you are curious about what I am trying to do: If we have $n$ Bell pairs, we can do Bell state measurement (or so-called entanglement swapping) $n-1$ times to generate one single Bell pair. This involves mid-circuit measurement and initialization with a density matrix to be memory-efficient.


1 Answer 1


According to my investigation and experiments, we cannot initialize a circuit with mixed state density matrix trivially. Finally, I used QuTip to perform the simulation and succeeded.

Please be critical of my following words, since it might be wrong. 

If you use mixed state density matrix to initialize a circuit with

  1. Qiskit, it will check whether it is a pure state or mixed state and raised error for the latter.
  2. Cirq, it will not raise any error, but I found that the density matrix corrupts (i.e. trace not equal to 1 and raise error) after some noisy gates.
  3. QuTip, it is actually not a circuit-level simulator. But it can serve as a last resort for any wired simulation requirements. The cost is the speed and memory space.

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.