1
$\begingroup$

I am an electrical engineer and am learning about quantum computing. I am writing a simulator in Python to help with the learning process.

The code that I have can simulate up to 10 qubits. I have (so far) implemented the CNOT gate along with most of the single qubit gates.

My computed final state vectors match with those from the IBM Quantum Composer, so I am encouraged that I'm on the right track.

Quantum Composer shows the amount of entanglement for each qubit in a circuit, and this is the part that I'm having a lot of difficulty figuring out. IBM has given clues to how they do it, but it's very confusing to me due to my lack of education in this subject. See the first image below for their description.

I am able to create the density matrix for my system, and from my reading it seems that partial traces of the density matrix are key to finding the per-qubit entanglement values.

For the circuit show below, IBM shows that qubits 0,2 and 3 are "maximally entangled" with values of 0.5 (shown on the right with the three smaller black circles), while qubit 1 has no entanglement with its value of 1.0 (the larger circle).

Could someone either describe the steps to find the per-qubit entanglement values or point me in the proper direction?

Thank you very much.

The four images below:

IBM's definition of measure of entanglement.

Circuit for three entangled qubits and one with no entanglement.

State vector for this circuit.

Probability amplitudes vs basis state (in a bar graph).

IBM's definition of measure of entanglement Circuit for three entangled qubits and one with no entanglement State vector for this circuit Probability amplitudes vs basis state (in a bar graph)

$\endgroup$

3 Answers 3

3
$\begingroup$

The entanglement measure that you quote from IBM is equivalent to the "linear entropy" of the reduced system. The idea is that, if you have a pure quantum state and you trace out one of the subsystems, the resulting state will be pure if the original state had no entanglement. Conversely, if the resulting state is not pure, you know the original state was entangled. A drawback of this method is that it requires the overall original state to be pure.

This can be seen from an example. If the state is of the form $|\psi\rangle_0\otimes |\phi\rangle_1$, tracing out system $1$ leaves the system in state $|\psi\rangle_0$, which is pure. If the state is of the form $\left(|\uparrow\rangle_0\otimes|\downarrow\rangle_1+|\downarrow\rangle_0\otimes|\uparrow\rangle_1\right)/\sqrt{2}$, tracing out system $1$ leaves the system in the mixed state $\left(|\uparrow\rangle_0 \langle\uparrow|+ |\downarrow\rangle_0 \langle\downarrow|\right)/2$, which is maximally mixed.

So the requisite steps are: 1) tracing out extra degrees of freedom and 2) computing the purity of the resulting state.

  1. "Tracing out" degrees of freedom: We begin with writing the overall state $|\Psi\rangle$ as a density matrix $\rho=|\Psi\rangle\langle\Psi|$. This is like making a rank-one matrix out of a unit vector. Then we choose which subsystem we are interested in keeping and which one we want to trace out - the example says keep subsystem $j$ and trace out all subsystems with $i\neq j$, so let's keep system $0$ and trace out all the subsystems with $i\neq 0$. Note: some people use the notation $\mathrm{Tr}_i$ to mean "trace out subsystem $i$" and others use it to mean "trace out all but subsystem $i$." I am interpretting it as the former but I am not sure what IBM's convention is.

We need to know a set of orthonormal basis states for each subsystem. Since we are dealing with qubits, we know that subsystem $i$ has basis states $|0\rangle_i$ and $|1\rangle_i$, or something like $|\uparrow\rangle_i$ and $|\downarrow\rangle_i$ that I wrote before. The partial trace of $\rho$ with respect to system $i$ (in my notation, "tracing out subsystem $i$") is $$\mathrm{Tr}_i(\rho)=\vphantom{a}_i\langle 0|\rho|0\rangle_i+\vphantom{a}_i\langle 1|\rho|1\rangle_i .$$ In general, for basis states labeled by $|n\rangle_i$, tracing out subsystem $i$ is done by $$\mathrm{Tr}_i(\rho)=\sum_n \vphantom{a}_i\langle n|\rho|n\rangle_i.$$

This procedure can be repeated for tracing out all of the subsystems that are not of interest. In your case, I believe you want to trace out all of the other qubit degrees of freedom other than some $j$, then repeat the process for all $j$.

  1. Purity is rather straightforward: compute the trace of the square of the density matrix. So once you've gotten $\mathrm{Tr}_i(\rho)$, or maybe some cascaded thing like $$\mathrm{Tr}_1\{\mathrm{Tr}_2[\mathrm{Tr}_3(\rho)]\},$$ you square the matrix, take the trace, and voila! If the initial pure state was separable, of the form $|\Psi\rangle=|\psi_0\rangle_0\otimes |\psi_1\rangle_1\otimes\cdots |\psi_n\rangle_n$, then tracing out everything but subsystem $j$ leaves pure the density matrix $|\psi_j\rangle_j \langle \psi_j|_j$. If the initial pure state is entangled, the purity of the reduced state is less than unity.

Finding amounts of entanglement when the original state is itself mixed is much more nuanced, but does not seem to be the focus of your question.

$\endgroup$
1
  • 1
    $\begingroup$ Thanks! This is exactly what I was looking for. $\endgroup$ May 20, 2021 at 23:00
1
$\begingroup$

You should use an entanglement measure. An overview of these are in this paper.

In your case, you could try to use entropy of entanglement which quantifies the amount of uncertainty in a quantum state (always between 0 and 1).

  • If we know a state is classical then there's no uncertainty because we know the state of the system exactly i.e. entropy of entanglement is zero.
  • If the state is maximally entangled then entropy of entanglement is one because it's the maximum amount of uncertainty one can have about the state.

Another measure that could be useful is quantum mutual information.It quantifies the amount of correlations present in the state.

$\endgroup$
1
  • $\begingroup$ These papers would help but they're too complicated for my level. I am learning and some day I will be able to understand them better. Thanks for your response. $\endgroup$ May 21, 2021 at 0:28
0
$\begingroup$

Extracting the partial trace for each qubit and taking it's purity does not match the results when you measure the circuit histogram from qasm_simulator: Suppose this Bell state with a purity 0.5 for both qubits:

qc = QuantumCircuit(2,2)
qc.h(0)
qc.cx(0,1)

If I add this line: qc.ry(np.pi/4,0)
When you measure u get:
00 and 11 = 42 %
01 and 10 = 7 %
So It isn't maximally entangled because I expect that qubit 0 will always be the same measure as qubit 1 and purity stills 0.5.
So What I do is first compute the purity and if it's less than 1 then extract the dictionary counts from the statevector for compare one qubit with other:

rho = qi.DensityMatrix.from_instruction(qc)
rho_q = qi.partial_trace(rho,[numqubit])
p = rho_q.purity()   
if p < 1.0: entagle = QuantifyEntaglement(qc,0,1)

def QuantifyEntaglement(qc,iqa,iqb, bEntagleEqual=True):
    psi=qi.Statevector.from_instruction(qc)
    dic = psi.probabilities_dict()
    enta=0
    for key, value in dic.items(): 
        print(key, ' : ', value)                
        if key[iqa]==key[iqb]:
            enta +=value

    if not bEntagleEqual: enta = 1.0 - enta
    return enta

which returns 85 % of entaglement like the counts I get in the histogram.

$\endgroup$

Your Answer

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

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