some fixes

This commit is contained in:
Daniel Knüttel 2020-03-23 16:02:07 +01:00
parent 8ab401c292
commit 54705023fb
6 changed files with 72 additions and 63 deletions

View File

@ -2,10 +2,10 @@
\section{Conclusion and Outlook}
As seen in \ref{ref:performance} simulation using stabilizers is exponentially
faster than simulating using dense state vectors. Using a graphical
representation for the stabilizers is on average more efficiently than using
a stabilizer tableaux. In particular one can simulate more qbits while only
applying Clifford gates.
faster than simulating using state vectors. Using a graphical representation
for the stabilizers is on average more efficiently than using a stabilizer
tableaux. In particular one can simulate more qbits while only applying
Clifford gates.
This is considerably useful when working on quantum error correcting strategies
as they often include many qbits; the smallest quantum error correcting
@ -43,7 +43,7 @@ matrices. A general unitary on $n$ qbits would be a $2^{n} \times 2^{n}$ matrix
which requires more space than a dense state vector. The Clifford group is
a group preserving this tensor product property.
When the constraint that $\ket{\varphi}$ is stabilized by the multilocal Pauli
When lifting the constraint that $\ket{\varphi}$ is stabilized by the multilocal Pauli
group but using $n$ arbitrary commuting hermitians $\langle h_1, ..., h_n
\rangle$ that are the tensor product of $2\times 2$ hermitians one quickly
realizes that one could apply any single-qbit gate to the $h_i$ and preserve

View File

