Skip to content

Entanglement#

As one of the fundamental aspects of quantum computing, entanglement plays also an important role in quantum machine learning. Our package offers various methods for calculating the entangling capability of a particular model.

Meyer-Wallach#

In the simplest case, using the Meyer-Wallach measure, this could look as follows:

from qml_essentials.model import Model
from qml_essentials.entanglement import Entanglement

model = Model(
            n_qubits=2,
            n_layers=1,
            circuit_type="Hardware_Efficient",
        )

ent_cap = Entanglement.meyer_wallach(
    model, n_samples=1000, random_key=jax.random.key(1000)
)

Here, n_samples is the number of samples for the parameters, sampled according to the default initialization strategy of the model, and random_key is an optional JAX random key for parameter initialization. If not provided, the model's internal random key is used.

Note, that every function in this class accepts keyword-arguments which are being passed to the model call, so you could e.g. enable caching by

ent_cap = Entanglement.meyer_wallach(
    model, n_samples=1000, random_key=jax.random.key(1000)
)

If you set n_samples=None, we will use the currently stored parameters of the model to estimate the degree of entanglement.

Bell-Measurement#

An alternate method for calculating the entangling capability is the Bell-Measurement method. We can utilize this by

ent_cap = Entanglement.bell_measurements(
    model, n_samples=1000, random_key=jax.random.key(1000)
)

Mean Negativity#

For pure and mixed states, mean_negativity averages the negativity across each qubit-versus-rest partition and normalizes the result to \([0,1]\):

\[ \overline{\mathcal{N}}(\rho)=\frac{2}{n}\sum_{k=0}^{n-1}\mathcal{N}_k(\rho), \qquad \mathcal{N}_k(\rho)=\frac{\|\rho^{T_k}\|_1-1}{2}. \]

Here \(T_k\) denotes the partial transpose on qubit \(k\). Each negativity is the sum of the absolute values of the negative eigenvalues of \(\rho^{T_k}\), following Vidal and Werner.

ent_cap = Entanglement.mean_negativity(
    model, n_samples=1000, random_key=jax.random.key(1000), noise_params={"BitFlip": 0.1}
)

You can compute the mean logarithmic negativity instead by setting log=True:

ent_cap = Entanglement.mean_negativity(model, n_samples=None, log=True)
\[ \overline{E}_{\mathcal{N}}(\rho)=\frac{1}{n}\sum_{k=0}^{n-1}\log_2(1+2\mathcal{N}_k(\rho)). \]

The logarithm is applied to each partition of each output state before averaging. Note that this generally differs from taking \(\log_2(1+\overline{\mathcal{N}})\) after averaging (hence this flag).

The method averages the metric over the output states, rather than evaluating their averaged density matrix. Set n_samples=None or a nonpositive value to use the current parameters. If scale is set to True, the sample count is multiplied by \(2^n\).

Fully separable states give zero, while Bell and GHZ states give one. Note that, this metric differs from Meyer-Wallach even for pure states as zero does not exclude entanglement with positive partial transpose (PPT), according to the Separability Criterion for Density Matrices. In contrast, a positive value, does not establish genuine multipartite entanglement.

This metric allows to be used in a noisy and noiseless setting.

Relative Entropy#

While calculating entanglement using the Meyer-Wallach or Bell-Measurements method works great for noiseless circuits, it won't result in the correct values when being used together with incoherent noise. To account for this, you can use the Relative Entropy method as follows:

ent_cap = Entanglement.relative_entropy(
    model, n_samples=1000, n_sigmas=10, random_key=jax.random.key(1000), noise_params={"BitFlip": 0.1}
)

Note that this method takes an additional parameter n_sigmas, which is the number of density matrices of the next separable state that we use for comparison. The runtime scales with n_sigmas\(\times\)n_samples and both increase exponentially if scale=True is set.

Internally, we compare the states, obtained from the PQC, against those from a GHZ state of the same size (which we consider the next separable state). This approach is explained in detail in this paper and illustrated in the following figure:

Relative Entropy

Entanglement of Formation#

Another possibility to compute the entanglement of a noisy circuit is the Entanglement of Formation. Similar to the relative entropy of entanglement, this measure presents an approximation, and can be used via:

ent_cap = Entanglement.entanglement_of_formation(
    model, n_samples=1000, random_key=jax.random.key(1000), noise_params={"BitFlip": 0.1}
)

For a technical description we refer to the review by Plenio and Virmani. The general idea is that a mixed state gets decomposed into pure states with respective probabilities using the eigendecomposition of the density matrix. Then, entanglement is computed for each pure state, weighted by the eigenvalue. In our implementation, we use the Meyer-Wallach measure for this purpose.

Note however, that the decomposition is not unique! Therefore, this measure presents the entanglement for some decomposition into pure states, not necessarily the one that is anticipated when applying the Kraus channels. This becomes particularly evident, when computing the entanglement of a noisy GHZ-circuit. To prevent unintended decompositions for pure states, the methods of EF and Meyer-Wallach are equivalent for these.

Concentratable Entanglement#

This measure, introduced in Computable and operationally meaningful multipartite entanglement measures, utilizes a parallelized SWAP test to compute the entanglement of a given model with the advantage of having only a constant depth circuit while not requiring access to the density matrix.

ent_cap = Entanglement.concentratable_entanglement(
    model, n_samples=1000, random_key=jax.random.key(1000)
)

The same quantity can also be obtained from a Bell-basis measurement instead of the ancilla-based SWAP test, via concentratable_entanglement_estimation:

ent_cap = Entanglement.concentratable_entanglement_estimation(
    model, n_samples=1000, random_key=jax.random.key(1000)
)

Here the concentratable entanglement is read off from the expectation value of a Bell-basis observable rather than from the overlap measured on an ancilla register.