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

Commit b01ba97

Browse files
author
kephircheek
authored
Merge pull request #7 from marekyggdrasil/detail-measurements
I defined Hamming distance in terms of projected expectation values
2 parents 337904d + 29be69d commit b01ba97

File tree

2 files changed

+56
-30
lines changed

2 files changed

+56
-30
lines changed

manuscript.pdf

4.78 KB
Binary file not shown.

manuscript.tex

Lines changed: 56 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -201,19 +201,22 @@ \subsection{Optimized quantum scheme for Hamming distance calculation}
201201

202202

203203

204-
We now introduce an optimized algorithm for calculating the matrix of Hamming distances \cite{trugenberger2001} between a sample vector and all cluster vectors at once.
205-
This allows for a simple encoding of the classical information into a quantum register.
206-
Initially we have two registers each with $n$ qubits in that we encode our set of binary vectors defined as
204+
We now introduce an optimized algorithm for calculating the matrix of Hamming distances \cite{trugenberger2001} between a sample vector and all cluster vectors at once. This allows for a simple encoding of the classical information into a quantum register.
205+
206+
The overall procedure involves two registers of $n$ qubits each, denoted $\left| X \right\rangle$ and $\left| Y \right\rangle$, along with a single auxiliary qubit $\left| a \right\rangle$. During entire processing, the $\left| Y \right\rangle$ is used to store the cluster states, then at the beginning and at the end of the processing the $\left| X \right\rangle$ register stores the input vectors, while during the processing it stores the differences between input vectors and cluster states.
207+
208+
Now for this demonstration let us assume we have $k$ input vectors and $l$ cluster states. The $i$th input vector and $j$th cluster vector are respectively denoted as $\left| x_i \right\rangle$ and $\left| y_j \right\rangle$.
209+
210+
The registers $\left| X \right\rangle$ and $\left| Y \right\rangle$ will properly store input vectors and cluster vectors if initialized as follows.
211+
207212
%
208213
\begin{align}
214+
\left| X \right\rangle & = \frac{1}{\sqrt{k}} \sum\limits_{i=1}^{k} \left| x_i \right\rangle, \\
215+
\left| Y \right\rangle& = \frac{1}{\sqrt{l}} \sum\limits_{j=1}^{l} \left| y_j \right\rangle,
209216
\label{eq:encodnig}
210-
\left| X \right\rangle & = \sum\limits_{i=1}^{k} \left| x_i \right\rangle, \\
211-
\left| Y \right\rangle& = \sum\limits_{i=1}^{l} \left| y_i \right\rangle,
212217
\end{align}
213218
%
214-
where $ 1 \le k, l \le n $.
215-
Here the registers $\left| X \right\rangle$ and $\left| Y \right\rangle$ correspond to the input states and the cluster states respectively.
216-
The initial state of whole circuit is
219+
Both registers along with the auxiliary qubit compose into initial state of the entire circuit in a form denoted below.
217220
%
218221
\begin{equation}
219222
\left| \psi_0 \right\rangle =
@@ -225,23 +228,22 @@ \subsection{Optimized quantum scheme for Hamming distance calculation}
225228
%
226229
where $\left| a \right\rangle$ is an auxiliary qubit in the state $\left| 0 \right\rangle$ initially.
227230

228-
We then apply a CNOT gate between $\left| X \right\rangle$ and $\left| Y \right\rangle$
231+
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$
229232

230233
\begin{equation}
231234
\left| \psi_1 \right\rangle =
232235
\mathrm{CNOT(Y,X)\left| \psi_0 \right\rangle} =
233-
\sum\limits_{i, j}^{k}
236+
\frac{1}{\sqrt{kl}} \sum\limits_{i, j}^{k}
234237
\left| d^1_{ij}, \dots, d^n_{ij} \right\rangle
235238
\left| y^1_j, \dots, y^n_j \right\rangle
236239
\left| 0 \right\rangle
237240
\end{equation}
238241
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.
239242

240-
In the result, we encoded information about pairwise different qubits in $\{X\}$ and $\{Y\}$ into register $\left| X \right\rangle$.
243+
In the result, at this stage of the computation the $\left| X \right\rangle$ no longer stores the input vectors, instead it stores the information about pairwise different qubits between the input vector $\{X\}$ and cluster vector $\{Y\}$.
241244

242245

