-
Notifications
You must be signed in to change notification settings - Fork 39
/
main.tex
266 lines (229 loc) · 12.1 KB
/
main.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
\documentclass[aspectratio=43]{beamer}
\usepackage[utf8]{inputenc}
%%%%%%%%%%%%%%%%%%%%%%%% THEME
\usetheme{material}
\useLightTheme
\usePrimaryBlueGrey
\useAccentDeepPurple
\usepackage{macros} % must come after theme
\title{High-Level Quantum Programming}
\keywords{\qk, \q Programming}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}{Table of contents}
\begin{card}
\tableofcontents
\end{card}
\end{frame}
\section{Introduction}
\begin{frame}{Meta-Introduction}
\begin{card}
By now, you should have a good grasp of the \textit{magic underneath the hood} of \qc. Meaning that quantum circuitry and quantum programming are now within your grasp.
\end{card}
\pagenumber
\end{frame}
\begin{frame}{Introduction}
\begin{cardTiny}
This week, a different approach will be taken. We will see how quantum computing can be used for the benefit of many other scientific and industry areas. Hopefully, some of the topics you will learn will have a direct application on your life and work.
\end{cardTiny}
\begin{cardTiny}
We will do some \qka troubleshooting and then go through the latest examples on \href{https://github.com/Qiskit/qiskit-tutorial}{qiskit-tutorial} on how to use \qsa for solving real world problems. This example set is not fully explored and is expected to grow quite a lot in the short term (so keep your eyes open).\\
\small{*If you are an autodidact, feel free to skip examples on areas that do not interest you.}
\end{cardTiny}
\pagenumber
\end{frame}
\begin{frame}{Motivation}
\begin{card}
\begin{chapquote}[2pt]{\href{https://msramalho.github.io/}{Me}}
``The better people understand that quantum computing is within their grasp and can be leveraged towards personal gain, the sooner a day will come when running quantum algorithms is but a triviality.''
\end{chapquote}
\end{card}
\pagenumber
\end{frame}
\section{\qka}
\begin{frame}{\qka}
\begin{center}
\includegraphics[width=1\textwidth]{qka}
\end{center}
\begin{card}
As we saw in \href{\weekOne}{Week 1 - Quantum Tools}, \qka is the top-level block on the \qk full-stack infrastructure. This means it works on a higher level then what we have seen so far, abstracting a quantum compiler and providing an interface much similar to that of classical computing.
\end{card}
\pagenumber
\end{frame}
\begin{frame}{The Premise of \qka}
\begin{card}
\qka contains ``a library of cross-domain quantum algorithms upon which applications for near-term quantum computing can be built''. \textbf{Near-term} means this is the time to look into this, as these algorithms and applications will become feasible in a short time.
\end{card}
\pagenumber
\end{frame}
\section{\q Supremacy}
\begin{frame}{\q Supremacy}
\begin{card}
The term \textbf{\q Supremacy} (not to be mistaken for a crossover between \textit{Quantum of Solace} and \textit{The Bourne Supremacy}...) stands for the moment in time in which quantum computers can do better than the most powerful computer in simulating a quantum system.\\
This may seem strange, but the fact is that classical computers are so developed they they are still able to simulate better quantum computers than those in existence, but this classical "quantum simulation" fits into the \np family and so there will come a time, in the not so far away future, when they are no longer able to do better than \textit{the real thing}.
\end{card}
\pagenumber
\end{frame}
\begin{frameImg}[height]{quantum_supremacy.jpeg}
\end{frameImg}
\section{Running algorithms in \qka}
\begin{frame}{Running algorithms in \qka}
\begin{card}
First and foremost: \mintinline{bash}{pip install qiskit-aqua}
\end{card}
\begin{cardTiny}
Then, we need to understand which algorithms have already been implemented in \qka. A comprehensive list can be found \href{https://qiskit.org/documentation/aqua/algorithms.html}{in the docs}, some that you may recognize are:
\begin{itemize}
\item \href{https://qiskit.org/documentation/aqua/algorithms.html#quantum-grover-search}{Grover Search}
\item \href{https://qiskit.org/documentation/aqua/algorithms.html#quantum-dynamics}{Quantum Dynamics} (Simulating Universal Quantum Systems)
\item \href{https://qiskit.org/documentation/aqua/algorithms.html#support-vector-machine-quantum-kernel-svm-q-kernel}{Support Vector Machine Quantum Kernel} (Machine Learning)
\item \href{https://qiskit.org/documentation/aqua/algorithms.html#cplex}{CPLEX} (Constraint Solver)
\end{itemize}
\end{cardTiny}
\pagenumber
\end{frame}
\begin{frame}{Running algorithms in \qka}
\small{
\qka is very declarative, in fact, running an algorithm can be thought of as defining a description of your problem, for instance in a \href{https://www.json.org/}{JSON} file or in a \href{https://docs.python.org/3/tutorial/datastructures.html#dictionaries}{Python Dictionary}. It is a composition of the following settings (For more information, check the \href{https://qiskit.org/documentation/aqua/execution.html#input-file}{docs}.):
\begin{description}
\item[Problem] The type of experiment (\mintinline{python}{"energy" | "excited_states" | "ising" | "search" ...})
\item[Input/Oracle] The way to specify the input to the problem, depends on the type (SAT configuration, dataset, oracle, ...)
\item[Algorithm] Optional specification of the algorithm to use (each problem has default algorithms) and its configurations
\item[Backend] Which device to use (simulator, real device), highly customizable with number of shots (how many times should an experiment be repeated), activate compiler optimization, specify device noise parameters, ...
\end{description}
}
\pagenumber
\end{frame}
\section{Troubleshooting \qka}
\begin{frame}{Troubleshooting \qka}
\begin{card}
After installing head to a command line and run \mintinline{bash}{qiskit_aqua_ui}. If nothing happens, you should make sure you add your python \mintinline{bash}{bin} folder to the \href{https://docs.alfresco.com/4.2/tasks/fot-addpath.html}{system variable path}, it should be something like: \mintinline{python}{"C:/Program Files/Python36/Library/bin"}.\\
The same solution goes for \href{https://stackoverflow.com/questions/14778178/import-cvxopt-base-the-specified-module-could-not-be-found}{the cvxopt error} when running python scripts.
\end{card}
\pagenumber
\end{frame}
\begin{frame}{Troubleshooting \qka}
\small{When everything is properly installed you should see something like (The \qka GUI for editing experimental settings):}
\begin{center}
\includegraphics[width=1\textwidth]{qskit_aqua_ui}
\end{center}
\pagenumber
\end{frame}
\section{\gvsa in \qka}
\begin{frame}[fragile]{\gvsa in \qka}
Go ahead and run the following code, while trying to understand it:\begin{minted}{python}
from qiskit_aqua import run_algorithm
# problem in DIMACS CNF format:
sat_cnf = """
p cnf 3 5
-1 -2 -3 0
1 -2 3 0
1 2 -3 0
1 -2 -3 0
-1 2 3 0
"""
params = {
'problem': {'name': 'search'},
'oracle': {'name': 'SAT', 'cnf': sat_cnf},
'algorithm': {'name': 'Grover'},
'backend': {'name': 'qasm_simulator'}
}
print(run_algorithm(params)['result']) # [1, -2, 3] or another
\end{minted}
\end{frame}
\section{\ai}
\begin{frame}{\ai}
\begin{card}
If you work in Machine Learning, you probably know how the \href{https://en.wikipedia.org/wiki/Support_vector_machine}{Support Vector Machine}(SVM) works. It is simply an algorithm for \href{https://en.wikipedia.org/wiki/Supervised_learning}{supervised learning}.\\
\qka comes with more than one implementation of SVM Kernels. We will have a complete exercise on it this week (optional).
\end{card}
\begin{card}
More \ai related algorithms are expected to be implemented on \qka in the future, and you may even \href{https://qiskit.org/documentation/aqua/extending.html#algorithms}{implement your own}!
\end{card}
\pagenumber
\end{frame}
\begin{frame}[fragile]{\ai (SVM)}
\small{Here's an example of a configuration for an SVM classification model:}\begin{minted}{python}
params = {
'problem': {
'name': 'svm_classification',
'random_seed': 1219 # same seed ensures reproducibility
},
'algorithm': {
'name': 'QSVM.Kernel'
},
'backend': {
'name': 'qasm_simulator',
'shots': 1024
},
'feature_map': {
'name': 'SecondOrderExpansion',
'depth': 2,
'entanglement': 'linear'
}
}
\end{minted}
\end{frame}
\section{Optimization}
\begin{frame}{Optimization}
\begin{cardTiny}
Still related to AI, there is another very important topic nowadays in both research and industry settings: \textbf{optimization}.
\end{cardTiny}
\begin{cardTiny}
In this week's exercises you will have 2 examples of optimization problems: \href{https://en.wikipedia.org/wiki/Maximum_cut}{maximum cut} and the iconic \href{https://en.wikipedia.org/wiki/Travelling_salesman_problem}{traveling salesman problem}. These can both be reduced to a traditional model called \href{https://en.wikipedia.org/wiki/Ising_model}{ising model} that has been studied from a \href{https://arxiv.org/ftp/arxiv/papers/1210/1210.0113.pdf}{quantum point of view}. Thus, by using the ising solver in \qka we are able to solve many different problems, literally the only limitation is our ability to map problem formulations into know and solved problems.
\end{cardTiny}
\pagenumber
\end{frame}
\section{Chemistry in \qka}
\begin{frame}{Chemistry in \qka}
\begin{card}
Lastly, and especially directed at chemistry related research, there are also examples of extrapolation of quantum mechanical properties that allow to make simulation on the behaviour of atoms, electrons and on the evolution of molecule configurations.\\ If you think about it, what better to simulate an atomic process than quantum?
\end{card}
\begin{card}
As a matter of fact, there is a \href{https://github.com/Qiskit/aqua-chemistry}{complete repository} form the \qk team dedicated to chemistry algorithms for research on the field.
\end{card}
\pagenumber
\end{frame}
\begin{frame}[fragile]{Chemistry in \qka}
\small{We will not go much deeper into explaining the typical approaches, as this should be done by those students that truly benefit from it. However, here is an example of how such problems may be configured (the input comes from \href{https://support.hdfgroup.org/HDF5/whatishdf5.html}{HDF5} files):}\begin{minted}{python}
# Input dictionary to configure Qiskit aqua Chemistry
# for the chemistry problem.
aqua_chemistry_dict = {
'driver': {'name': 'HDF5'},
'HDF5': {'hdf5_input': 'H2/0.7_sto-3g.hdf5'},
'operator': {'name': 'hamiltonian'},
'algorithm': {'name': 'VQE'},
'optimizer': {'name': 'COBYLA'},
'variational_form': {'name': 'UCCSD'},
'initial_state': {'name': 'HartreeFock'},
'backend': {'name': 'statevector_simulator'}
}
\end{minted}
\end{frame}
\section{Hands-on}
\begin{frame}{Hands-on}
\begin{card}
This week there will be quite a few exercise tutorials available, each student is expected to select and study at least one of them. Here are the topics covered in each:
\begin{enumerate}
\item Grover algorithm with \qka (search)
\item SVM for Breast Cancer classification (\ai)
\item Maximum Cut problem (optimization)
\item Traveling Salesman problem (optimization)
\item Computing the ground state energy of an $H_2$ molecule (Chemistry)
\end{enumerate}
\end{card}
\end{frame}
\section{Where to learn more?}
\begin{frame}{Where to learn more?}
\begin{card}
\begin{itemize}
\item \href{https://qiskit.org/documentation/aqua/index.html}{\qka documentation} seriously a good point to start
\item \href{https://github.com/Qiskit/qiskit-tutorial/tree/master/qiskit/aqua}{\qka official tutorials}
\item \href{https://github.com/Qiskit/qiskit-tutorial/tree/master/community/aqua}{\qka community tutorials}
\item \href{https://en.wikipedia.org/wiki/Quantum_programming}{A comprehensive analysis of \q Programming SDKs and languages} including, of course, \qk
\end{itemize}
\end{card}
\end{frame}
\end{document}