|
5 | 5 | "id": "03995d6e-9a58-4c26-9b9a-a789cb90dd90", |
6 | 6 | "metadata": {}, |
7 | 7 | "source": [ |
8 | | - "# Using QSVT for fixed-point amplitude amplification" |
| 8 | + "# Using QSVT for Fixed-point Amplitude Amplification" |
9 | 9 | ] |
10 | 10 | }, |
11 | 11 | { |
12 | 12 | "cell_type": "markdown", |
13 | 13 | "id": "fdf4c557-fbf3-43ad-a840-4d25a038931e", |
14 | 14 | "metadata": {}, |
15 | 15 | "source": [ |
16 | | - "This demo will show how to use the QSVT framework for search problems. Specifically, we will implement fixed-point amplitude amplification (FPAA). In FPAA, we do not know in advance the concentration of solutions to the search problem, want to sample a solution with high probability. In contrast, for the original grover search algorithm, too much iterations might 'overshoot'.\n", |
| 16 | + "This demo shows how to use the QSVT framework for search problems; specifically, implementing fixed-point amplitude amplification (FPAA). With FPAA, we do not know in advance the concentration of solutions for the search problem, but we want to sample a solution with high probability. In contrast, for the original Grover search algorithm, too many iterations might 'overshoot' the mark.\n", |
17 | 17 | "\n", |
18 | 18 | "The demo is based on the paper [Grand unification of quantum algorithms](#grand).\n", |
19 | 19 | "\n", |
20 | | - "Given $|s\\rangle$ the initial state and $|t\\rangle$ the 'good' states, we get an effective block encoding of a 1-dimensional matrix $A=|t\\rangle\\langle s|$.\n", |
| 20 | + "Given $|s\\rangle$ the initial state and $|t\\rangle$ the 'good' states, we get an effective block encoding of a one-dimensional matrix $A=|t\\rangle\\langle s|$.\n", |
21 | 21 | "\n", |
22 | | - "Given that $a = \\langle s|t\\rangle\\gt0$, we want to amplify $a$. The signal operator $U$ here will be $I$ (and also $\\dagger{U}$). Now we implement 2 projector-rotations - one in '$|s\\rangle$' space and one in '$|t\\rangle$' space, each one around the given state, giving phase to the specific state." |
| 22 | + "Given that $a = \\langle s|t\\rangle\\gt0$, we want to amplify $a$. The signal operator $U$ here is $I$ (and also $\\dagger{U}$). Now we implement two projector-rotations: one in the '$|s\\rangle$' space and one in the '$|t\\rangle$' space; each one around the given state, giving phase to the specific state." |
23 | 23 | ] |
24 | 24 | }, |
25 | 25 | { |
|
29 | 29 | "tags": [] |
30 | 30 | }, |
31 | 31 | "source": [ |
32 | | - "### Defining the QSVT circuit for the problem" |
| 32 | + "## Defining the QSVT Circuit for the Problem" |
33 | 33 | ] |
34 | 34 | }, |
35 | 35 | { |
36 | 36 | "cell_type": "markdown", |
37 | 37 | "id": "e456f39b-39a5-4232-9bbf-fbc6224dfad7", |
38 | 38 | "metadata": {}, |
39 | 39 | "source": [ |
40 | | - "We start with the general qsvt framework definition. It accepts a unitary which block-encode a matrix together with projector-controlled-phase functions which rotate the state around each of the subspaces where the matrix is encoded.\n", |
| 40 | + "We start with the general QSVT framework definition. It accepts a unitary that block-encodes a matrix together with projector-controlled phase functions, which rotate the state around each of the subspaces where the matrix is encoded.\n", |
41 | 41 | "\n", |
42 | | - "It applies the `qsvt_step` multiple times, iterating over the rotation angles provided which encode the polynomial transformation.\n", |
43 | | - "Notice - The last step is quite tricky and depend on the specific transformation we wish to perform. Here the code is suitable for the FP Amplitude Amplification case. Also - we wrap the auxilliary qubit with $H$ gates." |
| 42 | + "It applies the `qsvt_step` multiple times, iterating over the rotation angles provided that encode the polynomial transformation.\n", |
| 43 | + "\n", |
| 44 | + "Note that the last step is quite tricky and depends on the specific transformation to perform. The code here is suitable for the FP Amplitude Amplification case. In addition, we wrap the auxilliary qubit with $H$ gates." |
44 | 45 | ] |
45 | 46 | }, |
46 | 47 | { |
|
116 | 117 | "id": "ba2ae29c-e041-45a3-abf2-be7da1814650", |
117 | 118 | "metadata": {}, |
118 | 119 | "source": [ |
119 | | - "## Initial state z-rotation - rotation around $|s\\rangle$" |
| 120 | + "## Initial State z-rotation: Rotation Around $|s\\rangle$" |
120 | 121 | ] |
121 | 122 | }, |
122 | 123 | { |
|
141 | 142 | "id": "f93e8ef7-cc2f-423b-9bbe-8365c7d0b3ba", |
142 | 143 | "metadata": {}, |
143 | 144 | "source": [ |
144 | | - "## Good states z-rotation - rotation around $|t\\rangle$" |
| 145 | + "## Good States z-rotation: Rotation Around $|t\\rangle$" |
145 | 146 | ] |
146 | 147 | }, |
147 | 148 | { |
|
167 | 168 | "id": "40488ffb-ebd4-49b4-aa24-7ae212150202", |
168 | 169 | "metadata": {}, |
169 | 170 | "source": [ |
170 | | - "## Defining the arithmetic Oracle" |
| 171 | + "## Defining the Arithmetic Oracle" |
171 | 172 | ] |
172 | 173 | }, |
173 | 174 | { |
174 | 175 | "cell_type": "markdown", |
175 | 176 | "id": "850f4d03-5e30-47d7-a6f9-a39414f26baf", |
176 | 177 | "metadata": {}, |
177 | 178 | "source": [ |
178 | | - "Implement the following equation: \n", |
| 179 | + "We implement the following equation: \n", |
179 | 180 | "`(a + b) == 3 and (c - a) == 2`\n", |
180 | | - "with `a, b, c` in sizes 2, 1, 3." |
| 181 | + "with `a, b, c` in sizes 2, 1, 3:" |
181 | 182 | ] |
182 | 183 | }, |
183 | 184 | { |
|
208 | 209 | "id": "d727b48b-672d-4734-8b98-348943ce4fb6", |
209 | 210 | "metadata": {}, |
210 | 211 | "source": [ |
211 | | - "## Wrapping everything together for the FPAA case" |
| 212 | + "## Wrapping Everything for the FPAA Case" |
212 | 213 | ] |
213 | 214 | }, |
214 | 215 | { |
215 | 216 | "cell_type": "markdown", |
216 | 217 | "id": "90e79829-8e88-448e-824b-f1bc72470d81", |
217 | 218 | "metadata": {}, |
218 | 219 | "source": [ |
219 | | - "In the FPAA case, the provided unitary is just the Identity matrix! In addition, we provide both projector-controlled phase functions - the initial and target state rotations." |
| 220 | + "In the FPAA case, the provided unitary is just the Identity matrix! In addition, we provide both projector-controlled phase functions for the initial and target state rotations:" |
220 | 221 | ] |
221 | 222 | }, |
222 | 223 | { |
|
250 | 251 | "id": "640e9b8d-90eb-4caa-83d4-6f87be59a15f", |
251 | 252 | "metadata": {}, |
252 | 253 | "source": [ |
253 | | - "## get the phase sequence for the sign function" |
| 254 | + "## Getting the Phase Sequence for the Sign Function" |
254 | 255 | ] |
255 | 256 | }, |
256 | 257 | { |
|
260 | 261 | "tags": [] |
261 | 262 | }, |
262 | 263 | "source": [ |
263 | | - "Now we will use the package `pyqsp` in order to get the phases of the rotation sequence.\n", |
264 | | - "Get directly the coef of the sign function, based on the erfc approximation." |
| 264 | + "We use the `pyqsp` package to receive the phases of the rotation sequence and get the coefficient of the sign function directly, based on the ERFC approximation:" |
265 | 265 | ] |
266 | 266 | }, |
267 | 267 | { |
|
332 | 332 | "id": "4835e5a8-5e24-44bf-a3ee-087675d6a60a", |
333 | 333 | "metadata": {}, |
334 | 334 | "source": [ |
335 | | - "As $R(a)=-i*e^{i\\frac{\\pi}{4}Z}W(a)e^{i\\frac{\\pi}{4}Z}$ and we have odd number of rotations, we get an $i$ phase to our polynomial, so we get $Im(P(a))$ instead of the real part. So we will get the result in the $|1\\rangle$ state in the ancilla. However, we can fix it by adding $\\pi/2$ phase to the last or first rotation." |
| 335 | + "As $R(a)=-i*e^{i\\frac{\\pi}{4}Z}W(a)e^{i\\frac{\\pi}{4}Z}$ and we have an odd number of rotations, we get an $i$ phase for our polynomial, so we get $Im(P(a))$ instead of the real part. So we get the result in the $|1\\rangle$ state in the ancilla. However, we can fix it by adding an $\\pi/2$ phase to the last or first rotation." |
336 | 336 | ] |
337 | 337 | }, |
338 | 338 | { |
|
360 | 360 | "id": "2bee148a-9f0b-415f-a64a-173e2b23ceda", |
361 | 361 | "metadata": {}, |
362 | 362 | "source": [ |
363 | | - "## Create the full QSVT Model" |
| 363 | + "## Creating the Full QSVT Model" |
364 | 364 | ] |
365 | 365 | }, |
366 | 366 | { |
|
390 | 390 | "id": "6493595c-d92d-4470-865c-367b1ba0e662", |
391 | 391 | "metadata": {}, |
392 | 392 | "source": [ |
393 | | - "## Synthesis and execution on a simulator" |
| 393 | + "## Synthesizing and Executing on a Simulator" |
394 | 394 | ] |
395 | 395 | }, |
396 | 396 | { |
397 | 397 | "cell_type": "markdown", |
398 | 398 | "id": "e1de3b81-2152-4ecf-9cd4-97be748561f9", |
399 | 399 | "metadata": {}, |
400 | 400 | "source": [ |
401 | | - "We will use Classiq's synthesis engine to translate the model to a quantum circuit, and execute on Classiq's simulator" |
| 401 | + "We use the Classiq synthesis engine to translate the model to a quantum circuit, and execute on the Classiq simulator:" |
402 | 402 | ] |
403 | 403 | }, |
404 | 404 | { |
|
520 | 520 | "source": [ |
521 | 521 | "What do we expect?\n", |
522 | 522 | "\n", |
523 | | - "We need to subtitue the amplitude of $|s\\rangle\\langle t|$ in $P(x)$:" |
| 523 | + "We need to substitute the amplitude of $|s\\rangle\\langle t|$ in $P(x)$:" |
524 | 524 | ] |
525 | 525 | }, |
526 | 526 | { |
|
549 | 549 | "id": "0af1b8bf-2e53-4c4b-bb31-27b7463bc245", |
550 | 550 | "metadata": {}, |
551 | 551 | "source": [ |
552 | | - "Indeed, we got the expected result according to the polynomial we created with the QSVT sequence." |
| 552 | + "Indeed, we received the expected result according to the polynomial we created with the QSVT sequence:" |
553 | 553 | ] |
554 | 554 | }, |
555 | 555 | { |
|
0 commit comments