5

I come from a CS background

I was reading Neven and Farhi's paper ("Classification with Quantum Neural Networks on near Term Processors"), and I am trying to implement the subset parity problem using Qiskit, and solve it using a quantum Neural Network.

There is one thing that doesn't make sense to me though. In the paper, they measure "the Pauli Y gate on the readout qubit" (perhaps this phrasing is wrong, as I have to admit that whenever one does not measure in the computational basis, the whole thing doesn't make sense to me anymore). In one of the questions I already asked on this site, I was told that measuring in a basis other than the computational basis is simply the same as applying a matrix to the qubit and then measuring it in a computational basis.

Through various research, I was able to determine that, for this problem "to measure the Pauli Y gate the readout qubit", I had to apply $HS^{\dagger}$ and then measure in the computational basis in order to obtain the same result. It works, but I don't understand why it has to be this matrix in particular (is there any mathematical proof that shows that this is indeed this matrix ?)

glS
  • 27,510
  • 7
  • 37
  • 125
Skyris
  • 167
  • 2
  • 12

3 Answers3

6

Your normal measurement is a pauli-$Z$ measurement. If you apply a unitary $U$ just before measurement, this transforms the $Z$ measurement into $U^\dagger ZU$. So, any $U$ that transforms $U^\dagger ZU=Y$ will do the job. One convenient way of doing this is $$ \frac{Y+Z}{\sqrt{2}}, $$ but your choice will also work: $$ SHZHS^\dagger=SXS^\dagger=-iS^2X=-iZX=Y $$

If you want to know why it's the transformation $U^\dagger ZU$, well think about a circuit with input $|\psi\rangle$ that has a unitary $U$ enacted upon it, and then it's measured in the standard basis. The probability of getting the 0 answer is $$ |\langle 0|U|\psi\rangle|^2, $$ which is the same as the probability that $|\psi\rangle$ is in the state $U^\dagger|0\rangle$. This corresponds to a measurement projector $U^\dagger |0\rangle\langle 0|U$, so you can see that transformation starting to come out.

DaftWullie
  • 62,671
  • 4
  • 55
  • 140
4

Measurement in $Y$ basis means that we want to measure is the qubit in $|+i\rangle$ state or $|-i\rangle$ state which are eigenbasis vectors for $Y$ gate. Because they are eigenbasis vectors we can express any $|\psi_1 \rangle$ state in this form:

$$| \psi_1 \rangle = \alpha_{+i} |+i\rangle + \alpha_{-i} |-i\rangle$$

where $|\alpha_{+i}|^2$ is the probability of measuring $|+i\rangle$ state and $|\alpha_{-i}|^2$ is the probability of measuring $|-i\rangle$. And

\begin{equation} |+i\rangle = |0\rangle + i |1\rangle \qquad |-i\rangle = |0\rangle - i |1\rangle \end{equation}

Now when we apply $HS^{\dagger}$ to $|\psi_1 \rangle$ state, we will obtain:

$$| \psi_2 \rangle = \alpha_{+i} |0\rangle + \alpha_{-i} |1\rangle$$

Then, with $|\alpha_{+i}|^2$ we will measure $|0\rangle$ (the same probability that we had for $|+i \rangle$ measurment in the initial $|\psi_1\rangle$), and with with $|\alpha_{-i}|^2$ we will measure $|1\rangle$ (the same probability that we had for $| -i \rangle$ measurment in the initial $|\psi_1\rangle$). For any gate that will do $U |+i\rangle = e^{i \varphi_1} |0\rangle$ and $U |-i\rangle = e^{i \varphi_2}|1\rangle$ mapping (where $\varphi_1$ and $\varphi_2$ are some phases that will not have any influence on probabilities), we will have this correspondence. For example, if I understand this Riggeti's code right, they are doing $Y$ basis measurement by applying firstly $U = R_x(\pi /2)$ gate that maps $R_x(\pi /2) |+i\rangle = |0\rangle$ and $R_x(\pi /2) |-i\rangle = -i|1\rangle$.

The other thing is to measure the expectation value of $Y$ operator:

$$\langle \psi_1 | Y | \psi_1 \rangle = |\alpha_{+i}|^2 - |\alpha_{-i}|^2$$

