Pareto-Efficient Quantum Circuit Simulation Using Tensor Contraction Deferral
Extracted source text · arXiv 1710.05867
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% name: fidelity_50qubit.tex
% author: Pednault et al.
% purpose: Assessing fidelity of quantum circuits
% history: 170920 work on class started
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[letterpaper,11pt]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb} %additional math symbols (see amsguide.tex)
\usepackage{amsopn}
\usepackage{amsthm}
\usepackage{latexsym}
\usepackage{graphicx} %graphic and .eps files
\usepackage{mathrsfs} %calligraphic fonts
\usepackage{psfrag}
\usepackage{algorithm}
\usepackage[noend]{algorithmic}
\usepackage{color}
\usepackage{verbatim}
\usepackage{url}
\usepackage{multirow}
\usepackage{setspace}
\usepackage{booktabs,longtable,rotating}
\usepackage{afterpage}
\usepackage{sidecap}
\usepackage{marvosym}
\usepackage[caption=false]{subfig}
\usepackage{enumerate}
\usepackage[left=1.0in,top=1.2in,right=1.0in]{geometry}
\usepackage{import}
\usepackage{relsize}
\usepackage{lipsum}
\usepackage{array}
\usepackage{qcircuit}
\usepackage{mathtools}
\usepackage{afterpage}
\usepackage{rotating}
\usepackage{hyperref}
\usepackage{authblk}
%\setlength{\tabcolsep}{.8mm}
%% ______________________etc_____________________________
%\pagestyle{headings}
%\renewcommand{\baselinestretch}{1}
% N.B. if paper has sections and subsections add "[section]"
% or "[subsection]" at the end of the following 5 lines.
\newtheorem{theorem}{Theorem}
\newtheorem{definition}{Definition}
\newtheorem{lemma}{Lemma}
\newtheorem{corollary}{Corollary}
\newtheorem{proposition}{Proposition}
\newtheorem{example}{Example}
\newtheorem{axiom}{Axiom}
\newtheorem{assumption}{Assumption}
\newtheorem*{assumption*}{Assumption}
\newtheorem{remark}{Remark}
\renewcommand{\vec}[1]{\underline{#1}}
\newcommand{\transpose}[1]{{#1}^{\top}}
\newcommand{\tS}{@{$\;$}}
\newcommand{\floor}[1]{{\left\lfloor{#1}\right\rfloor}}
\newcommand{\ceil}[1]{{\left\lceil{#1}\right\rceil}}
\newcommand{\rint}[1]{{\left\lfloor{#1}\right\rceil}}
\newcommand{\N}{\ensuremath{\mathbb{N}}}
\newcommand{\Q}{\ensuremath{\mathbb{Q}}}
\newcommand{\Z}{\ensuremath{\mathbb{Z}}}
\newcommand{\R}{\ensuremath{\mathbb{R}}}
\newcommand{\C}{\ensuremath{\mathbb{C}}}
\newcommand{\Hil}{\ensuremath{\mathbb{H}}}
\newcommand{\todo}[1]{\marginpar{$\Longleftarrow$}({\bf TODO:} {#1})}
\DeclarePairedDelimiter\bra{\langle}{\rvert}
\DeclarePairedDelimiter\ket{\lvert}{\rangle}
\DeclarePairedDelimiterX\braket[2]{\langle}{\rangle}{#1 \delimsize\vert #2}
\DeclarePairedDelimiterX\dotp[2]{\langle}{\rangle}{#1, #2}
\title{Breaking the 49-Qubit Barrier in the Simulation of Quantum Circuits}
\author[1]{Edwin Pednault}
\author[1]{John A.~Gunnels}
\author[1]{Giacomo Nannicini}
\author[1]{Lior Horesh}
\author[2]{Thomas Magerlein}
\author[3]{Edgar Solomonik}
%\author[4]{Erik W.~Draeger}
%\author[4]{Jonathan L.~DuBois}
%\author[4]{Eric T.~Holland}
\author[1]{Robert Wisnieff}
\affil[1]{IBM T.J.~Watson Research Center, Yorktown Heights, NY
{\small Email: {\tt pednault,gunnels,nannicini,lhoresh,wisnieff@us.ibm.com}}
}
\affil[2]{Tufts University, Medford, MA
{\small Email: {\tt tmagerlein@gmail.com}}
}
\affil[3]{Dept.~of Computer Science, University of Illinois at Urbana-Champaign, Champaign, IL
{\small Email: {\tt solomon2@illinois.edu}}
}
%% \affil[4]{Lawrence Livermore National Laboratory, Livermore, CA
%% {\small Email: {\tt draeger1,dubois9,holland25@llnl.gov}}
%% }
\begin{document}
\allowdisplaybreaks
\thispagestyle{empty}
\maketitle
\begin{abstract}
With the current rate of progress in quantum computing technologies,
50-qubit systems will soon become a reality. To assess, refine and
advance the design and control of these devices, one needs a means
to test and evaluate their fidelity. This in turn requires the
capability of computing ideal quantum state amplitudes for devices
of such sizes and larger. In this study, we present a new approach
for this task that significantly extends the boundaries of what can
be classically computed. We demonstrate our method by presenting
results obtained from a calculation of the complete set of output
amplitudes of a universal random circuit with depth 27 in a 2D
lattice of $7 \times 7$ qubits. We further present results obtained
by calculating an arbitrarily selected slice of $2^{37}$ amplitudes
of a universal random circuit with depth 23 in a 2D lattice of $8
\times 7$ qubits. Such calculations were previously thought to be
impossible due to impracticable memory requirements. Using the
methods presented in this paper, the above simulations required 4.5
and 3.0 TB of memory, respectively, to store calculations, which is
well within the limits of existing classical computers.
\end{abstract}
\input{introduction.tex}
\input{simulation.tex}
\input{results.tex}
\input{conclusions.tex}
\section*{Acknowledgments}
We are very grateful to Erik W.~Draeger, Jonathan L.~DuBois, Jay
Gambetta, Eric T. Holland, Ramis Movassagh, John Smolin, Fred Streitz,
Maika Takita, Robert Walkup, Chris Wood, the whole IBM Q team, and the
Lawrence Livermore National Laboratory for their collaboration that
made this paper possible. Work of Tom Magerlein was performed during
an internship at the IBM T.J.~Watson Research Center.
%% Work of Erik W.~Draeger, Jonathan L.~DuBois, and Eric
%% T. Holland was performed under the auspices of the U.S.~Department of
%% Energy by Lawrence Livermore National Laboratory under Contract
%% DE-AC52-07NA27344 under LLNL-LDRD (16-SI-004).
\bibliographystyle{plainurl}
\bibliography{gn,lh,jg,rm}
\appendix
\section*{Appendix}
\input{mle_analysis.tex}
\input{googlecirc.tex}
\end{document}
\section{Introduction}
\label{s:intro}
In the last few years, significant technological progress has enabled
quantum computing to evolve from a visionary idea
\cite{feynman1982simulating} to reality \cite{NatureNewsIBMQ,
castelvecchi2017quantum}. With existing devices now providing
$10$--$20$ qubits with controllable couplings, the topic of ``quantum
supremacy'' --- that is, the ability of a quantum device to perform a
computational task beyond what any classical computer can currently
perform --- is receiving much attention
\cite{harrow2017quantum,preskill2012quantum,boixo2016supremacy,aaronson2016complexity,farhi2016quantum}.
Work in this area is raising many issues, two of which are
particularly relevant to advancing quantum technology: (1) the ability
to quantify circuit fidelity (e.g.,
\cite{bishop2017volume,reed2010high,gambetta2015building,boixo2016supremacy,linke2017experimental}),
(2) the ability to assess correctness, performance and scaling
behavior of quantum algorithms
\cite{Gheorghiu2017verification}. Fundamental to both is the ability
to calculate quantum state amplitudes for measured outcomes.
It is important to distinguish the problem of computing ideal quantum
state amplitudes for measured outcomes from the problem of calculating
all amplitudes in a quantum state, and from the problem of randomly
sampling from the implied probability distribution to simulate quantum
computation. These problems become intractable very quickly, simply
because the number of amplitudes grows exponentially with the number
of qubits. By way of contrast, we present empirical evidence that
suggests that the problem of calculating quantum state amplitudes for
measured outcomes may not grow to intractable levels quite as
quickly as one might expect, neither in terms of computational
complexity nor memory requirements, a fortunate circumstance from an
engineering standpoint.
This empirical evidence derives from simulations we have performed of
two quantum circuits: one with depth 27 for a $7 \times 7$ grid of
qubits, the other with depth 23 for an $8 \times 7$ grid of
qubits. The depth of a circuit is the number of layers that the
circuit can be partitioned into in such a way that the gates acting on
the qubits at any given layer do no overlap. Both circuits are
examples of {\em universal random circuits} constructed according to
the rules described in \cite{boixo2016supremacy}, where the first
layer of Hadamard gates are not counted in the depth. The primary data
structures employed in the 49-qubit simulation required just over 4.5
Terabytes of main memory to store results, while for the 56-qubit
simulation they required just over 3.0 Terabytes. In contrast,
existing state-of-the-art techniques \cite{haner2017simulation} would
have required 8 Petabytes and 1 Exabyte, respectively. The 49-qubit
circuit contained 761 gates and requires an average of 3.83
floating-point operations per gate per amplitude to compute
results. The 56-qubit circuit contained 745 gates and requires an
average of 3.90 floating-point operations per gate per amplitude. In
contrast, a complex multiplication operation requires six
floating-point operations: four multiplications and two additions.
Our approach to calculating quantum amplitudes abandons the
conventional Dirac matrix-vector representation of gates and quantum
states \cite{dirac1939notation,haner2017simulation}. Instead, we
employ a tensor representation \cite{joshi1995matrices}. This
mathematical shift in representation enables the full power of the
commutative, associative, and distributive laws of the field of
complex numbers to be exploited to reorganize the equations that
define quantum circuits without being encumbered by the more
restrictive algebras that govern matrices and inner products. In
particular, these laws enable:
\begin{itemize}
\item Quantum circuits to be arbitrarily partitioned into subcircuits.
\item Subcircuits to be simulated in arbitrary orders, even independently.
\item Simulation results of subcircuits to be combined in arbitrary orders.
\end{itemize}
Our approach combines this flexibility with tensor slicing methods to
enable final quantum states of circuits to be calculated in slices
instead of having to materialize entire quantum states in memory all
at once.
The computations were performed on the Vulcan supercomputer at
Lawrence Livermore National Laboratories, an IBM Blue Gene/Q system
with 24576 nodes, each one equipped with 16 cores and 16GB of memory
(in total, we required less than 5 Terabytes of memory for output). The tensor
calculations for each circuit were implemented using Cyclops
Tensor Framework \cite{solomonik2014massively}, a distributed-memory
C++ library for algebraic transformations of multidimensional arrays.
We used the simulation on Vulcan to investigate the isotropic
properties of the resulting distributions of quantum-state
probabilities. Theory predicts that these probabilities should exhibit
exponential (a.k.a.~Porter-Thomas \cite{porter1956fluctuations})
distributions across the aggregate quantum state
\cite{boixo2016supremacy}. However, because the pattern in which these
probabilities occur within the final quantum state is also chaotic,
the same exponential distribution of probabilities should likewise be
observed within small local slices of the state as well. Our
simulation of the 49-qubit circuit confirms this phenomenon: the same
exponential distribution of probabilities was observed in the tensor
slices that were calculated as was observed in the overall quantum
state, with only minor variations observed among tensor slices. We
then simulated an arbitrarily selected slice of amplitudes for the
56-qubit circuit to further confirm this phenomenon. This slice of the
56-qubit quantum state likewise exhibited the same expected
exponential distribution of probabilities.
Our simulations demonstrate that the computation of quantum amplitudes
for measured outcomes has now entered the realm of the possible for
quantum devices of 50 qubits or more. The extent to which the
simulation methodology proposed in this paper can be advanced is yet
to be fully explored; investigation of this aspect is left for future
research.
This paper is organized as follows. Section \ref{s:methodology}
describes the mathematical foundations of our simulation
methodology. Section \ref{s:results} presents a summary of our
numerical results. Section \ref{s:conclusions} concludes the paper and
discusses future research directions. The appendix contains details on
the analytical form of the outcome distribution, and more details on
the decomposition of the two large circuits that we simulated.
\section{Simulation methodology}
\label{s:methodology}
We now describe our approach for simulating quantum circuits, thereby
computing the probabilities needed to characterize circuit fidelity.
As previously noted, our approach abandons the usual Dirac
matrix-vector representation of circuit equations in favor of a tensor
representation. To keep the exposition accessible, self-contained,
and still relatable to Dirac notation, we use a tensor notation
derived from linear algebra.
We define a {\em circuit} to be a sequence of $d$ layers $G_1, \dots,
G_d$, where each layer consists of an undirected graph on the same
vertex set $V := \{1,\dots,n\}$; formally, $G_t = (V_t, E_t), V_t =
\{1,\dots,n\}, E_t \subseteq V_t \times V_t$. Every edge represents a
two-qubit gate, and no vertex can appear in two edges on the same
layer. At each layer, a single-qubit gate is applied to every vertex
that does not appear in a two-qubit gate. This is done without loss of
generality, as we can always think of the identity gate being applied.
Gates involving more than two qubits are not considered, but in
principle the representation could be extended to accommodate such
gates as well. Alternatively, circuits containing such gates could be
transformed into equivalent circuits containing only one- and
two-qubit gates.
Let $V_t^1 := V_t \setminus \{j : (i,j) \in E_t \text{ or } (j,k) \in
E_t\}$ be the qubits in layer $t$ that are not involved in two-qubit
gates. For $j \in V_t^1$, let $U^{t,j}$ be the gate applied to qubit
$j$ in layer $t$, where $U^{t,j} \in \C^{2 \times 2}$ is a unitary
matrix. For $(i, j) \in E_t$, let $U^{t,(i,j)}$ be the two-qubit gate
applied to qubits $i$ and $j$ in layer $t$, where $U^{t,(i,j)}
\in \C^{4 \times 4}$ is likewise a unitary matrix.
We use subscripts to denote elements of vectors and matrices, and in
particular we use binary strings as indices as is customary in
quantum mechanics. For example, given binary digits $i, j, k,h \in
\{0,1\}$ and a vector $\psi \in (\C^2)^{\otimes 3} \equiv \C^{8}$,
$\psi_{ijk}$ denotes the element in the position corresponding to the
binary string ${ijk}$, and given $U \in \C^{4 \times 4}$, $U_{ij,kh}$
denotes the matrix element whose row is indexed by the binary string
$ij$ and whose column is indexed by the binary string $kh$.
Let $n$ be the number of qubits and $N = 2^n$. The quantum state is
therefore a unitary vector in $\Hil \equiv \mathbb{C}^{N}$. The
initial state is denoted $\delta_{i_1\dots i_n}$, with:
\begin{align*}
\delta_i &= \begin{cases} 1 & \text{if } i = 0 \\ 0 & \text{otherwise} \end{cases} \\
\delta_{i_1\dots i_n} &= \delta_{i_1} \cdots \delta_{i_n}.
\end{align*}
Using the above notation, and given the state $\psi^{t-1}$ after the
$(t-1)$-th layer of gates, we can express the state after the $t$-th
layer as follows:
\begin{equation*}
\psi^{t}_{i_1\dots i_n} = \sum_{j_1,\dots,j_n \in \{0,1\}}
\left(\prod_{k \in V_t^1} U^{t,k}_{i_k,j_k} \prod_{(h,k) \in E_t}
U^{t,(h,k)}_{i_hi_k,j_hj_k} \psi^{t-1}_{j_1\dots j_n}\right)
\end{equation*}
Together with the initial conditions on the state, we obtain the
following recursion that fully describes the amplitudes of the final
state:
\begin{align}
\label{eq:staterecursion}
\forall t = 1,\dots,d \quad \psi^{t}_{i_1\dots i_n} &=
\sum_{j_1,\dots,j_n \in \{0,1\}}
\left(\prod_{k \in V_t^1} U^{t,k}_{i_k,j_k} \prod_{(h,k) \in E_t}
U^{t,(h,k)}_{i_hi_k,j_hj_k} \psi^{t-1}_{j_1\dots j_n}\right)\\
\label{eq:initialcondition}
\psi^{0}_{i_1\dots i_n} &= \delta_{i_1\dots i_n}.
\end{align}
The simulation of a quantum circuit is equivalent to the solution of
this recursion. The recursion can be solved by dynamic programming
\cite{bellmandp}, and the computation can be accelerated in many
possible ways; e.g., memoization to store intermediate results. Note
that in principle \eqref{eq:staterecursion} can be written as a single
matrix-vector multiplication
\begin{equation*}
\psi^t = \bar{U}^t \psi^{t-1}
\end{equation*}
with
\begin{equation}
\label{eq:fullunitary}
\bar{U}^t_{i_1\dots i_n, j_1\dots j_n} = \left(\prod_{k \in V_t^1}
U^{t,k}_{i_k,j_k} \prod_{(h,k) \in E_t}
U^{t,(h,k)}_{i_hi_k,j_hj_k}\right).
\end{equation}
This has the advantage of computing the entire state, but the matrix
$\bar{U}^t$ has size $4^n$, which is often prohibitive even for
moderate $n$: even with $n=25$, a dense matrix would require 16
Petabytes of storage for complex numbers in double precision.
The solution of \eqref{eq:staterecursion}-\eqref{eq:initialcondition}
can be carried out efficiently in specific cases. For example, the
computation becomes trivial when $V^1_t = V_t$ at every layer; i.e.,
there are no two-qubit gates in the circuit. Indeed, in this case the
quantum state $\psi^{t}_{i_1\dots i_n}$ can be expressed as a product
of simpler terms $\psi^t_{i_1},\dots,\psi^t_{i_n}$. This is trivially
true at $t = 0$ because $\psi^0_{i_1\dots i_n} = \delta_{i_1\dots i_n}
= \delta_{i_1}\cdots \delta_{i_n}$, and the property propagates
forward by induction following \eqref{eq:staterecursion} because:
\begin{align}
\notag
\psi^{t}_{i_1\dots i_n} &=
\sum_{j_1,\dots,j_n \in \{0,1\}}
\left(\prod_{k=1,\dots,n} U^{t,k}_{i_k,j_k} \delta_{j_1\dots j_n}
\right) =
\sum_{j_1\in \{0,1\}}\sum_{j_2\in \{0,1\}}\cdots \sum_{j_n \in \{0,1\}}
\prod_{k=1,\dots,n} U^{t,k}_{i_k,j_k} \psi^{t-1}_{j_1}\cdots \psi^{t-1}_{j_n} \\
&= \sum_{j_1\in \{0,1\}} U^{t,1}_{i_1 j_1} \psi^{t-1}_{j_1}
\sum_{j_2\in \{0,1\}} U^{t,2}_{i_2 j_2} \psi^{t-1}_{j_2} \cdots
\sum_{j_n \in \{0,1\}} U^{t,n}_{i_n j_n} \psi^{t-1}_{j_n}
\label{eq:productstate}\\
&:= \psi^{t}_{i_1} \psi^{t}_{i_2} \cdots \psi^{t}_{i_n}. \notag
\end{align}
The equation above shows that the state at layer 1 can be expressed as
a product of simpler terms that depend on a single qubit, and it is
easy to see that the recursion continues in this product form until
the last layer. This is a well-known fact: because the initial state
is a so-called product state (tensor product of individual qubits) and
because there are no entangling two-qubit gates, the quantum state
remains a product state and can be computed qubit by qubit. It follows
that computing a single amplitude of the final state in such cases
requires linear time and space. Other cases in which
\eqref{eq:staterecursion}-\eqref{eq:initialcondition} can be easily
solved include stabilizer circuits \cite{aaronson2004improved},
match gates \cite{valiant2002quantum}, and circuits with polynomially
bounded entanglement under a certain measure
\cite{vidal2003efficient}. In general, however, the computation as
stated may require exponential time and/or memory because of the
exponential number of terms in the summation.
\subsection{Overview of known simulation techniques}
\label{s:knowntechniques}
There are two widely used strategies to approach the recursion
\eqref{eq:staterecursion}-\eqref{eq:initialcondition}. The first
strategy consists of following the recursion layer by layer, fully
computing the state $\psi^t$ for $t=0,\dots,d$ at each layer, and
expanding the calculation \eqref{eq:staterecursion} using tensor
contractions. This approach, sometimes called the ``Schr\"odinger
algorithm'' \cite{aaronson2016complexity}, has the drawback of storing
the entire state vector in memory at each layer, requiring $O(2^n)$
memory and $O(dn 2^n)$ operations, which is prohibitive for $\approx
50$ qubits. Another strategy involves following all the ``paths'' from
a final state to the initial state in the dynamic programming
recursion. This approach requires $O(2^{nd})$ time but linear space.
See also the description of the ``Feynman algorithm'' given in
\cite{aaronson2016complexity} and
\cite[Thm.~8.6]{bernstein1997quantum}.
Clearly, other strategies are possible. When solving
\eqref{eq:staterecursion}-\eqref{eq:initialcondition}, we are only
bound by ingenuity and the rules of linear
algebra. \cite{aaronson2016complexity} proposes a scheme for circuits
that can be embedded into a given 2D grid; i.e., when the graphs $G_t$
are planar and there is an embedding of the vertex set onto a
two-dimensional grid such that edges (two-qubit gates) only appear
between adjacent vertices (qubits). If such an embedding is given, the
2D grid can be partitioned into two sets $V^1,V^2$ such that
$\max\{|V^1|,|V^2|\} \le \frac{2}{3}|V|$, and there are at most
$O(\sqrt{|V|})$ edges crossing the partition with one endpoint in
$V^1$ and one in $V^2$ \cite[Lem.~4.1]{aaronson2016complexity}. Let
$R$ be the set of edges crossing the partition. We can then apply
\eqref{eq:staterecursion}-\eqref{eq:initialcondition} to the induced
subcircuits $G[V^1], G[V^2]$ separately, and combine the results
looping over the $16^{|R|}$ elements resulting from all possible
combinations of the matrix elements of the gates corresponding to
edges in $R$. In terms of \eqref{eq:staterecursion} and assuming
without loss of generality that $V^1 = \{1,\dots,m\}, V^2 =
\{m+1,\dots,n\}$, this corresponds to computing:
\begin{align*}
\phi^{t}_{i_1\dots i_m} &=
\sum_{j_1,\dots,j_m \in \{0,1\}}
\left(\prod_{k \in V_t^1} U^{t,k}_{i_k,j_k} \prod_{(h,k) \in E_t}
U^{t,(h,k)}_{i_hi_k,j_hj_k} \phi^{t-1}_{j_1\dots j_m}\right) \\
\xi^{t}_{i_{m+1}\dots i_n} &=
\sum_{j_{m+1},\dots,j_n \in \{0,1\}}
\left(\prod_{k \in V_t^1} U^{t,k}_{i_k,j_k} \prod_{(h,k) \in E_t}
U^{t,(h,k)}_{i_hi_k,j_hj_k} \xi^{t-1}_{j_{m+1}\dots j_n}\right),
\end{align*}
which are then combined together to form $\psi^d$ looping over all
possible combinations of the elements in $U^{t,(h,k)}$ for $(h,k) \in
R, t=1,\dots,d$. The idea can be applied recursively to $V^1,
V^2$. Combined with another speedup obtained by recursively
partitioning the layers $t=1,\dots,d$ into two, this yields an
algorithm for 2D grid circuits that requires $O\left(2^n \left[1 +
\left(\frac{d}{c\sqrt{n}}\right)^{n+1}\right]\right)$ time and $O(d n\log
n)$ space for each amplitude.
A simulation methodology based on tensor network contractions is
presented in \cite{markov2008simulating}. This methodology relies on
the construction of a tensor network in which nodes represent gates,
and edges represent ``common indices'' between gates. To compute the
outcome probability of a given state, one needs to perform a
contraction of the entire network to a single node, where a
contraction corresponds to a summation. It is shown in
\cite{markov2008simulating} that the contraction can be performed
efficiently if the circuit graph has small treewidth. More
specifically, the algorithm of \cite{markov2008simulating} runs in
exponential time in the treewidth of said graph. We remark that
treewidth often occurs as a measure of complexity for problems that
may be difficult in general: for example, the NP-hard problems of
determining a minimum-sized vertex coloring, Hamiltonian cycle, or
vertex cover of a graph are easy to solve by dynamic programming if
the graph has bounded treewidth \cite{bienstock1995algorithmic}. For
the class of circuits considered in this paper,
Fig.~\ref{fig:treewidth} suggests that the treewidth grows with both
the number of qubits and the circuit depth. The figure depicts a lower
bound to the treewidth of universal random circuits, computed using
the MDD+ algorithm \cite{bodlaender2006contraction} (exact computation
of the treewidth is an NP-hard problem). Although lower bounds may not
accurately characterize the overall trend, the growth of these bounds
indicates that this class of circuits may be nontrivial to simulate
with the approach of \cite{markov2008simulating}. We remark that
tensor network representations have been a crucial component of other
works as well, e.g., \cite{darmawan2017tensor}; in this paper we do
not directly employ a tensor network representation.
\begin{figure}
\centering
\includegraphics[width=0.8\textwidth]{figures/treewidth_graph.png}
\caption{Lower bound on the treewidth as a function of qubit count
and circuit depth for universal random circuits. The two red dots
correspond to the specific circuits simulated in Section
\ref{s:results}. The lower bounds are computed for circuits of
size $5 \times 5, 5 \times 6, 5 \times 7, 5 \times 8, 6 \times 6,
6 \times 7, 6 \times 8, 7 \times 7, 7 \times 8, 8 \times 8$ and
all depths from 15 to 30; the remaining values are interpolated.}
\label{fig:treewidth}
\end{figure}
From a more practical point of view, one can employ a strategy that
combines the ``Schr\"odinger algorithm'' with circuit partitioning.
Initially, $V$ is partitioned into the $n$ singletons $V^i := \{i\},
i=1,\dots,n$ and each subcircuit $G[V^i]$ is simulated independently
if possible, just as in \eqref{eq:productstate}. Whenever an
entangling gate between two partitions is encountered, the two
partitions are merged into a single subcircuit, and the simulation then
proceeds in the same fashion. In other words, we initially consider
each qubit as a separate subcircuit and we merge subcircuits as
necessary whenever entanglement between subcircuits occurs. This
approach is exemplified in Figure \ref{fig:simstrat}.
\begin{figure}[tb]
\leavevmode
\centering
\Qcircuit @C=2em @R=1em {
& \gate{H} & \ctrl{1} & \qw & \qw \\
& \gate{H} & \targ & \ctrl{1} & \qw \\
& \gate{H} & \gate{X} & \targ & \qw
\gategroup{1}{1}{1}{2}{.6em}{--} \gategroup{2}{1}{2}{2}{.6em}{--}
\gategroup{3}{1}{3}{3}{.6em}{--} \gategroup{1}{3}{2}{3}{1.6em}{--}
\gategroup{1}{4}{3}{4}{1.6em}{--}
}
\caption{A common simulation strategy: each qubit is initially
a separate subcircuit whose simulation is carried out independently,
and subcircuits are merged as entangling gates are encountered.}
\label{fig:simstrat}
\end{figure}
Of course, if the circuit being simulated is nontrivial (i.e., does
not trivially yield a product state), this simulation strategy
eventually has to compute the full state vector of size $2^n$.
\subsection{Building blocks for our simulation technique}
\label{s:buildingblocks}
We use a combination of several techniques to speedup and reduce the memory footprint of the computation
\eqref{eq:staterecursion}-\eqref{eq:initialcondition}. Many of the
calculations can be carried out in multiple mathematically equivalent
ways that yield different memory and time requirements; hence, for
each circuit we consider several possibilities and choose one that
fits the capacity of the available computing cluster. We will
elaborate on this aspect after describing the building blocks of our
methodology, which are the following:
\begin{enumerate}
\item Tensor slicing;
\item Circuit transformation;
\item Deferral of entangling gates.
\end{enumerate}
\subsubsection{Tensor slicing}
\label{s:slicing}
The simplest technique that we consider is that of simplifying the
recursion \eqref{eq:staterecursion} in the presence of diagonal gates;
i.e., quantum gates described by diagonal matrices. Examples of such
gates include $Z$, $S$, $T$ and $CZ$ gates. Suppose that there exists
a qubit $q$ such that, in all layers from $\tau$ to $d$, qubit $q$ is only
involved in diagonal gates. Then we can write:
\begin{equation}
\label{eq:diagonal}
\forall t = \tau,\dots,d \quad \psi^{t}_{i_1\dots i_q \dots i_n} =
\sum_{\substack{j_1,\dots j_{q-1}, j_{q+1},j_n \in \{0,1\} \\ j_q = i_q}}
\left(\prod_{k \in V_t^1} U^{t,k}_{i_k,j_k} \prod_{(h,k) \in E_t}
U^{t,(h,k)}_{i_hi_k,j_hj_k} \psi^{t-1}_{j_1\dots j_n}\right)\\
\end{equation}
Writing the expression in this form has two advantages. First, by
eliminating one index (i.e., $j_q$) from the summation in
\eqref{eq:diagonal}, we are effectively halving the memory
requirements for simulation via matrix-vector multiplication: instead
of a single matrix \eqref{eq:fullunitary} of size $4^n$ we only
require two matrices of size $4^{n-1}$. Second, if we are interested
in the full state $\psi^t$, we can loop over the two possible values
for $i_q = 0, 1$ in a very efficient embarrassingly-parallel manner,
thereby slicing the computation as well. Notice that these two
advantages hold for each index $i_q$ that can be sliced: if there are,
in total, $m$ indices that can be sliced because all the corresponding
gates from layer $\tau$ to $d$ are diagonal, then we save $2^m$
storage space for the matrix \eqref{eq:fullunitary}, and we can
perform the computation in parallel over $2^m$ processors.
\subsubsection{Circuit transformation}
\label{s:diagonalize}
It is well-known that there are several equivalent representations for
a given quantum circuit. In principle, since each circuit can be
simulated in a different way and therefore yield different memory and
time requirements, one would have to consider all possible equivalent
representations. However, in practice, only transformations that cater
to the strength of a particular simulation methodology need be
considered. Because we want to apply tensor slicing, we consider
transformations that diagonalize gates. For example, for every
$CX$ in the circuit, we consider whether the transformation indicated
in Fig.~\ref{fig:cxequiv} is beneficial.
\begin{figure}[tb]
\leavevmode
\centering
\Qcircuit @C=1em @R=.9em {
& \ctrl{1} & \qw & \\
& \targ & \qw &
}
\hspace{7em}
\Qcircuit @C=1em @R=0.7em {
& \qw & \ctrl{1} & \qw & \qw & \\
& \gate{H} & \gate{Z} & \gate{H} & \qw &
}
\caption{Transformation of a $CX$ gate into a $CZ$ and two Hadamards.}
\label{fig:cxequiv}
\end{figure}
The transformation involves a trade-off between the number of
non-diagonal two-qubit gates with the total number of gates. The
total number of gates increases, but instead of two-qubits with
non-diagonal operators, we now have one qubit with diagonal gates and
one with non-diagonal gates. This type of transformation can be
beneficial if it allows tensor slicing to be applied earlier, so the
trade-off has to be considered on a case-by-case basis.t
\subsubsection{Deferral of entangling gates}
\label{s:deferral}
The third and final building block of our simulation technique is the
selection of some entangling gates for deferred computation in order
to maintain a partitioning of a circuit into subcircuits that decrease
memory usage. The idea is somewhat similar to
\cite{aaronson2016complexity}, but we are flexible as to which two-qubit
gates are deferred. We describe the idea for a single two-qubit gate
$(m,m+1)$ at layer $\tau$. Assume (with a possible rearrangement of
qubit indices) that there exists a partition $V^m := \{1,\dots,m\},
V^{m+1} := \{m+1,\dots,n\}$ of $V$ such that up to layer $\tau$, there
are no two-qubit gates between $V^m$ and $V^{m+1}$. A commonly
employed strategy in this case is to simulate the subcircuits $G[V^m],
G[V^{m+1}]$ induced by the two sets of qubits separately, and then
perform a merge (with the corresponding multiplicative increase in
memory requirements) only when necessary, in this case at layer
$\tau$. However, another possibility, and the one we advocate here, is to
instead defer merging the quantum state information associated with
each subcircuit by introducing additional indices to mathematically
account for the entanglement of the two subcircuits. We can write:
\begin{align*}
\psi^{\tau}_{i_1\dots i_n} &=
\sum_{j_1,\dots,j_n \in \{0,1\}}
\left(\prod_{k \in V_t^1} U^{\tau,k}_{i_k j_k} \prod_{(h,k) \in E_t}
U^{\tau,(h,k)}_{i_hi_k,j_hj_k} \psi^{\tau-1}_{j_1\dots j_n}\right) \\
&= \sum_{j_1,\dots,j_m \in \{0,1\}} \sum_{j_{m+1},\dots,j_n \in \{0,1\}}
\left(\prod_{k \in V_t^1} U^{\tau,k}_{i_k j_k} \prod_{(h,k) \in E_t}
U^{\tau,(h,k)}_{i_hi_k,j_hj_k} \psi^{\tau-1}_{j_1\dots j_n}\right) \\
&= \sum_{\ell_m,\ell_{m+1} \in \{0,1\}}
\sum_{\substack{j_1,\dots,j_m \in \{0,1\} \\ j_m = \ell_m}}
\sum_{\substack{j_{m+1},\dots,j_n \in \{0,1\} \\ j_{m+1} =
\ell_{m+1}}} \left(\prod_{k \in V_t^1} U^{\tau,k}_{i_k j_k}
\prod_{(h,k) \in E_t} U^{\tau,(h,k)}_{i_hi_k,j_hj_k}
\psi^{\tau-1}_{j_1\dots j_n}\right) \\
&= \sum_{\ell_m,\ell_{m+1} \in \{0,1\}} U^{\tau,(m,m+1)}_{i_mi_{m+1},\ell_m\ell_{m+1}}
\sum_{\substack{j_1,\dots,j_m \in \{0,1\} \\ j_m = \ell_m}}
\left(\prod_{k \in V_t^1 \cap V^{m}} U^{\tau,k}_{i_k j_k}
\prod_{\substack{(h,k) \in E_t \\ h,k \in V^m}} U^{\tau,(h,k)}_{i_hi_k,j_hj_k}
\psi^{\tau-1}_{j_1\dots j_m}\right) \\
&\phantom{=}\sum_{\substack{j_{m+1},\dots,j_n \in \{0,1\} \\ j_{m+1} =
\ell_{m+1}}} \left(\prod_{k \in V_t^1 \cap V^{m+1}} U^{\tau,k}_{i_k j_k}
\prod_{\substack{(h,k) \in E_t \\ h,k \in V^{m+1}}}
U^{\tau,(h,k)}_{i_hi_k,j_hj_k}
\psi^{\tau-1}_{j_{m+1}\dots j_n}\right)
\end{align*}
This expression shows that we can still carry out computations
separately for $G[V^m], G[V^{m+1}]$, if we are willing to pay the
bookkeeping price of extra indices $\ell_m, \ell_{m+1}$. In
particular, we have two choices, shown by the following equation that
is easily seen to be equivalent to the last row of the expression above:
\begin{equation}
\label{eq:deferralchoice}
\begin{split}
\sum_{\ell_m,\ell_{m+1} \in \{0,1\}}
\sum_{\substack{j_1,\dots,j_m \in \{0,1\} \\ j_m = \ell_m}}
\left(U^{\tau,(m,m+1)}_{i_mi_{m+1},\ell_m\ell_{m+1}} \prod_{k \in V_t^1 \cap V^{m}} U^{\tau,k}_{i_k j_k}
\prod_{\substack{(h,k) \in E_t \\ h,k \in V^m}} U^{\tau,(h,k)}_{i_hi_k,j_hj_k}
\psi^{\tau-1}_{j_1\dots j_m}\right) \\
\phantom{=}\sum_{\substack{j_{m+1},\dots,j_n \in \{0,1\} \\ j_{m+1} =
\ell_{m+1}}} \left(\prod_{k \in V_t^1 \cap V^{m+1}} U^{\tau,k}_{i_k j_k}
\prod_{\substack{(h,k) \in E_t \\ h,k \in V^{m+1}}}
U^{\tau,(h,k)}_{i_hi_k,j_hj_k}
\psi^{\tau-1}_{j_{m+1}\dots j_n}\right) =\\
\sum_{\ell_m,\ell_{m+1} \in \{0,1\}}
\sum_{\substack{j_1,\dots,j_m \in \{0,1\} \\ j_m = \ell_m}}
\left(\prod_{k \in V_t^1 \cap V^{m}} U^{\tau,k}_{i_k j_k}
\prod_{\substack{(h,k) \in E_t \\ h,k \in V^m}} U^{\tau,(h,k)}_{i_hi_k,j_hj_k}
\psi^{\tau-1}_{j_1\dots j_m}\right) \\
\phantom{=}\sum_{\substack{j_{m+1},\dots,j_n \in \{0,1\} \\ j_{m+1} =
\ell_{m+1}}} \left(U^{\tau,(m,m+1)}_{i_mi_{m+1},\ell_m\ell_{m+1}} \prod_{k \in V_t^1 \cap V^{m+1}} U^{\tau,k}_{i_k j_k}
\prod_{\substack{(h,k) \in E_t \\ h,k \in V^{m+1}}}
U^{\tau,(h,k)}_{i_hi_k,j_hj_k}
\psi^{\tau-1}_{j_{m+1}\dots j_n}\right). \\
\end{split}
\end{equation}
According to \eqref{eq:deferralchoice}, we can assign the entangling
gate $U^{\tau,(m,m+1)}$ to $G[V^m]$, or to $G[V^{m+1}]$. Notice that
if we assign $U^{\tau,(m,m+1)}$ to $G[V^m]$ (l.h.s.\ of
\eqref{eq:deferralchoice}), the part of the equation concerning
indices $j_{m+1},\dots,j_n$ is not affected by the indices
$j_1,\dots,j_m$. However, since $j_{m+1} = \ell_{m+1}$, the $(m+1)$-th
qubit line now depends on the index $\ell_{m+1}$, so the subcircuit
$G[V^{m+1}]$ must, in general, keep track not only of $i_{m+1}$, but
also of $\ell_{m+1}$. (If only diagonal gates are applied to the
$(m+1)$-th qubit line after layer $\tau$, this bookkeeping work
is not necessary thanks to slicing.) As a consequence, calculations
for $G[V^{m+1}]$ can be carried out as a separate subcircuit with the
overhead (both in terms of memory, and floating point operations) of
additional bookkeeping indices. Likewise, the subcircuit $G[V^m]$ now
has to keep track of extra indices $i_{m+1},\ell_{m+1}$ because it
depends directly on them, and this induces an overhead. The same
considerations apply if we assign $U^{\tau,(m,m+1)}$ to $G[V^{m+1}]$
(r.h.s.\ of \eqref{eq:deferralchoice}): the two subcircuits $G[V^m],
G[V^{m+1}]$ are carried out separately, the calculations related to
$U^{\tau,(m,m+1)}$ are performed in the $G[V^{m+1}]$ subcircuit, and
both subcircuits must keep track of $i_m, \ell_m$ (the ``entanglement
indices''). Note that if the entangling gate is diagonal, we can
impose the constraints $i_{m} = \ell_m$ and $i_{m+1} = \ell_{m+1}$, so
the extra bookkeeping work is cut down in half. If further entangling
two-qubit gates are present at subsequent layers between the partition
$V^m, V^{m+1}$, we have two possible choices: we can resolve the
entanglement by merging the partitions, or we can defer the additional
entangling gates as well, increasing the amount of bookkeeping. The
entanglement has to be resolved before outputting the full state
$\psi^d$.
\subsubsection{An example of possible computation schemes}
\label{s:example}
We now provide two small examples of the ideas discussed in this
section. In our first example we work with the circuit given in
Fig.~\ref{fig:exbase}. The memory and floating point requirements for
the operations that will be used in this example are given in Table
\ref{tab:memcpuops}. Notice that these requirements assume that we
want to compute the full state vector, and each complex number
requires 16 bytes of memory (two double-precision floating point
numbers).
\begin{figure}[tb]
\leavevmode
\centering
\Qcircuit @C=1em @R=.7em {
\lstick{\ket{0}} & \gate{H} & \ctrl{1} & \gate{Z} & \qw \\
\lstick{\ket{0}} & \gate{X} & \targ & \gate{Y} & \qw
\gategroup{1}{2}{1}{2}{.6em}{--} \gategroup{2}{2}{2}{2}{.6em}{--}
\gategroup{1}{3}{2}{4}{.6em}{--}
}
\caption{Example circuit with a classical partitioning scheme.}
\label{fig:exbase}
\end{figure}
\begin{table}
\centering
\begin{tabular}{|l|c|c|c|}
\hline
Gate & Multiplications & Additions & Memory [bytes] \\
\hline
$X$ & $2^{n+1}$ & $2^{n}$ & $2^{n+4}$ \\
$Y$ & $2^{n+1}$ & $2^{n}$ & $2^{n+4}$ \\
$Z$ & $2^{n}$ & $0$ & $2^{n+4}$ \\
$H$ & $2^{n+1}$ & $2^{n}$ & $2^{n+4}$ \\
$CX$ & $2^{n+2}$ & $3\cdot 2^{n}$ & $2^{n+4}$ \\
$CZ$ & $2^{n}$ & $0$ & $2^{n+4}$ \\
\hline
\end{tabular}
\caption{Memory requirements and number of floating point of operations for some quantum gates, when applied to a $n$-qubit quantum state ($2^n$-dimensional complex vector).}
\label{tab:memcpuops}
\end{table}
The simple partitioning scheme given in Fig.~\ref{fig:exbase} carries
out the first gate operations independently on each qubit, then merges
the two subcircuits. The total cost is 48 operations and 128 bytes of
memory. A different partitioning scheme is given in
Fig.~\ref{fig:exdeferred}: the computation of the entangling gate is
deferred, and the entire $CX$ gate is assigned to the bottom
subcircuit. In this case, the computation requires 62 operations and
256 bytes of memory. The reason the memory occupation and number of
operations is worse than the simple partitioning scheme of
Fig.~\ref{fig:exbase} is that we are only considering two qubits. In
this case, the extra bookkeeping due to deferring the entangling gate
is as much as the cost of merging the top and bottom subcircuits;
therefore, there is no advantage. However, for larger circuits the
benefit of keeping the circuit partitioned into subcircuits can be
substantial.
\begin{figure}[tp]
\leavevmode
\centering
\Qcircuit @C=1em @R=1em {
\lstick{\ket{0}} & \gate{H} & \ctrl{1} & \gate{Z} & \qw \\
\lstick{\ket{0}} & \gate{X} & \targ & \gate{Y} & \qw
\gategroup{1}{2}{1}{4}{.6em}{--} \gategroup{1}{3}{2}{3}{.7em}{.}
\gategroup{2}{2}{2}{4}{.6em}{--}
}
\caption{Example circuit with a deferred computation of the $CX$
gate. We assign the $CX$ gate to the bottom subcircuit.}
\label{fig:exdeferred}
\end{figure}
A better approach to carry out the computation in
Fig.~\ref{fig:exbase} is described in Fig.~\ref{fig:exsliced}.
\begin{figure}[tb]
\leavevmode
\centering
\Qcircuit @C=1em @R=.7em {
\lstick{\ket{0}} & \gate{H} & \qw & \ctrl{1} & \qw & \gate{Z} & \qw \\
\lstick{\ket{0}} & \gate{X} & \gate{H} & \gate{Z} & \gate{H} & \gate{Y} & \qw
\gategroup{1}{2}{1}{3}{.6em}{--} \gategroup{2}{2}{2}{3}{.6em}{--}
\gategroup{1}{4}{2}{6}{.6em}{--}
}
\caption{Example circuit with the $CX$ gate diagonalized, and
slicing of the right subcircuit.}
\label{fig:exsliced}
\end{figure}
In this computation scheme, the $CX$ gate is transformed into a $CZ$
gate and two $H$ gates. Because of the transformation, the top qubit
can be sliced in the subcircuit on the right, so we can carry out the
computations for the top qubit equal to $\ket{0}$ and $\ket{1}$
independently, without expanding the tensor product of the two
qubits. By doing so, the total cost is of 42 operations, and 96 bytes
of memory.
A more elaborate example is a universal random circuit for a $4 \times
1$ grid of qubits with depth 15. It turns out that the generating
rules produce many empty layers for this example and the circuit can
be represented using 9 layers. Such a circuit is depicted in
Fig.~\ref{fig:googleex}, together with a possible partitioning scheme.
\begin{figure}[tb]
\leavevmode
\centering
\Qcircuit @C=1em @R=.7em {
\lstick{i_0 \; \ket{0}} & \gate{H} & \qw & \qw & \ctrl{1} & \qw & \gate{T} & \qw & \qw & \ctrl{1} & \qw\\
\lstick{i_1 \; \ket{0}} & \gate{H} & \ctrl{1} & \gate{T} & \gate{Z} & \qw & \gate{Y} & \ctrl{1} & \gate{X} & \gate{Z} & \qw \inputgrouph{1}{2}{.8em}{\ket{\phi}}{4.8em} \inputgrouph{2}{3}{.8em}{\ket{\psi}}{-25em} \\
\lstick{i_2 \; \ket{0}} & \gate{H} & \gate{Z} & \gate{T} & \qw & \ctrl{1} & \gate{X} & \gate{Z} & \gate{T} & \qw & \qw \\
\lstick{i_3 \; \ket{0}} & \gate{H} & \qw & \qw & \qw & \gate{Z} & \gate{T} & \qw & \qw & \qw & \qw \inputgrouph{3}{4}{.8em}{\ket{\xi}}{4.8em}
\gategroup{1}{2}{2}{7}{.6em}{--} \gategroup{3}{2}{4}{7}{.6em}{--}
\gategroup{2}{3}{3}{3}{.6em}{.} \gategroup{1}{8}{3}{11}{.6em}{--}
}
\caption{Example of a random $4 \times 1$-qubit, depth 15 circuit generated according to
\cite{boixo2016supremacy}. The circuit can be contracted to 9
layers. The partitioning scheme is indicated in the figure.
The entangling gate in the second layer is deferred and assigned
to the bottom subcircuit.}
\label{fig:googleex}
\end{figure}
Using the labeling indicated in the diagram, and assigning the first
$CZ$ gate to the bottom $\ket{\xi}$ subcircuit, the full equations
governing the state are the following (for simplicity, we use gate
names to indicate the corresponding matrix, and omit the superscript
that denotes the layer in \eqref{eq:staterecursion}):
\begin{align*}
\phi_{i_0i_1\ell_1} &= T_{i_0,i_0} Y_{i_1,\ell_1} CZ_{i_0\ell_1,i_0\ell_1} T_{\ell_1,\ell_1} \sum_{j_0,j_1 \in \{0,1\}} H_{i_0,j_0} H_{\ell_1,j_1} \delta_{j_0 j_1} \\
\xi_{\ell_1 i_2 i_3} &= T_{i_3,i_3} \sum_{j_2 \in \{0,1\}} X_{i_2,j_2} CZ_{j_2i_3,j_2i_3} T_{j_2,j_2} CZ_{\ell_1j_2, \ell_1j_2} \sum_{k_2,k_3 \in \{0,1\}} H_{j_2,k_2} H_{i_3,k_3} \delta_{k_2k_3} \\
\psi_{i_0 i_1 i_2 i_3} &= CZ_{i_0i_1, i_0i_1} T_{i_2,i_2} \sum_{j_1 \in \{0,1\}} X_{i_1,j_1} CZ_{j_1i_2, j_1i_2} \sum_{\ell_1 \in \{0,1\}} \phi_{i_0 j_1 \ell_1} \xi_{\ell_1 i_2 i_3}.
\end{align*}
Note that, although the first $CZ$ gate in the circuit is assigned to
the bottom $\ket{\xi}$ subcircuit, we have to keep track of the extra
$\ell_1$ index associated with that $CZ$ gate in the top $\ket{\phi}$
subcircuit once the $T$ gate is introduced. We remark that the indices
$i_0, i_2, i_3$ in the final state $\ket{\psi}$ can be sliced, because the
corresponding indices appear only in diagonal gates. Therefore, we
never have to explicitly materialize the full state $\ket{\psi}$ in memory,
and can work on slices. In this example, deferring the entangling gate
$CZ$ in the second layer and slicing the last subcircuit allows us to
compute the final state without ever allocating memory to hold a full
$2^4$-dimensional state vector. Instead, the final state can be
computed in 8 slices using a state vector of size 2 for the
computation of a slice.
\subsection{Optimizing the circuit simulation strategy}
The general scheme that we follow in the computation of
\eqref{eq:staterecursion}-\eqref{eq:initialcondition} is to keep the
circuits partitioned into small subcircuits if possible, and decide on
the deferral of entangling gates on a case-by-case basis. We apply
tensor slicing whenever possible. For every $CX$ gate, we have the
choice of transforming it as indicated in Section \ref{s:diagonalize};
and for every entangling gate between qubits in different subcircuits,
we have the choice of deferring the entanglement as indicated in
Section \ref{s:deferral}. In this latter case, we have the choice of
assigning the entangling gate to either of the two
subcircuits. Alternatively, the subcircuits can be merged instead of
deferring the entanglement.
These options generate a space of possible computation schemes for
any given circuit. Given a circuit and a computation scheme, we can
compute the memory requirements and floating-point operations required
simply by analyzing the gates, as is done in Section
\ref{s:example}. In principle, we would like to run a bi-objective
optimization over the space of possible computation schemes to
generate the Pareto frontier that defines the optimal trade-off
between memory usage and floating-point operations. However, even
limiting ourselves to the schemes generated using the ideas of Section
\ref{s:buildingblocks}, the number of possible choices is
exponentially large, so a brute force exploration strategy of all
combinations is not viable for large circuits.
Nevertheless, the fact that this Pareto frontier has now been
identified means that in order to rule out the possibility of
simulating a given circuit within a given amount of memory and/or
time, one must prove that there does not exist a computation scheme
which satisfies the requirements of the stated claim. This could, in
general, be a difficult task.
To obtain the simulation results presented in this paper, we employed
both a heuristic search strategy that implemented some hand-crafted
circuit partitioning criteria based on our intuitions, as well as an
automated search that explores the choices described above in a
time-bounded and largely depth-first manner. The hand-crafted
strategies adopted the following principles:
\begin{itemize}
\item Diagonalize $CX$ gates if all subsequent gates applied to the
control qubit are diagonalized.
\item Try to keep each circuit partitioned into two or three
subcircuits.
\item Defer entanglement gates if merging would create a large
circuit; i.e., exceed a given memory threshold.
\item Assign deferred entanglement gates to the smallest subcircuit,
or to a subcircuit that can be sliced.
\end{itemize}
Figure \ref{fig:googlepart} in Appendix \ref{s:partitioning}
illustrates how a 49-qubit, depth 27 random circuit and a 56-qubit,
depth 23 random circuit were partitioned into subcircuits using the
hand-crafted approach described above. These circuits and subcircuits
were used in our simulation studies.
In addition, we used a time-bounded automated search method to explore
the trade-off between memory usage and floating-point operations for
various circuits. This search had the freedom to explore arbitrary
circuit partitionings unconstrained by our heuristic intuitions. In
each execution, the search method was given a circuit and a limit on
the available memory that could be used, and it then attempted to find
circuit partitionings that minimized the number of floating-point
operations needed to perform a simulation without exceeding the
specified memory limit. Fig.~\ref{fig:tradeoff} illustrates the
trade-off between memory and computation identified by the analysis
for the 49-qubit circuit shown in Figure \ref{fig:googlepart}. Note
that because the search strategy employed was time bounded and it did
not perform an exhaustive search, it is likely that this curve is
suboptimal and circuit partitioning schemes that strictly dominate
ours could be found.
\begin{figure}
\centering
\includegraphics[width=0.6\textwidth]{figures/memcputradeoff.png}
\caption{Trade-off between floating point operations and memory usage.}
\label{fig:tradeoff}
\end{figure}
We remark that the combination of the three building blocks of tensor
slicing, circuit transformation, and deferral of entangling gates in a
dynamic way yields a simulation approach with many differences with
respect to those described in the existing literature. We list here
the main differences as compared to
\cite{aaronson2016complexity,markov2008simulating}, which are the most
similar to our paper:
\begin{itemize}
\item We use diagonalization of gates and tensor slicing in order to
efficiently parallelize operations and reduce the memory footprint.
\item The partitioning of the graph into subcircuits is fixed in
\cite{aaronson2016complexity}, while it is dynamically determined at
each layer using our approach. Furthermore, in
\cite{aaronson2016complexity} the gates that cross subcircuits are
decomposed into components that are assigned to each subcircuit (the
number of components grows exponentially in the number of gates that
cross subcircuits), whereas in our approach such gates are assigned
in their entirety to either subcircuit.
\item In \cite{markov2008simulating}, the tensor contractions are
performed pairwise and in a fixed order (as determined by the tree
decomposition of the circuit graph), while in principle our scheme
allows arbitrary contractions and arbitrary order (but certain
orders are preferred to others because they are more memory
efficient). In addition, the deferral operations performed using our
approach are not tensor contractions, so they have no counterpart in
\cite{markov2008simulating}.
\end{itemize}
Many aspects of the decomposition scheme that we propose have still to
be thoroughly investigated, and their ramifications to be fully
understood. We discuss some of the open questions in Section
\ref{s:conclusions}.
\section{Numerical results}
\label{s:results}
In this section, we discuss the technical details of how we carried out
the simulation of the 49- and 56-qubit circuits on existing hardware,
and we summarize the results obtained from analyzing the amplitudes
computed by the simulation. We first describe the platform for the
computation.
\subsection{Hardware platform: Blue Gene/Q}
Our experiments were executed on an IBM Blue Gene/Q supercomputer \cite{BGchip2013},
which is the third generation of high-performance computers in the Blue
Gene series. A Blue Gene/Q node consists of 18 A2 PowerPC 64 bit
cores, 16 accessible from application space. The floating-point
performance of each core is augmented through the integration of a
four-way SIMD floating-point engine, dubbed QPX, capable of delivering
up to eight double-precision floating-point operations per processor
cycle. Designed to be energy-efficient, each A2 core runs at 1.6 GHz,
and is four-way (symmetrically) multi-threaded. Each thread is capable
of executing instructions, in-order, in two pipelines. One pipeline
executes all integer control and memory access instructions while the
other pipeline executes all floating point arithmetic instructions.
When multiple threads are used, instructions can execute on both
pipelines simultaneously.
Each core has a 16 KB private level 1 (L1) cache and a 2 KB
prefetching buffer (L1P). All the cores on the same processor share a
32 MB level 2 (L2) cache and 16GB of main memory. The compute nodes are connected in a 5D
torus network with a total network bandwidth of 44 GB/s per node.
\subsection{Software platform: Cyclops Tensor Framework}
We implemented the quantum circuit simulation approach described in
Section \ref{s:methodology} using Cyclops Tensor Framework
(CTF)~\cite{solomonik2014massively}, a distributed-memory C++ library
for tensor summations and contractions. The library provides a
domain-specific language for tensor operations using an Einstein-summation
syntax. CTF tensors are distributed over all processors
with tensor summations and contractions performed in a data-parallel
manner using MPI~\cite{gropp1999using}, OpenMP~\cite{dagum1998openmp},
and BLAS~\cite{lawson1979basic}. The library is capable of mapping
data directly to the 5D torus network topology of the Blue Gene/Q
architecture.
\subsection{Code generation and tuning}
We describe quantum circuits using a syntax similar to the QASM
specification \cite{cross2017qasm} used in the IBM Quantum Experience
\cite{ibmqexp}, since it is widely adopted. We developed a code
transformation and generation system in order to translate stylized
QASM code, with ordered gates and subcircuits, into CTF code that
could run on the Blue Gene/Q system at scale.
The massively parallel tensor contraction calculations enabled by CTF
have been driven by applications in computational chemistry and
physics~\cite{Bartlett:1981:ARPC:CC,orus2014practical} that involve
contractions of tensors with 4 to 8 dimensions. The quantum circuit
models employed in our calculation use tensors of much higher
dimension. In performing these contractions using CTF, the main new
challenge is the need for higher-dimensional virtual topologies; i.e.,
the decomposition of tensors among more dimensions than CTF typically
performs. CTF operates by mapping tensor dimensions onto dimensions
of a processor grid, often redistributing tensors to new mappings at
contraction time. As all the dimensions of our tensors are small,
mappings to high-dimensional processor grids are necessary. To
achieve these, we increased the space of virtual topologies CTF
considers, made improvements to the mapping logic in CTF, and enabled
dynamic creation and destruction of MPI communicators (defined for
each processor grid dimension). These changes make execution more
memory-efficient and substantially improved load-balance, but prevent
us from making effective use of rectangular collectives on Blue
Gene/Q~\cite{BGP2009,Kumar2014}, as few of the communicators used for
collectives would map to a contiguous hypercube or toroid.
We used the built-in profiling capabilities of CTF and the
performance-counter libraries made available on
Vulcan~\cite{WalkupPerf}, the hardware platform used in our
experiments, to determine the bottlenecks within CTF incurred during
circuit simulation contractions. For reasons of brevity, we do not
describe all optimizations in this paper. Local copy, summation, and
multiplication primitives were automatically replaced by appropriate
optimized variants, chosen with knowledge of the parameters employed
during the circuit simulations. These low-level changes substantially
improved the performance with respect to the original implementation.
% are highly inefficient. The most glaring
%example of this is the zcopy routine called on vectors of length two,
%resulting in poor performance because the run time would be dominated
%by parameter and error-checking in this case. The solution is to
%intercept all calls to zcopy with very short vectors and use a simple
%C loop. The second high-level performance fix has already been
%alluded to in one form: namely, the fact that we need to use small,
%high-dimensional virtual networks. This requires a change to the
%standard CTF description: otherwise, at large node counts CTF will
%interrogate the system and map itself to the hardware dimensions in
%order to take advantage of multiple communication channels, greatly
%increasing realized bandwidth and, in some cases, decreased latency.
%An implication of this change is that the performance model employed
%by CTF, and specialized for Blue Gene/Q, is then invalid and has to be
%altered to be consistent with the more standard communication
%algorithms utilized by the system.
The bulk of our performance improvements were high-level changes
applied to CTF or made at the application code level. As has been
described, the circuit-simulation code resulting from our code
generation system contains, in the performance-critical slicing loop
(Section \ref{s:slicing}), interactions between high-dimensional
tensors. There is a reasonably even mix between operations that
contain contractions and those that do not (e.g., diagonal gates that
involve only multiplications). The first performance optimization at
the application level was the aggregation of the (small) gate
operators that mutate the large state tensors in a manner similar to
that described in~\cite{haner2017simulation}. Thus, instead of
applying, for example, fifteen two-dimensional gates/tensors to a
tensor of dimension 38, we can apply one 30-dimensional tensor. As
the complexity of the application of each gate operator is generally
linear in the size of the tensor of states, the flop-to-byte ratio is
low (there are few computational operations for each memory access).
Aggregation of the operators incurs a greater computational cost, but
better amortizes the cost of transpositions and lowers the amount of
memory traffic associated with the tensor of states. We chose the
sizes both by considering the CTF performance model and through the
analysis of experimental data.
We further optimized the performance of the CTF multiplications and
contractions by tuning over possible ordering permutations of the
tensor modes. A tensor whose dimensions are greater than that of the
underlying (virtual) communication network is typically distributed by
CTF over its leading modes; e.g., elements $\psi_{ijk}$ for all $k$
may be owned by processor $p_{ij}$. The initial distribution of the
tensors plays a significant role in the performance characteristics of
both CTF multiplications and contractions. Certain distributions may
avoid the need for communication altogether in given multiplication or
contraction operations. We considered these permutations in light of a
variety of levels of aggregation of gate operators (e.g., aggregating
multiple gates into a single gate), which we observed to be beneficial
in terms of performance.
%% operators $U$ and $V$ into $Q$,
%% \[Z_{abcdefgh} = \sum_k \sum_l \underbrace{U_{abck}V_{abdl}}_{Q_{abcdkl}}W_{abcdefkl}.\]
%% which we observed to be beneficial in performance.
\subsection{Results}
In the case of the 49-qubit circuit, the final quantum state is
calculated in slices, where each slice involves the calculation of
$2^{38}$ amplitudes and a total of $2^{11}$ slices were calculated. In the
case of the 56-qubit circuit, only one slice with $2^{37}$ amplitudes
was calculated out of the $2^{19}$ such slices that defined the final
quantum state.
All experimental results were obtained over the course of two days on
Lawrence Livermore National Laboratory's Vulcan Blue Gene/Q
supercomputer. This time included the time to setup the experiments
described in this paper, as well as that to conduct additional
experiments beyond the scope of what is described here.
Memory usage required strong scaling to 4,096 nodes, with 64~TB of
memory, for each (parallel) calculation. As reported in Section
\ref{s:intro}, the theoretical minimum memory footprint to hold a
slice of the state vector is less than 5~TB for the 49-qubit circuit
($2^{38}$ complex doubles are used to store the $2^{38}$ amplitudes);
it is common in the literature to report just the memory required for
the state vector, e.g., \cite{haner2017simulation}. In practice, runs
required more than 32~TB. The bulk of these operations require two
tensors to compute and CTF internal buffering introduces approximately
a factor of 4 in overhead. Memory was also needed to reformat
contraction operands for efficiency and for buffer space as messages
are passed between nodes. Other sources of memory consumption stem
from the precise manner in which certain operations are performed in
CTF and we plan to address some of these trade-offs in future work.
After computing the ideal state amplitudes, we analyzed the
distributions of the corresponding outcome probabilities (i.e., the
squared magnitudes of the amplitudes) in aggregate across slices as
well as individually per slice. The ranges of these outcome
probabilities vary with the number of possible outcomes $N=2^n$, where
$n$ is the number of qubits. The values of these probabilities also
vary over several orders of magnitude. For these reasons, histograms
were calculated for the values of $z=\log(Np)$ for outcome
probabilities $p$. This transformation normalizes the resulting
histograms across varying numbers of qubits, simplifying their
comparison. It also better reveals the full dynamic range of the
outcome probabilities. The theoretical probability density of
$z=\log(Np)$ for universal random circuits with circuit fidelity
$\alpha$ is distributed according to the following equation, which
describes a truncated Gumbel distribution in the case of a perfect
fidelity of $\alpha = 1$:
\begin{equation}
\label{eq:gumbel}
f_z(z) =\frac{d}{dz} F_z(z)=\begin{cases}
\frac{\frac{1}{\alpha}e^{z-\frac{1}{\alpha}(e^z+\alpha-1)}}{1-e^{-N}} & 1-\alpha \leq e^z \leq 1+(N-1)\alpha \\
0 & \textrm{otherwise}.\\
\end{cases}
\end{equation}
The full derivation of this equation is given in Appendix
\ref{s:analysis}.
Fig.~\ref{fig:histogram} shows the histograms of the log-transformed
outcome probabilities ($\log(Np)$) obtained for the 49- and 56-qubit
circuits plotted together with their theoretical distributions given
by Equation~\eqref{eq:gumbel} for $\alpha=1$. The histogram for the
49-qubit circuit incorporates all $2^{49}$ outcome probabilities, while
the one for the 56-qubit circuit incorporates only the arbitrarily
selected slice of $2^{37}$ outcome probabilities that were calculated
for that circuit. As these graphs illustrate, there is an extremely
close agreement between the observed and predicted distributions in
both cases.
\begin{figure}[tb]
\centering
\includegraphics[width=0.49\textwidth]{figures/49_qubit_histogram.png}
\includegraphics[width=0.49\textwidth]{figures/56_qubit_histogram.png}
\caption{Histograms of log-transformed outcome probabilities
calculated for the 49-qubit circuit (left) and the 56-qubit
circuit (right), compared to their theoretically predicted
distributions.}
\label{fig:histogram}
\end{figure}
Fig.~\ref{fig:amplitudeplot} shows a plot of the histograms obtained
for an aggregation of the slices calculated for the 49-qubit circuit.
Each histogram is an aggregation of 32 slices, and the 64 individual
histograms have been stacked together and rendered as a surface plot
to better reveal variations between the histograms. As can be seen in
this figure, the variations are concentrated at the extreme tails of
the distribution where very low probabilities and, hence, very low bin
counts are observed in the histograms. Such variations are expected in
histograms whenever one is dealing with low bin counts. The effects
are magnified in this case because the vertical axis (corresponding to
bin counts) is plotted on a log scale. The same magnification effect
can likewise be observed in Fig.~\ref{fig:histogram}. Except for such
minor variations at low bin counts, Fig.~\ref{fig:amplitudeplot}
reveals that the distributions of outcome probabilities across slices
are virtually identical, demonstrating that this distribution is
essentially isotropic across the quantum state.
\begin{figure}[tb]
\centering
\includegraphics[width=0.8\textwidth]{figures/log_scale_amplitudes.png}
\caption{Histograms of log-transformed outcome probabilities for the
individual slices of the 49-qubit circuit rendered together as a
surface plot. The vertical axis is plotted on a log-scale for
consistency with Fig.~\ref{fig:histogram}.}
\label{fig:amplitudeplot}
\end{figure}
\section{Conclusions and future research}
\label{s:conclusions}
In this paper we addressed a fundamental question in the engineering
of more powerful computing devices. Our key contribution is a new
circuit simulation methodology that allowed us to break the 50-qubit
barrier, previously thought to be the limit beyond which quantum
computers cannot be simulated. Our results confirm the expected
Porter-Thomas distribution as the distribution of the outcome
probabilities for universal random circuits. This expectation was
confirmed per slice across the entire quantum state produced by the
49-qubit circuit, and for a single slice of the quantum state
resulting from the 56-qubit circuit. As mentioned in the introduction,
the ability to calculate quantum amplitudes for measured outcomes is
important to assess the correct operation of quantum devices; however,
this application was not explored in the present study.
The implications of Fig.~\ref{fig:tradeoff} should be self-evident.
If a 49-qubit random circuit that was previously thought to be
impossible to simulate on a classical computer can now be simulated in
slices where the data structures fit comfortably within the memory
available on high-end servers, then the possibility now
exists to perform routine calculations of amplitudes for measured
outcomes of such quantum devices without requiring access to
supercomputers. We plan to fully explore the extent to which this is
possible to do both in terms of numbers of qubits and depths of
circuits. Because tensor slice calculations can also be embarrassingly
parallelized, circuits whose output amplitudes can now be calculated
on high-end servers can also, in principle, be simulated in their
entirety by distributing the calculations across a sufficiently large
number of high-end servers. No longer are these calculations limited
by the resources available on specific supercomputers. One could, in
principle, run such simulations on the Cloud. For this class of circuits,
whose extent still needs to be determined, the question of whether they can be
fully simulated has now become more a question of economics than one of a physical plausibility.
Beyond the aforementioned computational utility on a complete circuit
scale, tensor slicing can be instrumental for algorithmic analysis, as
well as in simulation of active control subcircuits, where measured
slice outcomes can serve as dynamic input to the remaining part of a
circuit.
\subsection*{Future research}
In terms of the optimization of the parallel computation of quantum
states, we plan to explore the use of low-precision computation,
leveraging CTF support for user-defined tensor element types.
Dynamic (contraction-time) tensor
unfoldings should make it possible to map to lower-dimensional
topologies, expanding the space of available algorithms and making use
of rectangular collectives again possible. In some cases we may be
able to combine folding with improvements in performance prediction,
especially as relates to the offload model, to exploit the
capabilities of GPUs. Integration of optimized batched-BLAS routines
into CTF should result in substantial speed-ups in many cases. The
utility of these changes should be greatly amplified with a
commensurate set of changes to the performance prediction models
employed.
Characterizing the fidelity of quantum circuits is a crucial aspect
for the evolution of the design of quantum devices, and is enabled by
the computation of ideal state probabilities. There are several
possible research directions in this area. For instance, we could
consider a (sequential) optimal experimental design framework, in
which the goal is to maximize the extraction of useful information
regarding the fidelity of the system, while being conscious to
considerations such as limited experimentation or simulation
budgets. Such a framework would provide means to assess the
diminishing-return nature of information gain measures, and their
trade-off with experimentation and simulation budgets
\cite{haber2009numerical,alexanderian2016fast}.
Finally, there are several open questions regarding the optimal
partitioning of circuits for simulation purposes. The difficulty of
determining an optimal partitioning for circuit graphs with an
underlying 2D lattice structure is an important aspect that emerges
from our paper: such difficulty should be characterized from both an
empirical, and a theoretical point of view (we conjecture that the
corresponding decision problem is NP-hard). Another topic for future
research is the precise relationship between treewidth, tensor network
contractions, and our proposed methodology.
\section{Analysis of the amplitude distribution}
\label{s:analysis}
Let $p$ be a random variable representing the measurement probability
of a randomly selected measurement outcome of a (pseudo) randomly generated
universal quantum circuit of sufficient depth.
It is known \cite{boixo2016supremacy} that as the depth increases, the
distribution of $p$ converges to a truncated exponential (a.k.a.,
Porter-Thomas \cite{porter1956fluctuations}) distribution:
\begin{equation*}
f_p(p)=\begin{cases}
\frac{N e^{-Np}}{1-e^{-N}} & \text{if } 0 \leq p \leq 1\\
0 & \text{otherwise}
\end{cases}
\end{equation*}
Let the actual measurement probability with respect to the physical
realization of the circuit, with circuit fidelity $\alpha$ be
\begin{equation*}
q = \alpha p + \frac{1-\alpha}{N}.
\end{equation*}
The cumulative distribution of $p$ is given by:
\begin{equation*}
F_p(p)=\begin{cases}
\frac{1-e^{-Np}}{1-e^{-N}} & \text{if } 0 \leq p \leq 1 \\
0 & \text{if } p < 0\\
1 & \text{otherwise.}
\end{cases}
\end{equation*}
The cumulative distribution of $q$ is given by:
\begin{equation*}
F_q(q) = F_p\left(\frac{1}{\alpha}\left(q - \frac{1-\alpha}{N}\right)\right)=\begin{cases}
\frac{1-e^{-\frac{N}{\alpha}(q-\frac{1-\alpha}{N})}}{1-e^{-N}} & \text{if } \frac{1-\alpha}{N} \leq q \leq \alpha + \frac{1-\alpha}{N} \\
0 & \text{if } q < \frac{1-\alpha}{N}\\
1 & \text{otherwise.} % q > \alpha + \frac{1-\alpha}{N}
\end{cases}
\end{equation*}
Hence, the probability density of $q$ is:
\begin{equation*}
f_q(q) = \frac{d}{dq}F_q(q) \begin{cases}
\frac{\frac{N}{\alpha}e^{-\frac{N}{\alpha}(q-\frac{1-\alpha}{N})}}{1-e^{-N}} & \text{if } \frac{1-\alpha}{N} \leq q \leq \alpha + \frac{1-\alpha}{N} \\
0 & \text{otherwise}\\
\end{cases}
\end{equation*}
In our own experiments working with 49-qubit and 56-qubit circuits, we
found it convenient to plot the distribution of $\log(Nq)$ to better
visualize the shape of this distribution over several orders of
magnitude of variation in the value of $Nq$. We therefore first derive
the distribution w.r.t.~$Nq$, and then w.r.t.~$\log Nq$. Let $x = Nq$.
The cumulative distribution of $x$ is:
\begin{equation*}
F_x(x) = F_q\left(\frac{x}{N}\right)=\begin{cases}
\frac{1-e^{-\frac{1}{\alpha}(x+\alpha-1)}}{1-e^{-N}} & \text{if } 1-\alpha \leq x \leq 1+(N-1)\alpha \\
0 & \text{if } x < 1-\alpha\\
1 & \text{otherwise.} %x >1+(N-1)\alpha
\end{cases}
\end{equation*}
Thus, the probability density of $x$ is:
\begin{equation*}
f_x(x) =\frac{d}{dx} F_x(x)=\begin{cases}
\frac{\frac{1}{\alpha}e^{-\frac{1}{\alpha}(x+\alpha-1)}}{1-e^{-N}} & \text{if } 1-\alpha \leq x \leq 1+(N-1)\alpha \\
0 & \text{otherwise.}\\
\end{cases}
\end{equation*}
%The above equation provides the theoretical distributions that
%correspond to the empirical histograms illustrated in Figure 2 of
%\cite{boixo2016supremacy} in their simulations of quantum circuits
%with different Pauli error rates.
Finally, let $z = \log(Nq) = \log(x)$. The cumulative distribution of
$z$ is:
\begin{equation*}
F_z(z) = F_z(e^z)=\begin{cases}
\frac{1-e^{-\frac{1}{\alpha}(e^z+\alpha-1)}}{1-e^{-N}} & \text{if } 1-\alpha \leq e^z \leq 1+(N-1)\alpha \\
0 & \text{if } e^z < 1-\alpha\\
1 & \text{otherwise.} %e^z >1+(N-1)\alpha
\end{cases}
\end{equation*}
The probability density of $z$ is therefore:
\begin{equation}
\label{eq:zdist}
f_z(z) =\frac{d}{dz} F_z(z)=\begin{cases}
\frac{\frac{1}{\alpha}e^{z-\frac{1}{\alpha}(e^z+\alpha-1)}}{1-e^{-N}} & 1-\alpha \leq e^z \leq 1+(N-1)\alpha \\
0 & \textrm{otherwise}\\
\end{cases}
\end{equation}
With perfect circuit fidelity (i.e., $\alpha=1$), Equation
\ref{eq:zdist} becomes a truncated Gumbel distribution that precisely
fits the empirical distributions obtained in our 49-qubit and 56-qubit
simulations.
\section{Partitioning of the 49- and 56-qubit circuits}
\label{s:partitioning}
In this section we describe the 49- and 56-qubit circuits analyzed in
Section \ref{s:results}, and the partitioning adopted to compute the
final amplitudes. To indicate gates, we use the notation given in
Fig.~\ref{fig:googlelegend}.
\begin{figure}[tb]
\centering
\includegraphics[width=0.3\textwidth]{figures/google_legend.png}
\caption{Notation for random circuits.}
\label{fig:googlelegend}
\end{figure}
\begin{figure}[tb]
\centering
\includegraphics[width=0.45\textwidth]{figures/google_4_15.png}
\includegraphics[width=0.45\textwidth]{figures/google_4_15_partition.png}
\caption{The 4-qubit, depth 15 circuit used in Section \ref{s:example} and its partitioning, see also Fig.~\ref{fig:googleex}.}
\label{fig:googleexpart}
\end{figure}
To familiarize the reader with the notation, we start by representing
the example discussed at the end of Section \ref{s:example}: this is
given in Fig.~\ref{fig:googleex}. We use colors to indicate
subcircuits, and ``S'' to indicate qubits that can be sliced.
\begin{sidewaysfigure}
\centering
\includegraphics[width=0.49\textwidth]{figures/google_49_27.png}
\includegraphics[width=0.49\textwidth]{figures/google_49_27_partition.png}\\[5em]
\includegraphics[width=0.49\textwidth]{figures/google_56_23.png}
\includegraphics[width=0.49\textwidth]{figures/google_56_23_partition.png}
\caption{The 49-qubit, depth 27 circuit and the 56-qubit, depth 23
circuit are represented in the first column. The second column
contains the respective partitioning. Qubits marked with an ``S''
can be sliced, as can the qubits in subcircuits 1 and 2 that are
not involved in subcircuit 3 (i.e., those for which subcircuit 3
does not contain any gates applied to them).}
\label{fig:googlepart}
\end{sidewaysfigure}
The two large circuits that we simulated are given in
Fig.~\ref{fig:googlepart}, together with their partitioning. From the
picture, it can be seen that we defer entanglement so that the
subcircuits do not get too large, and we exploit slicing in the final
layers to reduce memory usage.
\begin{thebibliography}{10}
\bibitem{aaronson2016complexity}
Scott Aaronson and Lijie Chen.
\newblock Complexity-theoretic foundations of quantum supremacy experiments.
\newblock {\em arXiv preprint arXiv:1612.05903}, 2016.
\bibitem{aaronson2004improved}
Scott Aaronson and Daniel Gottesman.
\newblock Improved simulation of stabilizer circuits.
\newblock {\em Physical Review A}, 70(5):052328, 2004.
\bibitem{alexanderian2016fast}
Alen Alexanderian, Noemi Petra, Georg Stadler, and Omar Ghattas.
\newblock A fast and scalable method for a-optimal design of experiments for
infinite-dimensional bayesian nonlinear inverse problems.
\newblock {\em SIAM Journal on Scientific Computing}, 38(1):A243--A272, 2016.
\bibitem{Bartlett:1981:ARPC:CC}
Rodney~J. Bartlett.
\newblock Many-body perturbation theory and coupled cluster theory for electron
correlation in molecules.
\newblock 32(1):359--401, 1981.
\bibitem{bellmandp}
Richard Bellman.
\newblock {\em Dynamic Programming}.
\newblock Princeton University Press, Princeton, NJ, 1957.
\bibitem{bernstein1997quantum}
Ethan Bernstein and Umesh Vazirani.
\newblock Quantum complexity theory.
\newblock {\em SIAM Journal on Computing}, 26(5):1411--1473, 1997.
\bibitem{bienstock1995algorithmic}
Daniel Bienstock and Michael~A Langston.
\newblock Algorithmic implications of the graph minor theorem.
\newblock {\em Handbooks in Operations Research and Management Science},
7:481--502, 1995.
\bibitem{bishop2017volume}
Lev~S. Bishop, Sergey Bravyi, Andrew Cross, Jay~M. Gambetta, and John Smolin.
\newblock Quantum volume.
\newblock Technical report, 2017.
\newblock URL:
\url{https://dal.objectstorage.open.softlayer.com/v1/AUTH_039c3bf6e6e54d76b8e66152e2f87877/community-documents/quatnum-volumehp08co1vbo0cc8fr.pdf}.
\bibitem{bodlaender2006contraction}
Hans~L Bodlaender, Thomas Wolle, and Arie~MCA Koster.
\newblock Contraction and treewidth lower bounds.
\newblock {\em J. Graph Algorithms Appl.}, 10(1):5--49, 2006.
\bibitem{boixo2016supremacy}
Sergio Boixo, Sergei~V Isakov, Vadim~N Smelyanskiy, Ryan Babbush, Nan Ding,
Zhang Jiang, John~M Martinis, and Hartmut Neven.
\newblock Characterizing quantum supremacy in near-term devices.
\newblock {\em arXiv preprint arXiv:1608.00263}, 2016.
\bibitem{NatureNewsIBMQ}
Davide Castelvecchi.
\newblock Quantum cloud goes commercial.
\newblock {\em Nature}, 543, 2017.
\bibitem{castelvecchi2017quantum}
Davide Castelvecchi.
\newblock Quantum computers ready to leap out of the lab in 2017.
\newblock {\em Nature}, 541:9--10, 2017.
\bibitem{cross2017qasm}
Andrew~W Cross, Lev~S Bishop, John~A Smolin, and Jay~M Gambetta.
\newblock Open quantum assembly language.
\newblock {\em arXiv preprint arXiv:1707.03429}, 2017.
\bibitem{dagum1998openmp}
Leonardo Dagum and Ramesh Menon.
\newblock {OpenMP}: an industry standard {API} for shared-memory programming.
\newblock {\em IEEE computational science and engineering}, 5(1):46--55, 1998.
\bibitem{darmawan2017tensor}
Andrew~S Darmawan and David Poulin.
\newblock Tensor-network simulations of the surface code under realistic noise.
\newblock {\em Physical Review Letters}, 119(4):040502, 2017.
\bibitem{dirac1939notation}
Paul A.~M. Dirac.
\newblock A new notation for quantum mechanics.
\newblock {\em Mathematical Proceedings of the Cambridge Philosophical
Society}, 35(3):416–418, 1939.
\bibitem{BGP2009}
Ahmad Faraj, Sameer Kumar, Brian Smith, Amith Mamidala, and John Gunnels.
\newblock {MPI} collective communications on the Blue Gene/P supercomputer:
Algorithms and optimizations.
\newblock In {\em Proceedings of the 2009 17th IEEE Symposium on High
Performance Interconnects}, HOTI '09, pages 63--72, Washington, DC, USA,
2009. IEEE Computer Society.
\bibitem{farhi2016quantum}
Edward Farhi and Aram~W Harrow.
\newblock Quantum supremacy through the quantum approximate optimization
algorithm.
\newblock {\em arXiv preprint arXiv:1602.07674}, 2016.
\bibitem{feynman1982simulating}
Richard~P Feynman.
\newblock Simulating physics with computers.
\newblock {\em International journal of theoretical physics}, 21(6):467--488,
1982.
\bibitem{gambetta2015building}
Jay~M Gambetta, Jerry~M Chow, and Matthias Steffen.
\newblock Building logical qubits in a superconducting quantum computing
system.
\newblock {\em arXiv preprint arXiv:1510.04375}, 2015.
\bibitem{Gheorghiu2017verification}
Alexandru Gheorghiu, Theodoros Kapourniotis, and Elham Kashefi.
\newblock Verification of quantum computation: An overview of existing
approaches.
\newblock {\em arXiv preprint arXiv:1709.06984}, 2017.
\bibitem{gropp1999using}
William Gropp, Ewing Lusk, and Anthony Skjellum.
\newblock {\em Using {MPI}: portable parallel programming with the
message-passing interface}, volume~1.
\newblock MIT press, 1999.
\bibitem{haber2009numerical}
Eldad Haber, Lior Horesh, and Luis Tenorio.
\newblock Numerical methods for the design of large-scale nonlinear discrete
ill-posed inverse problems.
\newblock {\em Inverse Problems}, 26(2):025002, 2009.
\bibitem{haner2017simulation}
Thomas H{\"a}ner and Damian~S Steiger.
\newblock 0.5 petabyte simulation of a 45-qubit quantum circuit.
\newblock {\em arXiv preprint arXiv:1704.01127}, 2017.
\bibitem{harrow2017quantum}
Aram~W Harrow and Ashley Montanaro.
\newblock Quantum computational supremacy.
\newblock {\em Nature}, 549(7671):203, 2017.
\bibitem{ibmqexp}
The {IBM} quantum experience.
\newblock URL: \url{http://www.research.ibm.com/quantum/}.
\bibitem{joshi1995matrices}
Avinash~Wasudeo Joshi.
\newblock {\em Matrices and tensors in physics}.
\newblock New Age International, 1995.
\bibitem{Kumar2014}
Sameer Kumar, Amith Mamidala, Philip Heidelberger, Dong Chen, and Daniel Faraj.
\newblock Optimization of {MPI} collective operations on the {IBM} Blue Gene/Q
supercomputer.
\newblock {\em Int. J. High Perform. Comput. Appl.}, 28(4):450--464, November
2014.
\bibitem{lawson1979basic}
Chuck~L Lawson, Richard~J. Hanson, David~R Kincaid, and Fred~T. Krogh.
\newblock Basic linear algebra subprograms for {Fortran} usage.
\newblock {\em ACM Transactions on Mathematical Software (TOMS)},
5(3):308--323, 1979.
\bibitem{linke2017experimental}
Norbert~M Linke, Dmitri Maslov, Martin Roetteler, Shantanu Debnath, Caroline
Figgatt, Kevin~A Landsman, Kenneth Wright, and Christopher Monroe.
\newblock Experimental comparison of two quantum computing architectures.
\newblock {\em Proceedings of the National Academy of Sciences}, page
201618020, 2017.
\bibitem{markov2008simulating}
Igor~L Markov and Yaoyun Shi.
\newblock Simulating quantum computation by contracting tensor networks.
\newblock {\em SIAM Journal on Computing}, 38(3):963--981, 2008.
\bibitem{WalkupPerf}
H.~McCraw, D.~Terpstra, J.~Dongarra, K.~Davis, and Musselman R.
\newblock Beyond the {CPU}: Hardware performance counter monitoring on Blue
Gene/Q.
\newblock volume 7905 of {\em LNCS}, pages 213--225, Heidelberg, June 2013.
Springer.
\bibitem{orus2014practical}
Rom{\'a}n Or{\'u}s.
\newblock A practical introduction to tensor networks: Matrix product states
and projected entangled pair states.
\newblock {\em Annals of Physics}, 349:117--158, 2014.
\bibitem{porter1956fluctuations}
CE~Porter and RG~Thomas.
\newblock Fluctuations of nuclear reaction widths.
\newblock {\em Physical Review}, 104(2):483, 1956.
\bibitem{preskill2012quantum}
John Preskill.
\newblock Quantum computing and the entanglement frontier.
\newblock {\em arXiv preprint arXiv:1203.5813}, 2012.
\bibitem{reed2010high}
MD~Reed, L~DiCarlo, BR~Johnson, L~Sun, DI~Schuster, L~Frunzio, and
RJ~Schoelkopf.
\newblock High-fidelity readout in circuit quantum electrodynamics using the
jaynes-cummings nonlinearity.
\newblock {\em Physical review letters}, 105(17):173601, 2010.
\bibitem{solomonik2014massively}
Edgar Solomonik, Devin Matthews, Jeff~R Hammond, John~F Stanton, and James
Demmel.
\newblock A massively parallel tensor contraction framework for coupled-cluster
computations.
\newblock {\em Journal of Parallel and Distributed Computing},
74(12):3176--3190, 2014.
\bibitem{BGchip2013}
IBM Blue~Gene team.
\newblock Design of the {IBM} Blue Gene/Q compute chip.
\newblock {\em IBM Journal of Research and Development}, 57(1/2):1:1--1:13, Jan
2013.
\bibitem{valiant2002quantum}
Leslie~G. Valiant.
\newblock Quantum circuits that can be simulated classically in polynomial
time.
\newblock {\em SIAM Journal on Computing}, 31(4):1229--1254, 2002.
\bibitem{vidal2003efficient}
Guifr{\'e} Vidal.
\newblock Efficient classical simulation of slightly entangled quantum
computations.
\newblock {\em Physical Review Letters}, 91(14):147902, 2003.
\end{thebibliography}