@ -5,11 +5,11 @@ This chapter discusses how the concepts introduced before are implemented into
a simulator. Futher the infrastructure around the simulation and some tools are
explained.
The implementation is written as a \lstinline{python3} module. This allows
users to quickly construct circuit, apply them to a state and measure
amplitudes. Full access to the state (including intermediate) state has been
The implementation is written as the \lstinline{python3} package \lstinline{pyqcs} \cite{pyqcs}. This allows
users to quickly construct circuits, apply them to states and measure
amplitudes. Full access to the state (including intermediate states) has been
priorized 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}.
\subsection{Dense State Vector Simulation}
@ -76,7 +76,7 @@ A basic set of gates is implemented in PyQCS:
\item{$Z$ rotation $R_\phi$ gate.}
\item{Controlled $X$ gate: $CX$.}
\item{Controlled $Z$ gate: $CZ$.}
\item{The measurement "gate" $M$.}
\item{The "measurement gate" $M$.}
\end{itemize}
To allow the implementation of possible hardware related gates the class
@ -118,8 +118,8 @@ Out[2]: (0.7071067811865476+0j)*|0b0>
\end{lstlisting}
Large circuits can be constructed using the binary OR operator \lstinline{|} in
an analogy to the pipeline operator on many *NIX systems. As usual circuits are
read from left to right similar to pipelines on *NIX systems:
an analogy to the pipeline operator on many *NIX shells. As usual circuits are
read from left to right similar to pipelines on *NIX shells:
%\adjustbox{max width=\textwidth}{
@ -195,7 +195,7 @@ their order is
&\left(\begin{matrix}\frac{1}{2} - \frac{i}{2} & - \frac{1}{2} + \frac{i}{2}\\- \frac{1}{2} + \frac{i}{2} & - \frac{1}{2} + \frac{i}{2}\end{matrix}\right),
\left(\begin{matrix}0 & -1\\1 & 0\end{matrix}\right),
\left(\begin{matrix}\frac{\sqrt{2}}{2} & - \frac{\sqrt{2}}{2}\\- \frac{\sqrt{2} i}{2} & - \frac{\sqrt{2} i}{2}\end{matrix}\right),
\left(\begin{matrix}\frac{1}{2} - \frac{i}{2} & \frac{i \left(-1 + i\right)}{2}\\- \frac{1}{2} + \frac{i}{2} & \frac{i \left(-1 + i\right)}{2}\end{matrix}\right)
\left(\begin{matrix}\frac{1}{2} - \frac{i}{2} & \frac{i \left(-1 + i\right)}{2}\\- \frac{1}{2} + \frac{i}{2} & \frac{i \left(-1 + i\right)}{2}\end{matrix}\right).
\end{aligned}
\end{equation}
@ -217,13 +217,13 @@ Recalling some operations on the graph as described in
\ref{ref:dynamics_graph}, \ref{ref:meas_graph} or Lemma \ref{lemma:M_a} one
sees that it is important to efficiently access and modify the neighbourhood of
a vertex. To ensure good performance when accessing the neighbourhood while
keeping the memory requirements low a linked list-array hybrid is used to store
keeping the required memory low a linked list-array hybrid is used to store
the adjacency matrix. For every vertex the neighbourhood is stored in a sorted
linked list (which is a sparse representation of a column vector) and these
adjacency lists are stored in a length $n$ array.
Using this storage method all operations including searching and toggling edges
are inherite their time complexity from the sorted linked list.
inherite their time complexity from the sorted linked list.
\subsubsection{Operations on Graphical States}
@ -315,9 +315,9 @@ one can generate random graphical states which is more performant than using
random circuits.
The function \lstinline{pyqcs.util.to_circuit.graph_state_to_circuit} converts
graphical states into circuits (mapping the $\ket{0b0..0}$ to this state.
graphical states to circuits (mapping the $\ket{0b0..0}$ to this state).
Using these circuits the graphical state can be copied or converted to a
dense vector state. Further it is a way to optimize circuits to run them on
dense vector state. Further it is a way to optimize circuits and later run them on
other simulators. Also the circuits can be exported to \lstinline{qcircuit} code
(see below) which is a relatively readable way to represent graphical states.
@ -328,7 +328,7 @@ circuits in this documents use \lstinline{qcircuit}. To visualize the circuits
built using \lstinline{pyqcs} the function\\
\lstinline{pyqcs.util.to_diagram.circuit_to_diagram} can be used to generate
\lstinline{qcircuit} code that can be used in \LaTeX documents or exported to
PDFs directly. The diagrams produced by this function is not optimized and the
PDFs directly. The diagrams produced by this function are not optimized and the
diagrams can be unnecessary long. Usually this can be fixed easily by editing
the produced code manually.
@ -380,9 +380,10 @@ dense vector simulator $S$ can be replaced by $R_\phi$ with the parameter $x$.
Using this method circuits are generated and applied both to graphical and
dense vector states and the time required to execute the operations
\cite{timeit} is measured. The resulting graph can be seen in
Figure \ref{fig:scaling_qbits_linear} and Figure \ref{fig:scaling_qbits_log}. Note in both cases the length of the circuits
have been scaled linearely with the amount of qbits and the measured time was
divided by the number of qbits:
Figure \ref{fig:scaling_qbits_linear} and Figure \ref{fig:scaling_qbits_log}.
Note that in both cases the length of the circuits have been scaled linearely
with the amount of qbits and the measured time was divided by the number of
qbits:
\begin{equation}
\begin{aligned}
@ -465,8 +466,8 @@ edges increases which makes toggling neighbourhoods harder. Graphs from the
low-linear, intermediate and high-linear regime can be seen in
Figure \ref{fig:graph_low_linear_regime}, Figure \ref{fig:graph_intermediate_regime} and
Figure \ref{fig:graph_high_linear_regime}. The latter is hardly visible; this is due
to the great amount of edges in this regime. Further these two regimes are only
visibly for $n>30$ qbits so choosing smaller graphs is not possible.
to the great amount of edges in this regime. Further the regimes are not clearly
visibe for $n>30$ qbits so choosing smaller graphs is not possible.
Because states with more qbits reach the intermediate regime at higher circuit
lengths it is important to account for this virtual performance boost when
@ -477,10 +478,10 @@ in Figure \ref{fig:scaling_qbits_linear} had to be scaled with the qbit number.
Although the simulator(s) are in a working state and have been tested there is
still some work that can be done. A noise model helping to teach and analyze
noisy execution is one particularly interesting piece of work that should be
done. To allow a user to execute circuits on other machines, including both
real hardware and simulators, a module that exports circuits to OpenQASM
\cite{openqasm} seems useful.
noisy execution is one particularly interesting piece of work. To allow a user
to execute circuits on other machines, including both real hardware and
simulators, a module that exports circuits to OpenQASM \cite{openqasm} seems
useful.
The current implementation of some graphical operations can be optimized. While
clearing VOPs as described in \ref{ref:dynamics_graph} the neighbourhood of

View File

@ -6,7 +6,7 @@ many companies and institutions working on building and using quantum computers
\cite{ibmq}\cite{intelqc}\cite{microsoftqc}\cite{dwavesys}\cite{lrzqc}\cite{heise25_18}.
One important topic in this research is quantum error correction
\cite{nielsen_chuang_2010}\cite{gottesman2009}\cite{gottesman1997}\cite{shor1995}
that will allow the execution of arbitrarily long quantum circuits. One
that will allow the execution of arbitrarily long quantum circuits \cite{nielsen_chuang_2010}. One
important class of quantum error correction strategies are stabilizer codes
\cite{gottesman2009}\cite{gottesman1997} that can be simulated exponentially
faster than general quantum circuits
@ -20,7 +20,7 @@ This paper describes the development of a quantum computing simulator
using both the usual dense state vector representation for a general state
and a graphical representation for stabilizer states. After giving some introduction
to quantum computing some basic properties of stabilizer states and their
dynamics are given. Using this the graphical representation is introduced
dynamics are eludicated. Using this the graphical representation is introduced
and some operations on the graphical states are explained. Following is
a chapter describing the implementation of these techniques and some performance
analysis.

View File

@ -5,7 +5,7 @@
\subsubsection{Single Qbits}
\begin{definition}
A qbit is a two level quantum mechanical system, i.e. it has the eigenbasis
A qbit is a two level quantum mechanical system \cite{nielsen_chuang_2010}, i.e. it has the eigenbasis
$ \{\ket{\uparrow} \equiv \ket{1}, \ket{\downarrow} \equiv \ket{0}\} $
with $\braket{\uparrow}{\downarrow} = 0$. In the following this basis will be called
the $Z$ basis in analogy to the conventions used in spin systems ($\sigma_Z$). For some computations
@ -94,8 +94,9 @@ with the normation condition
\end{equation}
The states $\ket{i}$ for $i = 0, ..., 2^{n}-1$ are called integer states. Note
that integer states are eigenstates of the $Z$ operators. The computational basis
is $\{\ket{i_0} \otimes ... \otimes \ket{i_{n-1}} | i_0, ..., i_{n-1} = 0, 1\}$.
that integer states are eigenstates of the $Z$ operators.\\
The computational basis is
$\left\{\ket{i_0} \otimes ... \otimes \ket{i_{n-1}} \middle| i_0, ..., i_{n-1} = 0, 1\right\}$.
\begin{definition}
For a single-qbit gate $U$ and a qbit $j = 0, 1, ..., n - 1$
@ -116,14 +117,14 @@ is acting on qbit $j$.
the controlled version of $U$ is defined by
\begin{equation}
\begin{aligned}\label{eq:CU}
CU_{i, j} &:= &\ket{0}\bra{0}_j\otimes I_i
CU_{i, j} &:= \ket{0}\bra{0}_j\otimes I_i
+ \ket{1}\bra{1}_j \otimes U_i \\
&:= &\left(\bigotimes\limits_{l < j} I\right)
&:= \left(\bigotimes\limits_{l < j} I\right)
\otimes \ket{0}\bra{0}
\otimes \left(\bigotimes\limits_{j < l < i} I\right)
\otimes I
\otimes \left(\bigotimes\limits_{j > l} I \right)\\
& &+ \left(\bigotimes\limits_{l < j} I\right)
&\mbox{ } + \left(\bigotimes\limits_{l < j} I\right)
\otimes \ket{1}\bra{1}
\otimes \left(\bigotimes\limits_{j < l < i} I\right)
\otimes U
@ -147,7 +148,7 @@ In Definition \ref{def:CU} $i$ is called the act-qbit and $j$ the control-qbit.
$CU$ applies the gate $U$ to the act-qbit if the control-qbit is in its $\ket{1}$ state.
One can show that the gates in \ref{ref:singleqbitgates} together with an entanglement gate, such as $CX$ or $CZ$ are enough
to generate an arbitrary $n$-qbit gate \cite[Chapter 4.3]{kaye_ea2007}\cite{barenco_ea_1995}.
to generate an arbitrary $n$-qbit gate \cite{nielsen_chuang_2010}\cite[Chapter 4.3]{kaye_ea2007}\cite{barenco_ea_1995}.
The matrix representation of $CX$ and $CZ$ for two qbits is given by
\begin{equation}
@ -232,17 +233,18 @@ Several qbits can be abbreviated by writing a slash on the qbit line:
\subsection{Quantum Algorithms}
The great hope behind quantum computing is that it will speed up some computations
exponentially using algorithms that utilize the laws of quantum mechanics. Current
algorithms are based upon quantum search and quantum fourier transform \cite{nielsen_chuang_2010}.
The latter is particular interesting for physical problems as it is used in the phase estimation
algorithm that can be used to analyze the spectrum of the transfer matrix:
The great hope behind quantum computing is that it will speed up some
computations exponentially using algorithms that utilize the laws of quantum
mechanics. Current algorithms are based upon quantum search and quantum fourier
transform \cite{nielsen_chuang_2010}. The latter is particular interesting for
physical problems as it is a key component in the phase estimation algorithm
that can be used to analyze the spectrum of the transfer matrix:
\begin{equation}
T = \exp(itH)
\end{equation}
The eigenvalue of $T$ can now be estimated by using the phase estimation circuit
The spectrum of $T$ can now be estimated by using the phase estimation circuit
\[
\Qcircuit @C=1em @R=.7em {
@ -251,7 +253,12 @@ The eigenvalue of $T$ can now be estimated by using the phase estimation circuit
}
\]
Where $T\ket{\varphi} = \exp(2\pi i\varphi) \ket{\varphi}$ and the measurement result $\tilde{\varphi} = \frac{x}{2^n}$ is an
estimation for $\varphi$. If a success rate of $1-\epsilon$ and an accuracy of $| \varphi - \tilde{\varphi} | < 2^{-m}$
is wanted, then $N = m + \log_2(2 + \frac{1}{2\epsilon})$ qbits are required \cite{nielsen_chuang_2010}\cite{lehner2019}.
Where $T\ket{\varphi} = \exp(2\pi i\varphi) \ket{\varphi}$ and the measurement
result $\tilde{\varphi} = \frac{x}{2^n}$ is an estimation for $\varphi$. If
a success rate of $1-\epsilon$ and an accuracy of $| \varphi - \tilde{\varphi}
| < 2^{-m}$ is wanted, then $N = m + \log_2(2 + \frac{1}{2\epsilon})$ qbits are
required \cite{nielsen_chuang_2010}\cite{lehner2019}.
%Another possible way to use quantum computers in physics is to simulate a system's
%time evolution using the transfer matrix. By mapping an interesting system to
%the qbit space and applying the

View File

@ -72,7 +72,7 @@ The discussion below follows the argumentation given in \cite{nielsen_chuang_201
\begin{enumerate}
\item{$(iI)^2 = (-iI)^2 = -I$. Which contradicts the definition of $S$.}
\item{From the definition of $S$ ($G_n$ respectively) follows that any
\item{From the definition of $S$ ($P_n$ respectively) follows that any
$S^{(i)} \in S$ has the form $\pm i^l \left(\bigotimes\limits_{j=0}^{n-1} \tilde{p}_j\right)$ where
$\tilde{p}_j \in \{X, Y, Z, I\}$ and $l \in \{0, 1\}$. As $\left(\bigotimes\limits_{j=0}^{n-1} \tilde{p}_j\right)$
is hermitian and unitary $(S^{(i)})^2$ is either $+I$ or $-I$. As $-I \notin S$ $(S^{(i)})^2 = I$ follows directly.
@ -153,7 +153,7 @@ describes the dynamics of the system, i.e.
\begin{equation} \ket{\psi'} = U \ket{\psi} \end{equation}
It is clear that in general $\ket{\psi'}$ will not be stabilized by $S$
anymore. There are however some statements that can still be made
anymore. There are however some statements that can be made
\cite{nielsen_chuang_2010}:
\begin{equation}
@ -212,18 +212,18 @@ a set of stabilizers.
\end{proof}
This is quite an important result: As under a transformation $U \in C_n$ $S'
= U^\dagger S U$ is a set of $n$ independent stabilizers and $\ket{\psi'}$ is
= U S U^\dagger$ is a set of $n$ independent stabilizers and $\ket{\psi'}$ is
stabilized by $S'$ one can consider the dynamics of the stabilizers instead of
the actual state. This is considerably more efficient as only $n$ stabilizers
have to be modified, each being just the tensor product of $n$ Pauli matrices.
This has led to the simulation using stabilizer tableaux
\cite{gottesman_aaronson2008}.
\cite{gottesman_aaronson2008}\cite{CHP}.
\subsubsection{Measurements on Stabilizer States} \label{ref:meas_stab}
Interestingly also measurements are dynamics covered by the stabilizers. When
an observable $g_a \in \{\pm X_a, \pm Y_a, \pm Z_a\}$ acting on qbit $a$ is
measured one has to consider the projector
Interestingly also measurements are dynamics covered by the stabilizers
\cite{nielsen_chuang_2010}. When an observable $g_a \in \{\pm X_a, \pm Y_a,
\pm Z_a\}$ acting on qbit $a$ is measured one has to consider the projector
\begin{equation}
P_{g_a,s} = \frac{I + (-1)^s g_a}{2}.
@ -396,7 +396,7 @@ graph.
&\mbox{ }+ \left(\ket{0}\bra{0}_j \otimes I_i\right) X_i \prod\limits_{l \in n'_i} Z_l \left(\ket{0}\bra{0}_j \otimes I_i\right)\\
&= \left(\ket{1}\bra{1}_j \otimes Z_i\right) X_i \prod\limits_{l \in n'_i} Z_l \left(\ket{1}\bra{1}_j \otimes Z_i\right)\\
&\mbox{ }+ \left(\ket{0}\bra{0}_j \otimes I_i\right) X_i \prod\limits_{l \in n'_i} Z_l \left(\ket{0}\bra{0}_j \otimes I_i\right)\\
&= \left(\left(-\ket{1}\bra{1}_j + \ket{1}\bra{1}_j\right) \otimes I_i\right) X_i \prod\limits_{l \in n'_i} Z_l \\
&= \left(\left(-\ket{1}\bra{1}_j + \ket{0}\bra{0}_j\right) \otimes I_i\right) X_i \prod\limits_{l \in n'_i} Z_l \\
&= \left(Z_j \otimes I_i\right) X_i \prod\limits_{l \in n'_i} Z_l \\
&= X_i \prod\limits_{l \in n_i} Z_l \\
&= K_G^{(i)}
@ -554,7 +554,7 @@ Therefore the associated graph is changed as given in the third equation.
The definition of a VOP-free graph state above raises an obvious question: Can
any stabilizer state be described using just a graph? The answer is straight
forward: No. The most simple cases are the single qbit stated $\ket{0},\ket{1}$
forward: No. The most simple cases are the single qbit states $\ket{0},\ket{1}$
and $\ket{+_Y}, \ket{-_Y}$. But there is an extension to the VOP-free graph
states that allows the representation of an arbitrary stabilizer state. The
proof that indeed any state can be represented is purely constructive. As seen
@ -588,7 +588,7 @@ immediately:
\end{equation}
The great advantage of this representation of a stabilizer state is its space
requirement: Instead of storing $n^2$ $P$ 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
be stored. The following theorem will improve this even further: instead of $n$
matrices it is sufficient to store $n$ integers representing the vertex
@ -664,7 +664,7 @@ derive that any isolated clique of the graph can be treated independently.
Therefore the two isolated qbits can be treated as an independent state and the
set of two qbit stabilizer states is finite. An upper bound to the number of
two qbit stabilizer states is given by $2\cdot24^2$: A factor of two for the
options with and withoit an edge between the qbits and $24$ Clifford operators
options with and without an edge between the qbits and $24$ Clifford operators
on each vertex.
All those states and the resulting state after a $CZ$ application can be
@ -794,17 +794,17 @@ projector as $o_a$ is a Clifford operator
\end{aligned}
\end{equation}
Where $\tilde{g}_a \in \{+1, -1\}\cdot\{X_a, Y_a, Z_a\}$. Therefore, it is
Where $\tilde{g}_a \in \{\pm X_a, \pm Y_a, \pm Z_a\}$. Therefore, it is
enough to study the measurements of any Pauli operator on the vertex operator
free graph states. The commutators of the observable with the $K_G^{(i)}$ are
quite easy to compute. Note that Pauli matrices either commute or anticommute
and it is easier to list the operators that anticommute
and it is easier to list the operators that anticommute:
\begin{equation}
\begin{aligned}
A_{\pm X_a} &= \left\{j \middle| \{j, a\} \in E\right\}\\
A_{\pm Y_a} &= \left\{j \middle| \{j, a\} \in E\right\} \cup \{a\} \\
A_{\pm Z_a} &= \{a\}.\\
A_{\pm X_a} &= n_a \\
A_{\pm Y_a} &= n_a \cup \{a\} \\
A_{\pm Z_a} &= \{a\}\\
\end{aligned}
\end{equation}

View File

@ -16,6 +16,7 @@
%\usepackage{courier}
%\lstset{basicstyle=\fontfamily{qcr}\selectfont}
\lstset{basicstyle=\ttfamily}
\setlength{\parindent}{0cm}
\geometry{left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm}