suppSupplementary References

# MNISQ:
A Large-Scale Quantum Circuit Dataset for Machine Learning on/for Quantum
Computers in the NISQ era

Leonardo Placidi
Osaka University - QIQB
Osaka, Japan
<EMAIL_ADDRESS>Ryuichiro Hataya
RIKEN
Tokyo, Japan
<EMAIL_ADDRESS>
&Toshio Mori
Osaka University - QIQB - RIKEN
Osaka - Wako Saitama, Japan
<EMAIL_ADDRESS>
&Koki Aoyama
Osaka University
Osaka, Japan
<EMAIL_ADDRESS>
&Hayata Morisaki
Osaka University
Osaka, Japan
<EMAIL_ADDRESS>
Kosuke Mitarai
Osaka University - QIQB
Osaka, Japan
<EMAIL_ADDRESS>
&Keisuke Fujii
Osaka University - QIQB - RIKEN
Osaka - Wako Saitama, Japan
<EMAIL_ADDRESS>

###### Abstract

We introduce the first large-scale dataset, MNISQ, for both the Quantum and
the Classical Machine Learning community during the Noisy Intermediate-Scale
Quantum era. MNISQ consists of 4,950,000 data points organized in 9
subdatasets. Building our dataset from the quantum encoding of classical
information (e.g., MNIST dataset), we deliver a dataset in a dual form: in
quantum form, as circuits, and in classical form, as quantum circuit
descriptions (quantum programming language, QASM). In fact, also the Machine
Learning research related to quantum computers undertakes a dual challenge:
enhancing machine learning exploiting the power of quantum computers, while
also leveraging state-of-the-art classical machine learning methodologies to
help the advancement of quantum computing. Therefore, we perform circuit
classification on our dataset, tackling the task with both quantum and
classical models. In the quantum endeavor, we test our circuit dataset with
Quantum Kernel methods, and we show excellent results up to $97\%$ accuracy.
In the classical world, the underlying quantum mechanical structures within
the quantum circuit data are not trivial. Nevertheless, we test our dataset on
three classical models: Structured State Space sequence model (S4),
Transformer and LSTM. In particular, the S4 model applied on the tokenized
QASM sequences reaches an impressive $77\%$ accuracy. These findings
illustrate that quantum circuit-related datasets are likely to be quantum
advantageous, but also that state-of-the-art machine learning methodologies
can competently classify and recognize quantum circuits. We finally entrust
the quantum and classical machine learning community the fundamental challenge
to build more quantum-classical datasets like ours and to build future
benchmarks from our experiments. The dataset is accessible on GitHub and its
circuits are easily run in qulacs or qiskit.

##  1 Introduction

###  1.1 Background

The advent of quantum computers has garnered significant attention across
various scientific fields. By harnessing the principles of quantum mechanics,
these computers are capable of performing calculations that are beyond the
capabilities of classical computers [1]. While classical computers operate
using bits that can be either $0$ or $1$, quantum computers use qubits that
can take a superposed state of $0$ and $1$. This quantum property enables
calculations much faster than those on classical computers. As a result,
quantum computers excel at solving specific problems, such as prime
factorization [2], simulations of quantum many-body systems [3], and linear
system solvers [4].

With the realization of quantum computers comprising $50$ to $100$ qubits, the
field has entered the era of quantum computational supremacy [5, 6, 7, 8]. In
this era, even the most powerful supercomputers struggle to simulate the
behavior of quantum computers. However, this argument is based on a benchmark
task known as random quantum circuit sampling [5], and the usefulness of
quantum computers in more practical and meaningful tasks is yet to be fully
realized. Developing algorithms that effectively leverage the power of current
quantum computers to solve real-world problems remains a significant
challenge. The current generation of quantum computers, known as NISQ (Noisy
Intermediate-Scale Quantum) computers [9], are not yet fully error-corrected
and rely on small-to-medium-scale devices that are subject to noise. Among the
most promising applications of NISQ devices are variational quantum algorithms
[10], particularly in the context of quantum machine learning (QML) [11, 10,
12]. These algorithms have attracted considerable attention as they are
employed to address various problems like classification, regression, and
generative modeling. QML is currently at a phase similar to the early days of
classical machine learning, with numerous applications being proposed and
explored. However, when using NISQ computers, QML is primarily capable of
solving only “toy” problems [12], and it cannot yet directly compete with
state-of-the-art classical machine learning models, such as ChatGPT [13].

###  1.2 Motivation

The motivation behind this study is to establish datasets that demonstrate the
advantage of Quantum Machine Learning (QML) and compare its performance
against conventional classical machine learning approaches. While it has been
theoretically shown that QML can be advantageous for certain tasks, there is a
need to explore practical and experimentally friendly settings to showcase the
potential of QML.

One approach is to work with quantum data obtained from quantum systems
directly, without converting them to classical formats, as it has been shown
to be more efficient for certain learning tasks [14]. However, this approach
presents challenges in transferring quantum states obtained from physical
experiments to quantum computers, making it experimentally challenging.
Another approach is to define artificial machine learning tasks that are
solvable only by quantum computers, such as the discrete logarithm problem
[15]. While this demonstrates a rigorous advantage of QML, it is in a highly
artificial setting and may not directly translate to advantages in practical
problems.

To address these limitations and establish a more practical and experimentally
friendly setting, it is crucial to create datasets where the advantage of QML
can be expected and compare its performance against classical approaches. One
such dataset, called NTangle [16], has taken a step towards this direction by
using quantum states labeled by their level of entanglement. However, applying
classical machine learning to this dataset and comparing it with QML
approaches is challenging due to its quantum nature.

To overcome this challenge, a dataset described in a quantum-related classical
language called Quantum Assembly Language (QASM)[17] has been generated using
real-world quantum computing tasks[18]. Although this approach is interesting,
the dataset size is limited to only $1800$ elements due to the computational
cost of data generation. Additionally, such a small dataset size may not be
sufficient to demonstrate that classical machine learning techniques are
unable to learn the dataset, as modern machine learning research typically
utilizes much larger datasets. Existing quantum-related datasets, such as
PennyLane [19], also suffer from limitations such as small sizes and the
inability to be used for both quantum and classical machine learning.

In summary, the motivation of this study is to address the limitations of
existing datasets and establish a dataset, called MNISQ, that allows for the
comparison of QML and classical machine learning approaches. The MNISQ dataset
is generated using the AQCE algorithm [20], which generates quantum circuits
that encode classical data into quantum states. This dataset is provided in a
dual form that can be utilized for both quantum and classical machine
learning. The workflow of this study is summarized in Figure 1.

Figure 1: Summary of the workflow for this study. The AQCE algorithm generates
a quantum circuit that embeds classical data $\vec{x}$ into a quantum state
$|\Psi\rangle=AQCE(\vec{x})|0^{n}\rangle$ and delivers a dataset in dual form.
Quantum machine learning (quantum kernel method) and classical machine
learning (LSTM, S4, Transformer) are applied to classify the data encoded in
the quantum circuits or qasm files.

###  1.3 Approach

In this work, we introduce a novel large-scale quantum machine learning
dataset, which consists of hundreds of thousands of labeled quantum circuits.
Each circuit is accompanied by a classical description in the QASM programming
language. This dataset represents the largest collection of quantum circuits
to date (4,950,000 data points organized in $9$ subdatasets) and aims to
address the limitations and challenges faced by the quantum machine learning
(QML) community.

Our objectives are twofold. First, we utilize this dataset to seek for a
quantum advantage in meaningful tasks by executing it on relatively small-
scale quantum computers. Second, we leverage the vast quantum circuit dataset
to explore the classification problem of quantum circuits using state-of-the-
art classical machine learning techniques, thereby challenging the extent to
which classical methods can recognize quantum circuits.

To create the quantum circuit dataset MNISQ, we employ the automatic quantum
circuit encoding (AQCE) method, which embeds the MNIST dataset into the
complex amplitudes of quantum states [20]. This systematic approach allows us
to generate a massive number of quantum circuits, with each circuit encoding a
digit number in its quantum state representation when executed on a quantum
computer. MNISQ is compatible with modern quantum hardware (10-qubits),
including NISQ devices, despite the presence of noise and deviations from
ideal conditions. Future work could involve experimental demonstrations of
quantum machine learning using the MNISQ dataset, leveraging the robustness of
the quantum kernel method as demonstrated in previous experiments [21, 22].

For classification, we employ the Quantum Support Vector Machine (QSVM)
algorithm [21, 23], a powerful QML algorithm. Our experiments demonstrate
outstanding performance, achieving up to $97.91\%$ accuracy on the MNIST
dataset, with results ranging from $81\%$ to $97\%$ accuracy.

