Teaching_Quantum_Machine_Learning_in_Computer_Science
Teaching_Quantum_Machine_Learning_in_Computer_Science
Science
Gennaro De Luca Yinong Chen
School of Computing and Augmented Intelligence School of Computing and Augmented Intelligence
2023 IEEE 15th International Symposium on Autonomous Decentralized System (ISADS) | 978-1-6654-6451-2/23/$31.00 ©2023 IEEE | DOI: 10.1109/ISADS56919.2023.10092171
Abstract—The field of quantum computing is rapidly could aid our understanding of the power of quantum machine
growing, with near term applications immediately available for learning, especially with respect to classical approaches [8].
use. The application of quantum computing to machine learning
(i.e., quantum machine learning) is similarly growing rapidly. Another major area of QML research is the application of
The presence of noisy intermediate-scale quantum (NISQ) era QML to empower classical Convolutional Neural Networks
computers is further enabling research in the area. Historically, (CNN). Quantum CNNs (QCNNs) have multiple applications
the barrier to entry of quantum computing has been nearly aside from traditional image recognition, such as for solving
insurmountable for computer science students, or any other quantum phase recognition and quantum error correction
students who lack a strong physics background. However, optimization [9]. Some attempts have been made to directly
quantum computing and quantum machine learning are translate CNNs into QCNNs such as the study in [10]. Other
becoming increasingly accessible, regardless of background. attempts employ QML as a classifier, resorting to a traditional
The goal of this paper is to present and demonstrate that the CNN for the bulk of the image analysis [9][11].
field is accessible to computer science students and to provide a
sample curriculum. This curriculum can be used in a standalone The list of research topics in QML is numerous, and we
class or as part of another machine learning class, as the authors have outlined only a few with the goal of appealing to
have done. researchers in domains related to computer science, machine
learning, and data science. Work from these domains could
Keywords—quantum machine learning, computer science significantly improve the future success of QML in general.
education, quantum computing, machine learning As such, this paper serves multiple purposes in its aim to
support education in the area of QML. First, we hope that this
I. INTRODUCTION work helps promote novel research in these areas from
Quantum computing is a field founded on mathematics scholars of many different disciplines. Additionally, we hope
and quantum mechanics. In its youth, classical computing to help educate as many students as possible, so that students
shared many similarities with the modern field of quantum who enter the workforce will have a strong understanding of
computing, notably its reliance on understanding the this rising technology.
underlying principles to create programs. There was a similar
In this paper, we focus on a QML module in a machine
requirement of mathematics and (classical) physics until
learning course. Table 1 lists the topics and lecture hours for
layers of abstraction enabled more people to begin
this module. The curriculum assumes that the general machine
programming. From that point, learning how to program
learning topics are covered in other modules of the course. The
classical computers required very little to no understanding of
main contribution of this paper is a centralized collection of
those fields. Just as classical computing provided great
resources, including lecture and assignment guidelines, that
contributions to various fields, such as physics, mathematics,
can be used by computer science educators to begin teaching
chemistry and machine learning, quantum computing is
quantum machine learning. Particularly, this paper aims to
providing its own contributions to those fields, both the
reduce the barrier to entry of the field by minimizing the
classical and quantum fields. Each of these areas is a rich field
of research, with research being done in both academia and prerequisite physics knowledge required, enabling students
industry. Support for these research areas is also rapidly with little to no experience to begin working in the field.
growing as a result of programs such as the U.S. government’s Table 1 Suggested QML topics and lectures
national quantum initiative [1].
Suggested QML Topics Lectures
One of the major areas of research in the field of quantum
machine learning (QML) is the analysis of the loss landscape Introduction to quantum computing 1
of a given variational quantum algorithm (VQA) Quantum computing and programming 2
[2][3][4][5][6]. Various approaches have been taken to
quantify this landscape, such as the Fisher information Advanced quantum algorithms (optional) 2
spectrum [2], covering numbers [3], and the Hessian matrix
QML architecture 1
[4]. This topic is particularly important as barren plateaus, or
the minimization of the gradient of the loss function, is a major Data embedding 1
issue in quantum machine learning [7]. Furthermore, this topic
lends itself to potential advancement in the understanding of Quantum kernel methods (optional) 1
expressibility of quantum machine learning [4]. Such work Ansatz definition and analysis 2
Authorized licensed use limited to: VTU Consortium. Downloaded on April 03,2025 at 15:14:59 UTC from IEEE Xplore. Restrictions apply.
[12][13]. The CX gate is already a two-qubit gate and does to ensure students’ understanding of these topics. The more
not require such modification. The circuit in VIPLE is shown comfortable students are with gate-based quantum
in Figure 2. programming, the simpler their understanding of QML will
likely become. However, students who lack a strong
understanding of those concepts can still find some success
in practical QML, especially with the support of modern
QML libraries.
III. QML ARCHITECTURE
Fig. 2. VIPLE H and CX The term QML can be used to various different
Qiskit provides a draw function which VIPLE extends to architectures and model families, such as TensorFlow classic-
provide a visualization, which is shown in Figure 3. This quantum networks [21], variational classifiers [22], QCNNs
visualization facilitates seeing connections between qubits, [9], among many others. This paper will provide a curriculum
such as the one between 0 and 1 by the controlled not gate in focusing on hybrid quantum-classical variational classifiers.
this example. Connecting qubits in this way is fundamental This type of QML is similar in ideology to neural networks
to the creation of entangled states. [23], has similarities to kernel methods [24], and provides an
extensible baseline that can be applied to other areas such as
quantum chemistry [13] or other applications of variational
circuits. The general architecture of a hybrid quantum-
classical variational classifier is shown in Figure 5.
Authorized licensed use limited to: VTU Consortium. Downloaded on April 03,2025 at 15:14:59 UTC from IEEE Xplore. Restrictions apply.
quantum operations are linear [23], the only sources of showcases the major similarity between kernel methods and
nonlinearity in the system are essentially from measurement quantum embeddings, as described in [24].
and, potentially, the embedding. Thus, the selection of
embedding strategy can have a significant impact on the
success of the network [27].
The three key embedding strategies are basis encoding,
amplitude encoding, and angle encoding [24]. There are
various advanced strategies, such as Hamiltonian encoding,
which are excluded from this discussion due to their reliance
on a stronger physics background. Interested instructors and
students can apply the techniques from the basic strategies to
these more advanced ones in a straightforward manner. For
computer science students, runtime complexity analysis is
often an important part of many classes. As such, the space
and time complexities of each embedding strategy is provided
with each explanation.
Basis encoding treats the qubits as binary bits. As such, it
fails to leverage almost any power of the quantum computer
and requires N*t qubits, where t is the precision and N is the
number of features. This encoding takes O(N*t) time to
embed.
Amplitude encoding directly embeds the features in the
amplitude vector of the system. In this way, an exponential Fig. 6. Kernel methods vs quantum embeddings [24]
amount of data can be embedded in a linear number of qubits.
This exponential improvement is often cited as one of the key In order to work through the examples, students would
potential advantages QML may have over classical ML. benefit from understanding density matrices. For the purpose
However, since the wave function (amplitudes) collapse upon of this curriculum, students need only understand how to
measurement, this data cannot be directly extracted [13][23]. calculate them. With the vector representation of qubits, the
Amplitude embedding of N features can be done using log(N) density matrix is computed through an outer product (i.e., a
qubits. However, the runtime varies significantly depending simple matrix multiplication of the quantum state and its
on the structure of the data [23]. For example, data points that transpose). Students who successfully work through such
are identical can be easily embedded using Hadamard gates. material can be given assignments related to creating new
To embed arbitrary states into the system, the data first needs embedding strategies and calculating the relevant kernel
to be normalized. The state preparation circuit is known to be method or calculating the kernel method for larger systems. In
bounded from below by (2n)/n where n is the number of qubits such a case, students may benefit significantly from
[28][29][30][31][32], though current methods are not automated algebraic solvers.
currently at that efficiency. Current methods have a runtime V. ANSATZ DEFINITION
only slightly below 2n with many expensive two-qubit
operations [23]. For smaller datasets, amplitude encoding is The ansatz definition is an area where students often have
easily feasible. the greatest freedom. There are three main categories of ansatz
components that a student could easily benefit from. These are
Rotational embedding, also called angle embedding, is one the non-parameterized gates, parameterized gates, and multi-
of the easiest embedding strategies, is used widely in the qubit gates. Parameterized gates are any that require an
research literature, and often has reasonable success [27]. In additional input, such as Rx which requires an angle input.
this approach, each feature is embedded into a single qubit by Instead of a special angle, a weight vector can be used so that
rotating the qubit by the amount of the features. As such, the gates are trainable. Including parameterized gates is vital
scaling all the features to be within 2*pi can avoid different to the model’s success. Non-parameterized gates are optional
features being embedded as the same value. Since each feature but may provide some advantages. Gates such as X, Y, Z, and
is embedded on one qubit, N qubits are required. Only one H can be easily added or removed. Multi-qubit gates
rotation operator (Rx, Ry, Rz, etc.) is required per feature, so essentially serve as the only connection between qubits in the
the runtime is O(N). system. CNOT is a commonly used two-qubit operation that
Once students understand the fundamentals of the three will likely have a significant impact on the model
embedding strategies, they can begin repeating or combining performance.
them. Techniques such as repeated rotational embedding, More advanced students can review popular ansatz
where the rotations are repeated multiple times, can provide architectures from the literature. PennyLane provides an
potential speedups [24]. article summarizing much of this research. It categorizes the
One major research area related to data embedding architectures into layered gate, alternating operator, and tensor
compares the embedding strategy to a kernel method. Students network. Comparing ansatz performance experimentally is
with an understanding of kernel methods or other advanced relatively straightforward. Students can change the ansatz then
students can review this area in the literature, such as in [24]. compare the converged validation accuracy or the number of
That paper provides a relatively accessible introduction to epochs required for training to a specific accuracy.
kernel methods and the quantum counterpart. Figure 6
Authorized licensed use limited to: VTU Consortium. Downloaded on April 03,2025 at 15:14:59 UTC from IEEE Xplore. Restrictions apply.
Students with a strong machine learning background can though simulators are typically not subject to such errors or
read the literature on mathematical analysis of ansatz decoherence. A significant amount of literature on facing the
performance, such as the Fisher information spectrum [2], barren plateau problem is available. A significant amount of
covering numbers [3], and the Hessian matrix [4]. Students time can be spent covering such research or performing
who can successfully work at this level could complete experiments in training. Understanding the classical problem
assignments requiring calculation and comparison of one or and the classical solution could provide additional beneficial
multiple of these metrics. material for the students.
VI. MEASUREMENT AND OPTIMIZATION VII. QML ASSIGNMENTS
Measurement is perhaps the simplest aspect of the As the field of QML is significantly large, there are many
variational quantum classifier. By employing the expectation varying opportunities for assessments under this curriculum.
value, the randomness from the quantum circuit can be This section will include both fundamental assignments that
overcome, enabling statistical analysis of the results and are more basic in their requirements and required knowledge
optimization of the weights. Conversely, the optimization of as well as more advanced projects that push the boundaries of
the network is a potential source of some of the most difficult the curriculum’s material and some that extend beyond the
problems in the field of QML. However, entry-level students curriculum.
can simply employ classical optimization classes, such as the
Each section of the curriculum builds on the previous
Adam Optimizer. PennyLane provides an API for various
section, enabling continuous improvement of the student
such optimizers [26]. Students with a strong machine learning
code. Instructors who prefer standalone assessments can
background can explore the source code for these optimizers
in PennyLane’s open-source code and implement other individually assess each category and have a standalone final
classical optimizers for use in their model. project that synthesizes all the material. For example, the
embedding section could be assessed by asking students to
The variational classifier tutorial mentioned earlier has the embed a certain amount of data into a system with a given
weakness of only supporting two-class classification. accuracy. Questions could cover material such as time
Classical approaches to handling multi-class classification can efficiency of embedding, required preprocessing, and number
be employed in similar ways in QML. Alternatively, there are of required qubits. The ansatz section could require creation
several QML-specific methodologies discussed in the relevant of multiple different ansatzes with significantly different
literature. Adding a classical network after the quantum circuit combinations of circuits. Students may be asked to experiment
is another potential method for supporting multi-class with removing non-parameterized, parameterized, and/or
classification. multi-qubit gates.
Optimizers for variational quantum circuits work similarly A cumulative assessment could ask students to build on a
to classifiers for neural networks. Namely, some sort of sample variational quantum classifier by using a new dataset
backpropagation using the results of the loss function needs to or new methodologies for each component. As briefly
be performed. Advanced students can explore the various mentioned in section VI, adding support for multi-class
options for doing so, including symbolic, numerical, and classification could increase the difficulty of this assessment.
automatic differentiation. The topic of backpropagation can Students can be asked to compare performances when
also be covered along with optimization. Variational quantum changing the various components or comparing performance
circuits often make use of automatic differentiation to between different datasets. Students could also be asked to
compute the quantum gradients. Many operations employ build classical models for each dataset and attempt to achieve
parameter-shift rules for this task [26]. A sample circuit is similar results using QML.
shown in Figure 7 with information on the number of
To give students experience with physical quantum
parameters and gradient method for each operation. Students
computers, students can be asked to use the Qiskit plugin for
who successfully work through the literature related to
parameter-shift rules can be tasked with manually calculating PennyLane and connect to one of the IBM quantum
computers. Such a task may be time consuming but can
gradients.
provide students with a free experience. Additionally, students
will be given the opportunity to learn about the importance of
decoherence time, circuit depth, number of qubits, and errors.
Such an experiment could also choose to only require a non-
trainable quantum circuit. In this case, students could be given
many of the same experiences with quicker runtimes.
Additional experimentation can be performed in this case,
such as testing the effect of multi-qubit operations on error
rate.
For instructors who want to offer students an in-depth end-
Fig. 7. Automatic differentiation to-end experience, students can be asked to build their own
QML system without using a QML library or the QML classes
A major issue that has historically affected classical neural in a library such as Qiskit. Such a task would require students
networks in addition to QML is the barren plateau issue, also to calculate gradients of the circuit and implement the
known as the vanishing gradient problem [7]. This problem is optimizer or employ a standard classical optimizer with their
significantly less impactful in classical machine learning, in own gradient calculations. Such a project could provide
part due to significant increase in computational power over students with a stronger understanding of how a variational
the years. However, quantum computers are significantly quantum classifier works.
more limited in addition to being more susceptible to errors,
Authorized licensed use limited to: VTU Consortium. Downloaded on April 03,2025 at 15:14:59 UTC from IEEE Xplore. Restrictions apply.
Variational quantum circuits are used in various areas concepts are both transferable and extensible. An experiment
outside of QML, such as in quantum simulation and quantum testing specific assessments and measuring the efficacy of
chemistry. Should a student have experience in one of these different approaches would be strongly valuable. The authors
fields, developing a variational quantum circuit for such a have only tested the curriculum as a single module in a general
problem could enhance their understanding of both areas. machine learning class. In that case, students had strong
PennyLane provides support for many different such knowledge of the classical machine learning components.
applications, facilitating the transition from this curriculum to However, assessment was limited to a cumulative project
different projects [26]. Another sample variational quantum without significant added complexity due to time constraints.
algorithm is the variational quantum linear solver (VQLS), an
As QML continues to grow and affect other areas of many
application of variational quantum circuits that should be
different disciplines, it is becoming increasingly important to
accessible to any student who has worked through this
prepare the workers and researchers of the future to
curriculum.
understand and potentially undertake such work.
Students with a strong classical machine learning
background could explore other intersections of machine REFERENCES
learning and quantum computing. For example, CNNs are [1] https://www.quantum.gov/
particularly effective at image recognition. Adding a quantum [2] Abbas, A., Sutter, D., Zoufal, C., Lucchi, A., Figalli, A., & Woerner,
component or completely building a QCNN with only S. (2021). The power of quantum neural networks. Nature
quantum components could be interesting projects. A simple Computational Science, 1(6), 403-409.
architecture comparing a pure classical CNN and a pure [3] Du, Y., Tu, Z., Yuan, X., & Tao, D. (2022). Efficient measure for the
expressivity of variational quantum algorithms. Physical Review
classical QCNN is shown in Figure 8. The possible Letters, 128(8), 080506.
intersections between these areas are not well known, with [4] Huembeli, P., & Dauphin, A. (2021). Characterizing the loss landscape
many such applications arising with each passing year. of variational quantum circuits. Quantum Science and Technology,
6(2), 025011.
[5] Thanasilp, S., Wang, S., Nghiem, N. A., Coles, P. J., & Cerezo, M.
(2021). Subtleties in the trainability of quantum machine learning
models. arXiv preprint arXiv:2110.14753.
[6] Hamilton, K. E., Lynn, E., & Pooser, R. C. (2021). Mode connectivity
in the loss landscape of parameterized quantum circuits. arXiv preprint
arXiv:2111.05311.
[7] McClean, J. R., Boixo, S., Smelyanskiy, V. N., Babbush, R., & Neven,
H. (2018). Barren plateaus in quantum neural network training
landscapes. Nature communications, 9(1), 1-6.
[8] Biamonte, J., Wittek, P., Pancotti, N., Rebentrost, P., Wiebe, N., &
Lloyd, S. (2017). Quantum machine learning. Nature, 549(7671), 195-
202.
[9] I. Cong, S. Choi, and M. D. Lukin, “Quantum convolutional neural
networks,” Nat. Phys., vol. 15, no. 12, pp. 1273–1278, Dec. 2019, doi:
10.1038/s41567-019-0648-8.
[10] S. Wei, Y. Chen, Z. Zhou, and G. Long, “A Quantum Convolutional
Neural Network on NISQ Devices,” arXiv:2104.06918 [quant-ph],
Apr. 2021, Accessed: Nov. 16, 2021. [Online]. Available:
http://arxiv.org/abs/2104.06918
[11] Azevedo, Vanda, Carla Silva, and Inês Dutra. "Quantum transfer
Fig. 8. (a) Classical CNN vs (b) QCNN [9] learning for breast cancer detection." Quantum Machine Intelligence
4.1 (2022): 1-14.
TensorFlow Quantum provides a method for users to
easily experiment with variational (parameterized) quantum [12] Michael A. Nielsen and Isaac L. Chuang. 2011. Quantum Computation
and Quantum Information: 10th Anniversary Edition (10th. ed.).
circuits inside an otherwise classical neural network [21]. Cambridge University Press, USA.
Although TensorFlow Quantum makes use of the Cirq [13] Anis, M. D. S., Abraham, H., AduOffei, Agarwal, R., Agliardi, G.,
library, the concepts behind the quantum layer are very Aharoni, M., … Čepulkovskis, M. (2021). Qiskit: An Open-source
similar to the variational quantum classifier covered in the Framework for Quantum Computing. doi:10.5281/zenodo.2573505
curriculum. Thus, such a project could be a potentially [14] Y. Chen and G. De Luca, "VIPLE: Visual IoT/Robotics Programming
straightforward opportunity to compare quantum and Language Environment for Computer Science Education," 2016 IEEE
classical layers in the context of a given problem and International Parallel and Distributed Processing Symposium
Workshops (IPDPSW), 2016, pp. 963-971, doi:
network architecture. 10.1109/IPDPSW.2016.55.
VIII. CONCLUSION [15] Y. Chen, G. De Luca, Service-Oriented Computing and System
Integration: Software, IoT, Big Data, and AI as Services, 8th edition,
This paper provided a curriculum for teaching QML to Kendall Hunt Publishing, 2022.
computer science students, though the curriculum is also [16] Y. Chen, G. De Luca, ASU VIPLE in Computing and Engineering
accessible in large part to students from other disciplines. This Curricula. 2015, http://venus.sod.asu.edu/VIPLE/
curriculum teaches students many of the fundamental ideas [17] G. De Luca and Y. Chen, "Semantic Analysis of Concurrent
that underline both basic and advanced QML projects and Computing in Decentralized IoT and Robotics Applications," 2019
IEEE 14th International Symposium on Autonomous Decentralized
research. As such, students who complete the material should System (ISADS), 2019, pp. 1-8, doi:
be prepared to begin undertaking more advanced projects. 10.1109/ISADS45777.2019.9155627.
[18] Gennaro De Luca, Zhongtao Li, Sami Mian, Yinong Chen: " Visual
Future work in this area includes testing such a curriculum programming language environment for different IoT and robotics
in a full semester course. Though this paper largely discussed
the PennyLane library for a simple variational classifier, the
Authorized licensed use limited to: VTU Consortium. Downloaded on April 03,2025 at 15:14:59 UTC from IEEE Xplore. Restrictions apply.
platforms in computer science education ", CAAI Transactions on Intelligence and Knowledge Economy (ICCIKE), Dubai, United Arab
Intelligence Technology, Volume 3, Issue 2, June 2018, pp. 119 – 130. Emirates, Mar. 2021, pp. 345–349. doi:
[19] G. De Luca, & Y. Chen (2020). Explainable Artificial Intelligence for 10.1109/ICCIKE51210.2021.9410753.
Workflow Verification in Visual IoT/Robotics Programming [26] https://pennylane.ai/
Language Environment. Journal of Artificial Intelligence and [27] G. De Luca and Y. Chen, “Quantum Embeddings of Classical Data for
Technology, 1(1), 21–27. https://doi.org/10.37965/jait.2020.0023 Quantum Machine Learning.” The 6th Asian Conference on Artificial
[20] https://javafxpert.github.io/grok-bloch/ Intelligence Technology (ACAIT), 2022. In press.
[21] Broughton, M., Verdon, G., McCourt, T., Martinez, A. J., Yoo, J. H., [28] Knill, E.: Approximation by quantum circuits (1995). arXiv:quant-
Isakov, S. V., ... & Mohseni, M. (2020). Tensorflow quantum: A ph/9508006
software framework for quantum machine learning. arXiv preprint [29] Möttönen, M., Vartiainen, J.J., Bergholm, V., Salomaa, M.M.:
arXiv:2003.02989. Quantum circuits for general multiqubit gates. Phys. Rev. Lett. 93(13),
[22] De Luca, G. (2022). A survey of NISQ era hybrid quantum-classical 130502 (2004)
machine learning research. Journal of Artificial Intelligence and [30] Vartiainen, J.J., Möttönen, M., Salomaa, M.M.: Efficient
Technology, 2(1), 9-15, doi: https://doi.org/10.37965/jait.2021.12002 decomposition of quantum gates. Phys. Rev. Lett. 92(17), 177902
[23] Schuld, M., & Petruccione, F. (2021). Machine Learning with (2004)
Quantum Computers. Springer. [31] Plesch, M., Brukner, Cˇ : Quantum-state preparation with universal
[24] Schuld, M. (2021). Supervised quantum machine learning models are gate decompositions. Phys. Rev. A 83(3), 032302 (2011)
kernel methods. arXiv preprint arXiv:2101.11020. [32] Iten, R., Colbeck, R., Kukuljan, I., Home, J., Christandl, M.: Quantum
[25] S. Farhan Ahmad, R. Rawat, and M. Moharir, “Quantum Machine circuits for isometries. Phys. Rev. A 93(3), 032318 (2016)
Learning with HQC Architectures using non-Classically Simulable
Feature Maps,” in 2021 International Conference on Computational
Authorized licensed use limited to: VTU Consortium. Downloaded on April 03,2025 at 15:14:59 UTC from IEEE Xplore. Restrictions apply.