|
2 | 2 | "cells": [ |
3 | 3 | { |
4 | 4 | "cell_type": "markdown", |
5 | | - "id": "4d6203af-01d0-4362-a44c-66c2128e63d1", |
| 5 | + "id": "943cf52c-41c8-4a2b-bf1d-6df8a90a6353", |
6 | 6 | "metadata": {}, |
7 | 7 | "source": [ |
8 | 8 | "# Classical feedforward and control flow" |
9 | 9 | ] |
10 | 10 | }, |
11 | 11 | { |
12 | 12 | "cell_type": "markdown", |
13 | | - "id": "e64d4278-879b-4319-9fbe-85a64327bcac", |
| 13 | + "id": "b1d96290-2e64-43aa-bae9-c74b8529894d", |
14 | 14 | "metadata": { |
15 | 15 | "tags": [ |
16 | 16 | "version-info" |
|
31 | 31 | }, |
32 | 32 | { |
33 | 33 | "cell_type": "markdown", |
34 | | - "id": "67b2704d-aa3d-4e39-b417-536093be274e", |
| 34 | + "id": "85a4d698-ee2a-4b3d-9331-1b91eea49338", |
35 | 35 | "metadata": {}, |
36 | 36 | "source": [ |
37 | 37 | "<Admonition type=\"note\" title=\"Dynamic circuits now available on all backends\">\n", |
38 | 38 | "The new version of dynamic circuits is now available to all users on all backends. You can now run dynamic circuits at utility scale. See [the announcement](/announcements/product-updates/2025-09-25-new-dynamic-circuits) for more details.\n", |
39 | 39 | "</Admonition>\n", |
40 | 40 | "\n", |
41 | | - "Dynamic circuits are powerful tools with which your can measure qubits in the middle of a quantum circuit execution and then perform classical logic operations within the circuit, based on the outcome of those mid-circuit measurements. This process is also known as _classical feedforward_. While these are early days of understanding how best to take advantage of dynamic circuits, the quantum research community has already identified a number of use cases, such as the following:\n", |
| 41 | + "Dynamic circuits are powerful tools with which you can measure qubits in the middle of a quantum circuit execution and then perform classical logic operations within the circuit, based on the outcome of those mid-circuit measurements. This process is also known as _classical feedforward_. While these are early days of understanding how best to take advantage of dynamic circuits, the quantum research community has already identified a number of use cases, such as the following:\n", |
42 | 42 | "\n", |
43 | 43 | "* Efficient quantum state preparation, such as [GHZ state,](https://journals.aps.org/prxquantum/abstract/10.1103/PRXQuantum.5.030339) [W-state,](https://arxiv.org/abs/2403.07604) (for more information about W-state, also refer to [\"State preparation by shallow circuits using feed forward\"](https://arxiv.org/abs/2307.14840)) and a broad class of [matrix product states](https://arxiv.org/abs/2404.16083)\n", |
44 | 44 | "* [Efficient long-range entanglement](https://journals.aps.org/prxquantum/abstract/10.1103/PRXQuantum.5.030339) between qubits on the same chip by using shallow circuits\n", |
|
51 | 51 | }, |
52 | 52 | { |
53 | 53 | "cell_type": "markdown", |
54 | | - "id": "0767b203-ad69-428f-b8c1-50ceab758b35", |
| 54 | + "id": "5d846edf-fc09-4808-bd62-3a8cfdcc1585", |
55 | 55 | "metadata": {}, |
56 | 56 | "source": [ |
57 | 57 | "## `if` statement\n", |
|
64 | 64 | { |
65 | 65 | "cell_type": "code", |
66 | 66 | "execution_count": 1, |
67 | | - "id": "008f85d9-5b48-4e84-b250-846b07901607", |
| 67 | + "id": "60924bfa-50ed-4d9d-a17b-9d64f2cc053f", |
68 | 68 | "metadata": {}, |
69 | 69 | "outputs": [ |
70 | 70 | { |
71 | 71 | "data": { |
72 | 72 | "text/plain": [ |
73 | | - "<Image src=\"/docs/images/guides/classical-feedforward-and-control-flow/extracted-outputs/008f85d9-5b48-4e84-b250-846b07901607-0.svg\" alt=\"Output of the previous code cell\" />" |
| 73 | + "<Image src=\"/docs/images/guides/classical-feedforward-and-control-flow/extracted-outputs/60924bfa-50ed-4d9d-a17b-9d64f2cc053f-0.avif\" alt=\"Output of the previous code cell\" />" |
74 | 74 | ] |
75 | 75 | }, |
76 | 76 | "execution_count": 1, |
|
99 | 99 | }, |
100 | 100 | { |
101 | 101 | "cell_type": "markdown", |
102 | | - "id": "fdc99e4d-fcd0-4397-b6da-2e36a51f90a8", |
| 102 | + "id": "bef3f447-7282-4de9-9410-6b671e9902c3", |
103 | 103 | "metadata": {}, |
104 | 104 | "source": [ |
105 | 105 | "The `with` statement can be given an assignment target which is itself a context manager that can be stored and subsequently used to create an else block, which is executed whenever the contents of the `if` block are *not* executed.\n", |
|
110 | 110 | { |
111 | 111 | "cell_type": "code", |
112 | 112 | "execution_count": 2, |
113 | | - "id": "5b22ae93-27d1-4a0c-89e2-9f88383039d6", |
| 113 | + "id": "20f0640a-a3f7-41b3-aada-b66bc89b0555", |
114 | 114 | "metadata": {}, |
115 | 115 | "outputs": [ |
116 | 116 | { |
117 | 117 | "data": { |
118 | 118 | "text/plain": [ |
119 | | - "<Image src=\"/docs/images/guides/classical-feedforward-and-control-flow/extracted-outputs/5b22ae93-27d1-4a0c-89e2-9f88383039d6-0.svg\" alt=\"Output of the previous code cell\" />" |
| 119 | + "<Image src=\"/docs/images/guides/classical-feedforward-and-control-flow/extracted-outputs/20f0640a-a3f7-41b3-aada-b66bc89b0555-0.avif\" alt=\"Output of the previous code cell\" />" |
120 | 120 | ] |
121 | 121 | }, |
122 | 122 | "execution_count": 2, |
|
146 | 146 | }, |
147 | 147 | { |
148 | 148 | "cell_type": "markdown", |
149 | | - "id": "d70a3dec-33fe-4a2f-942e-592770c4868e", |
| 149 | + "id": "f0f00f48-a1f2-40cc-b5f5-9a122d8dd24e", |
150 | 150 | "metadata": {}, |
151 | 151 | "source": [ |
152 | 152 | "In addition to conditioning on a single classical bit, it's also possible to condition on the value of a classical register composed of multiple bits.\n", |
|
157 | 157 | { |
158 | 158 | "cell_type": "code", |
159 | 159 | "execution_count": 3, |
160 | | - "id": "15ac9465-c61f-4de1-81e8-e4edfafb07b4", |
| 160 | + "id": "98e8f552-4169-42a3-8182-e14e9ffb59e2", |
161 | 161 | "metadata": {}, |
162 | 162 | "outputs": [ |
163 | 163 | { |
164 | 164 | "data": { |
165 | 165 | "text/plain": [ |
166 | | - "<Image src=\"/docs/images/guides/classical-feedforward-and-control-flow/extracted-outputs/15ac9465-c61f-4de1-81e8-e4edfafb07b4-0.svg\" alt=\"Output of the previous code cell\" />" |
| 166 | + "<Image src=\"/docs/images/guides/classical-feedforward-and-control-flow/extracted-outputs/98e8f552-4169-42a3-8182-e14e9ffb59e2-0.avif\" alt=\"Output of the previous code cell\" />" |
167 | 167 | ] |
168 | 168 | }, |
169 | 169 | "execution_count": 3, |
|
192 | 192 | }, |
193 | 193 | { |
194 | 194 | "cell_type": "markdown", |
195 | | - "id": "86219c0c-4b81-405d-8cb9-3fbe00353832", |
| 195 | + "id": "ef8fd422-6bab-46c9-9455-c79244cf1fb7", |
196 | 196 | "metadata": {}, |
197 | 197 | "source": [ |
198 | 198 | "## Classical expressions\n", |
|
208 | 208 | { |
209 | 209 | "cell_type": "code", |
210 | 210 | "execution_count": 4, |
211 | | - "id": "42454b75-8e80-4e22-9d3b-ec85746e0550", |
| 211 | + "id": "7581ac2f-53e9-43d0-bad0-2c80790172e1", |
212 | 212 | "metadata": {}, |
213 | 213 | "outputs": [], |
214 | 214 | "source": [ |
|
267 | 267 | { |
268 | 268 | "cell_type": "code", |
269 | 269 | "execution_count": 5, |
270 | | - "id": "3bdb923d-c466-4743-99b1-d46fda9660ef", |
| 270 | + "id": "d0f0abdb-50d5-408d-a704-a1a555acdd85", |
271 | 271 | "metadata": {}, |
272 | 272 | "outputs": [ |
273 | 273 | { |
274 | 274 | "data": { |
275 | 275 | "text/plain": [ |
276 | | - "<Image src=\"/docs/images/guides/classical-feedforward-and-control-flow/extracted-outputs/3bdb923d-c466-4743-99b1-d46fda9660ef-0.svg\" alt=\"Output of the previous code cell\" />" |
| 276 | + "<Image src=\"/docs/images/guides/classical-feedforward-and-control-flow/extracted-outputs/d0f0abdb-50d5-408d-a704-a1a555acdd85-0.avif\" alt=\"Output of the previous code cell\" />" |
277 | 277 | ] |
278 | 278 | }, |
279 | 279 | "execution_count": 5, |
|
287 | 287 | }, |
288 | 288 | { |
289 | 289 | "cell_type": "markdown", |
290 | | - "id": "f01b52c8-77d3-4052-bece-75ca998e7bb5", |
| 290 | + "id": "0152155a-2c6d-4f87-bf29-c306e9f1082c", |
291 | 291 | "metadata": {}, |
292 | 292 | "source": [ |
293 | 293 | "## Find backends that support dynamic circuits\n", |
|
301 | 301 | }, |
302 | 302 | { |
303 | 303 | "cell_type": "code", |
304 | | - "execution_count": null, |
305 | | - "id": "6b04b732-8143-4d76-bc43-a12ed0790bf6", |
| 304 | + "execution_count": 6, |
| 305 | + "id": "555e5491-de0e-49fe-b919-9ab51bed00ef", |
306 | 306 | "metadata": {}, |
307 | | - "outputs": [], |
| 307 | + "outputs": [ |
| 308 | + { |
| 309 | + "name": "stderr", |
| 310 | + "output_type": "stream", |
| 311 | + "text": [ |
| 312 | + "management.get:WARNING:2025-10-28 10:10:23,538: Loading default saved account\n", |
| 313 | + "qiskit_runtime_service.__init__:WARNING:2025-10-28 10:10:32,937: Instance was not set at service instantiation. Free and trial plan instances will be prioritized. Based on the following filters: (tags: None, region: us-east, eu-de), and available plans: (internal, premium), the available account instances are: Documentation premium fleet, Documentation internal fleet, Documentation premium fleet, Documentation internal fleet. If you need a specific instance set it explicitly either by using a saved account with a saved default instance or passing it in directly to QiskitRuntimeService().\n", |
| 314 | + "qiskit_runtime_service.backends:WARNING:2025-10-28 10:10:32,939: Loading instance: Documentation premium fleet, plan: premium\n", |
| 315 | + "qiskit_runtime_service.backends:WARNING:2025-10-28 10:10:34,963: Loading instance: Documentation internal fleet, plan: internal\n", |
| 316 | + "qiskit_runtime_service.backends:WARNING:2025-10-28 10:10:35,402: Loading instance: Documentation premium fleet, plan: premium\n", |
| 317 | + "qiskit_runtime_service.backends:WARNING:2025-10-28 10:10:37,875: Loading instance: Documentation internal fleet, plan: internal\n" |
| 318 | + ] |
| 319 | + }, |
| 320 | + { |
| 321 | + "name": "stdout", |
| 322 | + "output_type": "stream", |
| 323 | + "text": [ |
| 324 | + "[<IBMBackend('ibm_brussels')>, <IBMBackend('ibm_aachen')>, <IBMBackend('ibm_strasbourg')>, <IBMBackend('test_eagle_eu-de')>, <IBMBackend('ibm_fez')>, <IBMBackend('ibm_brisbane')>, <IBMBackend('ibm_pittsburgh')>, <IBMBackend('ibm_marrakesh')>, <IBMBackend('ibm_kingston')>, <IBMBackend('ibm_torino')>, <IBMBackend('ibmq_dublin')>, <IBMBackend('test_eagle_us-east')>, <IBMBackend('ibm_pinguino2')>, <IBMBackend('test_heron_pok_1')>, <IBMBackend('ibm_pinguino3')>, <IBMBackend('ibm_pinguino1')>]\n" |
| 325 | + ] |
| 326 | + } |
| 327 | + ], |
308 | 328 | "source": [ |
309 | 329 | "from qiskit_ibm_runtime import QiskitRuntimeService\n", |
310 | 330 | "\n", |
|
315 | 335 | }, |
316 | 336 | { |
317 | 337 | "cell_type": "markdown", |
318 | | - "id": "0378a45f-7a28-48bc-993d-0e4308d38bfc", |
| 338 | + "id": "6aca448f-2bc7-46ef-9832-01a14456d774", |
319 | 339 | "metadata": {}, |
320 | 340 | "source": [ |
321 | 341 | "## Qiskit Runtime limitations\n", |
|
397 | 417 | }, |
398 | 418 | { |
399 | 419 | "cell_type": "markdown", |
400 | | - "id": "6aa76130-acc1-4479-8a54-edab6a133e7c", |
| 420 | + "id": "7c80c5d0-a447-4590-8426-6eb33ae2d817", |
401 | 421 | "metadata": {}, |
402 | 422 | "source": [ |
403 | 423 | "## Next steps\n", |
|
431 | 451 | "title": "Classical feedforward and control flow (dynamic circuits)" |
432 | 452 | }, |
433 | 453 | "nbformat": 4, |
434 | | - "nbformat_minor": 2 |
| 454 | + "nbformat_minor": 4 |
435 | 455 | } |
0 commit comments