Furthermore, we investigate the learnability of the quantum circuit dataset by
classical machine learning methods. Although the task is significantly more
challenging due to the nature of the text data, we successfully train models
such as Structured Search Space (S4) [24], Transformers [25], and LSTM [26].
Surprisingly, our experiments reveal that the S4 model performs the best,
achieving $77.78\%$ accuracy. These results indicate that while our dataset
clearly is likely quantum advantageous, it is also well learnable by classical
machine learning models.

The significance of datasets in the history of machine learning cannot be
overstated, as they have played a pivotal role in the field’s development and
progress (e.g., think of the impact of mnist or imagenet[27, 28]). Similarly,
the establishment of quantum-related datasets is crucial for the healthy
growth of QML research. Additionally, our work introduces a new field in
classical machine learning, namely, learning quantum circuits. By leveraging
the robust capabilities of classical machine learning, we aim to design and
develop efficient quantum algorithms.

In conclusion, our research presents exciting opportunities for researchers
and practitioners to explore and exploit the potential advantages of quantum
computing in machine learning and vice versa. This work paves the way for
breakthroughs and discoveries that may shape the future of computing and
artificial intelligence.

###  1.4 Contributions

  * •

We introduce a large-scale quantum dataset in the form of quantum circuits and
QASM, facilitating research in quantum machine learning and classical machine
learning. The dataset is easily accessible and, given its QASM formalism,
easily used in qulacs or qiskit.

  * •

We demonstrate the outstanding performance of a quantum support vector machine
on the dataset, suggesting potential quantum advantage.

  * •

We explore the classification of circuits using classical models (S4,
Transformers, LSTM), revealing the solvability of the problem by classical
machine learning.

  * •

We highlight the remarkable capability (and the implications) of classical
machine learning in comprehending quantum circuit computations without prior
knowledge of quantum mechanics.

##  2 Preliminaries

In classical computation, information is represented via binary bits; however,
in the realm of quantum computing, these superposition states can be exploited
through the principle of superposition inherent in quantum mechanics. Such
superposed states assign complex numbers, referred to as "complex probability
amplitudes", to each potential state of $n$ classical binary bits, thereby
expressing them as a $2^{n}$-dimensional complex vector. Quantum computers
execute computation by transforming these $2^{n}$-dimensional complex vectors
via physical allowed operations, i.e., unitary matrices. Thereby, quantum
computers provide quantum speedup for solving certain class of problems that
are intractable on classical computers, such as the prime factorization.
Machine learning is one of the fields in which quantum computers are expected
to have an advantage, especially through the high-dimensional vector space
that quantum computers represent. Additionally, the realization of quantum
computers presents substantial challenges both experimentally and in terms of
software, suggesting the potential direction of employing existing machine
learning for the benefit of quantum computers. The interdisciplinary field
between quantum computing and machine learning is now driven by two major
challenges: enhancing machine learning exploiting the power of quantum
computers, while also leveraging state-of-the-art classical machine learning
methodologies to help the advancement of quantum computing.

For readers of any background, we included a detailed introduction to quantum
computing in the supplementary materials.

##  3 MNISQ Dataset: Construction and Characteristics

Figure 2: Schematic diagram of how to embed classical data into the
probability amplitude of a quantum state the using the AQCE [20] algorithm.

To enable quantum machine learning on classical data like MNIST, it is crucial
to transform the classical data into quantum states. In this study, we utilize
the Automatic Quantum Circuit Encoding (AQCE) approach [20] to achieve this
embedding process. Figure 2 illustrates the procedure.

###  3.1 Quantum Encoding of Classical Information (AQCE method)

Note that, for readers of any background, we provide a detailed introduction
to quantum computing in the supplementary materials.

Given a classical data $\vec{x}$ as $d$-dimensional vector, AQCE generates a
quantum circuit $\mathcal{C}$ that encode the classical data $\vec{x}$ into
the complex amplitudes of the output quantum state:

$\displaystyle|\Psi\rangle:=\sum_{i\in\\{{0,1}\\}^{n}}\tilde{x}_{i}|i\rangle,$
(1)

where the number of qubits $n$ is chosen to be $n:=\lceil\log_{2}(d)\rceil$
and complex amplitudes $\tilde{x}_{i}$ is normalized appropriately so that
$\sum_{i}|\tilde{x}_{i}|^{2}=1$. If $2^{n}>d$, for those indices that do not
have corresponding elements in $\vec{x}$, $\tilde{x}_{i}$ is set to be zero.
AQCE constructs such a quantum circuit $\mathcal{C}$ generating any given
quantum state $\ket{\Psi}$ by optimizing the configuration and parameters of
the quantum gates in $\mathcal{C}$ by maximizing the absolute value of the
following overlap, which we call fidelity here:

$F=|\bra{0}\mathcal{C}^{\dagger}\ket{\Psi}|.$ (2)

The AQCE iteration ends when the fidelity exceeds the target fidelity $F_{\rm
target}$ or the maximum number of gates $M_{\rm max}$ initially set for
$\mathcal{C}$. The resulting quantum circuit generated by the AQCE procedure
from classical data $\vec{x}$ will be referred to as the $AQCE(\vec{x})$
circuit.

The above AQCE procedure is intended to be performed by simulating a quantum
computation on a classical computer. Although this can only be done on the
order of tens of qubits, we believe that the dimension of the classical data
that can be amplitude embedded is sufficient, for example, $10^{9}$ for a
classical simulation of $30$ qubits. Also, the embedding operation with AQCE
may cause a computational bottleneck, but once the quantum circuit data is
generated in this format (like JPG format for images), it can be used
efficiently thereafter. For a more detailed description of AQCE, please refer
to the supplementary material paragraph on the AQCE method.

###  3.2 Dataset Construction

Using a cluster machine, we employed the AQCE method to encode the standard
machine learning datasets MNIST [27], Fashion-MNIST [29], and Kuzushiji-MNIST
[30]. These datasets were obtained from OpenML [31].

For each dataset, we generated 60,000 training samples and 10,000 test
samples. Additionally, to train classical machine learning models, we
augmented our quantum dataset to include 480,000 samples. The data
augmentation involved applying various transformations to the original images,
such as rotation (random angle of ±$50$ degrees), rotation followed by
cropping, and rotation-cropping combined with shifting. This resulted in a
total of 480,000 training samples for each of the three datasets. We preserved
the original test data without augmentation to ensure a direct comparison
between the predictions of the quantum and classical models.

Since the AQCE method allows adjusting the fidelity of the quantum state by
specifying parameters, we created three variations for each dataset. These
variations correspond to different generation procedures with a minimum
fidelity of $80\%$, $90\%$, and $95\%$ for the generated quantum circuit
dataset. Higher fidelity values require a larger number of quantum gates in
the circuit.

###  3.3 Dataset Accessibility

The datasets we have created are easily accessible through the MNISQ library.
To install the library from PyPI, use the following command: `pip install
mnisq`. Alternatively, the datasets can be accessed directly from the URLs
provided below.

The MNISQ library automatically downloads predefined quantum circuits for
Qulacs (Quantum Circuit Simulator), which are ready for use. When executing a
circuit starting from the initial zero state, one of the images from the
dataset is embedded in the quantum state.

Note: The QASM files come in two different forms:

  * •

QASM with Dense() formalism: These files can be used in Qulacs but not in
Qiskit or other platforms due to the proprietary Dense() operator.

  * •

Base QASM formalism: These files can be run in different platforms, including
Qiskit [32]. A tutorial on how to run them in Qiskit can be found on our
GitHub page at the following link: tutorial link. Please note that to access
these files, they begin with the prefix "base_..".

The datasets can be found at the following URL:

https://qulacs-quantum-datasets.s3.us-
west-1.amazonaws.com/[data]_[type]_[fidelity].zip

Here are the parameters for the URL:

  * •

data:

    1. 1.

"train_orig": 60,000 original encoded training data QASM files with Dense()
formalism.

    2. 2.

"base_train": Same as above, but the QASM files do not include the Dense()
operator. Instead, they use a gate conversion and can be run on Qiskit and
other platforms.

    3. 3.

"train": "train_orig" augmented to 480,000 training data for each subdataset
using Dense() formalism.

    4. 4.

"test": 10,000 test elements from the original encoding. QASM files with
Dense() formalism.

    5. 5.

"base_test": Same as above, but the QASM files do not include the Dense()
operator. Instead, they use a gate conversion and can be run on Qiskit and
other platforms.

  * •

type:

    1. 1.

"mnist_784": MNIST dataset.

    2. 2.

"Fashion-MNIST"

    3. 3.

"Kuzushiji-MNIST"

  * •

fidelity:

    1. 1.

