Questions on QGAN tutorial

Hello, I have some questions about Quantum GAN. For point (3) Non-Linear Transform, I did not know why we could add the ancilla qubit to create the non-linear transformation. Another question is, don’t we lose the critical information of the image while tracing out the ancilla qubit?

Thanks.

Hi @mini, thanks for the question :slight_smile:

Strictly speaking, it’s not necessary to include a non-linear transformation here. The author of this demo likely included it as it’s one way to make the model “more interesting”.

Adding an ancilla qubit alone is not enough to make the quantum process nonlinear. It’s the fact that we make a measurement that causes this (as the author says, the resulting state depends on the variable z in both the numerator and the denominator, making a nonlinear dependence on z. One could also add a measurement on the non-ancilla qubits, but this would consume them. Instead, we can use an ancilla to give us something to measure without changing the number of working qubits our model uses.

As for your second question, one of the goals of introducing a nonlinearity into a (Q)ML model is in fact to lose information. For example, we may need to go down from a very high-dimensional object (an image), to a single number (prediction for the class of that image). This requires throwing away some information! The task of machine learning is to train your model (in this case, a quantum circuit) to only throw away information that is not useful, while keeping critical information that is useful for making the final prediction.

Hope this helps :slight_smile:

Hello, I’m new to quantum theory and I’m interested in the derivation of the expression for the post-measurement reduced density matrix for the nonlinear transform:

\rho(\boldsymbol{z}) = \frac{\text{Tr}_\mathcal{A}(\Pi \otimes \mathbb{I}|\Psi(\boldsymbol{z})\rangle \langle\Psi(\boldsymbol{z})|)}{\text{Tr}(\Pi \otimes \mathbb{I} |\Psi(\boldsymbol{z})\rangle \langle \Psi(\boldsymbol{z})|)}.

From what I understand, after performing the partial measurement, the post-measurement density matrix (before tracing out \mathcal{A}) is given by:

\frac{(\Pi \otimes \mathbb{I})|\Psi(\boldsymbol{z})\rangle \langle\Psi(\boldsymbol{z})|(\Pi \otimes \mathbb{I})}{\text{Tr} (\Pi \otimes \mathbb{I}|\Psi(\boldsymbol{z})\rangle \langle\Psi(\boldsymbol{z})|)}.

Tracing out \mathcal{A}, we get:

\text{Tr}_\mathcal{A} \left( \frac{(\Pi \otimes \mathbb{I})|\Psi(\boldsymbol{z})\rangle \langle\Psi(\boldsymbol{z})|(\Pi \otimes \mathbb{I})}{\text{Tr} (\Pi \otimes \mathbb{I}|\Psi(\boldsymbol{z})\rangle \langle\Psi(\boldsymbol{z})|)} \right).

If the post-measurement non-reduced density matrix expression is correct, why does the following equality hold?

\text{Tr}_\mathcal{A} \left( \frac{(\Pi \otimes \mathbb{I})|\Psi(\boldsymbol{z})\rangle \langle\Psi(\boldsymbol{z})|(\Pi \otimes \mathbb{I})}{\text{Tr} (\Pi \otimes \mathbb{I}|\Psi(\boldsymbol{z})\rangle \langle\Psi(\boldsymbol{z})|)} \right) = \frac{\text{Tr}_\mathcal{A}(\Pi \otimes \mathbb{I}|\Psi(\boldsymbol{z})\rangle \langle\Psi(\boldsymbol{z})|)}{\text{Tr}(\Pi \otimes \mathbb{I} |\Psi(\boldsymbol{z})\rangle \langle \Psi(\boldsymbol{z})|)} .

Many thanks!

Hi @sotskopa,

Welcome to the Forum!
I’ll forward this question to the team. We’ll get back to you in the next couple of days.

Hello! @sotskopa

Actually they seem to have skipped a few steps there :sweat_smile:

The partial trace is linear, so the denominator can be brought out of the trace. The denominator is just a number, after all! The partial trace also has the cyclic property, that is

\text{Tr}_{\mathcal{A}}(ABC) = \text{Tr}_{\mathcal{A}}(CAB) = \text{Tr}_{\mathcal{A}}(BCA).

This means that you can rearrange

\text{Tr}_{\mathcal{A}}(\Pi\otimes \mathbb{I} |\Psi (z)\rangle\langle \Psi (z)| \Pi\otimes \mathbb{I}) = \text{Tr}_{\mathcal{A}}((\Pi\otimes \mathbb{I})^2 |\Psi (z)\rangle\langle \Psi (z)|).

Since \Pi\otimes \mathbb{I} is a projection, and for all projections P it is true that P^2 = P, you can simplify the above and get the final result.

Hope this helps!

Alvaro

1 Like

Hello @Alvaro_Ballon,

Thanks for explaining the expression; it makes more sense to me now! Just one follow-up question about the cyclic property of the partial trace: for which operators does the cyclicity hold? I tried experimenting with two random density matrices \rho_1 and \rho_2, but it seems the partial trace is different.

import numpy as np
import pennylane as qml


def random_statevector(dim):
    rng = np.random.default_rng()
    vec = rng.standard_normal(dim).astype(complex)
    vec += 1j * rng.standard_normal(dim)
    vec /= np.linalg.norm(vec)
    return vec


# Set the number of qubits
n = 2

# Prepare some state vectors
state1 = random_statevector(2**n)
state2 = random_statevector(2**n)

# Create density matrices
rho1 = np.outer(state1, state1.conj())
rho2 = np.outer(state2, state2.conj())

# Trace out the first qubit of the cyclic permutations
reduced1 = qml.math.partial_trace(rho1 @ rho2, indices=[0])
reduced2 = qml.math.partial_trace(rho2 @ rho1, indices=[0])

print(np.allclose(reduced1, reduced2))  # False

Thanks again for your help!

Hello @sotskopa

Yes, I wasn’t precise enough. For this cyclic property to work, the operator must act on one of the subsystems. That is, it has to be of the form A\otimes\mathbb{I} or \mathbb{I}\otimes B. Unfortunately, the best source I have on this is this Stack Exchange post. It does seem to have the correct argument though.

Cheers,

Alvaro

1 Like