|
88 | 88 | "cell_type": "markdown", |
89 | 89 | "metadata": {}, |
90 | 90 | "source": [ |
91 | | - "## Synthesizing the Algorithm" |
| 91 | + "## Synthesizing The Algorithm" |
92 | 92 | ] |
93 | 93 | }, |
94 | 94 | { |
|
115 | 115 | "metadata": {}, |
116 | 116 | "source": [ |
117 | 117 | "Then, pass `qmod` to the synthesis engine to obtain a concrete quantum program `qprog`.\\\n", |
118 | | - "Note: here we'll use a simple call to the function `synthesize`. Later on in this tutorial, you will learn to provide configuration details (for example, which elementary gates are allowed to use?) using [`set_preferences`](https://docs.classiq.io/latest/sdk-reference/synthesis/?h=set_pre#classiq.set_preferences)." |
| 118 | + "Here we will simply call to the function `synthesize`. Later on you will learn to provide configuration details (for example, which elementary gates are allowed to use?) using [`set_preferences`](https://docs.classiq.io/latest/sdk-reference/synthesis/?h=set_pre#classiq.set_preferences)." |
119 | 119 | ] |
120 | 120 | }, |
121 | 121 | { |
|
180 | 180 | "cell_type": "markdown", |
181 | 181 | "metadata": {}, |
182 | 182 | "source": [ |
183 | | - "By clicking the `+` icons on the blocks' top-left corner, you can inspect the gate-level implementation of each functional block (for example, inspecting the complex combination of `H`, `CPHASE`, `CX` and `U` gates that implements the `Power` block." |
| 183 | + "By clicking the `+` icons on the blocks' top-left corner, you can inspect the gate-level implementation of each functional block. For example, inspect the complex combination of `H`, `CPHASE`, `CX` and `U` gates that implements the `Power` block." |
| 184 | + ] |
| 185 | + }, |
| 186 | + { |
| 187 | + "cell_type": "markdown", |
| 188 | + "metadata": {}, |
| 189 | + "source": [ |
| 190 | + "## Executing The Quantum Program\n", |
| 191 | + "Now that we have a concrete circuit implementation of the desired algorithm, we can execute it and sample the resulting states of the output variables.\\\n", |
| 192 | + "Here we will simply call the function `execute`, which uses Classiq's default quantum simulator, and samples the variable with the default `n_shots`=2048 times:" |
| 193 | + ] |
| 194 | + }, |
| 195 | + { |
| 196 | + "cell_type": "code", |
| 197 | + "execution_count": 18, |
| 198 | + "metadata": {}, |
| 199 | + "outputs": [], |
| 200 | + "source": [ |
| 201 | + "job = execute(qprog)" |
| 202 | + ] |
| 203 | + }, |
| 204 | + { |
| 205 | + "cell_type": "markdown", |
| 206 | + "metadata": {}, |
| 207 | + "source": [ |
| 208 | + "Later on you will learn how to execute on hardwares and simulators of your choice and manage advanced executions (for example, hybrid execution that uses classical logic to alter the circuit between runs)." |
| 209 | + ] |
| 210 | + }, |
| 211 | + { |
| 212 | + "cell_type": "markdown", |
| 213 | + "metadata": {}, |
| 214 | + "source": [ |
| 215 | + "## Post-processing The Results" |
| 216 | + ] |
| 217 | + }, |
| 218 | + { |
| 219 | + "cell_type": "markdown", |
| 220 | + "metadata": {}, |
| 221 | + "source": [ |
| 222 | + "Having executed the quantum program multiple times (`nshots`=2048) we can now inspect the possible pairs `x`,`y` that our arithmetic expression allows ($y=x^2+1$).\\\n", |
| 223 | + "This can be done by looking into `parsed_counts` - a list of all the states that were measured on the output variables, ordered by the number of shots (counts) that they were measured." |
| 224 | + ] |
| 225 | + }, |
| 226 | + { |
| 227 | + "cell_type": "code", |
| 228 | + "execution_count": 25, |
| 229 | + "metadata": {}, |
| 230 | + "outputs": [ |
| 231 | + { |
| 232 | + "name": "stdout", |
| 233 | + "output_type": "stream", |
| 234 | + "text": [ |
| 235 | + "[{'x': 6, 'y': 37}: 280, {'x': 4, 'y': 17}: 273, {'x': 0, 'y': 1}: 267, {'x': 3, 'y': 10}: 260, {'x': 1, 'y': 2}: 258, {'x': 5, 'y': 26}: 248, {'x': 2, 'y': 5}: 238, {'x': 7, 'y': 50}: 224]\n" |
| 236 | + ] |
| 237 | + } |
| 238 | + ], |
| 239 | + "source": [ |
| 240 | + "pc = job.get_sample_result().parsed_counts\n", |
| 241 | + "print(pc)" |
| 242 | + ] |
| 243 | + }, |
| 244 | + { |
| 245 | + "cell_type": "markdown", |
| 246 | + "metadata": {}, |
| 247 | + "source": [ |
| 248 | + "***something about inspecting the hisogram" |
| 249 | + ] |
| 250 | + }, |
| 251 | + { |
| 252 | + "cell_type": "markdown", |
| 253 | + "metadata": {}, |
| 254 | + "source": [ |
| 255 | + "***note on the fact that it is not a useful quantum algo but a building block..." |
184 | 256 | ] |
185 | 257 | }, |
186 | 258 | { |
187 | 259 | "cell_type": "markdown", |
188 | 260 | "metadata": {}, |
189 | 261 | "source": [ |
190 | 262 | "## Practice\n", |
191 | | - "Edit the arithmetic expression inside `main`, using the `+`, `-`, `**` operators as well as literal numbers of your choice.\\\n", |
192 | | - "Do the sampled states of `x` and `y` satsify your arithmetic expression?\n" |
| 263 | + "Edit the arithmetic expression inside `main`, using the `+`, `-`, `**` operators as well as literal numbers of your choice. Validate that the sampled states of `x` and `y` satsify your arithmetic expression.\n" |
193 | 264 | ] |
194 | 265 | }, |
195 | 266 | { |
|
0 commit comments