"f80": Fidelity greater than or equal to 80

    2. 2.

"f90": Fidelity greater than or equal to 90

    3. 3.

"f95": Fidelity greater than or equal to 95

For example, the URL for a specific dataset could be: https://qulacs-quantum-
datasets.s3.us-west-1.amazonaws.com/test_mnist_784_f90.zip.

Figure 3: Example of a dataset directory structure that includes information
about the fidelity, label, QASM files, and state vector for each image encoded
in MNISQ.

As shown in Figure 3, each dataset is represented as a dictionary with
accessible key information. Although there are a total of nine datasets (three
for each different fidelity level across the three datasets), options for
augmentation or QASM formalism are available. The dataset is composed of 9
subdatasets (60,000 training data - 10,000 test data) in two QASM formalism
(but they are the same data) and 9 subdatasets from augmented data (480,000
training data each). The total is thus 4,950,000 data points.

The official GitHub repository for the dataset is:
https://github.com/FujiiLabCollaboration/MNISQ-quantum-circuit-dataset.

##  4 Experimental results

###  4.1 Quantum Machine Learning experiments

In this section, we present the first quantum machine learning experiments on
MNISQ. Our excellent results, when compared with the classical machine
learning benchmark of the next section, show that our dataset may be quantum
advantageous and represent the best performance in mnist dataset
classification with any quantum machine learning method.

Table 1: Experiments with the Quantum Kernel approach Dataset | Fidelity | 1-versus-1 QSVM | 1-versus-the-rest QSVM
---|---|---|---
MNIST-784 | 80 | 0.9486 | 0.9494
| 90 | 0.9733 | 0.9713
| 95 | 0.9791 | 0.9777
Fashion-MNIST | 80 | 0.8204 | 0.8151
| 90 | 0.8541 | 0.8463
| 95 | 0.8678 | 0.8656
Kuzushiji-MNIST | 80 | 0.8417 | 0.8360
| 90 | 0.8909 | 0.8847
| 95 | 0.9066 | 0.9004

In table 1 are shown our results on the three subdatasets of MNISQ (mnist_784,
Fashion-MNIST, Kuzushiji-MNIST). The two methods employed are a variation of
the quantum support vector machines (QSVMs) where, instead of performing a
binary classification task, we perform a multiclass classification. We leave
in the supplementary material an introduction to the classical SVMs, which
differ from QSVM only in the computation of the kernel while leaving the same
optimization procedure. The use of a quantum kernel is motivated by its
ability to compute classically hard or intractable kernels [23]. Recent
studies have shown that quantum kernels can offer a quantum advantage over
classical methods on carefully engineered datasets [15].

Looking at the table 1, the one-versus-one approach fits
$n_{classes}(n_{classes}-1)$ QSVMs on all the possible couples of classes and
finally classifies based on a voting scheme called one-versus-one. On the
other side, one-versus-the-rest approach consists in training $n_{classes}$
QSVMs (10 for MNISQ subdatasets), each one able to classify one class versus
any other. We performed our experiments using qulacs [33] quantum computer
simulator for the quantum kernels and sklearn implementations for the
classifiers [34]. The one-versus-the-rest training is significantly faster
because of its limited number of classifiers [35], but since every classifier
is trained on a small subset of the dataset, the one-versus-one is likely more
robust and, in fact, presents a slightly better performance. QSVMs differ from
SVMs only because in the formulation of the decision function:

$f(\vec{x})={\rm
sgn}\Bigl{(}\sum_{n=1}^{N}t_{n}\alpha_{n}K(\vec{x}^{(i)},\vec{x})\Bigl{)},\vec{x}\in{\rm
TestSet},$ (3)

The Kernel function $K(\vec{x}^{(i)},\vec{x}^{(j)})$ is obtained by taking the
inner product between quantum states. In our examples, the quantum states come
from the encoding of our information (AQCE) available in the dataset, thus we
can also write our quantum kernel as:

$K(\vec{x}^{(i)},\vec{x}^{(j)})=|\bra{00...0}AQCE(\vec{x}^{(i)})AQCE(\vec{x}^{(j)})^{\dagger}\ket{00...0}|^{2}$
(4)

Figure 4: Example of the standard computation of the quantum kernel elements
by generating the circuits $AQCE(\vec{x}^{(1)})AQCE(\vec{x}^{(2)})^{\dagger}$
for every pair of elements and computing the probability of the zero state
after measurement in the computational basis.

We compare our prediction results based on the accuracy of the decision
function, and we observe that our best prediction is reached when the fidelity
is at least $95\%$ for the data. Thus, a higher fidelity circuit leads to a
better approximation of the target state and a more effective feature map for
the quantum kernel.

###  4.2 Classical Machine Learning experiments

Figure 5: A schematic view of data processing in classical machine learning
models.

We evaluate the performance of classical machine learning methods in
recognizing quantum circuits by using classical deep neural networks for
sequence classification. Specifically, we used Transformer [25], LSTM [26],
and S4 [24] models as sequence classifiers, which are trained to classify
QASMs (Quantum Assembly Language) in the MNISQ datasets. Detailed experimental
settings are described in the supplementary material.

The input QASMs were processed by tokenizing the text files, removing
unnecessary information (such as headers), and rounding dense matrix elements
(e.g., from $0.12345$ to $0.12$) as shown in Figure 5. We specify that we
performed the experiments using the version of the dataset with QASM files
with the proprietary extension $\mathit{Dense()}$. The alternative QASM files,
where $\mathit{Dense()}$ operators are substituted by gates descriptions,
remain untested.

Table 2 presents test accuracy of the classical machine learning models on the
MNISQ datasets. Among the models, S4 achieved the highest accuracy, with a
test accuracy of $77.78\%$ on mnist_784 with a fidelity of $95$. This
performance surpassed that of the other models by a significant margin.
Interestingly, as the fidelity decreased, both the accuracy of the quantum
methods and the accuracy of the S4 and LSTM also dropped. On the other hand,
the accuracy of the Transformer showed the opposite trend, where datasets with
lower fidelity resulted in better performance. Because higher-fidelity
datasets have more information and consist of longer QASM sequences, these
results suggest that S4 and LSTM can effectively capture long-range
dependencies while Transformer cannot. In particular, the S4 model was
designed to capture long-range dependencies [24], and thus, achieved the
highest performance.

Table 2: Test accuracy of classical machine learning models. Dataset | Fidelity | S4 | Transformer | LSTM
---|---|---|---|---
MNIST-784 | 80 | 66.61 | 43.42 | 59.06
| 90 | 72.41 | 41.85 | 60.88
| 95 | 77.78 | 40.40 | 66.93
Fashion-MNIST | 80 | 64.93 | 46.22 | 59.30
| 90 | 67.91 | 43.71 | 63.19
| 95 | 71.42 | 43.60 | 64.64
Kuzushiji-MNIST | 80 | 42.27 | 27.66 | 32.31
| 90 | 46.64 | 26.87 | 37.79
| 95 | 51.83 | 26.63 | 40.07

Table 3 shows test accuracy of the S4 model trained with and without augmented
datasets. We can observe clear performance improvement on each dataset,
indicating the effectiveness of data augmentation in MNISQ as other machine
learning problems. We may also expect that dataset size matters to machine
learning methods for quantum-circuit recognition tasks from these results.

Table 3: Test accuracy of the S4 model trained with and without augmented data with a fidelity of 95. Dataset | mnist_784 | Fashion-MNIST | Kuzushiji-MNIST
---|---|---|---
w/ augmentation | 81.36 | 75.49 | 57.67
w/o augmentation | 77.78 | 71.42 | 51.83

It is important to note that these results were achieved without incorporating
any prior knowledge of quantum computing into the classical machine learning
methods. It is possible that incorporating such knowledge could further
improve the performance of these classical models in classifying quantum
circuits.

##  5 Conclusion

We have accomplished the generation of MNISQ, a comprehensive large-scale
quantum circuit dataset comprising hundreds of thousands of samples. This task
was achieved by embedding classical data into the complex amplitudes of the
quantum state through AQCE. Given the critical role of datasets in advancing
machine learning, MNISQ is poised to emerge as a standard quantum circuit
dataset for quantum machine learning research. Its importance lies in its
ability to shape and advance the development of new techniques and approaches
in this area of research. Our numerical experiments show that quantum machine
learning show a high classification performance of over $97\%$. This result
implicates that if we have a circuit that successfully embeds classical data
into a quantum state, we can use quantum machine learning to achieve
comparable high performance as classical machine learning. Hence, should the
benefits of quantum machine learning be discovered, it may be prudent to
consider storing the data in a condensed format, such as compressed quantum
circuit data with preprocessing, offering the potential to enhance efficiency
and optimize the utilization of quantum computing resources.