243-
After that we transfer information about distance between sample state and cluster state into the amplitude of the superposed state.
244-
In order to make that we apply Hadamard gate on auxiliary qubit, then control phase gate on $\left| Xa \right\rangle$,
246+
The next stage, for each pair $\{X\}$ and $\{Y\}$, an accumulated information of all the differences is projected into the amplitude of the superposed state. this is achieved by applying the Hadamard gate on auxiliary qubit, then control phase gate on $\left| Xa \right\rangle$,
245247

246248
\begin{equation}
247249
\label{eq:control_phase_rotation}
@@ -261,7 +263,7 @@ \subsection{Optimized quantum scheme for Hamming distance calculation}
261263

262264
\begin{equation}
263265
\left| \psi_2 \right\rangle = H_a\left| \psi_1 \right\rangle =
264-
\sum\limits_{i, j}^{k}
266+
\frac{1}{\sqrt{kl}} \sum\limits_{i, j}^{k}
265267
\left| d^1_{ij}, \dots, d^n_{ij} \right\rangle
266268
\left| y^1_j, \dots, y^n_j \right\rangle
267269
\dfrac{\left| 0 \right\rangle + \left| 1 \right\rangle}{\sqrt{2}}
@@ -271,12 +273,12 @@ \subsection{Optimized quantum scheme for Hamming distance calculation}
271273

272274
\begin{multline}
273275
\left| \psi_3 \right\rangle = R_{(X,a)}\left(\dfrac{\pi}{n}\right)\left| \psi_2 \right\rangle
274-
\\ = \dfrac{1}{\sqrt{2}}
276+
\\ = \dfrac{1}{\sqrt{2kl}}
275277
\sum\limits_{i, j}^{k}
276278
\left| d^1_{ij}, \dots, d^n_{ij} \right\rangle
277279
\left| y^1_j, \dots, y^n_j \right\rangle
278280
\left| 0 \right\rangle
279-
\\ + \dfrac{1}{\sqrt{2}}
281+
\\ + \dfrac{1}{\sqrt{2kl}}
280282
\sum\limits_{i, j}^{k}
281283
\exp\left(\dfrac{-i \pi}{n}\sum\limits_l^n d^l_{ij} \right)
282284
\left| d^1_{ij}, \dots, d^n_{ij} \right\rangle
@@ -301,7 +303,7 @@ \subsection{Optimized quantum scheme for Hamming distance calculation}
301303

