some fixes

This commit is contained in:
Daniel Knüttel 2020-04-07 11:40:55 +02:00
parent cdb8b2692a
commit 434285f9fe
2 changed files with 35 additions and 29 deletions

View File

@ -11,6 +11,10 @@ amplitudes. Full access to the states (including intermediate states) has been
prioritized over execution speed. To keep the simulation speed as high as prioritized over execution speed. To keep the simulation speed as high as
possible under these constraints some parts are implemented in \lstinline{C}. possible under these constraints some parts are implemented in \lstinline{C}.
This document is based on \lstinline{pyqcs} \lstinline{2.1.0} that
can be downloaded under \\
\href{https://github.com/daknuett/PyQCS/releases/tag/v2.1.0}{https://github.com/daknuett/PyQCS/releases/tag/v2.1.0}.
\section{Dense State Vector Simulation} \section{Dense State Vector Simulation}
\subsection{Representation of Dense State Vectors} \subsection{Representation of Dense State Vectors}
@ -40,7 +44,7 @@ Python states also have a NumPy \lstinline{cdouble} array that stores the
quantum mechanical state. Using NumPy arrays has the advantage that access to quantum mechanical state. Using NumPy arrays has the advantage that access to
the data is simple and safe while operations on the states can be implemented the data is simple and safe while operations on the states can be implemented
in \lstinline{C} \cite{numpy_ufunc} providing a considerable speedup in \lstinline{C} \cite{numpy_ufunc} providing a considerable speedup
\ref{ref:benchmark_ufunc_py}. (see \ref{ref:benchmark_ufunc_py}).
This quantum mechanical state is the component vector in integer basis This quantum mechanical state is the component vector in integer basis
therefore it has $2^n$ components. Storing those components is acceptable in therefore it has $2^n$ components. Storing those components is acceptable in
@ -58,7 +62,7 @@ what qbits have been measured. Using ufuncs has the great advantage that
managing memory is done by NumPy and an application programmer just has to managing memory is done by NumPy and an application programmer just has to
implement the logic of the function. Because ufuncs are written in implement the logic of the function. Because ufuncs are written in
\lstinline{C} they provide a considerable speedup compared to an implementation \lstinline{C} they provide a considerable speedup compared to an implementation
in Python \ref{ref:benchmark_ufunc_py}. in Python (see \ref{ref:benchmark_ufunc_py}).
The logic of gates is usually easy to implement using the integer basis. The The logic of gates is usually easy to implement using the integer basis. The
example below implements the Hadamard gate \ref{ref:singleqbitgates}: example below implements the Hadamard gate \ref{ref:singleqbitgates}:
@ -162,6 +166,7 @@ Out[2]: (0.7071067811865476+0j)*|0b0>
\section{Graphical State Simulation} \section{Graphical State Simulation}
\subsection{Graphical States} \subsection{Graphical States}
\label{ref:impl_g_states}
For the graphical state $(V, E, O)$ the list of vertices $V$ can be stored implicitly For the graphical state $(V, E, O)$ the list of vertices $V$ can be stored implicitly
by demanding $V = \{0, ..., n - 1\}$. This leaves two components that have to be stored: by demanding $V = \{0, ..., n - 1\}$. This leaves two components that have to be stored:

View File

@ -188,9 +188,8 @@ a set of stabilizers.
and $\sqrt{-iX} = \frac{1}{\sqrt{2}} \left(\begin{array}{cc} 1 & -i and $\sqrt{-iX} = \frac{1}{\sqrt{2}} \left(\begin{array}{cc} 1 & -i
\\ -i & 1 \end{array}\right)$. \\ -i & 1 \end{array}\right)$.
Also $C_L$ is generated by $\sqrt{iZ}$, $\sqrt{-iX}$. When When using $\sqrt{iZ}, \sqrt{-iX}$ the product has a length
using $\sqrt{iZ}, \sqrt{-iX}$ the product has a length not greater not greater than $5$. }
than $5$. }
\item{$C_n$ can be generated using $C_L$ and $CZ$ or $CX$.} \item{$C_n$ can be generated using $C_L$ and $CZ$ or $CX$.}
\end{enumerate} \end{enumerate}
\end{theorem} \end{theorem}
@ -251,7 +250,7 @@ result of the measurement.
\label{lemma:stab_measurement} Let $J := \left\{ S^{(i)} \middle| [g_a, \label{lemma:stab_measurement} Let $J := \left\{ S^{(i)} \middle| [g_a,
S^{(i)}] \neq 0\right\} \neq \{\}$ and $J^c := \left\{S^{(i)} \middle| S^{(i)}] \neq 0\right\} \neq \{\}$ and $J^c := \left\{S^{(i)} \middle|
S^{(i)} \notin J \right\}$. When measuring $\frac{I + (-1)^s g_a}{2} $ $s=1$ S^{(i)} \notin J \right\}$. When measuring $\frac{I + (-1)^s g_a}{2} $ $s=1$
and $s=0$ are obtained with probability $\frac{1}{2}$ and after choosing a $j and $s=0$ are obtained with probability $\frac{1}{2}$ and after choosing a $S^{(j)}
\in J$ the new state $\ket{\psi'}$ is stabilized by \cite{nielsen_chuang_2010} \in J$ the new state $\ket{\psi'}$ is stabilized by \cite{nielsen_chuang_2010}
\begin{equation} \begin{equation}
\langle \{(-1)^s g_a\} \cup \left\{S^{(i)} S^{(j)} \middle| S^{(i)} \in J \setminus \{S^{(j)}\} \right\} \cup J^c \rangle. \langle \{(-1)^s g_a\} \cup \left\{S^{(i)} S^{(j)} \middle| S^{(i)} \in J \setminus \{S^{(j)}\} \right\} \cup J^c \rangle.
@ -259,7 +258,7 @@ and $s=0$ are obtained with probability $\frac{1}{2}$ and after choosing a $j
\end{lemma} \end{lemma}
\begin{proof} \begin{proof}
As $g_a$ is a Pauli operator and $S^{(i)} \in J$ are multi-local Pauli As $g_a$ is a Pauli operator and $S^{(i)} \in J$ are multilocal Pauli
operators, $S^{(i)}$ and $g_a$ anticommute. Choose a $S^{(j)} \in J$. Then operators, $S^{(i)}$ and $g_a$ anticommute. Choose a $S^{(j)} \in J$. Then
\begin{equation} \begin{equation}
@ -327,17 +326,17 @@ commute is trivial for $\{a,b\} \notin E$. If $\{a, b\} \in E$
\begin{aligned} \begin{aligned}
K_G^{(a)} K_G^{(b)} &= X_a \left(\prod\limits_{i \in n_a} Z_i\right) K_G^{(a)} K_G^{(b)} &= X_a \left(\prod\limits_{i \in n_a} Z_i\right)
X_b \left(\prod\limits_{j\in n_b} Z_j\right)\\ X_b \left(\prod\limits_{j\in n_b} Z_j\right)\\
&= X_a \left(\prod\limits_{i \in \setminus \{b\}} Z_i\right) Z_b &= X_a \left(\prod\limits_{i \in n_a\setminus \{b\}} Z_i\right) Z_b
X_b \left(\prod\limits_{j\in n_b\setminus \{b\}} Z_j\right) Z_a\\ X_b \left(\prod\limits_{j\in n_b\setminus \{a\}} Z_j\right) Z_a\\
&= X_a Z_b X_b Z_a &= X_a Z_b X_b Z_a
\left(\prod\limits_{j\in n_b\setminus \{b\}} Z_j\right) \left(\prod\limits_{j\in n_b\setminus \{a\}} Z_j\right)
\left(\prod\limits_{i \in \setminus \{b\}} Z_i\right)\\ \left(\prod\limits_{i \in n_a\setminus \{b\}} Z_i\right)\\
&= -X_b Z_b X_a Z_a &= -X_b Z_b X_a Z_a
\left(\prod\limits_{j\in n_b\setminus \{b\}} Z_j\right) \left(\prod\limits_{j\in n_b\setminus \{a\}} Z_j\right)
\left(\prod\limits_{i \in \setminus \{b\}} Z_i\right)\\ \left(\prod\limits_{i \in n_a\setminus \{b\}} Z_i\right)\\
&= X_b Z_a X_a Z_b &= X_b Z_a X_a Z_b
\left(\prod\limits_{j\in n_b\setminus \{b\}} Z_j\right) \left(\prod\limits_{j\in n_b\setminus \{a\}} Z_j\right)
\left(\prod\limits_{i \in \setminus \{b\}} Z_i\right)\\ \left(\prod\limits_{i \in n_a \setminus \{b\}} Z_i\right)\\
&= K_G^{(b)} K_G^{(a)}.\\ &= K_G^{(b)} K_G^{(a)}.\\
\end{aligned} \end{aligned}
\end{equation} \end{equation}
@ -481,7 +480,7 @@ that will be used later \cite{andersbriegel2005}.
\begin{aligned} \begin{aligned}
n_a' &= n_a \\ n_a' &= n_a \\
n_j' &= n_j, \hbox{ if } j \notin n_a\\ n_j' &= n_j, \hbox{ if } j \notin n_a\\
n_j' &= n_j \Delta n_a, \hbox{ if } j \in n_a n_j' &= n_j \Delta n_a \setminus \{j\}, \hbox{ if } j \in n_a
\end{aligned} \end{aligned}
\end{equation} \end{equation}
\end{lemma} \end{lemma}
@ -524,7 +523,7 @@ that will be used later \cite{andersbriegel2005}.
&= Z_j X_a X_j Z_a \left(\prod\limits_{l \in D} Z_l\right) &= Z_j X_a X_j Z_a \left(\prod\limits_{l \in D} Z_l\right)
\left(\prod\limits_{l \in F}Z_l\right) \left(\prod\limits_{l \in F}Z_l\right)
\left(\prod\limits_{l \in F}Z_l\right) \\ \left(\prod\limits_{l \in F}Z_l\right) \\
&= Z_j X_a X_j Z_a \left(\prod\limits_{l \in ((F\cup D) \setminus (F\cap D))} Z_L\right) &= Z_j X_a X_j Z_a \left(\prod\limits_{l \in ((F\cup D) \setminus (F\cap D))} Z_l\right)
\left(\prod\limits_{l \in F}Z_l\right) \\ \left(\prod\limits_{l \in F}Z_l\right) \\
&= K_{G'}^{(a)} K_{G'}^{(j)} \\ &= K_{G'}^{(a)} K_{G'}^{(j)} \\
&= K_{G}^{(a)} K_{G'}^{(j)} &= K_{G}^{(a)} K_{G'}^{(j)}
@ -541,7 +540,7 @@ that will be used later \cite{andersbriegel2005}.
Because $\left\{K_G^{(i)} \middle| i \notin n_a\right\} \cup \left\{S^{(i)} Because $\left\{K_G^{(i)} \middle| i \notin n_a\right\} \cup \left\{S^{(i)}
\middle| i\in n_a\right\}$ and $\left\{K_G^{(i)} \middle| i \notin \middle| i\in n_a\right\}$ and $\left\{K_G^{(i)} \middle| i \notin
n_a\right\} \cup \left\{K_{G'}^{(i)} \middle| i\in n_a \right\}$ are both $n$ n_a\right\} \cup \left\{K_{G'}^{(i)} \middle| i\in n_a \right\}$ are both $n$
commuting multi-local Pauli operators where the $S^{(i)}$ can be generated from commuting multilocal Pauli operators where the $S^{(i)}$ can be generated from
the $K_{G'}^{(i)}$ and $\ket{\bar{G}'}$ is a $+1$ eigenstate of $K_{G'}^{(j)}$ the $K_{G'}^{(i)}$ and $\ket{\bar{G}'}$ is a $+1$ eigenstate of $K_{G'}^{(j)}$
$\langle\left\{K_G^{(i)} \middle| i \notin n_a\right\} \cup \left\{K_{G'}^{(i)} $\langle\left\{K_G^{(i)} \middle| i \notin n_a\right\} \cup \left\{K_{G'}^{(i)}
\middle| i\in n_a \right\}\rangle$ are the stabilizers of $\ket{\bar{G}'}$. \middle| i\in n_a \right\}\rangle$ are the stabilizers of $\ket{\bar{G}'}$.
@ -602,31 +601,33 @@ immediately:
The great advantage of this representation of a stabilizer state is its space The great advantage of this representation of a stabilizer state is its space
requirement: Instead of storing $n^2$ Pauli matrices only some vertices (which requirement: Instead of storing $n^2$ Pauli matrices only some vertices (which
often are implicit), the edges and some vertex operators ($n$ matrices) have to are implicit when choosing $V=\{0, ..., n-1\}$), the edges and some vertex
be stored. Theorem \ref{thm:cl24} will improve this even further: Instead of $n$ operators ($n$ matrices) have to be stored. Theorem \ref{thm:cl24} will improve
matrices it is sufficient to store $n$ integers representing the vertex this even further: Instead of $n$ matrices it is sufficient to store $n$
operators. integers representing the vertex operators.
\begin{theorem} \begin{theorem}
\label{thm:cl24} \label{thm:cl24}
$C_L$ has $24$ degrees of freedom disregarding a global phase \cite{andersbriegel2005}. $C_L$ has $24$ degrees of freedom disregarding a global phase \cite{andersbriegel2005}.
\end{theorem} \end{theorem}
\begin{proof} It is clear that $\forall a \in C_L$ a is a group isomorphism $P \begin{proof} It is clear that any $a \in C_L$ is a group isomorphism $P
\rightarrow P$: $apa^\dagger a p' a^\dagger = a pp'a^\dagger$. Therefore \rightarrow P$: $apa^\dagger a p' a^\dagger = a pp'a^\dagger$. Therefore
$a$ will preserve the (anti-)commutator relations of $P$. Further note $a$ will preserve the (anti-)commutator relations of $P$. Further note
that $Y = iXZ$, so one has to consider the anti-commutator relations of that $Y = iXZ$, so one has to consider the (anti-)commutator relations of
$X,Z$ only. $X,Z$ only.
As the transformations are unitary they preserve eigenvalues, so $X$ can be As the transformations are unitary they preserve eigenvalues, so $X$ can be
mapped to $\pm X, \pm Y, \pm Z$ which gives $6$ degrees of freedom. mapped to $\pm X, \pm Y, \pm Z$ which gives $6$ degrees of freedom.
Furthermore the image of $Z$ has to anti-commute with the image of $X$ so Furthermore the image of $Z$ has to anti-commute with the image of $X$ therefore
$Z$ has four possible images under the transformation. This gives another $Z$ has four possible images under the transformation. This gives another
$4$ degrees of freedom and a total of $24$. \end{proof} $4$ degrees of freedom and a total of $24$.
\end{proof}
From now on $C_L = \langle H, S \rangle$ (disregarding a global phase) will be From now on $C_L = \langle H, S \rangle$ (disregarding a global phase) will be
used. One can show (by construction) that $H, S$ generate a possible choice of used. One can show (by construction) that $H, S$ generate a possible choice of
$C_L$, as do $\sqrt{-iX}, \sqrt{-iZ}$ which is required in one specific $C_L$, as do $\sqrt{-iX}, \sqrt{-iZ}$ which is required in one specific
operation on graph states \cite{andersbriegel2005}. operation on graph states \cite{andersbriegel2005}. All elements of $C_L$ can
be found in \ref{ref:impl_g_states}.
\begin{equation} \begin{equation}
S = \left(\begin{array}{cc} 1 & 0 \\ 0 & i \end{array}\right) S = \left(\begin{array}{cc} 1 & 0 \\ 0 & i \end{array}\right)
@ -783,13 +784,13 @@ the graph after a measurement is described in \cite{hein_eisert_briegel2008}.
Recalling \ref{ref:meas_stab} it is clear that one has to compute the Recalling \ref{ref:meas_stab} it is clear that one has to compute the
commutator of the observable $g_a = Z_a$ with the stabilizers to get the commutator of the observable $g_a = Z_a$ with the stabilizers to get the
probability amplitudes which is a expensive computation in theory. It is probability amplitudes which is an expensive computation in theory. It is
possible to simplify the problem by pulling the observable behind the vertex possible to simplify the problem by pulling the observable behind the vertex
operators. For this consider the projector $P_{a,s} = \frac{I + (-1)^sZ_a}{2}$ operators. For this consider the projector $P_{a,s} = \frac{I + (-1)^sZ_a}{2}$
\begin{equation} \begin{equation}
\begin{aligned} \begin{aligned}
P_{a,s} \ket{\psi} &= P_{a,s} \left(\prod\limits_{o_i \in O} o_i \right) \ket{\bar{G}} \\ P_{a,s} \ket{G} &= P_{a,s} \left(\prod\limits_{o_i \in O} o_i \right) \ket{\bar{G}} \\
&= \left(\prod\limits_{o_i \in O \setminus \{o_a\}}o_i \right)P_a o_a \ket{\bar{G}} \\ &= \left(\prod\limits_{o_i \in O \setminus \{o_a\}}o_i \right)P_a o_a \ket{\bar{G}} \\
&= \left(\prod\limits_{o_i \in O \setminus \{o_a\}}o_i \right) o_a o_a^\dagger P_a o_a \ket{\bar{G}} \\ &= \left(\prod\limits_{o_i \in O \setminus \{o_a\}}o_i \right) o_a o_a^\dagger P_a o_a \ket{\bar{G}} \\
&= \left(\prod\limits_{o_i \in O} o_i \right) o_a^\dagger P_a o_a \ket{\bar{G}} \\ &= \left(\prod\limits_{o_i \in O} o_i \right) o_a^\dagger P_a o_a \ket{\bar{G}} \\