Furthermore, we have transcended the boundaries of quantum machine learning by
applying classical machine learning models to our generated large-scale
quantum circuit datasets. The remarkable outcome of this endeavor is that
these classical models, devoid of any knowledge about the underlying
mathematics of quantum mechanics and quantum computation within the quantum
circuits, have achieved an astonishingly promising classification performance
of up to $77\%$. This revelation underscores the incredible capability of
classical machine learning in discerning the nature of computations performed
by quantum circuits: an inherently complex and nontrivial task. Thus, our
findings not only demonstrate the profound potential of quantum machine
learning in realizing quantum advantages, but also unveil a groundbreaking
capability of classical machine learning in comprehending the functionality of
quantum circuits. The former represents a central challenge in the burgeoning
field of quantum machine learning, while the latter has only become possible
due to the advent of large-scale quantum circuit datasets. While constructing
and optimizing quantum circuits remains a paramount task for harnessing the
full potential of quantum computers, our study highlights the remarkable
synergy between classical machine learning and this endeavor.

## Acknowledgments and Disclosure of Funding

This work is supported by MEXT Quantum Leap Flagship Program (MEXT Q-LEAP)
Grant No. JPMXS0118067394 and JPMXS0120319794, and JST COI- NEXT Grant No.
JPMJPF2014. We finally acknowledge the use of LLMs ([13]) for improving our
drafts.

## References

  * [1] Michael A. Nielsen and Isaac L. Chuang.  Quantum Computation and Quantum Information.  Cambridge University Press, 2010.
  * [2] Peter W. Shor.  Algorithms for quantum computation: discrete logarithms and factoring.  Proceedings of the 35th Annual Symposium on Foundations of Computer Science, pages 124–134, 1994.
  * [3] Seth Lloyd.  Universal quantum simulators.  Science, 273(5278):1073–1078, 1996.
  * [4] Aram W. Harrow, Avinatan Hassidim, and Seth Lloyd.  Quantum algorithm for linear systems of equations.  Physical Review Letters, 103(15):150502, 2009.
  * [5] Frank Arute, Kunal Arya, Ryan Babbush, Dave Bacon, Joseph C Bardin, Rami Barends, Rupak Biswas, Sergio Boixo, Fernando GSL Brandao, David A Buell, et al.  Quantum supremacy using a programmable superconducting processor.  Nature, 574(7779):505–510, 2019.
  * [6] Yulin Wu, Wan-Su Bao, Sirui Cao, Fusheng Chen, Ming-Cheng Chen, Xiawei Chen, Tung-Hsun Chung, Hui Deng, Yajie Du, Daojin Fan, et al.  Strong quantum computational advantage using a superconducting quantum processor.  Physical review letters, 127(18):180501, 2021.
  * [7] Qingling Zhu, Sirui Cao, Fusheng Chen, Ming-Cheng Chen, Xiawei Chen, Tung-Hsun Chung, Hui Deng, Yajie Du, Daojin Fan, Ming Gong, et al.  Quantum computational advantage via 60-qubit 24-cycle random circuit sampling.  Science bulletin, 67(3):240–245, 2022.
  * [8] A Morvan, B Villalonga, X Mi, S Mandrà, A Bengtsson, PV Klimov, Z Chen, S Hong, C Erickson, IK Drozdov, et al.  Phase transition in random circuit sampling.  arXiv preprint arXiv:2304.11119, 2023.
  * [9] John Preskill.  Quantum computing in the nisq era and beyond.  Quantum, 2:79, 2018.
  * [10] Marco Cerezo, Andrew Arrasmith, Ryan Babbush, Simon C Benjamin, Suguru Endo, Keisuke Fujii, Jarrod R McClean, Kosuke Mitarai, Xiao Yuan, Lukasz Cincio, et al.  Variational quantum algorithms.  Nature Reviews Physics, 3(9):625–644, 2021.
  * [11] Jacob Biamonte, Peter Wittek, Nicola Pancotti, Patrick Rebentrost, Nathan Wiebe, and Seth Lloyd.  Quantum machine learning.  Nature, 549(7671):195–202, Sep 2017.
  * [12] M. Cerezo, Guillaume Verdon, Hsin-Yuan Huang, Lukasz Cincio, and Patrick J. Coles.  Challenges and opportunities in quantum machine learning.  Nature Computational Science, 2:567–576, September 2022.
  * [13] OpenAI.  ChatGPT: OpenAI’s Language Model.  Online, 2023.
  * [14] Hsin-Yuan Huang, Michael Broughton, Jordan Cotler, Sitan Chen, Jerry Li, Masoud Mohseni, Hartmut Neven, Ryan Babbush, Richard Kueng, John Preskill, and Jarrod R. McClean.  Quantum advantage in learning from experiments.  Science, 376(6598):1182–1186, 2022.
  * [15] Yunchao Liu, Srinivasan Arunachalam, and Kristan Temme.  A rigorous and robust quantum speed-up in supervised machine learning.  Nature Physics, 17(9):1013–1017, 2021.
  * [16] Louis Schatzki, Andrew Arrasmith, Patrick J Coles, and Marco Cerezo.  Entangled datasets for quantum machine learning.  arXiv preprint arXiv:2109.03400, 2021.
  * [17] Andrew W. Cross, Ali Javadi-Abhari, Thomas Alexander, Niel de Beaudrap, Lev S. Bishop, Steven Heidel, Colm A. Ryan, Prasahnt Sivarajah, John Smolin, Jay M. Gambetta, and Blake R. Johnson.  Openqasm 3: A broader and deeper quantum assembly language.  ACM Transactions on Quantum Computing, 3(3):1–60, 2022.  Version: 2, submitted on 30 Apr 2021, last revised on 16 Mar 2022.
  * [18] Akimoto Nakayama, Kosuke Mitarai, Leonardo Placidi, Takanori Sugimoto, and Keisuke Fujii.  Vqe-generated quantum circuit dataset for machine learning.  arXiv preprint arXiv:2302.09751, 2023.
  * [19] Ville Bergholm, Josh Izaac, Maria Schuld, Christian Gogolin, Shahnawaz Ahmed, Vishnu Ajith, M. Sohaib Alam, Guillermo Alonso-Linaje, B. AkashNarayanan, Ali Asadi, Juan Miguel Arrazola, Utkarsh Azad, Sam Banning, Carsten Blank, Thomas R Bromley, Benjamin A. Cordier, Jack Ceroni, Alain Delgado, Olivia Di Matteo, Amintor Dusko, Tanya Garg, Diego Guala, Anthony Hayes, Ryan Hill, Aroosa Ijaz, Theodor Isacsson, David Ittah, Soran Jahangiri, Prateek Jain, Edward Jiang, Ankit Khandelwal, Korbinian Kottmann, Robert A. Lang, Christina Lee, Thomas Loke, Angus Lowe, Keri McKiernan, Johannes Jakob Meyer, J. A. Montañez-Barrera, Romain Moyard, Zeyue Niu, Lee James O’Riordan, Steven Oud, Ashish Panigrahi, Chae-Yeun Park, Daniel Polatajko, Nicolás Quesada, Chase Roberts, Nahum Sá, Isidor Schoch, Borun Shi, Shuli Shu, Sukin Sim, Arshpreet Singh, Ingrid Strandberg, Jay Soni, Antal Száva, Slimane Thabet, Rodrigo A. Vargas-Hernández, Trevor Vincent, Nicola Vitucci, Maurice Weber, David Wierichs, Roeland Wiersema, Moritz Willmann, Vincent Wong, Shaoming Zhang, and Nathan Killoran.  Pennylane: Automatic differentiation of hybrid quantum-classical computations.  arXiv preprint, 2022.  Version: 4, submitted on 12 Nov 2018, last revised on 29 Jul 2022.
  * [20] Tomonori Shirakawa, Hiroshi Ueda, and Seiji Yunoki.  Automatic quantum circuit encoding of a given arbitrary quantum state.  arXiv preprint arXiv:2112.14524, 2021.
  * [21] Vojtěch Havlíček, Antonio D. Córcoles, Kristan Temme, Aram W. Harrow, Abhinav Kandala, Jerry M. Chow, and Jay M. Gambetta.  Supervised learning with quantum-enhanced feature spaces.  Nature, 567(7747):209–212, mar 2019.
  * [22] Takeru Kusumoto, Kosuke Mitarai, Keisuke Fujii, Masahiro Kitagawa, and Makoto Negoro.  Experimental quantum kernel machine learning with nuclear spins in a solid.  arXiv preprint arXiv:1911.12021, 2019.
  * [23] Riccardo Mengoni and Alessandra Di Pierro.  Kernel methods in quantum machine learning.  Quantum Machine Intelligence, 1:65 – 71, 2019.
  * [24] Albert Gu, Karan Goel, and Christopher Ré.  Efficiently modeling long sequences with structured state spaces, 2022\.
  * [25] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Ł ukasz Kaiser, and Illia Polosukhin.  Attention is all you need.  In I. Guyon, U. Von Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc., 2017.
  * [26] Sepp Hochreiter and Jürgen Schmidhuber.  Long short-term memory.  Neural computation, 9(8):1735–1780, 1997.
  * [27] Yann LeCun and Corinna Cortes.  The mnist database of handwritten digits.  2005\.
  * [28] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei.  Imagenet: A large-scale hierarchical image database.  In 2009 IEEE Conference on Computer Vision and Pattern Recognition, pages 248–255, 2009.
  * [29] Han Xiao, Kashif Rasul, and Roland Vollgraf.  Fashion-mnist: a novel image dataset for benchmarking machine learning algorithms, 2017.
  * [30] Tarin Clanuwat et al.  Deep learning for classical japanese literature.  arXiv preprint arXiv:1812.01718, 2018.
  * [31] Joaquin Vanschoren, Jan N. van Rijn, Bernd Bischl, and Luis Torgo.  Openml: networked science in machine learning.  SIGKDD Explorations, 15(2):49–60, 2013.
  * [32] Qiskit contributors.  Qiskit: An open-source framework for quantum computing, 2023.
  * [33] Yasunari Suzuki, Yoshiaki Kawase, Yuya Masumura, Yuria Hiraga, Masahiro Nakadai, Jiabao Chen, Ken M. Nakanishi, Kosuke Mitarai, Ryosuke Imai, Shiro Tamiya, Takahiro Yamamoto, Tennin Yan, Toru Kawakubo, Yuya O. Nakagawa, Yohei Ibe, Youyuan Zhang, Hirotsugu Yamashita, Hikaru Yoshimura, Akihiro Hayashi, and Keisuke Fujii.  Qulacs: a fast and versatile quantum circuit simulator for research purpose.  Quantum, 5:559, oct 2021.
  * [34] F. Pedregosa, G. Varoquaux, A. Gramfort, V. Michel, B. Thirion, O. Grisel, M. Blondel, P. Prettenhofer, R. Weiss, V. Dubourg, J. Vanderplas, A. Passos, D. Cournapeau, M. Brucher, M. Perrot, and E. Duchesnay.  Scikit-learn: Machine learning in Python.  Journal of Machine Learning Research, 12:2825–2830, 2011.
  * [35] Christopher M. Bishop.  Pattern Recognition and Machine Learning (Information Science and Statistics).  Springer-Verlag, Berlin, Heidelberg, 2006.

