1
$\begingroup$

I'm trying to test Clifford gates in qiskit according to the table in Fault-tolerant SQ, page 101. I tried 4 Cliffords in the test $$-X/2 - X -X/2,Y/2,X/2 - -X/2,Y/2,-X/2$$

using the following code

import numpy as np
from qiskit import QuantumCircuit, Aer, execute
from qiskit.quantum_info import Operator

qc = QuantumCircuit(1) 

qc.rx(-np.pi/2, 0)
qc.rx(np.pi, 0)
qc.rx(-np.pi/2, 0)
qc.ry(np.pi/2, 0)
qc.rx(np.pi/2, 0)

# 4th
qc.rx(-np.pi/2, 0)
qc.ry(np.pi/2, 0)
qc.rx(-np.pi/2, 0)

print('Final matrix:', Operator(qc).data)

qc.draw('mpl')

which gives me the output:

Final matrix: [[ 0.   +0.707j -0.707+0.j   ]
 [ 0.707+0.j     0.   -0.707j]]

next, I found the inverse of this:

np.linalg.inv(Operator(qc).data)

which gives me:

[[ 0.   -0.707j  0.707+0.j   ]
 [-0.707+0.j    -0.   +0.707j]]

and didn't find the corresponding Clifford in the table as I was expeccting.

What do I do wrong in my calculations in qiskit?

$\endgroup$
4
  • 1
    $\begingroup$ What matrix did you find? Code is helpful, but you should show the output, too! $\endgroup$
    – jecado
    Oct 6 at 16:13
  • 1
    $\begingroup$ @jecado, sorry for this, I edited the post and added outputs. $\endgroup$
    – Curious
    Oct 6 at 17:30
  • $\begingroup$ Thank you! The table on p. 101 of your reference confuses me; isn't Z a Clifford gate? But it does not appear in the table. $\endgroup$
    – jecado
    Oct 6 at 17:52
  • 1
    $\begingroup$ @jecado, Z-gate is here, it is $$-X/2, Y/2, X/2$$ (actually, it is just Z/2) $\endgroup$
    – Curious
    Oct 6 at 18:07
5
$\begingroup$

The matrix

$$ M = \frac{1}{\sqrt{2}}\begin{bmatrix}-i & 1\\-1 & i\end{bmatrix} $$

resembles

$$ X/2 = \frac{1}{\sqrt{2}}\begin{bmatrix}1 & -i\\-i & 1\end{bmatrix}\tag1 $$

where we follow the notation $\pm X/2$ for the $\pm\frac{\pi}{2}$ rotation around the $X$ axis as used in the table B.6 on page 101 in Julian Kelly's PhD thesis. We can make the similarity more apparent by multiplying $M$ by the imaginary unit. We get

$$ M\equiv iM = \frac{1}{\sqrt{2}}\begin{bmatrix}1 & i\\-i & -1\end{bmatrix}\tag2 $$

where $\equiv$ signifies equality up to global phase.

Comparing $(1)$ and $(2)$, we see that up to global phase $M$ differs from $X/2$ only by the relative phase of $\pi$ between the two columns. We can introduce this phase difference using right-multiplication by $Z$. We have

$$ \begin{align} M &\equiv (X/2) Z \\ M &\equiv (X/2) XY \\ M &\equiv (-X/2) Y \\ M &\equiv Y (X/2) \end{align} $$

where we used the identity $(X/2)X\equiv(-X/2)$ which follows from $X^2=I$ and $(-X/2)Y=Y(X/2)$ which follows from the fact that $X$ and $Y$ anti-commute.

Finally, we find $M\equiv Y(X/2)$ in the third row of the "Hadamard-like" section of the table B.6 and conclude that $M$ is a Clifford gate as expected.

$\endgroup$
13
  • 1
    $\begingroup$ $$Y(X/2)=\begin{bmatrix}&-i\\i&\end{bmatrix} \frac{1}{\sqrt{2}} \begin{bmatrix}1&-i\\-i&1\end{bmatrix}=\frac{1}{\sqrt{2}}\begin{bmatrix}-1&-i\\ i&1\end{bmatrix}=-iM\equiv M$$ where we ignore the unobservable global phase $-i$. Similarly, $Z=-iXY\equiv XY$. $\endgroup$ Oct 7 at 17:05
  • 2
    $\begingroup$ Regarding a mathematical technique: Instead of comparing $M$ against a list, you can instead verify that conjugation by $M$ maps the Pauli group to the Pauli group. This is a little less daunting than it sounds because you only need to examine the action on the generators. In particular, in the single-qubit case, you can compute $MXM^\dagger$ and $MZM^\dagger$ and verify that the two results together with $i=MiM^\dagger$ generate the Pauli group. $\endgroup$ Oct 7 at 17:12
  • 1
    $\begingroup$ 1) I could have used $RY$ (with angle $\pi$) for $Y$, just as I used $RX$ (with angle $\frac{\pi}{2}$) for $X$. They're the same up to global phase. Specifically, $RY(\pi)=\begin{bmatrix}&-1\\ 1&\end{bmatrix}$. 2) In linear algebra, when you apply $AB$ to a vector you first apply $B$ and then $A$. In quantum circuits, you first write the gate corresponding to $B$ and then the one corresponding $A$, i.e. the convention is opposite. In software packages for describing quantum circuits the latter convention is more common. $\endgroup$ Oct 7 at 20:42
  • 1
    $\begingroup$ You can do either: you can check that $M$ preserves the Pauli group under conjugation or you can compare $M$ against a full list of Cliffords (remembering to ignore the global phase). It is up to you, but note that the number of Cliffords grows quickly with the number of qubits. $\endgroup$ Oct 7 at 20:47
  • 1
    $\begingroup$ On second look, I think the table B.6 may be using the convention where gates are applied from left to right like in quantum circuits and not from right to left like in linear algebra. This is suggested by the heading which says the Cliffords are "written in terms of the physical microwave gates applied in time". If this is the case, then $M$ is in the fourth (rather than the third) row of the Hadamard-like section, as is clear from the calculations in my answer. $\endgroup$ Oct 8 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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