302304
\begin{multline}
303305
\left| \psi_4 \right\rangle =
304-
\sum\limits_{i, j}^{k}
306+
\frac{1}{\sqrt{kl}} \sum\limits_{i, j}^{k}
305307
e^{\left(\dfrac{-i \pi}{2n}\sum\limits_l^n d^l_{ij} \right)}
306308
\\ \times
307309
\left\{\cos\left(\dfrac{\pi}{2n}\sum\limits_l^n d^l_{ij} \right)
@@ -316,12 +318,14 @@ \subsection{Optimized quantum scheme for Hamming distance calculation}
316318
\end{multline}
317319

318320

319-
Then we return to our initial basis for register $\left| X \right\rangle$ with applying the pairwise CNOT gates:
321+
This completed the stage of projecting the differences between pairs of $\{X\}$ and $\{Y\}$ onto the amplitude of the auxiliary qubit. The process is done in the $x$-basis, which explains the surrounding Hadamard gates. There are two possible measurement outcomes of the auxiliary qubit, each pair of $\{X\}$ and $\{Y\}$ forms a subspace of the Hilbert space, the controlled phase gate ensures to change amplitudes of those outcomes within this subspace depending on how different the spin configurations between $\{X\}$ and $\{Y\}$ are.
322+
323+
At this stage, the information of differences between pairs of $\{X\}$ and $\{Y\}$ is no longer relevant, thus we return to our initial basis for register $\left| X \right\rangle$ by applying the pairwise CNOT gates:
320324

321325
\begin{multline}
322-
\left| \psi_5 \right\rangle =
326+
\left| \psi_f \right\rangle =
323327
\mathrm{CNOT(Y,X)\left| \psi_4 \right\rangle} \\=
324-
\sum\limits_{i, j}^{k}
328+
\frac{1}{\sqrt{kl}}\sum\limits_{i, j}^{k}
325329
e^{\left(\dfrac{-i \pi}{2n}\sum\limits_l^n d^l_{ij} \right)}
326330
\left\{\cos\left(\dfrac{\pi}{2n}\sum\limits_l^n d^l_{ij} \right)
327331
\left| X_i \right\rangle
@@ -334,16 +338,38 @@ \subsection{Optimized quantum scheme for Hamming distance calculation}
334338
\left| 1 \right\rangle\right\}
335339
\end{multline}
336340

337-
In the result we have the Hamming distances encoded into the amplitudes of the final state.
338-
After getting statistics of the measurement outcomes we can produce the distance matrix between two data sets of binary vectors (Fig.~\ref{fig:distance_matrix}).
339-
In this case, a biggest amplitude in measurement result coincide to a smallest Hamming distance when the measurement result of the auxiliary qubit is 0
340-
and we have the inverse relationship when measurement result on the auxiliary qubit is 1.
341-
In order to reduce noise we average measurement results over different states of the auxiliary qubit as $a_0(x_i,y_j) + (1-a_1(x_i,y_j))$
342-
where $a_0(x_i,y_j)$ and $a_1(x_i,y_j)$ are amplitudes for the measurement results $\left| x_i \right\rangle\left| y_j \right\rangle \left| 0 \right\rangle_a$ and $\left| x_i \right\rangle\left| y_j \right\rangle \left| 0 \right\rangle_a$ respectively.
343-
In comparison with the circuits for Hamming distance calculations proposed previously \cite{trugenberger2001},
344-
our method allows one to reduce number of gates in the circuit (at least in $2n$ one-qubit NOT gates,
345-
depends on actual realization control phase gate in a quantum register on the hardware level),
346-
reconstruct all distance matrix at once and can be implemented with high fidelity on current quantum devices.
341+
This made $\{X\}$ store input vectors again, just like at the initial stage, however it preserved the amplitudes of the auxiliary qubit which are proportional to how different each pairs of $\{X\}$ and $\{Y\}$ are.
342+
343+
In the result we have the Hamming distances encoded into the amplitudes of the final state. After getting statistics of the measurement outcomes we can produce the distance matrix between two data sets of binary vectors (Fig.~\ref{fig:distance_matrix}). In this case, a biggest amplitude in measurement result coincide to a smallest Hamming distance when the measurement result of the auxiliary qubit is 0 and we have the inverse relationship when measurement result on the auxiliary qubit is 1.
344+
345+
Measuring the Hamming distance of a particular pair of input vector $\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, this can be done using the following projector operator.
346+
347+
\begin{align}
348+
\Pi_{i,j} = &\left| X_i \rangle\langle X_i \right| \otimes \left| X_i \rangle\langle Y_j \right| \otimes I \nonumber \\
349+
\end{align}
350+
351+
Using the above projection operator, the subspace of the Hilbert space formed by particular pair of input vector and cluster vector can be traced out as follows.
352+
353+
\begin{align}
354+
\rho_{i,j} &= \text{Tr}_{1,\dots,2n} (\Pi_{i,j} \left| \psi_f \rangle\langle \psi_f \right| \Pi_{i,j})
355+
\end{align}
356+
357+
Now the following two relevant amplitudes for the measurement results can be extracted.
358+
359+
\begin{align}
360+
a_0(x_i,y_j) & = \frac{\left\langle 0 |\rho_{i,j}| 0 \right\rangle}{\text{tr}(\rho_{i,j})}, \\
361+
a_1(x_i,y_j) & = \frac{\left\langle 1 |\rho_{i,j}| 1 \right\rangle}{\text{tr}(\rho_{i,j})},
362+
\end{align}
363+
364+
In order to reduce noise we average measurement results over different states of the auxiliary qubit, thus the measured Hamming distance between the input vector $\left| X_i \right\rangle$ and cluster vector $\left| Y_j \right\rangle$ takes the following form.
365+
366+
\begin{align}
367+
d_{i,j}^H & \propto 1 - \frac{1}{2}(a_0(x_i,y_j) + (1-a_1(x_i,y_j)))
368+
\end{align}
369+
370+
The Hamming distance measured in this way is contained $0 \leq d_{i,j}^H \leq 1$, where intuitively, $0$ would indicate $x_i$ are $y_j$ identical and $1$ would mean they are completely opposite in terms of their pairwise binary coordinates.
371+
372+
In comparison with the circuits for Hamming distance calculations proposed previously \cite{trugenberger2001}, our method allows one to reduce number of gates in the circuit (at least in $2n$ one-qubit NOT gates, depends on actual realization control phase gate in a quantum register on the hardware level), reconstruct all distance matrix at once and can be implemented with high fidelity on current quantum devices.
347373

348374
% Please , add comparison of complexities in number of gates for realization between our scheme and previously proposed schemes (one qubit and two qubit separately)
349375
% ??

0 commit comments

Comments
 (0)