##  Appendix A Supplements for the paper

###  A.1 Related works

Given that the field of defining datasets related to quantum information and
quantum computing is still in its infancy, there is not an abundance of
existing works in this direction. Below we will introduce several existing
studies concerning data associated with quantum phenomena, referred to as
quantum datasets.

NTangle [16]: NTangle shares common ground with our research in the sense that
it emphasizes the importance of focusing on quantum-related datasets to gain
an advantage in QML. However, it defines the quantum state itself as the
dataset, which, unlike our quantum circuit dataset, cannot be directly applied
to existing classical machine learning. Furthermore, it uses the property of
the quantum state, whether it is entangled or not, as a label for the state. A
distinctive feature of our approach is that labels are assigned based on the
computational task that the quantum circuit is executing.

QDataSet perrier2022qdataset: QDataSet is a dataset defined from 52 types of
data concerning quantum operations for single and two-qubit systems,
encompassing both noise-inclusive and noise-free scenarios. It is constructed
to apply existing machine learning frameworks for characterizing quantum
systems and improving experimental control setups including classical
postprocesssing, and hence QDataSet constitutes a dataset pertaining to the
physical dynamics of one- or two-qubit systems. In our approach, we aim to
explore machine learning using quantum computers and to apply existing machine
learning frameworks to recognize the task done by quantum circuits, and hence
we generate a large-scale quantum circuit dataset using quantum gates as
fundamental units, avoiding elements considering the control of experimental
systems, such as noise.

Quantum datasets on Pennylane: PennyLane is an open-source software library
that provides tools for quantum machine learning and quantum computing.
Quantum Datasets in PennyLane, specifically for quantum chemistry and quantum
spin systems provide detailed problem systems descriptions, parameterized
models and their solution for these problems, aiding in the study of quantum
algorithms related to these molecular and spin systems. While these datasets
serve as a valuable baseline for transparent research, how to apply quantum
and classical machine learning for these data remain challenges. The size of
the dataset is also too small to be applied for the state-of-the-art machine
learning techniques.

VQE-generated dataset [18]: The VQE-generated dataset is the most akin to our
approach. It is a quantum circuit dataset labeled by the computational task it
performs. However, a significant issue arises due to the dataset’s size, as
there are only 300 quantum circuits for each label, which is too small to
apply state-of-the-art machine learning techniques. This problem is also the
case for all above datasets, which crucially causes lack of the state-of-the-
art classical machine learning benchmarking. To resolve this issue, we defined
a large-scale quantum circuit dataset, MNISQ, applied conventional machine
learning, and compared with QML.

###  A.2 Basics of quantum computing

In this section, we elucidate the fundamentals of quantum computation and
quantum gates, introducing the notation employed in quantum information.
Contrary to classical information, which is represented by binary bits
$\\{0,1\\}$, quantum information defines the quantum bit, or qubit, as the
smallest unit of information. This is represented as a linear combination of
two orthogonal vectors, thus forming a superposition state:

$\displaystyle|\psi\rangle=\alpha|0\rangle+\beta|1\rangle.$ (5)

We utilize Dirac’s bra-ket notation to describe column vectors using
$|\cdot\rangle$ symbol:

$\displaystyle|0\rangle=\left(\begin{array}[]{c}1\\\
0\end{array}\right),\;\;\;|1\rangle=\left(\begin{array}[]{c}0\\\
1\end{array}\right).$ (10)

Furthermore, the coefficients of the linear combination, referred to as
complex probability amplitudes, are normalized to satisfy
$|\alpha|^{2}+|\beta|^{2}=1$. In addition to the column vector $|\psi\rangle$,
we define the row vector obtained by taking the complex conjugate and
transpose, or adjoint, of this:

$\displaystyle\langle\psi|=\alpha^{*}\langle 0|+\beta^{*}\langle
1|=(|\psi\rangle)^{{\dagger}}.$ (11)

where

$\displaystyle\langle 0|=(|0\rangle)^{{\dagger}}=(1,0),\;\;\;\langle
1|=(|1\rangle)^{{\dagger}}=(0,1).$ (12)

Then, inner product of two vectors $|\psi\rangle,|\phi\rangle$ can be
expressed as $\langle\phi|\psi\rangle$. Also, a linear operator can be
represented by $|\phi\rangle\langle\psi|$.

For such a qubit, the operation executable on a quantum computer, the quantum
gate, is specified by a $2\times 2$ unitary matrix:

$\displaystyle\mathbf{U}=\left(\begin{array}[]{cc}u_{0|0}&u_{0|1}\\\
u_{1|0}&u_{1|1}\end{array}\right),$ (15)

The reason for being limited to unitary matrices is to preserve the
normalization condition. The symbol $|$ in-between the index is to explicitly
show which left and right indices correspond to output and input,
respectively.

When describing multiple qubits, we consider the multiple tensor product space
of a qubit space as a unit. As a basis for the tensor product space by $n$
qubits, the direct product state of $\\{|0\rangle,|1\rangle\\}$ specified by
the $n$-bit binary bit string $i_{1}...i_{n}$,

$\displaystyle|i_{1}....i_{n}\rangle=|i_{1}\rangle\otimes\cdots\otimes|i_{n}\rangle$
(16)

can be used. These $2^{n}$ orthonormal basis states are linearly combined to
describe the quantum state of $n$ qubits using $2^{n}$ complex numbers:

$\displaystyle|\psi\rangle=\sum_{i_{1}...i_{n}}c_{i_{1}...i_{n}}|i_{n}\rangle$
(17)

Hence, the quantum state of $n$ qubits is represented as a $2^{n}$-dimensional
complex vector. Similar to the case of a single qubit, the complex vector
satisfies the normalization condition:

$\displaystyle\sum_{i_{1}...i_{n}}|c_{i_{1}...i_{n}}|^{2}=1.$ (18)

When a quantum gate acts on the $k$-th qubit among $n$ qubits, its action is:

