Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

Commit 8533ecb

Browse files
author
Ilia Lazarev
committed
Imrove Step by step circuit explanation #16
1 parent 738bba6 commit 8533ecb

File tree

1 file changed

+70
-55
lines changed

1 file changed

+70
-55
lines changed

manuscript.tex

Lines changed: 70 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ \subsection{Optimized quantum scheme for Hamming distance calculation}
226226
\caption{
227227
Quantum circuit for the quantum parallelized Hamming distance calculating between all pairs of binary vectors from two sets ${X}$ and ${Y}$ encoded \cite{trugenberger2001} in $X$ and $Y$ quantum registers respectively.
228228
First, we encoded information about pairwise different qubits in a quantum state of the $X$-register with applying the CNOT gates.
229-
Second, Hamming distance values are extracted into the amplitudes of superposition with the controled rotation around $z$-axis gate and Hadamard gates.
229+
Second, Hamming distance values are extracted into the amplitudes of superposition with the controled rotation around $z$-axis gate~(\ref{eq:controled_rotation}) and Hadamard gates.
230230
Finally, a quantum state of the $X$-register returned to the initial basis for information retrieval.
231231
}
232232
\label{fig:qcircuit}
@@ -259,12 +259,12 @@ \subsection{Optimized quantum scheme for Hamming distance calculation}
259259
Meanwhile, during the procedure it stores the differences between input vectors and cluster states.
260260

261261
Let us assume we have $k$ input vectors and $l$ cluster states.
262-
The $i$th input vector and $j$th cluster vector are respectively denoted as $\left| X_i \right\rangle$, $\left| Y_j \right\rangle$.
262+
The $i$th input vector and $j$th cluster vector are respectively denoted as $\left| x_i \right\rangle$, $\left| y_j \right\rangle$.
263263
The registers $\left| X \right\rangle$ and $\left| Y \right\rangle$ are initialized to store the input vectors and cluster vectors according to
264264
%
265265
\begin{align}
266-
\left| X \right\rangle & = \frac{1}{\sqrt{k}} \sum\limits_{i=1}^{k} \left| X_i \right\rangle, \\
267-
\left| Y \right\rangle& = \frac{1}{\sqrt{l}} \sum\limits_{j=1}^{l} \left| Y_j \right\rangle .
266+
\left| X \right\rangle & = \frac{1}{\sqrt{k}} \sum\limits_{i=1}^{k} \left| x_i \right\rangle, \\
267+
\left| Y \right\rangle& = \frac{1}{\sqrt{l}} \sum\limits_{j=1}^{l} \left| y_j \right\rangle .
268268
\label{eq:encodnig}
269269
\end{align}
270270
%
@@ -280,28 +280,26 @@ \subsection{Optimized quantum scheme for Hamming distance calculation}
280280
%
281281
where $\left| a \right\rangle$ is an auxiliary qubit in the state $\left| 0 \right\rangle$ initially.
282282

283-
Given this initial state we may begin the processing of the problem. We start by applying a CNOT gate between $\left| X \right\rangle$ and $\left| Y \right\rangle$
283+
Given this initial state we may begin the processing of the problem. We start by applying a CNOT gate on $\left| x^{(\alpha)} y^{(\alpha)} \right\rangle$ and $\alpha = 1 \dots n$
284284