that can easily be calculated after enough measurements in the $Y$ basis. Here we took into accout that $Y|+i\rangle = (+1)|+i\rangle$ and $Y|-i\rangle = (-1)|-i\rangle$. $|\alpha_{+i}|^2 = \frac{N_{+i}}{N}$ and $|\alpha_{-i}|^2 = \frac{N_{-i}}{N}$, where $N$ is the number of measurements, $N_{+i}$ is the number of $| +i \rangle$ measurements, and $N_{-i}$ is the number of $| -i \rangle$ measurements.

I guess in the paper they mean expectation value of $Y$ operator, not just one simple measurement in the $Y$ basis, because of this line "Our predicted label value is the real number between $−1$ and $1$... which is the average of the observed outcomes if $Y_{n+1}$ is measured in multiple copies of...".

Davit Khachatryan
  • 4,461
  • 1
  • 11
  • 22
2

Although, correct answers are already posted here, I would like to offer a visual proof by using Bloch sphere. $\def\ket#1{\left\lvert#1\right\rangle} \def\bra#1{\left\langle#1\right\rvert}$

Measuring in $Z$ basis means that after measurement, the state is either $\ket0$ or $\ket1$. Similarly, measuring in $Y$ basis means measuring in $\left\{\ket{+i},\ket{-i}\right\}$ basis.

If we can map $\ket{+i}$ to $\ket0$ and map $\ket{-i}$ to $\ket1$ using an unitary operation, then measuring in computational basis is equivalent to measuring in $Y$ basis. We need not worry about the phase since it will not be observable anyway once we measure in the computational basis.

$$U\ket{+i}=e^{i\phi_0}\ket0$$ $$U\ket{-i}=e^{i\phi_1}\ket1$$

Now, how can we find such a $U$? Since we have a choice for the phases, $U$ is not unique. Let's use Bloch sphere visualization to find one such $U$.

If we apply $S^\dagger$ on $\ket{+i}$, it will rotate $90^\circ$ in clockwise direction and land on $\ket+$. Similarly, $\ket{-i}$ will land on $\ket-$. In other words, measuring $\ket\psi$ in $Y$ basis is the same as measuring $S^\dagger\ket\psi$ in $X$ basis.

Now, if we apply a Hadamard gate, we can convert a $X$ basis measurement to $Z$ basis measurement (and vice versa). In Bloch sphere, $H$ just rotates any state $180^\circ$ along the axis that bisects the $Z$ and $X$ axis. So, measuring $\ket\psi$ in $Y$ basis is the same as measuring $HS^\dagger\ket\psi$ in $Z$ basis.

$\ket{+i} \leftarrow S^\dagger \leftarrow H$ $\ket{+i} \leftarrow \left(HS^\dagger\right) $
H on S† on +i state HS† on +i state

The purple line is the eigenspace of $HS^\dagger$. Notice that it is equidistant from all three ($X,Y,Z$) axes. It rotates the Bloch sphere by $\frac{2\pi}{3}$ radian.

An alternative option for $U$ could be $\frac{Y+Z}{\sqrt2}$. It also maps $\ket{+i}$ to $\ket0$ (as seen in the image). Contrary to the previous method, this time, the eigenspace (purple line) now lies in the $YZ$ plane and is equidistant from $Y$ and $Z$ axis. This operator rotates the Bloch sphere by $\pi$ radian.

(Y+Z)/sqrt2 on +i

Although I haven't mentioned, but since unitary operations maps orthogonal statevectors to other orthogonal statevectors, $\ket{-i}$ will land on $\ket1$ for any such $U$.

As you can imagine there are infinitely many choices for $U$ which maps $\ket{+i}$ to $\ket0$. And so, there are many different choices to $U$. Generally, $U$ can be written as: $$U = e^{i\phi_0}\ket{0}\bra{+i} + e^{i\phi_1}\ket{1}\bra{-i}$$

In fact, even if we mapped $\ket{+i}$ to $\ket1$, measuring in $Z$ basis would have been equivalent to $Y$ basis (i.e. $XU$ also works). We just need to invert the result at the end.

Shawon
  • 71
  • 3