$\displaystyle U_{k}=I^{\otimes k-1}\otimes\mathbf{U}\otimes
I^{\otimes(n-k)}=\sum_{i_{1}...i_{n}}\sum_{j_{k}}u_{i_{k}|j_{k}}|i_{1}...i_{k}...i_{n}\rangle\langle
i_{1}...j_{k}i_{k+1}...i_{n}|.$ (19)

Universal quantum computation cannot be executed with operations acting only
on one qubit. To construct a universal quantum computation, a two-qubit gate
acting on two qubits is required. The two-qubit gate is specified by a
$4\times 4$ matrix:

$\displaystyle\mathbf{W}=\left(\begin{array}[]{cccc}w_{00|00}&w_{00|01}&w_{00|10}&w_{00|11}\\\
w_{01|00}&w_{01|01}&w_{01|10}&w_{01|11}\\\
w_{10|00}&w_{10|01}&w_{10|10}&w_{10|11}\\\
w_{11|00}&w_{11|01}&w_{11|10}&w_{11|11}\end{array}\right).$ (24)

When this two-qubit gate acts on the $k$-th and $l$-th ($l>k$) qubits, its
action in the tensor product space of $n$ qubits is:

$\displaystyle
W_{kl}=\sum_{i_{1}...i_{n}}\sum_{j_{k},j_{l}}u_{i_{k}i_{l}|j_{k}j_{l}}|i_{1}...i_{k}...i_{l}...i_{n}\rangle\langle
i_{1}...j_{k}i_{k+1}...j_{l}i_{l+1}...i_{n}|.$ (25)

By appropriately applying the two-qubit gate, any unitary transformation can
be constructed. It is also known that any two-qubit gate can be approximately
constructed from the product of specific basic gates, $T$ gate, $H$ gate, CNOT
gate, which are given by respectively:

$\displaystyle H=\frac{1}{\sqrt{2}}\left(\begin{array}[]{cc}1&1\\\
1&-1\end{array}\right),\;\;\;T=\left(\begin{array}[]{cc}e^{-i\pi/8}&0\\\
0&e^{i\pi/8}\end{array}\right),\;\;\;{\rm
CHOT}=\left(\begin{array}[]{cccc}1&0&0&0\\\ 0&1&0&0\\\ 0&0&0&1\\\
0&0&1&0\end{array}\right).$ (34)

However, in this study, we do not decompose the two-qubit gate into
$\\{T,H,{\rm CNOT}\\}$, and we take the two-qubit gate as a basic unit. A
quantum algorithm starts from the quantum state of $n$ initialized qubits,

$\displaystyle|0^{n}\rangle=\left(\begin{array}[]{c}1\\\ \vdots\\\
0\end{array}\right)$ (38)

and constructs a quantum circuit consisting of two-qubit gates according to
the problem to be solved:

$\displaystyle\mathcal{C}=\prod_{m=1}^{M}W_{k_{m}l_{m}}^{(m)}$ (39)

to obtain the output quantum state $|\psi\rangle=\mathcal{C}|0^{n}\rangle$.
When a measurement is performed on this quantum state, a certain $n$-bit
string $b\in\\{0,1\\}^{n}$ is obtained with probability

$\displaystyle p_{b}=|\langle b|\psi\rangle|^{2}$ (40)

As will be explained later in the quantum kernel method, if there are two
quantum circuits $\mathcal{C}$ and $\mathcal{C}^{\prime}$, the square of the
absolute value of the inner product between the quantum states
$\mathcal{C}|0^{n}\rangle$ and $\mathcal{C}^{\prime}|0^{n}\rangle$ generated
by these can be written as

$\displaystyle p_{0...0}=|\langle
0^{n}|(\mathcal{C}^{\prime})^{{\dagger}}\mathcal{C}|0^{n}\rangle|^{2}$ (41)

From this, we can define a new quantum circuit
$\mathcal{D}:=(\mathcal{C}^{\prime})^{{\dagger}}\mathcal{C}$, and estimate the
probability of obtaining all zeros to know the value of the inner product from
the quantum computer.

###  A.3 Automatic Quantum Circuit Encoding (AQCE) procedure

We here give a detailed explanation of the AQCE algorithm.

Assuming that the quantum circuit $\mathcal{C}$ is composed of $M$ 2-qubit
gates,

$\mathcal{C}=\prod_{m=1}^{M}\mathcal{U}_{m}=\mathcal{U}_{1}\mathcal{U}_{2}\dots\mathcal{U}_{M},$
(42)

With respect to the $m$th gate, $F$ can be rewritten as follows:

$F_{m}=\bra{\Phi_{m-1}}\mathcal{U}_{m}^{\dagger}\ket{\Psi_{m+1}}.$ (43)

Here, the quantum states $\ket{\Phi_{m}}$ and $\ket{\Psi_{m}}$ are defined,
respectively, by

$\displaystyle\ket{\Psi_{m}}$
$\displaystyle=\prod_{k=m}^{M}\mathcal{U}_{k}^{\dagger}\ket{\Psi}=\mathcal{U}_{m}^{\dagger}\mathcal{U}_{m+1}^{\dagger}\dots\mathcal{U}_{M}^{\dagger}\ket{\Psi},$
(44) $\displaystyle\bra{\Phi_{m}}$
$\displaystyle=\bra{0}\prod_{k=1}^{m}\mathcal{U}_{k}^{\dagger}=\bra{0}\mathcal{U}_{1}^{\dagger}\mathcal{U}_{2}^{\dagger}\dots\mathcal{U}_{m}^{\dagger}.$
(45)

Then, in terms of trace formula, $F_{m}$ can be rewritten as

$F_{m}=\text{Tr}[\ket{\Psi_{m+1}}\bra{\Phi_{m-1}}\mathcal{U}_{m}^{\dagger}].$
(46)

If we denote $\mathbb{I}_{m}={i,j}$ as the indices of the qubits on which
$\mathcal{U}_{m}$ acts, we can introduce the fidelity tensor operator
$\mathcal{F}_{m}$

$\mathcal{F}_{m}=\text{Tr}_{{\mathbb{I}}_{m}}[\ket{\Psi_{m+1}}\bra{\Phi_{m-1}}],$
(47)

by which we can obtain $F_{m}$ as

$F_{m}=\text{Tr}_{\mathbb{I}_{m}}[\mathcal{F}_{m}\mathcal{U}_{m}^{\dagger}],$
(48)

Furthermore, if we consider $\textbf{F}_{m}$ and $\textbf{U}_{m}$ as the
matrix representations of $\mathcal{F}_{m}$ and $\mathcal{U}_{m}$,
respectively, we obtain

$F_{m}=\text{tr}[\textbf{F}_{m}\textbf{U}_{m}]$ (49)

The singular value decomposition of $\textbf{F}_{m}$ provides
$\textbf{F}_{m}=\textbf{XDY}$, where $\textbf{X},\textbf{Y}$ are unitary
matrices, and D is a diagonal matrix with non-negative real diagonal elements
$d_{n}$. Then, we have

$F_{m}=\text{tr}[\textbf{XDY}\textbf{U}_{m}^{\dagger}]=\text{tr}[\textbf{DZ}]=\sum_{n=0}^{2^{2}-1}d_{n}[\textbf{Z}]_{nn},$
(50)

where $\textbf{Z}=\textbf{Y}\textbf{U}_{m}^{\dagger}\textbf{X}$. This leads

$|F_{m}|=\left|\sum_{k=0}^{2^{2}-1}d_{n}[\textbf{Z}]_{nn}\right|\leq\sum_{k=0}^{2^{2}-1}d_{n}\left|[\textbf{Z}]_{nn}\right|.$
(51)

Given that Z is a unitary matrix, the absolute value of $F_{m}$ is maximized
when Z is an identity matrix. Therefore, the matrix $\textbf{U}_{m}$ that
maximizes the absolute value of $F_{m}$ is given by

$\textbf{U}_{m}=\textbf{XY}.$ (52)

Using this, the quantum circuit is optimized through the following steps:

  1. (i)

Set $m=1$.

  2. (ii)

Compute the representation matrix $\textbf{F}_{m}^{(k)}$ of the fidelity
tensor
$\mathcal{F}_{m}^{(k)}=\text{tr}_{{\mathbb{I}}_{k}}[\ket{\Psi_{m+1}}\bra{\Phi_{m-1}}\mathcal{U}_{m}]$
for all possible pairs $\mathbb{I}_{k}$ of indices.

  3. (iii)

Perform singular value decomposition
$\textbf{F}_{m}^{(k)}=\textbf{X}^{(k)}\textbf{D}^{(k)}\textbf{Y}^{(k)}$ for
all $\textbf{F}_{m}^{(k)}$, and calculate
$S^{(k)}=\sum_{n=0}^{3}[\textbf{D}^{(k)}]_{nn}$.

  4. (iv)