285-
\begin{align}
286-
| \psi_1 \rangle & =
287-
\mathrm{CNOT} (Y,X)| \psi_0 \rangle \nonumber \\
288-
& =
285+
\begin{equation}
286+
| \psi_1 \rangle =
289287
\frac{1}{\sqrt{kl}} \sum_{i, j=1}^{k}
290288
| d^{(1)}_{ij}, \dots, d^{(n)}_{ij} \rangle
291289
| y^{(1)}_j, \dots, y^{(n)}_j \rangle
292290
| 0 \rangle
293-
\end{align}
291+
\end{equation}
294292
%
295-
where $d^\alpha_{ij} = \mathrm{CNOT}(y^\alpha_i, x^\alpha_j)$, $\alpha = 1 \dots n$, and $i,j$ are the qubit indexes in the registers.
293+
where $d^{(\alpha)}_{ij} = \mathrm{CNOT}(y^{(\alpha)}_i, x^{(\alpha)}_j)$, and $\alpha = 1 \dots n$ is the qubit index in the register.
296294
At this stage of the computation the $\left| X \right\rangle$ no longer stores the input vectors,
297295
instead it stores the information about pairwise different qubits between the input vector $\{X\}$ and cluster vector $\{Y\}$.
298296
Next, for each pair $\{X\}$ and $\{Y\}$, the accumulated information of all the differences is projected onto the amplitude of the superposed state.
299297
This is achieved by applying the Hadamard gate on auxiliary qubit,
300298
followed by a controlled rotation around $z$-axis gate on $\left| Xa \right\rangle$ defined as
301299
%
302300
\begin{equation}
303-
\label{eq:control_phase_rotation}
304-
R_{(X,a)}(\phi) =
301+
\label{eq:controled_rotation}
302+
C_{R_z}(\phi) =
305303
\begin{pmatrix}
306304
1 & 0 & 0 & 0 \\
307305
0 & e^{-i \frac \phi 2} & 0 & 0 \\
@@ -316,46 +314,57 @@ \subsection{Optimized quantum scheme for Hamming distance calculation}
316314
After the first Hadamard on the ancilla qubit the state is
317315
%
318316
\begin{equation}
319-
\left| \psi_2 \right\rangle = H_a\left| \psi_1 \right\rangle =
317+
\left| \psi_2 \right\rangle =
320318
\frac{1}{\sqrt{kl}}\sum\limits_{i, j=1}^{k}
321-
\left| d^{(1)}_{ij}, \dots, d^{(n)}_{ij} \right\rangle
322-
\left| y^{(1)}_j, \dots, y^{(n)}_j \right\rangle
319+
\left| d_{ij} \right\rangle
320+
\left| y_j \right\rangle
323321
\dfrac{(\left| 0 \right\rangle + \left| 1 \right\rangle)}{\sqrt{2}} .
324322
\end{equation}
325323
%
326-
Applying the controlled rotation around $z$-axis gate the state then becomes
324+
Applying the controlled rotation around $z$-axis gate on $\left| x^{(\alpha)} a \right\rangle$ where $\alpha = 1\dots n$ and the state then becomes
327325
%
328326
\begin{multline}
329-
\left| \psi_3 \right\rangle = R_{(X,a)}\left(\dfrac{\pi}{n}\right)\left| \psi_2 \right\rangle
330-
\\ = \dfrac{1}{\sqrt{2kl}}
331-
\sum\limits_{i, j=1}^{k}
332-
\left| d^{(1)}_{ij}, \dots, d^{(n)}_{ij} \right\rangle
333-
\left| y^{(1)}_j, \dots, y^{(n)}_j \right\rangle
334-
\left| 0 \right\rangle
335-
\\ + \dfrac{1}{\sqrt{2kl}}
336-
\sum\limits_{i, j=1}^{k}
337-
\exp\left(\dfrac{-i \pi}{n}\sum\limits_{l=1}^n d^{(l)}_{ij} \right)
338-
\left| d^{(1)}_{ij}, \dots, d^{(n)}_{ij} \right\rangle
339-
\\ \times \left| y^{(1)}_j, \dots, y^{(n)}_j \right\rangle
340-
\left| 1 \right\rangle
327+
\left| \psi_3 \right\rangle
328+
= \dfrac{1}{\sqrt{2kl}} \sum\limits_{i, j=1}^{k}
329+
\exp\left(
330+
\dfrac{-i \pi}{2n}
331+
\sum\limits_{\alpha=1}^n d^{(\alpha)}_{ij}
332+
\right)
333+
\left| d_{ij} \right\rangle
334+
\left| y_j \right\rangle
335+
\left| 0 \right\rangle \\
336+
+ \dfrac{1}{\sqrt{2kl}} \sum\limits_{i, j=1}^{k}
337+
\exp\left(
338+
\dfrac{i \pi}{2n}
339+
\sum\limits_{\alpha=1}^n d^{(\alpha)}_{ij}
340+
\right)
341+
\left| d_{ij} \right\rangle
342+
\left| y_j \right\rangle
343+
\left| 1 \right\rangle
341344
\end{multline}
342345
%
343346
Applying another Hadamard on the ancilla qubit we obtain
344347
%
345348
\begin{multline}
346349
\left| \psi_4 \right\rangle =
347350
\frac{1}{\sqrt{kl}}\sum\limits_{i, j=1}^{k}
348-
\exp \left(\dfrac{-i \pi}{2n}\sum\limits_{l=1}^n d^{(l)}_{ij} \right)
349-
\\ \times
350-
\left[ \cos\left(\dfrac{\pi}{2n}\sum\limits_{l=1}^n d^{(l)}_{ij} \right)
351-
\left| d^{(1)}_{ij}, \dots, d^{(n)}_{ij} \right\rangle
352-
\left| y^{(1)}_j, \dots, y^{(n)}_j \right\rangle
353-
\left| 0 \right\rangle\right.
354-
\\+
355-
\left. i \sin\left(\dfrac{\pi}{2n}\sum\limits_{l=1}^n d^{(l)}_{ij} \right)
356-
\left| d^{(1)}_{ij}, \dots, d^{(n)}_{ij} \right\rangle
357-
\left| y^{(1)}_j, \dots, y^{(n)}_j \right\rangle
358-
\left| 1 \right\rangle\right] .
351+
\left[
352+
\cos\left(
353+
\dfrac{\pi}{2n}
354+
\sum\limits_{\alpha=1}^n d^{(\alpha)}_{ij}
355+
\right)
356+
\left| d_{ij} \right\rangle
357+
\left| y_j \right\rangle
358+
\left| 0 \right\rangle\right.
359+
\\+
360+
\left. i \sin\left(
361+
\dfrac{\pi}{2n}
362+
\sum\limits_{\alpha=1}^n d^{(\alpha)}_{ij}
363+
\right)
364+
\left| d_{ij} \right\rangle
365+
\left| y_j \right\rangle
366+
\left| 1 \right\rangle
367+
\right] .
359368
\end{multline}
360369
%
361370
This completes the step for projecting differences between pairs of $\{X\}$ and $\{Y\}$ onto the amplitude of the auxiliary qubit.
@@ -367,19 +376,25 @@ \subsection{Optimized quantum scheme for Hamming distance calculation}
367376
At this stage, the information regarding the differences between pairs of $\{X\}$ and $\{Y\}$ \hl{encoded in the amplitudes, in order to extract the Hamming distances between the relevant $\left| x_i \right\rangle$, $\left| y_j \right\rangle$ we return to our initial basis} for register $\left| X \right\rangle$ by applying pairwise CNOT gates:
368377
%
369378
\begin{multline}
370-
\left| \psi_f \right\rangle =
371-
\mathrm{CNOT} (Y,X)\left| \psi_4 \right\rangle \\=
379+
\left| \psi_f \right\rangle =
372380
\frac{1}{\sqrt{kl}}\sum\limits_{i, j=1}^{k}
373-
\exp \left(\dfrac{-i \pi}{2n}\sum\limits_{l=1}^n d^{(l)}_{ij} \right)
374-
\left[ \cos\left(\dfrac{\pi}{2n}\sum\limits_{l=1}^n d^{(l)}_{ij} \right)
375-
\left| X_i \right\rangle
376-
\left| Y_j \right\rangle
381+
\left[
382+
\cos\left(
383+
\dfrac{\pi}{2n}
384+
\sum\limits_{\alpha=1}^n d^{(\alpha)}_{ij}
385+
\right)
386+
\left| x_i \right\rangle
387+
\left| y_j \right\rangle
377388
\left| 0 \right\rangle\right.
378389
\\+
379-
\left. i \sin\left(\dfrac{\pi}{2n}\sum\limits_{l=1}^n d^{(l)}_{ij} \right)
380-
\left| X_i \right\rangle
381-
\left| Y_j \right\rangle
382-
\left| 1 \right\rangle\right] .
390+
\left. i \sin\left(
391+
\dfrac{\pi}{2n}
392+
\sum\limits_{\alpha=1}^n d^{(\alpha)}_{ij}
393+
\right)
394+
\left| x_i \right\rangle
395+
\left| y_j \right\rangle
396+
\left| 1 \right\rangle
397+
\right] .
383398
\end{multline}
384399
%
385400
This makes $\{X\}$ store the input vectors again, as in the initial step
@@ -390,11 +405,11 @@ \subsection{Optimized quantum scheme for Hamming distance calculation}
390405
In this case, the biggest amplitude of the measurement result coincides with the smallest Hamming distance when the measurement result of the ancilla qubit is 0.
391406
If the ancilla qubit is 1, the smallest amplitude of the measurement result coincides with the smallest Hamming distance.
392407

