Skip to content

Commit add192c

Browse files
beckykdabbycrosskaelynj
authored
Document mid-circuit measurements (#4029)
closes #3983 closes #4027 preview: https://qiskit.github.io/documentation/pr-4029/docs/guides/measure-qubits --------- Co-authored-by: abbycross <across@us.ibm.com> Co-authored-by: Kaelyn Ferris <43348706+kaelynj@users.noreply.github.com>
1 parent 00575e9 commit add192c

11 files changed

+130
-47
lines changed

docs/guides/classical-feedforward-and-control-flow.ipynb

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "4d6203af-01d0-4362-a44c-66c2128e63d1",
5+
"id": "943cf52c-41c8-4a2b-bf1d-6df8a90a6353",
66
"metadata": {},
77
"source": [
88
"# Classical feedforward and control flow"
99
]
1010
},
1111
{
1212
"cell_type": "markdown",
13-
"id": "e64d4278-879b-4319-9fbe-85a64327bcac",
13+
"id": "b1d96290-2e64-43aa-bae9-c74b8529894d",
1414
"metadata": {
1515
"tags": [
1616
"version-info"
@@ -31,14 +31,14 @@
3131
},
3232
{
3333
"cell_type": "markdown",
34-
"id": "67b2704d-aa3d-4e39-b417-536093be274e",
34+
"id": "85a4d698-ee2a-4b3d-9331-1b91eea49338",
3535
"metadata": {},
3636
"source": [
3737
"<Admonition type=\"note\" title=\"Dynamic circuits now available on all backends\">\n",
3838
"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",
3939
"</Admonition>\n",
4040
"\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",
4242
"\n",
4343
"* 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",
4444
"* [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,7 +51,7 @@
5151
},
5252
{
5353
"cell_type": "markdown",
54-
"id": "0767b203-ad69-428f-b8c1-50ceab758b35",
54+
"id": "5d846edf-fc09-4808-bd62-3a8cfdcc1585",
5555
"metadata": {},
5656
"source": [
5757
"## `if` statement\n",
@@ -64,13 +64,13 @@
6464
{
6565
"cell_type": "code",
6666
"execution_count": 1,
67-
"id": "008f85d9-5b48-4e84-b250-846b07901607",
67+
"id": "60924bfa-50ed-4d9d-a17b-9d64f2cc053f",
6868
"metadata": {},
6969
"outputs": [
7070
{
7171
"data": {
7272
"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\" />"
7474
]
7575
},
7676
"execution_count": 1,
@@ -99,7 +99,7 @@
9999
},
100100
{
101101
"cell_type": "markdown",
102-
"id": "fdc99e4d-fcd0-4397-b6da-2e36a51f90a8",
102+
"id": "bef3f447-7282-4de9-9410-6b671e9902c3",
103103
"metadata": {},
104104
"source": [
105105
"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,13 +110,13 @@
110110
{
111111
"cell_type": "code",
112112
"execution_count": 2,
113-
"id": "5b22ae93-27d1-4a0c-89e2-9f88383039d6",
113+
"id": "20f0640a-a3f7-41b3-aada-b66bc89b0555",
114114
"metadata": {},
115115
"outputs": [
116116
{
117117
"data": {
118118
"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\" />"
120120
]
121121
},
122122
"execution_count": 2,
@@ -146,7 +146,7 @@
146146
},
147147
{
148148
"cell_type": "markdown",
149-
"id": "d70a3dec-33fe-4a2f-942e-592770c4868e",
149+
"id": "f0f00f48-a1f2-40cc-b5f5-9a122d8dd24e",
150150
"metadata": {},
151151
"source": [
152152
"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,13 +157,13 @@
157157
{
158158
"cell_type": "code",
159159
"execution_count": 3,
160-
"id": "15ac9465-c61f-4de1-81e8-e4edfafb07b4",
160+
"id": "98e8f552-4169-42a3-8182-e14e9ffb59e2",
161161
"metadata": {},
162162
"outputs": [
163163
{
164164
"data": {
165165
"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\" />"
167167
]
168168
},
169169
"execution_count": 3,
@@ -192,7 +192,7 @@
192192
},
193193
{
194194
"cell_type": "markdown",
195-
"id": "86219c0c-4b81-405d-8cb9-3fbe00353832",
195+
"id": "ef8fd422-6bab-46c9-9455-c79244cf1fb7",
196196
"metadata": {},
197197
"source": [
198198
"## Classical expressions\n",
@@ -208,7 +208,7 @@
208208
{
209209
"cell_type": "code",
210210
"execution_count": 4,
211-
"id": "42454b75-8e80-4e22-9d3b-ec85746e0550",
211+
"id": "7581ac2f-53e9-43d0-bad0-2c80790172e1",
212212
"metadata": {},
213213
"outputs": [],
214214
"source": [
@@ -267,13 +267,13 @@
267267
{
268268
"cell_type": "code",
269269
"execution_count": 5,
270-
"id": "3bdb923d-c466-4743-99b1-d46fda9660ef",
270+
"id": "d0f0abdb-50d5-408d-a704-a1a555acdd85",
271271
"metadata": {},
272272
"outputs": [
273273
{
274274
"data": {
275275
"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\" />"
277277
]
278278
},
279279
"execution_count": 5,
@@ -287,7 +287,7 @@
287287
},
288288
{
289289
"cell_type": "markdown",
290-
"id": "f01b52c8-77d3-4052-bece-75ca998e7bb5",
290+
"id": "0152155a-2c6d-4f87-bf29-c306e9f1082c",
291291
"metadata": {},
292292
"source": [
293293
"## Find backends that support dynamic circuits\n",
@@ -301,10 +301,30 @@
301301
},
302302
{
303303
"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",
306306
"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+
],
308328
"source": [
309329
"from qiskit_ibm_runtime import QiskitRuntimeService\n",
310330
"\n",
@@ -315,7 +335,7 @@
315335
},
316336
{
317337
"cell_type": "markdown",
318-
"id": "0378a45f-7a28-48bc-993d-0e4308d38bfc",
338+
"id": "6aca448f-2bc7-46ef-9832-01a14456d774",
319339
"metadata": {},
320340
"source": [
321341
"## Qiskit Runtime limitations\n",
@@ -397,7 +417,7 @@
397417
},
398418
{
399419
"cell_type": "markdown",
400-
"id": "6aa76130-acc1-4479-8a54-edab6a133e7c",
420+
"id": "7c80c5d0-a447-4590-8426-6eb33ae2d817",
401421
"metadata": {},
402422
"source": [
403423
"## Next steps\n",
@@ -431,5 +451,5 @@
431451
"title": "Classical feedforward and control flow (dynamic circuits)"
432452
},
433453
"nbformat": 4,
434-
"nbformat_minor": 2
454+
"nbformat_minor": 4
435455
}

0 commit comments

Comments
 (0)