Find $k^{*}$ such that $S_{k}^{*}$ is maximized.

  5. (v)

Set $\textbf{U}_{m}=\textbf{X}^{(k^{*})}\textbf{Y}^{(k^{*})}$, and apply the
operator $\mathcal{U}_{m}$ specified by $\textbf{U}_{m}$ acting on
$\mathbb{I}_{k^{*}}$.

  6. (vi)

If $m<M$, increment $m$ by 1 and return to step 2. If $m=M$, terminate the
process.

By following these steps, the structure of the quantum circuit, including
which qubits the two-qubit gates should operate on, is optimized while
autonomously constructing a quantum circuit that encodes the desired quantum
state. The fidelity of the embedded quantum state changes depending on the
number of gates $M$ employed in the circuit $\mathcal{C}$.

The AQCE algorithm combines this circuit optimization step with a gate
addition step to optimize the circuit while deepening it. In this work, we add
new $\delta$ two-qubit gates until $M$ < $M_{\text{max}}$ or $F$ <
$F_{\text{target}}$. Algorithm 1 shows the AQCE algorithm procedure.

Algorithm 1 AQCE

0: state $\ket{\Psi}$, integers $(M_{0},\delta,M_{\text{max}},N)$ and target
fidelity $F_{\text{target}}$

0: circuit $\mathcal{C}$ Initialisation : $\mathcal{C}\leftarrow I$ and
$M=M_{0}$

1: while $M<M_{\text{max}}\ \land\ F<F_{\text{target}}$ do

2: add new $\delta$ two-qubit gates to $\mathcal{C}$

3: $M\leftarrow M+\delta$

4: for $counter=1$ to $N$ do

5: optimize each of M gates (Above steps $(\mathrm{i})\sim(\mathrm{vi})$)

6: end for

7: end while

8: return $\mathcal{C}$

###  A.4 Support Vector Machines

Support Vector Machines (SVM) are supervised learning classifiers that learn a
decision boundary between two classes of elements. We define the training data
as $TR=\\{\vec{x}^{(i)},\vec{y}^{(i)}\\}_{i=1:N}\in X\times Z_{2}$ and test
data $TS=\\{\vec{x}^{(i)},\vec{y}^{(i)}\\}_{i=1:M}\in X\times Z_{2}$,
generally with $TS\cap TR=\emptyset$, where the two sets are assumed to have
been generated by the same or highly similar distribution. SVMs solve a convex
optimization problem on $TR$ to deliver a classifier for $TS$ with a trade-off
between an accurate performance for the true labels and maximization of the
orthogonal distance between the classes. The classification boundary is
generally highly non-linear, therefore the data is first mapped with a feature
function $\phi:X\rightarrow F$ to a higher dimensional space (feature space,
in the quantum case the Hilbert Space), with a scalar product
$\braket{\,,\,}$. In this space, the SVM is a linear classifier which aims at
maximizing the margin between decision boundary and data points:

$\arg\,\max_{w,b}\Biggl{\\{}\frac{1}{||w||}\min_{n}[t_{n}(\braket{w,\phi(\vec{x}^{(n)})}+b)]\Biggl{\\}}$
(53)

Here $t_{n}$ are target class values for the elements $\vec{x}^{(i)}\in TR$,
the $\frac{1}{||w||}$ is just a scaling factor to avoid dependence on $n$. As
an intuition, $\vec{y}(\vec{x}^{(n)})=\braket{w,\phi(\vec{x}^{(n)})}+b$
defines the classification in one of the two classes based on its positive or
negative sign. Instead, $t_{n}(\braket{w,\phi(\vec{x}^{(n)})}+b)$ is the
distance from the decision surface of the problem (which then we want to
maximize). In our case, we use a soft margin SVM, which means that
$t_{n}y(\vec{x}^{(n)})\geq 1-\xi_{n}$, where $\xi_{n}$ are slack variables
that help to deal with overlapping class distributions giving a small penalty
for misclassification. The previous formulation of 53 is too complex to solve,
therefore it is generally converted to the equivalent primal problem: w, b,
ξ12||w||^2 + C∑_n=1^Nξ_n t_n(⟨w,ϕ(→x^(n))⟩+b)≥1-ξ_n ξ_n≥0
The “Kernel trick” consists in shifting this formulation to one where we don’t
have to compute the computationally demanding mapping $\Phi$ for every point,
but instead just compute a Kernel function defined as
$K(\vec{x}^{(i)},\vec{x}^{(j)})=\braket{\phi(\vec{x}^{(i)}),\phi(\vec{x}^{(j)})}$.
Follows the dual formulation: α_i ∈R∑_n=1^Nα_n-12∑_n=1^N∑_m=1^Nα_n α_m
t_nt_mK(→x^(n), →x^(m)) 0 ≤α_i≤ C ∑_m=1^Nα_n t_n=0
Solving the dual problem allows then to solve the primal and the relationships
for the equivalence allows expressing the classification function as:

$f(\vec{x})=sgn\Bigl{(}\sum_{n=1}^{N}t_{n}\alpha_{n}K(\vec{x}^{(i)},\vec{x})\Bigl{)},\vec{x}\in
TS$ (54)

##  Appendix B Details on Dataset Generation

This section provides an in-depth look at the data and hardware used for
dataset generation.

Table 4: Parameters for Achieving Specified Fidelity Fidelity (%) | M (Max Number of 2-Qubit Gates) |  $\delta$ (Incremental Gate Factor)
---|---|---
80 | 25 | 3
90 | 50 | 6
95 | 100 | 12

Table 4 outlines the parameters used to ensure the attainment of the specified
fidelity. Here, ’M’ represents the maximum number of 2-qubit gates, while
’$\delta$’ is the factor determining the number of gates to be added in each
iteration.

The dataset was generated using a cluster machine with the following
specifications:

  * •

CPU: Dual Intel Xeon Platinum 9242 (2.3GHz, 48-Core)

  * •

Memory: 384 GB (24 x 16 GB DDR4 -2933 Reg.ECC)

The generation of one MNIST image with $90\%$ fidelity took approximately 8
seconds per process. Although the AQCE algorithm can be run in multiple
threads, we opted for single-threaded execution due to its efficiency when
generating a large number of images in parallel.

We divided the generation of 480,000 data sheets into 1000 processes, with
each process generating 480 sheets. Each process was registered as a single
job on the cluster machine. Considering the three types of fidelity and the
original 60,000 sheets of learning data, the number of jobs increased
proportionally. To avoid disk IO contention, we stored 480 copies in memory
and wrote them to the disk all at once after all 480 circuits were generated.

Our implementation uses Qulacs [33] internally and runs within a container
using Singularity to separate the cluster environment from the execution
environment. Using a 40-node cluster (3840 cores), we were able to generate
4.95 million pieces of data in approximately 8.5 hours.

Table 5: Data Breakdown for 4.95 Million Records Dataset | Description | Metric | Augmented Training Data?
---|---|---|---
MNIST | 60,000 Training Data, 10,000 Test Data | Fidelity | Yes (480,000)
Fashion MNIST | 60,000 Training Data, 10,000 Test Data | Fidelity | Yes (480,000)
Kuzushiji MNIST | 60,000 Training Data, 10,000 Test Data | Fidelity | Yes (480,000)

Table 5 provides a breakdown of the data for the 4.95 million records
generated. Each dataset includes original training and test data, and is
augmented with additional training data to enhance the learning process.

###  B.1 Dual-Form Representation: Quantum Circuits and QASM Descriptions

Quantum circuits for Qulacs can be generated with a specific dataset using the
following methods:

    qulacs_dataset.[type].loader.load_[type]_[data_type]_[fidelity]

In the above method:

  * •

type refers to the type of dataset, which can be mnist, fashion_mnist, or
kuzushiji_mnist.

  * •

data_type indicates whether the data is original, train, or test.

  * •

fidelity represents the fidelity level, which can be f80, f90, or f95.

For instance, to load the MNIST training dataset with a fidelity of 95%, you
would use:

    qulacs_dataset.mnist.loader.load_mnist_train_f95()

Running a circuit embeds a dataset into a quantum state. This embedded quantum
state can then be used to add a quantum machine learning circuit for learning
purposes.

The quantum circuit fetches QASM data from the cloud and transforms it into a
quantum circuit. The DenseMatrix feature is used for embedding the features of
your dataset.

Please note that DenseMatrix is not a part of OpenQASM and is a proprietary
extension with the following format:

  * •

Format:

        DenseMatrix (number of target qubits, number of control qubits,
        matrix elements a + bi ordered by "a, b"),
        target qubit column, control qubit column;

  * •

Example:

        DenseMatrix(2,0,0.900726,0,-0.267421,0, ... ,0.752815,0) q[2],q[6];