393-
Measuring the Hamming distance of a particular pair of input vectors $\left| X_i \right\rangle$ and cluster vector $\left| Y_j \right\rangle$ consists of extracting the relevant amplitude from the subspace that those states form,
408+
Measuring the Hamming distance of a particular pair of input vectors $\left| x_i \right\rangle$ and cluster vector $\left| y_j \right\rangle$ consists of extracting the relevant amplitude from the subspace that those states form,
394409
this can be done using the following projection operator
395410
%
396411
\begin{align}
397-
\Pi_{i,j} = &\left| X_i \rangle\langle X_i \right| \otimes \left| Y_j \rangle\langle Y_j \right| \otimes I .
412+
\Pi_{i,j} = &\left| x_i \rangle\langle x_i \right| \otimes \left| y_j \rangle\langle y_j \right| \otimes I .
398413
\end{align}
399414
%
400415
Using the above projection operator, the subspace of the Hilbert space formed by a particular pair of input and cluster vectors can be traced out as
@@ -411,7 +426,7 @@ \subsection{Optimized quantum scheme for Hamming distance calculation}
411426
\end{align}
412427
%
413428
In order to reduce noise we average the measurement results over different states of the ancilla qubit,
414-
thus the measured Hamming distance between the input vector $\left| X_i \right\rangle$ and cluster vector $\left| Y_j \right\rangle$ is
429+
thus the measured Hamming distance between the input vector $\left| x_i \right\rangle$ and cluster vector $\left| y_j \right\rangle$ is
415430
%
416431
\begin{align}
417432
d_{i,j}^H & \propto 1 - \frac{1}{2}(a_0(x_i,y_j) + (1-a_1(x_i,y_j))) .
@@ -429,7 +444,7 @@ \subsection{Optimized quantum scheme for Hamming distance calculation}
429444
\begin{figure}[t]
430445
\includegraphics[width=0.95\columnwidth]{vectorized_sample.png}
431446
\caption{
432-
(a) Representation of the data set of abstracts with the bag-of-words model is shown.
447+
(a) Representation of the data set of abstracts with the bag-of-words \cite{weikang2016} model is shown.
433448
Each abstract is represented by a binary vector with 9 elements, corresponding to the 9 words on the horizontal axis.
434449
The samples are sorted into groups (QML, MED, BIO) with 3 papers for each tag, for a total of 9 paper.
435450
(b) The Hamming distance between each vectorized abstract is shown as a number in the matrix.
@@ -467,7 +482,7 @@ \section{Experimental demonstration of QASOFM}
467482
``Quantum Machine Learning'' (QML),
468483
``Cancer'' (MED)
469484
and ``Gene Expression'' (BIO).
470-
Abstracts were vectorized by the bag-of-words\cite{weikang2016} model in order to choose most defining words in each data set (see Fig.~\ref{fig:vectorized_sample}) \cite{mctear2016}.
485+
Abstracts were vectorized by the bag-of-words \cite{weikang2016} model in order to choose most defining words in each data set (see Fig.~\ref{fig:vectorized_sample}) \cite{mctear2016}.
471486
This model represents text as a multiset ``bag'' of its words taking into account only multiplicity of words.
472487
Preparing the bag-of-words we excluded the words that appear only in one abstract and more than in 4 abstracts and we also excluded the word ``level'' from consideration due to the frequent overlap between the clusters because it gives instabilities for both classical and quantum algorithms.
473488
We restricted our bag-of-word size to 9 of the most frequent words from the full bags-of-word due to limitations of the number of qubits.

0 commit comments

Comments
 (0)