|
11 | 11 | },
|
12 | 12 | "source": [
|
13 | 13 | "# 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", |
15 | 15 | "\n",
|
16 | 16 | "## Background\n",
|
17 | 17 | "\n",
|
|
31 | 31 | "\n",
|
32 | 32 | "Before starting this tutorial, ensure that you have the following installed:\n",
|
33 | 33 | "\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`)" |
36 | 36 | ]
|
37 | 37 | },
|
38 | 38 | {
|
|
103 | 103 | },
|
104 | 104 | {
|
105 | 105 | "cell_type": "code",
|
106 |
| - "execution_count": 25, |
| 106 | + "execution_count": 4, |
107 | 107 | "id": "606dff18",
|
108 | 108 | "metadata": {},
|
109 | 109 | "outputs": [],
|
|
152 | 152 | " circuit.cx(qreg_data[2], qreg_measure[1])\n",
|
153 | 153 | " circuit.barrier(*qreg_data, *qreg_measure)\n",
|
154 | 154 | " 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", |
156 | 156 | " 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", |
158 | 158 | " circuit.x(qreg_measure[1])\n",
|
159 | 159 | " circuit.barrier(*qreg_data, *qreg_measure)\n",
|
160 | 160 | " return circuit\n",
|
|
181 | 181 | },
|
182 | 182 | {
|
183 | 183 | "cell_type": "code",
|
184 |
| - "execution_count": 26, |
| 184 | + "execution_count": 5, |
185 | 185 | "id": "dbe02949",
|
186 | 186 | "metadata": {},
|
187 | 187 | "outputs": [
|
|
191 | 191 | "<Image src=\"/docs/images/tutorials/repetition-codes/extracted-outputs/dbe02949-0.avif\" alt=\"Output of the previous code cell\" />"
|
192 | 192 | ]
|
193 | 193 | },
|
194 |
| - "execution_count": 26, |
| 194 | + "execution_count": 5, |
195 | 195 | "metadata": {},
|
196 | 196 | "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" |
197 | 206 | }
|
198 | 207 | ],
|
199 | 208 | "source": [
|
|
241 | 250 | },
|
242 | 251 | {
|
243 | 252 | "cell_type": "code",
|
244 |
| - "execution_count": 27, |
| 253 | + "execution_count": 6, |
245 | 254 | "id": "67b55eef",
|
246 | 255 | "metadata": {
|
247 | 256 | "slideshow": {
|
|
255 | 264 | "<Image src=\"/docs/images/tutorials/repetition-codes/extracted-outputs/67b55eef-0.avif\" alt=\"Output of the previous code cell\" />"
|
256 | 265 | ]
|
257 | 266 | },
|
258 |
| - "execution_count": 27, |
| 267 | + "execution_count": 6, |
259 | 268 | "metadata": {},
|
260 | 269 | "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" |
261 | 279 | }
|
262 | 280 | ],
|
263 | 281 | "source": [
|
|
271 | 289 | },
|
272 | 290 | {
|
273 | 291 | "cell_type": "code",
|
274 |
| - "execution_count": 28, |
| 292 | + "execution_count": 7, |
275 | 293 | "id": "67acea4f",
|
276 | 294 | "metadata": {},
|
277 | 295 | "outputs": [],
|
|
301 | 319 | },
|
302 | 320 | {
|
303 | 321 | "cell_type": "code",
|
304 |
| - "execution_count": 30, |
| 322 | + "execution_count": null, |
305 | 323 | "id": "d53319ba",
|
306 | 324 | "metadata": {},
|
307 | 325 | "outputs": [],
|
|
315 | 333 | },
|
316 | 334 | {
|
317 | 335 | "cell_type": "code",
|
318 |
| - "execution_count": 31, |
| 336 | + "execution_count": null, |
319 | 337 | "id": "df7421d0",
|
320 | 338 | "metadata": {
|
321 | 339 | "slideshow": {
|
|
325 | 343 | "outputs": [],
|
326 | 344 | "source": [
|
327 | 345 | "sampler_with_correction = Sampler(backend)\n",
|
| 346 | + "\n", |
328 | 347 | "job_with_correction = sampler_with_correction.run([isa_circuit], shots=1000)\n",
|
329 | 348 | "result_with_correction = job_with_correction.result()[0]"
|
330 | 349 | ]
|
331 | 350 | },
|
332 | 351 | {
|
333 | 352 | "cell_type": "code",
|
334 |
| - "execution_count": 32, |
| 353 | + "execution_count": 10, |
335 | 354 | "id": "1cba37f5",
|
336 | 355 | "metadata": {},
|
337 | 356 | "outputs": [
|
|
340 | 359 | "output_type": "stream",
|
341 | 360 | "text": [
|
342 | 361 | "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", |
344 | 363 | "Syndrome (no correction):\n",
|
345 |
| - "{'00': 729, '01': 213, '11': 18, '10': 40}\n" |
| 364 | + "{'00': 942, '10': 33, '01': 22, '11': 3}\n" |
346 | 365 | ]
|
347 | 366 | }
|
348 | 367 | ],
|
|
355 | 374 | },
|
356 | 375 | {
|
357 | 376 | "cell_type": "code",
|
358 |
| - "execution_count": 33, |
| 377 | + "execution_count": 11, |
359 | 378 | "id": "7b7697f2",
|
360 | 379 | "metadata": {},
|
361 | 380 | "outputs": [
|
|
364 | 383 | "output_type": "stream",
|
365 | 384 | "text": [
|
366 | 385 | "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", |
368 | 387 | "Syndrome (corrected):\n",
|
369 |
| - "{'00': 897, '01': 69, '11': 6, '10': 28}\n" |
| 388 | + "{'00': 929, '01': 39, '10': 20, '11': 12}\n" |
370 | 389 | ]
|
371 | 390 | }
|
372 | 391 | ],
|
|
389 | 408 | },
|
390 | 409 | {
|
391 | 410 | "cell_type": "code",
|
392 |
| - "execution_count": 34, |
| 411 | + "execution_count": 12, |
393 | 412 | "id": "fa59fb42",
|
394 | 413 | "metadata": {
|
395 | 414 | "slideshow": {
|
|
413 | 432 | },
|
414 | 433 | {
|
415 | 434 | "cell_type": "code",
|
416 |
| - "execution_count": 35, |
| 435 | + "execution_count": 13, |
417 | 436 | "id": "5b1ff3a3",
|
418 | 437 | "metadata": {},
|
419 | 438 | "outputs": [
|
420 | 439 | {
|
421 | 440 | "name": "stdout",
|
422 | 441 | "output_type": "stream",
|
423 | 442 | "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" |
428 | 447 | ]
|
429 | 448 | }
|
430 | 449 | ],
|
|
444 | 463 | },
|
445 | 464 | {
|
446 | 465 | "cell_type": "code",
|
447 |
| - "execution_count": 36, |
| 466 | + "execution_count": 14, |
448 | 467 | "id": "7f1c2d48",
|
449 | 468 | "metadata": {},
|
450 | 469 | "outputs": [
|
451 | 470 | {
|
452 | 471 | "name": "stdout",
|
453 | 472 | "output_type": "stream",
|
454 | 473 | "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" |
459 | 478 | ]
|
460 | 479 | }
|
461 | 480 | ],
|
|
0 commit comments