Skip to content

Commit

Permalink
Discrete Quantum Walks suggested English changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnePicus authored and TaliCohn committed Jan 19, 2025
1 parent c4f2e77 commit 04b51af
Showing 1 changed file with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
"source": [
"\"Quantum Walk\" is an approach for developing and designing quantum algorithms. Consider it as a quantum analogy to the classical random walk. This generic technique underlies many quantum algorithms. In particular, the Grover's search algorithm can be viewed as a quantum walk.\n",
"\n",
"Similarly to classical random walks, quantum walks are divided into the discrete case and the continuous one. This notebook focuses on discrete quantum walks, and is organized as follows: first, [one to one](##Classical-Random-Walks-vs.-Quantum-Walks) compares classical random walks with quantum walks via a specific example: a walk on a circle. Then, a [general quantum model](##How-to-Build-a-general-Quantum-Walk-with-Classiq) studies quantum walks and subsequently applies it to the [circle case](##Example:-Symmetric-Quantum-Walk-on-a-Circle) and to a [hypercube graph](##Example:-4D-Hypercube-with-a-Grover-Coin). "
"Similarly to classical random walks, quantum walks are divided into the discrete and continuous cases. This notebook focuses on discrete quantum walks, and is organized as follows: \n",
"\n",
"1. [One to one](##Classical-Random-Walks-vs.-Quantum-Walks) compares classical random walks with quantum walks via a specific example: a walk on a circle.\n",
"2. A [general quantum model](##How-to-Build-a-general-Quantum-Walk-with-Classiq) studies quantum walks and subsequently applies it to the [circle case](##Example:-Symmetric-Quantum-Walk-on-a-Circle) and to a [hypercube graph](##Example:-4D-Hypercube-with-a-Grover-Coin). "
]
},
{
Expand All @@ -24,6 +27,7 @@
"metadata": {},
"source": [
"This tutorial demonstrates the following concepts of Classiq:\n",
"\n",
"* The resemblance between classical and quantum programming with Classiq.\n",
"* Classiq's built-in constructs:\n",
" * `control`: general controlled-logic\n",
Expand Down Expand Up @@ -51,6 +55,7 @@
"metadata": {},
"source": [
"Specify and implement a simple example: a discrete walk on a circle, or more precisely, on a regular polygon with $2^N$ nodes (see Figure 1). The idea behind the random/quantum walk:\n",
"\n",
"1. Start at some initial point, e.g., the zeroth node.\n",
"2. Flip a coin. Heads moves one step clockwise; tails moves counterclockwise.\n",
"3. Repeat steps 1-2 for a given total number of steps $T$."
Expand Down Expand Up @@ -101,6 +106,7 @@
"metadata": {},
"source": [
"Define a function to flip a coin:\n",
"\n",
"* Classical: the coin is either 0 or 1. To flip the coin, draw a random number from the set $\\{0,1\\}$.\n",
"* Quantum: the coin is represented by a qubit and a \"flip\" is defined by some unitary operation on it. Choose the Hadamard gate, which sends the $|0\\rangle$ state into an equal superposition of $|0\\rangle$ and $|1\\rangle$."
]
Expand Down Expand Up @@ -133,7 +139,8 @@
"id": "d10a317a-0267-4b51-b230-3d3cd393d3fd",
"metadata": {},
"source": [
"Next, define a function for moving clockwise and counterclockwise. This operation is a modular addition by $\\pm 1$.\n",
"Next, define a function for moving clockwise and counterclockwise. This operation is a modular addition by $\\pm 1$:\n",
"\n",
"* Classical: the position is an integer in $[-2^{N-1}, 2^{N-1}-1]$. Use basic arithmetic operations.\n",
"* Quantum: the position is an $N$-qubits state. Build an in-place modular addition by 1 (see an explanation at [the end of this notebook](#Technical-Notes)). Note that since quantum operations are reversible, you can define a counterclockwise step as the inverse of the clockwise step."
]
Expand Down Expand Up @@ -237,7 +244,7 @@
"id": "ea9266b8-60a0-4f93-bc6b-942cd6d85cb7",
"metadata": {},
"source": [
"Define and run a specific example, taking a circle of size $2^7$, a total time of 50 steps, and 10000 samples. "
"Define and run a specific example, taking a circle of size $2^7$, a total time of 50 steps, and 10,000 samples. "
]
},
{
Expand Down Expand Up @@ -323,7 +330,7 @@
"source": [
"<center>\n",
"<img src=\"https://docs.classiq.io/resources/quantum_walk_circle_circuit.png\" style=\"width:100%\">\n",
"<figcaption align = \"middle\"> Figure 2. The circuit for a quantum walk on a circle with $2^7$ nodes. The last three blocks are repeated `t` times. </figcaption>\n",
"<figcaption align = \"middle\"> Figure 2. The circuit for a quantum walk on a circle with $2^7$ nodes. The last three blocks repeat `t` times. </figcaption>\n",
"</center>"
]
},
Expand Down Expand Up @@ -399,15 +406,15 @@
"id": "922b31e2-d1c4-4d7d-afd1-c633b5981441",
"metadata": {},
"source": [
"There is a clear difference between the two distributions. The classical distribution is symmetric around the zero position, whereas the quantum example is asymmetric with a peak far from 0. This is a small example of the different behaviors of classical random walks and quantum walks. More details and examples are in Ref. [[1](#review)]."
"There is a clear difference between the two distributions: the classical distribution is symmetric around the zero position, whereas the quantum example is asymmetric with a peak far from 0. This is a small example of the different behaviors of classical random walks and quantum walks. More details and examples are in Ref. [[1](#review)]."
]
},
{
"cell_type": "markdown",
"id": "d0115edd-4b37-4482-8a30-c80bc0e50bac",
"metadata": {},
"source": [
"## How to Build a General Quantum Walk with Classiq"
"## Building a General Quantum Walk with Classiq"
]
},
{
Expand All @@ -416,6 +423,7 @@
"metadata": {},
"source": [
"Define a quantum function for a discrete quantum walk. The arguments of the function:\n",
"\n",
"* `time`: an integer for the number of walking steps.\n",
"* `coin_flip_qfunc`: the quantum function for \"flipping\" the coin.\n",
"* `walks_qfuncs`: a list of quantum functions for all possible transitions at a given point.\n",
Expand Down Expand Up @@ -633,7 +641,7 @@
"id": "7dc4fde2-43ee-4249-84ee-909c3b694ce0",
"metadata": {},
"source": [
"Define a model for quantum walk on a hypercube. Two nodes in the hypercube are connected to each other if their Hamming distance is 1. Thus, a step along a hypercube is given by moving \"1 Hamming distance away\". For a $d$-dimentional hypercube, at each node there are $d$ possible directions to move. Each of them is given by applying a bit flip on one of the bits. In the quantum case, this is obtained by applying an X gate on one of the $N$ qubits.\n",
"Define a model for quantum walk on a hypercube. Two nodes in the hypercube are connected to each other if their Hamming distance is 1. Thus, a step along a hypercube is given by moving \"1 Hamming distance away\". For a $d$-dimensional hypercube, at each node there are $d$ possible directions to move. Each of them is given by applying a bit flip on one of the bits. In the quantum case, this is obtained by applying an X gate on one of the $N$ qubits.\n",
"\n",
"For the coin operator, take the \"Grover diffuser\" function. This choice refers to a symmetric quantum walk [[1](#review)]. The Grover diffuser operator is a reflection around a given state $|\\psi\\rangle$:\n",
"$$\n",
Expand Down Expand Up @@ -767,7 +775,7 @@
"source": [
"<center>\n",
"<img src=\"https://docs.classiq.io/resources/quantum_walk_hypercube_circuit.png\" style=\"width:100%\">\n",
"<figcaption align = \"middle\"> Figure 4. The circuit for a quantum walk on a 4D cube with a Grover coin. The last two blocks are repeated `t` times. </figcaption>\n",
"<figcaption align = \"middle\"> Figure 4. The circuit for a quantum walk on a 4D cube with a Grover coin. The last two blocks repeat `t` times. </figcaption>\n",
"</center>"
]
},
Expand Down Expand Up @@ -821,7 +829,7 @@
"id": "3cca3d17-4ec3-4cba-b770-13b38e58faa4",
"metadata": {},
"source": [
"We found that at $T=4$ the probability to measure the walker at the opposite corner is larger than $1/2$. We can check an analogous question in the classical random walk, where the distribution is taken over an ensemble of independent experiments):"
"At $T=4$, the probability to measure the walker at the opposite corner is larger than $1/2$. Check an analogous question in the classical random walk, where the distribution is taken over an ensemble of independent experiments:"
]
},
{
Expand Down Expand Up @@ -876,11 +884,9 @@
"id": "916c1dd1-3f08-417e-a7f7-adbaa33b60d4",
"metadata": {},
"source": [
"## Technical Notes\n",
"\n",
"### QFT modular adder\n",
"## Note Regarding QFT Modular Adder\n",
"\n",
"Below we explain the `quantum_step_clockwise` function defined for the quantum walk on a circle. The unitary matrix that represents walking on a circle operates as follows:\n",
"This section explains the `quantum_step_clockwise` function defined for the quantum walk on a circle. The unitary matrix that represents walking on a circle operates as follows:\n",
"$$\n",
"U_{+}|i\\rangle =\n",
"\\left\\{\n",
Expand All @@ -902,7 +908,7 @@
"\t 1 & 0 & 0 & \\cdots & 0 & 0\n",
"\\end{pmatrix}.\n",
"$$\n",
"In Fourier space this matrix is diagonal, namely, the Fourier matrix $\\mathcal{FT} $ diagonalizes it. Moreover, the diagonal entries forms a goemetric series:\n",
"In Fourier space, this matrix is diagonal; namely, the Fourier matrix $\\mathcal{FT} $ diagonalizes it. Moreover, the diagonal entries forms a goemetric series:\n",
"$$\n",
"U_+ = \\mathcal{FT} \\cdot \\begin{pmatrix}\n",
"\t\\alpha^0 & 0 & \\cdots& \\cdots & 0 \\\\\n",
Expand All @@ -912,15 +918,15 @@
"\t 0 & \\cdots & 0 & \\cdots & \\alpha^{2^N-1}\n",
"\\end{pmatrix} \\cdot \\mathcal{FT}^{\\dagger},\n",
"$$\n",
"with $\\alpha=e^{2\\pi i /2^N }$. We can implement both the $\\mathcal{FT}$ matrix and the diagonal matrix efficiently on a quantum computer, the former by a QFT and the latter by applying a series of $N$ RZ rotations."
"with $\\alpha=e^{2\\pi i /2^N }$. You can implement both the $\\mathcal{FT}$ matrix and the diagonal matrix efficiently on a quantum computer; the former by a QFT and the latter by applying a series of $N$ RZ rotations."
]
},
{
"cell_type": "markdown",
"id": "88b24611-5d16-4fa0-a014-d192459198d3",
"metadata": {},
"source": [
"<a id='review'>[1]</a>: [Kempe, J. \"Quantum random walks: an introductory overview.\" Contemporary Physics 44, 307 (2003)](https://arxiv.org/abs/quant-ph/0303081).\n",
"<a id='review'>[1]</a>: [Kempe, J. \"Quantum random walks: An introductory overview.\" Contemporary Physics 44, 307 (2003)](https://arxiv.org/abs/quant-ph/0303081).\n",
"\n",
"<a id='hypercube'>[2]</a>: [Kempe, J. \"Discrete quantum walks hit exponentially faster.\" Probability theory and related fields 133, 215 (2005)](https://arxiv.org/abs/quant-ph/0205083)."
]
Expand Down

0 comments on commit 04b51af

Please sign in to comment.