Skip to content

Commit 454df68

Browse files
miamicoabbycross
andauthored
Fix repetition code bug (#3817)
Fix variable name in reptition code tutorial and re-run on heron device --------- Co-authored-by: ABBY CROSS <[email protected]>
1 parent 02f869a commit 454df68

File tree

5 files changed

+49
-30
lines changed

5 files changed

+49
-30
lines changed

docs/tutorials/repetition-codes.ipynb

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"source": [
1313
"# Repetition codes\n",
14-
"*Usage estimate: less than 1 minute on ibm_brisbane (NOTE: This is an estimate only. Your runtime might vary.)*\n",
14+
"*Usage estimate: less than 1 minute on a Heron device (NOTE: This is an estimate only. Your runtime might vary.)*\n",
1515
"\n",
1616
"## Background\n",
1717
"\n",
@@ -31,8 +31,8 @@
3131
"\n",
3232
"Before starting this tutorial, ensure that you have the following installed:\n",
3333
"\n",
34-
"- Qiskit SDK 1.0 or later with visualization support (`pip install qiskit[visualization]`)\n",
35-
"- Qiskit Runtime 0.22 or later (`pip install qiskit-ibm-runtime`)"
34+
"- Qiskit SDK v2.0 or later with visualization support (`pip install qiskit[visualization]`)\n",
35+
"- Qiskit Runtime v0.40 or later (`pip install qiskit-ibm-runtime`)"
3636
]
3737
},
3838
{
@@ -103,7 +103,7 @@
103103
},
104104
{
105105
"cell_type": "code",
106-
"execution_count": 25,
106+
"execution_count": 4,
107107
"id": "606dff18",
108108
"metadata": {},
109109
"outputs": [],
@@ -152,9 +152,9 @@
152152
" circuit.cx(qreg_data[2], qreg_measure[1])\n",
153153
" circuit.barrier(*qreg_data, *qreg_measure)\n",
154154
" circuit.measure(qreg_measure, creg_measure)\n",
155-
" with circuit.if_test((creg_syndrome[0], 1)):\n",
155+
" with circuit.if_test((creg_measure[0], 1)):\n",
156156
" circuit.x(qreg_measure[0])\n",
157-
" with circuit.if_test((creg_syndrome[1], 1)):\n",
157+
" with circuit.if_test((creg_measure[1], 1)):\n",
158158
" circuit.x(qreg_measure[1])\n",
159159
" circuit.barrier(*qreg_data, *qreg_measure)\n",
160160
" return circuit\n",
@@ -181,7 +181,7 @@
181181
},
182182
{
183183
"cell_type": "code",
184-
"execution_count": 26,
184+
"execution_count": 5,
185185
"id": "dbe02949",
186186
"metadata": {},
187187
"outputs": [
@@ -191,9 +191,18 @@
191191
"<Image src=\"/docs/images/tutorials/repetition-codes/extracted-outputs/dbe02949-0.avif\" alt=\"Output of the previous code cell\" />"
192192
]
193193
},
194-
"execution_count": 26,
194+
"execution_count": 5,
195195
"metadata": {},
196196
"output_type": "execute_result"
197+
},
198+
{
199+
"data": {
200+
"text/plain": [
201+
"<Image src=\"/docs/images/tutorials/repetition-codes/extracted-outputs/dbe02949-1.avif\" alt=\"Output of the previous code cell\" />"
202+
]
203+
},
204+
"metadata": {},
205+
"output_type": "display_data"
197206
}
198207
],
199208
"source": [
@@ -241,7 +250,7 @@
241250
},
242251
{
243252
"cell_type": "code",
244-
"execution_count": 27,
253+
"execution_count": 6,
245254
"id": "67b55eef",
246255
"metadata": {
247256
"slideshow": {
@@ -255,9 +264,18 @@
255264
"<Image src=\"/docs/images/tutorials/repetition-codes/extracted-outputs/67b55eef-0.avif\" alt=\"Output of the previous code cell\" />"
256265
]
257266
},
258-
"execution_count": 27,
267+
"execution_count": 6,
259268
"metadata": {},
260269
"output_type": "execute_result"
270+
},
271+
{
272+
"data": {
273+
"text/plain": [
274+
"<Image src=\"/docs/images/tutorials/repetition-codes/extracted-outputs/67b55eef-1.avif\" alt=\"Output of the previous code cell\" />"
275+
]
276+
},
277+
"metadata": {},
278+
"output_type": "display_data"
261279
}
262280
],
263281
"source": [
@@ -271,7 +289,7 @@
271289
},
272290
{
273291
"cell_type": "code",
274-
"execution_count": 28,
292+
"execution_count": 7,
275293
"id": "67acea4f",
276294
"metadata": {},
277295
"outputs": [],
@@ -301,7 +319,7 @@
301319
},
302320
{
303321
"cell_type": "code",
304-
"execution_count": 30,
322+
"execution_count": null,
305323
"id": "d53319ba",
306324
"metadata": {},
307325
"outputs": [],
@@ -315,7 +333,7 @@
315333
},
316334
{
317335
"cell_type": "code",
318-
"execution_count": 31,
336+
"execution_count": null,
319337
"id": "df7421d0",
320338
"metadata": {
321339
"slideshow": {
@@ -325,13 +343,14 @@
325343
"outputs": [],
326344
"source": [
327345
"sampler_with_correction = Sampler(backend)\n",
346+
"\n",
328347
"job_with_correction = sampler_with_correction.run([isa_circuit], shots=1000)\n",
329348
"result_with_correction = job_with_correction.result()[0]"
330349
]
331350
},
332351
{
333352
"cell_type": "code",
334-
"execution_count": 32,
353+
"execution_count": 10,
335354
"id": "1cba37f5",
336355
"metadata": {},
337356
"outputs": [
@@ -340,9 +359,9 @@
340359
"output_type": "stream",
341360
"text": [
342361
"Data (no correction):\n",
343-
"{'011': 39, '111': 829, '101': 80, '001': 6, '110': 24, '010': 11, '100': 3, '000': 8}\n",
362+
"{'111': 878, '011': 42, '110': 35, '101': 40, '100': 1, '001': 2, '000': 2}\n",
344363
"Syndrome (no correction):\n",
345-
"{'00': 729, '01': 213, '11': 18, '10': 40}\n"
364+
"{'00': 942, '10': 33, '01': 22, '11': 3}\n"
346365
]
347366
}
348367
],
@@ -355,7 +374,7 @@
355374
},
356375
{
357376
"cell_type": "code",
358-
"execution_count": 33,
377+
"execution_count": 11,
359378
"id": "7b7697f2",
360379
"metadata": {},
361380
"outputs": [
@@ -364,9 +383,9 @@
364383
"output_type": "stream",
365384
"text": [
366385
"Data (corrected):\n",
367-
"{'101': 37, '111': 895, '011': 43, '110': 13, '000': 8, '010': 3, '100': 1}\n",
386+
"{'111': 889, '110': 25, '000': 11, '011': 45, '101': 17, '010': 10, '001': 2, '100': 1}\n",
368387
"Syndrome (corrected):\n",
369-
"{'00': 897, '01': 69, '11': 6, '10': 28}\n"
388+
"{'00': 929, '01': 39, '10': 20, '11': 12}\n"
370389
]
371390
}
372391
],
@@ -389,7 +408,7 @@
389408
},
390409
{
391410
"cell_type": "code",
392-
"execution_count": 34,
411+
"execution_count": 12,
393412
"id": "fa59fb42",
394413
"metadata": {
395414
"slideshow": {
@@ -413,18 +432,18 @@
413432
},
414433
{
415434
"cell_type": "code",
416-
"execution_count": 35,
435+
"execution_count": 13,
417436
"id": "5b1ff3a3",
418437
"metadata": {},
419438
"outputs": [
420439
{
421440
"name": "stdout",
422441
"output_type": "stream",
423442
"text": [
424-
"Completed bit code experiment data measurement counts (no correction): {'011': 39, '111': 829, '101': 80, '001': 6, '110': 24, '010': 11, '100': 3, '000': 8}\n",
425-
"Completed bit code experiment syndrome measurement counts (no correction): {'00': 729, '01': 213, '11': 18, '10': 40}\n",
426-
"Bit flip errors were detected/corrected on 271/1000 trials.\n",
427-
"A final parity error was detected on 163/1000 trials.\n"
443+
"Completed bit code experiment data measurement counts (no correction): {'111': 878, '011': 42, '110': 35, '101': 40, '100': 1, '001': 2, '000': 2}\n",
444+
"Completed bit code experiment syndrome measurement counts (no correction): {'00': 942, '10': 33, '01': 22, '11': 3}\n",
445+
"Bit flip errors were detected/corrected on 58/1000 trials.\n",
446+
"A final parity error was detected on 120/1000 trials.\n"
428447
]
429448
}
430449
],
@@ -444,18 +463,18 @@
444463
},
445464
{
446465
"cell_type": "code",
447-
"execution_count": 36,
466+
"execution_count": 14,
448467
"id": "7f1c2d48",
449468
"metadata": {},
450469
"outputs": [
451470
{
452471
"name": "stdout",
453472
"output_type": "stream",
454473
"text": [
455-
"Completed bit code experiment data measurement counts (corrected): {'101': 37, '111': 895, '011': 43, '110': 13, '000': 8, '010': 3, '100': 1}\n",
456-
"Completed bit code experiment syndrome measurement counts (corrected): {'00': 897, '01': 69, '11': 6, '10': 28}\n",
457-
"Bit flip errors were detected/corrected on 103/1000 trials.\n",
458-
"A final parity error was detected on 97/1000 trials.\n"
474+
"Completed bit code experiment data measurement counts (corrected): {'111': 889, '110': 25, '000': 11, '011': 45, '101': 17, '010': 10, '001': 2, '100': 1}\n",
475+
"Completed bit code experiment syndrome measurement counts (corrected): {'00': 929, '01': 39, '10': 20, '11': 12}\n",
476+
"Bit flip errors were detected/corrected on 71/1000 trials.\n",
477+
"A final parity error was detected on 100/1000 trials.\n"
459478
]
460479
}
461480
],
-2.02 KB
Binary file not shown.
12.7 KB
Binary file not shown.
-89 Bytes
Binary file not shown.
9.48 KB
Binary file not shown.

0 commit comments

Comments
 (0)