The dataset directory structure is organized as follows:

  * •

fidelity: This represents the fidelity between the original true quantum state
and the quantum state embedded by executing the quantum circuit.

  * •

label: These are the labels for the dataset.

  * •

qasm: These are the QASM files that are converted into quantum circuits.

  * •

state: This is the value of the state vector that is embedded as a quantum
state.

Note that the repository may be updated over time, so we will specify on the
GitHub page any change in format or syntax.

##  Appendix C Machine Learning models and details

###  C.1 Structured State Space Sequence model (S4)

The Structured State Space sequence model (S4) is a neural network based on
state space models designed to handle long sequences efficiently [24]. It is
the first model to solve the Path-X task in the Long Range Arena benchmarks
tay2021long that requires the ability to handle complex long-range
dependencies, which other previous methods including Transformer failed to
learn.

###  C.2 Transformer

Transformer is a neural network model consisting of self-attention and fully-
connected feed-forward network [25]. Although it was originally proposed for
machine translation, Transformer and its variants are now popularly used in
various tasks, including computer vision dosovitskiy2021an, and achieve state-
of-the-art performance. Compared with recurrent neural networks (RNNs) or
convolutional neural networks (CNNs), Transformer depends on less inductive
biases and thus expected to learn them from data.

###  C.3 Long Short-Term Memory (LSTM)

Long Short-Term Memory (LSTM) is a type of recurrent neural network (RNN) and
has been the standard neural network for sequence modeling for a long time
[26]. Compared with the vanilla RNN, LSTM has additional gates to control
information so that it can handle longer sequences. These gates avoid gradient
vanishing or gradient explosion, which the vanilla model suffers from,
enabling it to apply to complex sequence tasks, such as machine translation
sutskever2014sequence.

###  C.4 Experimental settings and models

In this section, we provide a comprehensive overview of the configuration
details for the S4, Transformer, and LSTM models used in our experiments. We
trained these models on the proposed datasets in the QASM format for 200
epochs.

The input QASMs were preprocessed by removing superfluous information such as
headers and rounding elements of dense matrices to _one_ decimal place, as
illustrated in Figure 5 of the paper. Interestingly, rounding to two decimal
places decreased the performance. Test accuracy of S4 dropped from 77.78% to
72.10% for mnist_784 classification at a fidelity of 95%.

        # The original format:
        DenseMatrix(2,0,0.541645,0,-0.038637,0, ... ,0.540171,0) q[0],q[1];

         # The preprocessed format:
         0.5, 0, 0, 0, ..., 0.5, q[0], q[1]

####  C.4.1 S4 Model

The S4 model was implemented using a JAX-based version available at
https://srush.github.io/annotated-s4/. We adopted its “CIFAR-10
classification” configuration, modifying the number of epochs.

The hyperparameters used for training the S4 model are as follows:

  * •

Hidden size: 512

  * •

Number of layers: 6

  * •

Dropout rate: 0.25

  * •

Optimizer: AdamW (initial learning rate of $1.0\times 10^{-3}$ with cosine
annealing with warmup and weight decay rate of $0.01$)

  * •

Batch size: 50

####  C.4.2 Transformer Model

We adopted a BERT-like Transformer architecture as a sequence classifier
devlin2018bert using the Transformer Encoder module in PyTorch. Layer
normalization was applied prior to self-attention and feedforward layers (pre-
norm), and the GELU activation function was used as [25].

The following hyperparameters are used for training the Transformer models.

  * •

Hidden size: 512

  * •

Number of heads: 8

  * •

Number of layers: 6

  * •

Dropout rate: 0.10

  * •

Optimizer: AdamW (initial learning rate of $1.0\times 10^{-5}$ with cosine
annealing with warmup and weight decay rate of $0.01$)

  * •

Batch size: 128

We selected the initial learning rate from $\\{1.0\times 10^{-5},5.0\times
10^{-5},1.0\times 10^{-4}\\}$ and weight decay from $\\{0.01,0.05,0.1\\}$ on
mnist_786 with a fidelity of 80.

####  C.4.3 LSTM Model

We implemented the LSTM model using the LSTM module in PyTorch followed by a
linear layer with the following hyperparameters.

  * •

Hidden size: 512

  * •

Number of layers: 2

  * •

Dropout rate: 0.25

  * •

Optimizer: AdamW (initial learning rate of $1.0\times 10^{-3}$ with cosine
annealing with warmup and weight decay rate of $0.01$)

  * •

Batch size: 128

We selected the initial learning rate from $\\{1.0\times 10^{-4},1.0\times
10^{-3}\\}$ on mnist_786 with a fidelity of 80.

###  C.5 Experiments with different data preprocessing

We show here alternative experiments using a different data processing
strategy from the QASM files testing on Transformer and LSTM. The real part of
the DenseMatrix in QASM is truncated to three decimal places and arranged in a
specific format.

     # The original format:
     DenseMatrix(2,0,0.541645,0,-0.038637,0, ... ,0.540171,0) q[0],q[1];

     # is converted to:
     0.541 -0.038 ... 0.54 q[0] q[1] _

The classification process involves the following steps:

  * •

Data Conversion: If there are 25 DenseMatrix instances, they are juxtaposed to
form a single sequence.

  * •

Vocabulary Building: The vocabulary is built from the real part (truncated to
three decimal places), $q[0]$, and the data delimiter, $\\_$. The following
command can be used to build the vocabulary:

             onmt_build_vocab -config config.yaml -n_sample 1000

  * •

Training: The model can be trained using the following command:

             onmt_train -config config.yaml

Table 6: Test accuracy of Transformer and LSTM with different preprocessing from before. Dataset | Fidelity | Transformer | LSTM
---|---|---|---
MNIST-784 | 80 | 58.84 | 55.68
| 90 | 57.74 | 55.14
| 95 | 54.90 | 55.68
Fashion-MNIST | 80 | 62.70 | 55.00
| 90 | 57.96 | 55.54
| 95 | 55.00 | 55.00
Kuzushiji-MNIST | 80 | 56.39 | 55.00
| 90 | 55.12 | 55.11
| 95 | 55.12 | 55.00

####  C.5.1 relative Transformer Model

For the Transformer and LSTM models, we employed OpenNMT-py opennmt. The
specific configuration for the Transformer model is detailed below:

  * •

Word vector size: 512

  * •

Hidden size: 512

  * •

Number of layers: 6

  * •

Feed-forward size (transformer_ff): 2048

  * •

Number of heads: 8

  * •

Accumulation count (accum_count): 8

  * •

Optimizer: Adam (Beta1: 0.9, Beta2: 0.998)

  * •

Decay method: Noam

  * •

Learning rate: 2.0

  * •

Maximum gradient norm (max_grad_norm): 0.0

  * •

Dropout rate: 0.1

  * •

Label smoothing: 0.1

####  C.5.2 relative LSTM Model

The LSTM model was constructed using the following components, each with their
respective hyperparameters:

  * •

RNNEncoder: LSTM encoder with 500 hidden units

  * •

RNNDecoder: Stacked LSTM decoder with two LSTM cells (First cell: 1000 hidden
units, Second cell: 500 hidden units)

  * •

GlobalAttention: Implemented in the model

  * •

Generator: Linear layer with 500 units for output generation

  * •

Word vector size: 500

  * •

Hidden size: 500

  * •

Number of layers: 2

  * •

Optimizer: SGD

  * •

Accumulation count: 1

  * •

Learning rate: 1.0

  * •

Maximum gradient norm: 5

  * •

Dropout rate: 0.3

##  Appendix D Dataset license

We release MNISQ dataset with the following license:

CC BY-SA 4.0

https://creativecommons.org/licenses/by-sa/4.0/

##  Appendix E Metadata

We added structured metadata to the dataset’s metadata page. We are also
including the metadata on the GitHub repository of the dataset
https://github.com/FujiiLabCollaboration/MNISQ-quantum-circuit-
dataset/blob/main/metadata.

##  Appendix F Authors statement

As authors of the MNISQ dataset, we affirm that we bear all responsibility in
case of any violation of rights or any legal issues that may arise from the
use of the dataset. We also confirm that the MNISQ dataset is licensed under
the Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
license, allowing users to share and adapt the dataset as long as proper
attribution is provided, and any derivative works are shared under the same
license.

##  Appendix G GitHub url

The dataset and the experiments are accessible on the GitHub URL:
https://github.com/FujiiLabCollaboration/MNISQ-quantum-circuit-dataset. We
will keep working on improving the directory, but the dataset is already
accessible as specified in the paper and there are a few tutorials. We will
maintain this repository and provide updates on the dataset. unsrt arxivMNISQ