713 lines
92 KiB
Plaintext
713 lines
92 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "552b1077",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Hello world"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "7cc19a86-a234-4220-bb4f-d66d3834e0c3",
|
|
"metadata": {
|
|
"tags": [
|
|
"version-info"
|
|
]
|
|
},
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "1a3c196d-545d-417f-b34e-fa422aa9a394",
|
|
"metadata": {},
|
|
"source": [
|
|
"This example contains two parts. You will first create a simple quantum program and run it on a quantum processing unit (QPU). Because actual quantum research requires much more robust programs, in the second section ([Scale to large numbers of qubits](#scale-to-large-numbers-of-qubits)), you will scale the simple program up to utility level. You can also follow along with the Hello World episode of the Coding with Qiskit 1.0 video series.\n",
|
|
"\n",
|
|
"<ImageLink\n",
|
|
" title=\"Coding with Qiskit 1.x, Episode 3: Hello world\"\n",
|
|
" alt=\"Video thumbnail: Dr. Derek Wang stands against a pink background.\"\n",
|
|
" href=\"https://youtu.be/93-zLTppFZw\"\n",
|
|
" src=\"/images/guides/hello-world/youtube-thumbnail.png\"\n",
|
|
"/>\n",
|
|
"\n",
|
|
"<Admonition title=\"Note\" type=\"note\">\n",
|
|
" This video uses the `QiskitRuntimeService.get_backend` method, which has since been deprecated. Use [`QiskitRuntimeService.backend`](https://docs.quantum.ibm.com/api/qiskit-ibm-runtime/qiskit_ibm_runtime.QiskitRuntimeService#backend) instead.\n",
|
|
"</Admonition>"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "7b65f7e0",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Before you begin\n",
|
|
"\n",
|
|
"Follow the [Install and set up](./install-qiskit) instructions if you haven't already, including the steps to [Set up to use IBM Quantum™ Platform](setup-channel#set-up-to-use-ibm-quantum-platform).\n",
|
|
"\n",
|
|
"It is recommended that you use the [Jupyter](https://jupyter.org/install) development environment to interact with quantum computers. Be sure to install the recommended extra visualization support (`'qiskit[visualization]'`). You'll also need the `matplotlib` package for the second part of this example.\n",
|
|
"\n",
|
|
"To learn about quantum computing in general, visit the [Basics of quantum information course](https://learning.quantum.ibm.com/course/basics-of-quantum-information) in IBM Quantum Learning.\n",
|
|
"\n",
|
|
"IBM® is committed to the responsible development of quantum computing. Learn more about responsible quantum at IBM and review our responsible quantum principles in the [Responsible quantum computing and inclusive tech](/responsible-quantum-computing) topic."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "80471a0a",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Create and run a simple quantum program"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "85fe979e",
|
|
"metadata": {
|
|
"raw_mimetype": "text/restructuredtext"
|
|
},
|
|
"source": [
|
|
"The four steps to writing a quantum program using Qiskit patterns are:\n",
|
|
"\n",
|
|
"1. Map the problem to a quantum-native format.\n",
|
|
"\n",
|
|
"2. Optimize the circuits and operators.\n",
|
|
"\n",
|
|
"3. Execute using a quantum primitive function.\n",
|
|
"\n",
|
|
"4. Analyze the results.\n",
|
|
"\n",
|
|
"### Step 1. Map the problem to a quantum-native format\n",
|
|
"\n",
|
|
"In a quantum program, *quantum circuits* are the native format in which to represent quantum instructions, and *operators* represent the observables to be measured. When creating a circuit, you'll usually create a new [`QuantumCircuit`](/api/qiskit/qiskit.circuit.QuantumCircuit#quantumcircuit-class) object, then add instructions to it in sequence."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "21f7a26c",
|
|
"metadata": {},
|
|
"source": [
|
|
"The following code cell creates a circuit that produces a *Bell state,* which is a state wherein two qubits are fully entangled with each other.\n",
|
|
"\n",
|
|
"<Admonition type=\"note\" title=\"Note: bit ordering\">\n",
|
|
" The Qiskit SDK uses the LSb 0 bit numbering where the $n^{th}$ digit has value $1 \\ll n$ or $2^n$. For more details, see the [Bit-ordering in the Qiskit SDK](./bit-ordering) topic.\n",
|
|
"</Admonition>"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"id": "930ca3b6",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"image/svg+xml": [
|
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg width=\"173.68pt\" height=\"125.65pt\" version=\"1.1\" viewBox=\"0 0 173.68 125.65\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs><style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style></defs><path d=\"m-0 125.65h173.68v-125.65h-173.68z\" fill=\"#ffffff\"/><path d=\"m64.497 44.283h97.343\" clip-path=\"url(#38ed091e689)\" fill=\"none\" stroke=\"#000000\" stroke-linecap=\"square\" stroke-width=\"2\"/><path d=\"m64.497 90.637h97.343\" clip-path=\"url(#38ed091e689)\" fill=\"none\" stroke=\"#000000\" stroke-linecap=\"square\" stroke-width=\"2\"/><path d=\"m59.862 21.106h-1158.8v139.06h1158.8z\" clip-path=\"url(#38ed091e689)\" fill=\"#ffffff\" stroke=\"#ffffff\" stroke-width=\"1.5\"/><path d=\"m135.88 90.637v-46.354\" clip-path=\"url(#38ed091e689)\" fill=\"none\" stroke=\"#002d9c\" stroke-linecap=\"square\" stroke-width=\"2\"/><path d=\"m74.463 59.348h30.13v-30.13h-30.13z\" clip-path=\"url(#38ed091e689)\" fill=\"#fa4d56\" stroke=\"#fa4d56\" stroke-width=\"1.5\"/><path d=\"m135.88 48.803c1.1986 0 2.3482-0.4762 3.1958-1.3237 0.84753-0.84753 1.3237-1.9972 1.3237-3.1958 0-1.1986-0.4762-2.3482-1.3237-3.1958-0.84753-0.84753-1.9972-1.3237-3.1958-1.3237-1.1986 0-2.3482 0.4762-3.1958 1.3237s-1.3237 1.9972-1.3237 3.1958c0 1.1986 0.4762 2.3482 1.3237 3.1958s1.9972 1.3237 3.1958 1.3237z\" clip-path=\"url(#38ed091e689)\" fill=\"#002d9c\" stroke=\"#002d9c\" stroke-width=\"1.5\"/><path d=\"m135.88 101.18c2.7967 0 5.4792-1.1111 7.4568-3.0887 1.9776-1.9776 3.0887-4.6601 3.0887-7.4568 0-2.7967-1.1111-5.4792-3.0887-7.4568-1.9776-1.9776-4.6601-3.0887-7.4568-3.0887-2.7967 0-5.4792 1.1111-7.4568 3.0887-1.9776 1.9776-3.0887 4.6601-3.0887 7.4568 0 2.7967 1.1111 5.4792 3.0887 7.4568 1.9776 1.9776 4.6601 3.0887 7.4568 3.0887z\" clip-path=\"url(#38ed091e689)\" fill=\"#002d9c\" stroke=\"#002d9c\" stroke-width=\"2\"/><path d=\"m135.88 96.663v-12.052\" clip-path=\"url(#38ed091e689)\" fill=\"none\" stroke=\"#ffffff\" stroke-linecap=\"square\" stroke-width=\"2\"/><path d=\"m129.86 90.637h12.052\" clip-path=\"url(#38ed091e689)\" fill=\"none\" stroke=\"#ffffff\" stroke-linecap=\"square\" stroke-width=\"2\"/><g clip-path=\"url(#38ed091e689)\"><g transform=\"translate(37.189 48.734) scale(.1625 -.1625)\"><defs><path id=\"DejaVuSans-Oblique-71\" transform=\"scale(.015625)\" d=\"m2669 525q-231-303-546-460-314-156-695-156-531 0-833 358-301 358-301 986 0 506 186 978t533 847q225 244 517 375t614 131q387 0 637-153t363-462l100 525h578l-934-4813h-579l360 1844zm-1778 813q0-463 193-705 194-242 560-242 544 0 928 520t384 1264q0 450-199 689-198 239-569 239-272 0-504-127-231-126-403-370-181-256-286-600-104-343-104-668z\"/><path id=\"DejaVuSans-30\" transform=\"scale(.015625)\" d=\"m2034 4250q-487 0-733-480-245-479-245-1442 0-959 245-1439 246-480 733-480 491 0 736 480 246 480 246 1439 0 963-246 1442-245 480-736 480zm0 500q785 0 1199-621 414-620 414-1801 0-1178-414-1799-414-620-1199-620-784 0-1198 620-414 621-414 1799 0 1181 414 1801 414 621 1198 621z\"/></defs><use xlink:href=\"#DejaVuSans-Oblique-71\"/><use transform=\"translate(63.477 -16.406) scale(.7)\" xlink:href=\"#DejaVuSans-30\"/></g></g><g clip-path=\"url(#38ed091e689)\"><g transform=\"translate(37.189 95.088) scale(.1625 -.1625)\"><defs><path id=\"DejaVuSans-31\" transform=\"scale(.015625)\" d=\"m794 531h1031v3560l-1122-225v575l1116 225h631v-4135h1031v-531h-2687v531z\"/></defs><use xlink:href=\"#DejaVuSans-Oblique-71\"/><use transform=\"translate(63.477 -16.406) scale(.7)\" xlink:href=\"#DejaVuSans-31\"/></g></g><g clip-path=\"url(#38ed091e689)\"><g transform=\"translate(84.64 47.87) scale(.13 -.13)\"><defs><path id=\"DejaVuSans-48\" transform=\"scale(.015625)\" d=\"m628 4666h631v-1913h2294v1913h631v-4666h-631v2222h-2294v-2222h-631v4666z\"/></defs><use xlink:href=\"#DejaVuSans-48\"/></g></g><defs><clipPath id=\"38ed091e689\"><rect x=\"7.2\" y=\"7.2\" width=\"159.28\" height=\"111.25\"/></clipPath></defs></svg>"
|
|
],
|
|
"text/plain": [
|
|
"<Figure size 287.294x200.667 with 1 Axes>"
|
|
]
|
|
},
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"from qiskit import QuantumCircuit\n",
|
|
"from qiskit.quantum_info import SparsePauliOp\n",
|
|
"from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager\n",
|
|
"from qiskit_ibm_runtime import EstimatorV2 as Estimator\n",
|
|
"\n",
|
|
"# Create a new circuit with two qubits\n",
|
|
"qc = QuantumCircuit(2)\n",
|
|
"\n",
|
|
"# Add a Hadamard gate to qubit 0\n",
|
|
"qc.h(0)\n",
|
|
"\n",
|
|
"# Perform a controlled-X gate on qubit 1, controlled by qubit 0\n",
|
|
"qc.cx(0, 1)\n",
|
|
"\n",
|
|
"# Return a drawing of the circuit using MatPlotLib (\"mpl\"). This is the\n",
|
|
"# last line of the cell, so the drawing appears in the cell output.\n",
|
|
"# Remove the \"mpl\" argument to get a text drawing.\n",
|
|
"qc.draw(\"mpl\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "0c957de9",
|
|
"metadata": {
|
|
"raw_mimetype": "text/restructuredtext"
|
|
},
|
|
"source": [
|
|
"See [`QuantumCircuit`](/api/qiskit/qiskit.circuit.QuantumCircuit#quantumcircuit-class) in the documentation for all available operations."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "f3ef4248-7938-44c1-85f1-edc997f0edcd",
|
|
"metadata": {},
|
|
"source": [
|
|
"When creating quantum circuits, you must also consider what type of data you want returned after execution. Qiskit provides two ways to return data: you can obtain a probability distribution for a set of qubits you choose to measure, or you can obtain the expectation value of an observable. Prepare your workload to measure your circuit in one of these two ways with [Qiskit primitives](./get-started-with-primitives) (explained in detail in [Step 3](#step-3-execute-using-the-quantum-primitives)).\n",
|
|
"\n",
|
|
"This example measures expectation values by using the `qiskit.quantum_info` submodule, which is specified by using operators (mathematical objects used to represent an action or process that changes a quantum state). The following code cell creates six two-qubit Pauli operators: `IZ`, `IX`, `ZI`, `XI`, `ZZ`, and `XX`."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"id": "c57b261c-b757-4432-beab-61b526c98a41",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Set up six different observables.\n",
|
|
"\n",
|
|
"observables_labels = [\"IZ\", \"IX\", \"ZI\", \"XI\", \"ZZ\", \"XX\"]\n",
|
|
"observables = [SparsePauliOp(label) for label in observables_labels]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "47150779",
|
|
"metadata": {},
|
|
"source": [
|
|
"<Admonition type=\"note\" title=\"Operator Notation\">\n",
|
|
"Here, something like the `ZZ` operator is a shorthand for the tensor product $Z\\otimes Z$, which means measuring Z on qubit 1 and Z on qubit 0 together, and obtaining information about the correlation between qubit 1 and qubit 0. Expectation values like this are also typically written as $\\langle Z_1 Z_0 \\rangle$.\n",
|
|
"\n",
|
|
"If the state is entangled, then the measurement of $\\langle Z_1 Z_0 \\rangle$ should be 1.\n",
|
|
"</Admonition>"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "83bf9151-3bc9-40d2-8615-31570238b08e",
|
|
"metadata": {},
|
|
"source": [
|
|
"<span id=\"optimize\"></span>\n",
|
|
"### Step 2. Optimize the circuits and operators\n",
|
|
"\n",
|
|
"When executing circuits on a device, it is important to optimize the set of instructions that the circuit contains and minimize the overall depth (roughly the number of instructions) of the circuit. This ensures that you obtain the best results possible by reducing the effects of error and noise. Additionally, the circuit's instructions must conform to a backend device's [Instruction Set Architecture (ISA)](./transpile#instruction-set-architecture) and must consider the device's basis gates and qubit connectivity.\n",
|
|
"\n",
|
|
"The following code instantiates a real device to submit a job to and transforms the circuit and observables to match that backend's ISA."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"id": "9a901271",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"image/svg+xml": [
|
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg width=\"434.54pt\" height=\"133.25pt\" version=\"1.1\" viewBox=\"0 0 434.54 133.25\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs><style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style></defs><path d=\"m0 133.25h434.54v-133.25h-434.54z\" fill=\"#ffffff\"/><path d=\"m93.592 51.882h329.11\" clip-path=\"url(#1a83ee3a2e3)\" fill=\"none\" stroke=\"#000000\" stroke-linecap=\"square\" stroke-width=\"2\"/><path d=\"m93.592 98.236h329.11\" clip-path=\"url(#1a83ee3a2e3)\" fill=\"none\" stroke=\"#000000\" stroke-linecap=\"square\" stroke-width=\"2\"/><g transform=\"translate(7.2 14.798) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-47\" transform=\"scale(.015625)\" d=\"m3809 666v1253h-1031v519h1656v-2004q-365-259-806-392-440-133-940-133-1094 0-1712 639-617 640-617 1780 0 1144 617 1783 618 639 1712 639 456 0 867-113 411-112 758-331v-672q-350 297-744 447t-828 150q-857 0-1287-478-429-478-429-1425 0-944 429-1422 430-478 1287-478 334 0 596 58 263 58 472 180z\"/><path id=\"DejaVuSans-6c\" transform=\"scale(.015625)\" d=\"m603 4863h575v-4863h-575v4863z\"/><path id=\"DejaVuSans-6f\" transform=\"scale(.015625)\" d=\"m1959 3097q-462 0-731-361t-269-989 267-989q268-361 733-361 460 0 728 362 269 363 269 988 0 622-269 986-268 364-728 364zm0 487q750 0 1178-488 429-487 429-1349 0-859-429-1349-428-489-1178-489-753 0-1180 489-426 490-426 1349 0 862 426 1349 427 488 1180 488z\"/><path id=\"DejaVuSans-62\" transform=\"scale(.015625)\" d=\"m3116 1747q0 634-261 995t-717 361q-457 0-718-361t-261-995 261-995 718-361q456 0 717 361t261 995zm-1957 1222q182 312 458 463 277 152 661 152 638 0 1036-506 399-506 399-1331t-399-1332q-398-506-1036-506-384 0-661 152-276 152-458 464v-525h-578v4863h578v-1894z\"/><path id=\"DejaVuSans-61\" transform=\"scale(.015625)\" d=\"m2194 1759q-697 0-966-159t-269-544q0-306 202-486 202-179 548-179 479 0 768 339t289 901v128h-572zm1147 238v-1997h-575v531q-197-318-491-470t-719-152q-537 0-855 302-317 302-317 808 0 590 395 890 396 300 1180 300h807v57q0 397-261 614t-733 217q-300 0-585-72-284-72-546-216v532q315 122 612 182 297 61 578 61 760 0 1135-394 375-393 375-1193z\"/><path id=\"DejaVuSans-50\" transform=\"scale(.015625)\" d=\"m1259 4147v-1753h794q441 0 681 228 241 228 241 650 0 419-241 647-240 228-681 228h-794zm-631 519h1425q785 0 1186-355 402-355 402-1039 0-691-402-1044-401-353-1186-353h-794v-1875h-631v4666z\"/><path id=\"DejaVuSans-68\" transform=\"scale(.015625)\" d=\"m3513 2113v-2113h-575v2094q0 497-194 743-194 247-581 247-466 0-735-297-269-296-269-809v-1978h-578v4863h578v-1907q207 316 486 472 280 156 646 156 603 0 912-373 310-373 310-1098z\"/><path id=\"DejaVuSans-73\" transform=\"scale(.015625)\" d=\"m2834 3397v-544q-243 125-506 187-262 63-544 63-428 0-642-131t-214-394q0-200 153-314t616-217l197-44q612-131 870-370t258-667q0-488-386-773-386-284-1061-284-281 0-586 55t-642 164v594q319-166 628-249 309-82 613-82 406 0 624 139 219 139 219 392 0 234-158 359-157 125-692 241l-200 47q-534 112-772 345-237 233-237 639 0 494 350 762 350 269 994 269 318 0 599-47 282-46 519-140z\"/><path id=\"DejaVuSans-65\" transform=\"scale(.015625)\" d=\"m3597 1894v-281h-2644q38-594 358-905t892-311q331 0 642 81t618 244v-544q-310-131-635-200t-659-69q-838 0-1327 487-489 488-489 1320 0 859 464 1363 464 505 1252 505 706 0 1117-455 411-454 411-1235zm-575 169q-6 471-264 752-258 282-683 282-481 0-770-272t-333-766l2050 4z\"/><path id=\"DejaVuSans-3a\" transform=\"scale(.015625)\" d=\"m750 794h659v-794h-659v794zm0 2515h659v-793h-659v793z\"/><path id=\"DejaVuSans-37\" transform=\"scale(.015625)\" d=\"m525 4666h3e3v-269l-1694-4397h-659l1594 4134h-2241v532z\"/><path id=\"DejaVuSans-Oblique-3c0\" transform=\"scale(.015625)\" d=\"m584 3500h3354l-113-575h-441l-418-2150q-44-225 15-325 57-97 228-97 47 0 116 10 72 6 94 9l-81-416q-116-40-235-59-122-19-237-19-375 0-478 203-104 207 3 757l406 2087h-1291l-568-2925h-588l569 2925h-447l112 575z\"/><path id=\"DejaVuSans-2f\" transform=\"scale(.015625)\" d=\"m1625 4666h531l-1625-5260h-531l1625 5260z\"/><path id=\"DejaVuSans-34\" transform=\"scale(.015625)\" d=\"m2419 4116-1594-2491h1594v2491zm-166 550h794v-3041h666v-525h-666v-1100h-628v1100h-2106v609l1940 2957z\"/></defs><use transform=\"translate(0 .015625)\" xlink:href=\"#DejaVuSans-47\"/><use transform=\"translate(77.49 .015625)\" xlink:href=\"#DejaVuSans-6c\"/><use transform=\"translate(105.27 .015625)\" xlink:href=\"#DejaVuSans-6f\"/><use transform=\"translate(166.46 .015625)\" xlink:href=\"#DejaVuSans-62\"/><use transform=\"translate(229.93 .015625)\" xlink:href=\"#DejaVuSans-61\"/><use transform=\"translate(291.21 .015625)\" xlink:href=\"#DejaVuSans-6c\"/><use transform=\"translate(318.99 .015625)\" xlink:href=\"#DejaVuSans-20\"/><use transform=\"translate(350.78 .015625)\" xlink:href=\"#DejaVuSans-50\"/><use transform=\"translate(411.08 .015625)\" xlink:href=\"#DejaVuSans-68\"/><use transform=\"translate(474.46 .015625)\" xlink:href=\"#DejaVuSans-61\"/><use transform=\"translate(535.74 .015625)\" xlink:href=\"#DejaVuSans-73\"/><use transform=\"translate(587.84 .015625)\" xlink:href=\"#DejaVuSans-65\"/><use transform=\"translate(649.37 .015625)\" xlink:href=\"#DejaVuSans-3a\"/><use transform=\"translate(683.06 .015625)\" xlink:href=\"#DejaVuSans-20\"/><use transform=\"translate(714.84 .015625)\" xlink:href=\"#DejaVuSans-37\"/><use transform=\"translate(778.47 .015625)\" xlink:href=\"#DejaVuSans-Oblique-3c0\"/><use transform=\"translate(838.67 .015625)\" xlink:href=\"#DejaVuSans-2f\"/><use transform=\"translate(872.36 .015625)\" xlink:href=\"#DejaVuSans-34\"/></g><path d=\"m88.957 28.705h-1158.8v139.06h1158.8z\" clip-path=\"url(#1a83ee3a2e3)\" fill=\"#ffffff\" stroke=\"#ffffff\" stroke-width=\"1.5\"/><path d=\"m103.56 66.947h30.13v-30.13h-30.13z\" clip-path=\"url(#1a83ee3a2e3)\" fill=\"#33b1ff\" stroke=\"#33b1ff\" stroke-width=\"1.5\"/><path d=\"m103.56 113.3h30.13v-30.13h-30.13z\" clip-path=\"url(#1a83ee3a2e3)\" fill=\"#33b1ff\" stroke=\"#33b1ff\" stroke-width=\"1.5\"/><path d=\"m149.91 66.947h30.13v-30.13h-30.13z\" clip-path=\"url(#1a83ee3a2e3)\" fill=\"#9f1853\" stroke=\"#9f1853\" stroke-width=\"1.5\"/><path d=\"m149.91 113.3h30.13v-30.13h-30.13z\" clip-path=\"url(#1a83ee3a2e3)\" fill=\"#9f1853\" stroke=\"#9f1853\" stroke-width=\"1.5\"/><path d=\"m196.27 113.3h30.13v-30.13h-30.13z\" clip-path=\"url(#1a83ee3a2e3)\" fill=\"#33b1ff\" stroke=\"#33b1ff\" stroke-width=\"1.5\"/><path d=\"m241.76 113.3h31.85v-76.484h-31.85z\" clip-path=\"url(#1a83ee3a2e3)\" fill=\"#9f1853\" stroke=\"#9f1853\" stroke-width=\"1.5\"/><path d=\"m288.97 66.947h30.13v-30.13h-30.13z\" clip-path=\"url(#1a83ee3a2e3)\" fill=\"#33b1ff\" stroke=\"#33b1ff\" stroke-width=\"1.5\"/><path d=\"m288.97 113.3h30.13v-30.13h-30.13z\" clip-path=\"url(#1a83ee3a2e3)\" fill=\"#33b1ff\" stroke=\"#33b1ff\" stroke-width=\"1.5\"/><path d=\"m335.33 66.947h30.13v-30.13h-30.13z\" clip-path=\"url(#1a83ee3a2e3)\" fill=\"#9f1853\" stroke=\"#9f1853\" stroke-width=\"1.5\"/><path d=\"m335.33 113.3h30.13v-30.13h-30.13z\" clip-path=\"url(#1a83ee3a2e3)\" fill=\"#9f1853\" stroke=\"#9f1853\" stroke-width=\"1.5\"/><path d=\"m381.68 66.947h30.13v-30.13h-30.13z\" clip-path=\"url(#1a83ee3a2e3)\" fill=\"#33b1ff\" stroke=\"#33b1ff\" stroke-width=\"1.5\"/><path d=\"m381.68 113.3h30.13v-30.13h-30.13z\" clip-path=\"url(#1a83ee3a2e3)\" fill=\"#33b1ff\" stroke=\"#33b1ff\" stroke-width=\"1.5\"/><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(27.121 56.333) scale(.1625 -.1625)\"><defs><path id=\"DejaVuSans-Oblique-71\" transform=\"scale(.015625)\" d=\"m2669 525q-231-303-546-460-314-156-695-156-531 0-833 358-301 358-301 986 0 506 186 978t533 847q225 244 517 375t614 131q387 0 637-153t363-462l100 525h578l-934-4813h-579l360 1844zm-1778 813q0-463 193-705 194-242 560-242 544 0 928 520t384 1264q0 450-199 689-198 239-569 239-272 0-504-127-231-126-403-370-181-256-286-600-104-343-104-668z\"/><path id=\"DejaVuSans-30\" transform=\"scale(.015625)\" d=\"m2034 4250q-487 0-733-480-245-479-245-1442 0-959 245-1439 246-480 733-480 491 0 736 480 246 480 246 1439 0 963-246 1442-245 480-736 480zm0 500q785 0 1199-621 414-620 414-1801 0-1178-414-1799-414-620-1199-620-784 0-1198 620-414 621-414 1799 0 1181 414 1801 414 621 1198 621z\"/><path id=\"DejaVuSans-21a6\" transform=\"scale(.015625)\" d=\"m4175 1741h-3278v-1078h-531v2687h531v-1078h3278l-728 728 375 375 1228-1228v-281l-1228-1228-375 375 728 728z\"/></defs><use transform=\"translate(0 .78125)\" xlink:href=\"#DejaVuSans-Oblique-71\"/><use transform=\"translate(63.477 -15.625) scale(.7)\" xlink:href=\"#DejaVuSans-30\"/><use transform=\"translate(157.29 .78125)\" xlink:href=\"#DejaVuSans-21a6\"/><use transform=\"translate(287.62 .78125)\" xlink:href=\"#DejaVuSans-30\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(27.121 102.69) scale(.1625 -.1625)\"><defs><path id=\"DejaVuSans-31\" transform=\"scale(.015625)\" d=\"m794 531h1031v3560l-1122-225v575l1116 225h631v-4135h1031v-531h-2687v531z\"/></defs><use transform=\"translate(0 .09375)\" xlink:href=\"#DejaVuSans-Oblique-71\"/><use transform=\"translate(63.477 -16.312) scale(.7)\" xlink:href=\"#DejaVuSans-31\"/><use transform=\"translate(157.29 .09375)\" xlink:href=\"#DejaVuSans-21a6\"/><use transform=\"translate(287.62 .09375)\" xlink:href=\"#DejaVuSans-31\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(112.86 63.128) scale(.08 -.08)\"><defs><path id=\"DejaVuSans-2212\" transform=\"scale(.015625)\" d=\"m678 2272h4006v-531h-4006v531z\"/></defs><use transform=\"translate(0 .3125)\" xlink:href=\"#DejaVuSans-2212\"/><use transform=\"translate(83.789 .3125)\" xlink:href=\"#DejaVuSans-Oblique-3c0\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(110.69 50.949) scale(.13 -.13)\"><defs><path id=\"DejaVuSans-52\" transform=\"scale(.015625)\" d=\"m2841 2188q203-69 395-294t386-619l641-1275h-679l-596 1197q-232 469-449 622t-592 153h-688v-1972h-631v4666h1425q800 0 1194-335 394-334 394-1009 0-441-205-732-205-290-595-402zm-1582 1959v-1656h794q456 0 689 211t233 620-233 617-689 208h-794z\"/><path id=\"DejaVuSans-5a\" transform=\"scale(.015625)\" d=\"m359 4666h3666v-482l-2950-3653h3022v-531h-3809v481l2950 3653h-2879v532z\"/></defs><use transform=\"translate(0 .09375)\" xlink:href=\"#DejaVuSans-52\"/><use transform=\"translate(70.439 -16.312) scale(.7)\" xlink:href=\"#DejaVuSans-5a\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(109.1 109.48) scale(.08 -.08)\"><defs><path id=\"DejaVuSans-32\" transform=\"scale(.015625)\" d=\"m1228 531h2203v-531h-2962v531q359 372 979 998 621 627 780 809 303 340 423 576 121 236 121 464 0 372-261 606-261 235-680 235-297 0-627-103-329-103-704-313v638q381 153 712 231 332 78 607 78 725 0 1156-363 431-362 431-968 0-288-108-546-107-257-392-607-78-91-497-524-418-433-1181-1211z\"/></defs><use transform=\"translate(0 .78125)\" xlink:href=\"#DejaVuSans-2212\"/><use transform=\"translate(83.789 .78125)\" xlink:href=\"#DejaVuSans-Oblique-3c0\"/><use transform=\"translate(143.99 .78125)\" xlink:href=\"#DejaVuSans-2f\"/><use transform=\"translate(174.06 .78125)\" xlink:href=\"#DejaVuSans-32\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(110.69 97.303) scale(.13 -.13)\"><use transform=\"translate(0 .09375)\" xlink:href=\"#DejaVuSans-52\"/><use transform=\"translate(70.439 -16.312) scale(.7)\" xlink:href=\"#DejaVuSans-5a\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(154.97 56.328) scale(.13 -.13)\" fill=\"#ffffff\"><defs><path id=\"STIXSizeOneSym-Regular-221a\" transform=\"scale(.015625)\" d=\"m6970 9933-3597-11821h-269l-1478 4806q-71 231-161 333-89 103-236 103-218 0-435-173l-77 128 1049 806h160l1453-4717h26l3200 10535h365z\"/><path id=\"DejaVuSans-58\" transform=\"scale(.015625)\" d=\"m403 4666h678l1160-1735 1165 1735h678l-1500-2241 1600-2425h-678l-1312 1984-1322-1984h-681l1665 2491-1453 2175z\"/></defs><use transform=\"translate(0 17.094) scale(.56391)\" xlink:href=\"#STIXSizeOneSym-Regular-221a\"/><use transform=\"translate(72.088 .84375)\" xlink:href=\"#DejaVuSans-58\"/><path d=\"m59.588 97.5v6.25h93.506v-6.25h-93.506z\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(154.97 102.68) scale(.13 -.13)\" fill=\"#ffffff\"><use transform=\"translate(0 17.094) scale(.56391)\" xlink:href=\"#STIXSizeOneSym-Regular-221a\"/><use transform=\"translate(72.088 .84375)\" xlink:href=\"#DejaVuSans-58\"/><path d=\"m59.588 97.5v6.25h93.506v-6.25h-93.506z\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(205.57 109.48) scale(.08 -.08)\"><use transform=\"translate(0 .3125)\" xlink:href=\"#DejaVuSans-2212\"/><use transform=\"translate(83.789 .3125)\" xlink:href=\"#DejaVuSans-Oblique-3c0\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(203.4 97.303) scale(.13 -.13)\"><use transform=\"translate(0 .09375)\" xlink:href=\"#DejaVuSans-52\"/><use transform=\"translate(70.439 -16.312) scale(.7)\" xlink:href=\"#DejaVuSans-5a\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(245.01 101.82) scale(.13 -.13)\" fill=\"#ffffff\"><use xlink:href=\"#DejaVuSans-30\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(245.01 55.469) scale(.13 -.13)\" fill=\"#ffffff\"><use xlink:href=\"#DejaVuSans-31\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(252.43 78.646) scale(.13 -.13)\" fill=\"#ffffff\"><defs><path id=\"DejaVuSans-45\" transform=\"scale(.015625)\" d=\"m628 4666h2950v-532h-2319v-1381h2222v-531h-2222v-1691h2375v-531h-3006v4666z\"/><path id=\"DejaVuSans-63\" transform=\"scale(.015625)\" d=\"m3122 3366v-538q-244 135-489 202t-495 67q-560 0-870-355-309-354-309-995t309-996q310-354 870-354 250 0 495 67t489 202v-532q-241-112-499-168-257-57-548-57-791 0-1257 497-465 497-465 1341 0 856 470 1346 471 491 1290 491 265 0 518-55 253-54 491-163z\"/><path id=\"DejaVuSans-72\" transform=\"scale(.015625)\" d=\"m2631 2963q-97 56-211 82-114 27-251 27-488 0-749-317t-261-911v-1844h-578v3500h578v-544q182 319 472 473 291 155 707 155 59 0 131-8 72-7 159-23l3-590z\"/></defs><use xlink:href=\"#DejaVuSans-45\"/><use x=\"63.183594\" xlink:href=\"#DejaVuSans-63\"/><use x=\"118.164062\" xlink:href=\"#DejaVuSans-72\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(294.52 63.128) scale(.08 -.08)\"><use transform=\"translate(0 .78125)\" xlink:href=\"#DejaVuSans-2212\"/><use transform=\"translate(83.789 .78125)\" xlink:href=\"#DejaVuSans-Oblique-3c0\"/><use transform=\"translate(143.99 .78125)\" xlink:href=\"#DejaVuSans-2f\"/><use transform=\"translate(174.06 .78125)\" xlink:href=\"#DejaVuSans-32\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(296.11 50.949) scale(.13 -.13)\"><use transform=\"translate(0 .09375)\" xlink:href=\"#DejaVuSans-52\"/><use transform=\"translate(70.439 -16.312) scale(.7)\" xlink:href=\"#DejaVuSans-5a\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(297.88 109.48) scale(.08 -.08)\"><use transform=\"translate(0 .78125)\" xlink:href=\"#DejaVuSans-Oblique-3c0\"/><use transform=\"translate(60.205 .78125)\" xlink:href=\"#DejaVuSans-2f\"/><use transform=\"translate(90.271 .78125)\" xlink:href=\"#DejaVuSans-32\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(296.11 97.303) scale(.13 -.13)\"><use transform=\"translate(0 .09375)\" xlink:href=\"#DejaVuSans-52\"/><use transform=\"translate(70.439 -16.312) scale(.7)\" xlink:href=\"#DejaVuSans-5a\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(340.38 56.328) scale(.13 -.13)\" fill=\"#ffffff\"><use transform=\"translate(0 17.094) scale(.56391)\" xlink:href=\"#STIXSizeOneSym-Regular-221a\"/><use transform=\"translate(72.088 .84375)\" xlink:href=\"#DejaVuSans-58\"/><path d=\"m59.588 97.5v6.25h93.506v-6.25h-93.506z\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(340.38 102.68) scale(.13 -.13)\" fill=\"#ffffff\"><use transform=\"translate(0 17.094) scale(.56391)\" xlink:href=\"#STIXSizeOneSym-Regular-221a\"/><use transform=\"translate(72.088 .84375)\" xlink:href=\"#DejaVuSans-58\"/><path d=\"m59.588 97.5v6.25h93.506v-6.25h-93.506z\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(390.59 63.128) scale(.08 -.08)\"><use transform=\"translate(0 .78125)\" xlink:href=\"#DejaVuSans-Oblique-3c0\"/><use transform=\"translate(60.205 .78125)\" xlink:href=\"#DejaVuSans-2f\"/><use transform=\"translate(90.271 .78125)\" xlink:href=\"#DejaVuSans-32\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(388.82 50.949) scale(.13 -.13)\"><use transform=\"translate(0 .09375)\" xlink:href=\"#DejaVuSans-52\"/><use transform=\"translate(70.439 -16.312) scale(.7)\" xlink:href=\"#DejaVuSans-5a\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(390.59 109.48) scale(.08 -.08)\"><use transform=\"translate(0 .78125)\" xlink:href=\"#DejaVuSans-Oblique-3c0\"/><use transform=\"translate(60.205 .78125)\" xlink:href=\"#DejaVuSans-2f\"/><use transform=\"translate(90.271 .78125)\" xlink:href=\"#DejaVuSans-32\"/></g></g><g clip-path=\"url(#1a83ee3a2e3)\"><g transform=\"translate(388.82 97.303) scale(.13 -.13)\"><use transform=\"translate(0 .09375)\" xlink:href=\"#DejaVuSans-52\"/><use transform=\"translate(70.439 -16.312) scale(.7)\" xlink:href=\"#DejaVuSans-5a\"/></g></g><defs><clipPath id=\"1a83ee3a2e3\"><rect x=\"7.2\" y=\"14.798\" width=\"420.14\" height=\"111.25\"/></clipPath></defs></svg>"
|
|
],
|
|
"text/plain": [
|
|
"<Figure size 757.83x200.667 with 1 Axes>"
|
|
]
|
|
},
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"from qiskit_ibm_runtime import QiskitRuntimeService\n",
|
|
"\n",
|
|
"# If you did not previously save your credentials, use the following line instead:\n",
|
|
"# service = QiskitRuntimeService(channel=\"ibm_quantum\", token=\"<MY_IBM_QUANTUM_TOKEN>\")\n",
|
|
"service = QiskitRuntimeService()\n",
|
|
"\n",
|
|
"backend = service.least_busy(simulator=False, operational=True)\n",
|
|
"\n",
|
|
"# Convert to an ISA circuit and layout-mapped observables.\n",
|
|
"pm = generate_preset_pass_manager(backend=backend, optimization_level=1)\n",
|
|
"isa_circuit = pm.run(qc)\n",
|
|
"\n",
|
|
"isa_circuit.draw(\"mpl\", idle_wires=False)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "9acac1d4",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Step 3. Execute using the quantum primitives\n",
|
|
"\n",
|
|
"Quantum computers can produce random results, so you usually collect a sample of the outputs by running the circuit many times. You can estimate the value of the observable by using the `Estimator` class. `Estimator` is one of two [primitives](./get-started-with-primitives); the other is `Sampler`, which can be used to get data from a quantum computer. These objects possess a `run()` method that executes the selection of circuits, observables, and parameters (if applicable), using a [primitive unified bloc (PUB).](primitives#sampler)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"id": "62c4ca44",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
">>> Job ID: cva14t3sgfsg008g7a50\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# Construct the Estimator instance.\n",
|
|
"\n",
|
|
"estimator = Estimator(mode=backend)\n",
|
|
"estimator.options.resilience_level = 1\n",
|
|
"estimator.options.default_shots = 5000\n",
|
|
"\n",
|
|
"mapped_observables = [\n",
|
|
" observable.apply_layout(isa_circuit.layout) for observable in observables\n",
|
|
"]\n",
|
|
"\n",
|
|
"# One pub, with one circuit to run against five different observables.\n",
|
|
"job = estimator.run([(isa_circuit, mapped_observables)])\n",
|
|
"\n",
|
|
"# Use the job ID to retrieve your job data later\n",
|
|
"print(f\">>> Job ID: {job.job_id()}\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "47479e76",
|
|
"metadata": {},
|
|
"source": [
|
|
"After a job is submitted, you can wait until either the job is completed within your current python instance, or use the `job_id` to retrieve the data at a later time. (See the [section on retrieving jobs](./monitor-job#retrieve-job-results-at-a-later-time) for details.)\n",
|
|
"\n",
|
|
"After the job completes, examine its output through the job's `result()` attribute."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"id": "792d2f01",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# This is the result of the entire submission. You submitted one Pub,\n",
|
|
"# so this contains one inner result (and some metadata of its own).\n",
|
|
"job_result = job.result()\n",
|
|
"\n",
|
|
"# This is the result from our single pub, which had six observables,\n",
|
|
"# so contains information on all six.\n",
|
|
"pub_result = job.result()[0]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"id": "f7339475",
|
|
"metadata": {
|
|
"tags": [
|
|
"remove-cell"
|
|
]
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Check there are six observables.\n",
|
|
"# If not, edit the comments in the previous cell and update this test.\n",
|
|
"assert len(pub_result.data.evs) == 6"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "48317a25",
|
|
"metadata": {},
|
|
"source": [
|
|
"<Admonition type=\"note\" title=\"Alternative: run the example using a simulator\">\n",
|
|
" When you run your quantum program on a real device, your workload must wait in a queue before it runs. To save time, you can instead use the following code to run this small workload on the [`fake_provider`](../api/qiskit-ibm-runtime/fake_provider) with the Qiskit Runtime local testing mode. Note that this is only possible for a small circuit. When you scale up in the next section, you will need to use a real device.\n",
|
|
"\n",
|
|
" ```python\n",
|
|
"\n",
|
|
" # Use the following code instead if you want to run on a simulator:\n",
|
|
"\n",
|
|
" from qiskit_ibm_runtime.fake_provider import FakeAlmadenV2\n",
|
|
" backend = FakeAlmadenV2()\n",
|
|
" estimator = Estimator(backend)\n",
|
|
"\n",
|
|
" # Convert to an ISA circuit and layout-mapped observables.\n",
|
|
"\n",
|
|
" pm = generate_preset_pass_manager(backend=backend, optimization_level=1)\n",
|
|
" isa_circuit = pm.run(qc)\n",
|
|
" mapped_observables = [\n",
|
|
" observable.apply_layout(isa_circuit.layout) for observable in observables\n",
|
|
" ]\n",
|
|
"\n",
|
|
" job = estimator.run([(isa_circuit, mapped_observables)])\n",
|
|
" result = job.result()\n",
|
|
"\n",
|
|
" # This is the result of the entire submission. You submitted one Pub,\n",
|
|
" # so this contains one inner result (and some metadata of its own).\n",
|
|
"\n",
|
|
" job_result = job.result()\n",
|
|
"\n",
|
|
" # This is the result from our single pub, which had five observables,\n",
|
|
" # so contains information on all five.\n",
|
|
"\n",
|
|
" pub_result = job.result()[0]\n",
|
|
" ```\n",
|
|
"</Admonition>"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "d200d1f8",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Step 4. Analyze the results\n",
|
|
"\n",
|
|
"The analyze step is typically where you might postprocess your results using, for example, measurement error mitigation or zero noise extrapolation (ZNE). You might feed these results into another workflow for further analysis or prepare a plot of the key values and data. In general, this step is specific to your problem. For this example, plot each of the expectation values that were measured for our circuit.\n",
|
|
"\n",
|
|
"The expectation values and standard deviations for the observables you specified to Estimator are accessed through the job result's `PubResult.data.evs` and `PubResult.data.stds` attributes. To obtain the results from Sampler, use the `PubResult.data.meas.get_counts()` function, which will return a `dict` of measurements in the form of bitstrings as keys and counts as their corresponding values. For more information, see [Get started with Sampler.](./get-started-with-primitives#get-started-with-sampler)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 7,
|
|
"id": "87143fcc",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"image/svg+xml": [
|
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg width=\"408.1pt\" height=\"310.87pt\" version=\"1.1\" viewBox=\"0 0 408.1 310.87\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs><style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style></defs><path d=\"m0 310.87h408.1v-310.87h-408.1z\" fill=\"#ffffff\"/><path d=\"m43.781 273.31h357.12v-266.11h-357.12z\" fill=\"#ffffff\"/><defs><path id=\"aa8ca3ffa9a\" d=\"m0 0v3.5\" stroke=\"#000000\" stroke-width=\".8\"/></defs><use x=\"60.013977\" y=\"273.312\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#aa8ca3ffa9a\"/><g transform=\"translate(55.114 287.91) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-49\" transform=\"scale(.015625)\" d=\"m628 4666h631v-4666h-631v4666z\"/><path id=\"DejaVuSans-5a\" transform=\"scale(.015625)\" d=\"m359 4666h3666v-482l-2950-3653h3022v-531h-3809v481l2950 3653h-2879v532z\"/></defs><use xlink:href=\"#DejaVuSans-49\"/><use x=\"29.492188\" xlink:href=\"#DejaVuSans-5a\"/></g><use x=\"124.944886\" y=\"273.312\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#aa8ca3ffa9a\"/><g transform=\"translate(120.04 287.91) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-58\" transform=\"scale(.015625)\" d=\"m403 4666h678l1160-1735 1165 1735h678l-1500-2241 1600-2425h-678l-1312 1984-1322-1984h-681l1665 2491-1453 2175z\"/></defs><use xlink:href=\"#DejaVuSans-49\"/><use x=\"29.492188\" xlink:href=\"#DejaVuSans-58\"/></g><use x=\"189.875795\" y=\"273.312\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#aa8ca3ffa9a\"/><g transform=\"translate(184.98 287.91) scale(.1 -.1)\"><use xlink:href=\"#DejaVuSans-5a\"/><use x=\"68.505859\" xlink:href=\"#DejaVuSans-49\"/></g><use x=\"254.806705\" y=\"273.312\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#aa8ca3ffa9a\"/><g transform=\"translate(249.91 287.91) scale(.1 -.1)\"><use xlink:href=\"#DejaVuSans-58\"/><use x=\"68.505859\" xlink:href=\"#DejaVuSans-49\"/></g><use x=\"319.737614\" y=\"273.312\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#aa8ca3ffa9a\"/><g transform=\"translate(312.89 287.91) scale(.1 -.1)\"><use xlink:href=\"#DejaVuSans-5a\"/><use x=\"68.505859\" xlink:href=\"#DejaVuSans-5a\"/></g><use x=\"384.668523\" y=\"273.312\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#aa8ca3ffa9a\"/><g transform=\"translate(377.82 287.91) scale(.1 -.1)\"><use xlink:href=\"#DejaVuSans-58\"/><use x=\"68.505859\" xlink:href=\"#DejaVuSans-58\"/></g><g transform=\"translate(191.23 301.59) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-4f\" transform=\"scale(.015625)\" d=\"m2522 4238q-688 0-1093-513-404-512-404-1397 0-881 404-1394 405-512 1093-512 687 0 1089 512 402 513 402 1394 0 885-402 1397-402 513-1089 513zm0 512q981 0 1568-658 588-658 588-1764 0-1103-588-1761-587-658-1568-658-984 0-1574 656-589 657-589 1763t589 1764q590 658 1574 658z\"/><path id=\"DejaVuSans-62\" transform=\"scale(.015625)\" d=\"m3116 1747q0 634-261 995t-717 361q-457 0-718-361t-261-995 261-995 718-361q456 0 717 361t261 995zm-1957 1222q182 312 458 463 277 152 661 152 638 0 1036-506 399-506 399-1331t-399-1332q-398-506-1036-506-384 0-661 152-276 152-458 464v-525h-578v4863h578v-1894z\"/><path id=\"DejaVuSans-73\" transform=\"scale(.015625)\" d=\"m2834 3397v-544q-243 125-506 187-262 63-544 63-428 0-642-131t-214-394q0-200 153-314t616-217l197-44q612-131 870-370t258-667q0-488-386-773-386-284-1061-284-281 0-586 55t-642 164v594q319-166 628-249 309-82 613-82 406 0 624 139 219 139 219 392 0 234-158 359-157 125-692 241l-200 47q-534 112-772 345-237 233-237 639 0 494 350 762 350 269 994 269 318 0 599-47 282-46 519-140z\"/><path id=\"DejaVuSans-65\" transform=\"scale(.015625)\" d=\"m3597 1894v-281h-2644q38-594 358-905t892-311q331 0 642 81t618 244v-544q-310-131-635-200t-659-69q-838 0-1327 487-489 488-489 1320 0 859 464 1363 464 505 1252 505 706 0 1117-455 411-454 411-1235zm-575 169q-6 471-264 752-258 282-683 282-481 0-770-272t-333-766l2050 4z\"/><path id=\"DejaVuSans-72\" transform=\"scale(.015625)\" d=\"m2631 2963q-97 56-211 82-114 27-251 27-488 0-749-317t-261-911v-1844h-578v3500h578v-544q182 319 472 473 291 155 707 155 59 0 131-8 72-7 159-23l3-590z\"/><path id=\"DejaVuSans-76\" transform=\"scale(.015625)\" d=\"m191 3500h609l1094-2937 1094 2937h609l-1313-3500h-781l-1312 3500z\"/><path id=\"DejaVuSans-61\" transform=\"scale(.015625)\" d=\"m2194 1759q-697 0-966-159t-269-544q0-306 202-486 202-179 548-179 479 0 768 339t289 901v128h-572zm1147 238v-1997h-575v531q-197-318-491-470t-719-152q-537 0-855 302-317 302-317 808 0 590 395 890 396 300 1180 300h807v57q0 397-261 614t-733 217q-300 0-585-72-284-72-546-216v532q315 122 612 182 297 61 578 61 760 0 1135-394 375-393 375-1193z\"/><path id=\"DejaVuSans-6c\" transform=\"scale(.015625)\" d=\"m603 4863h575v-4863h-575v4863z\"/></defs><use xlink:href=\"#DejaVuSans-4f\"/><use x=\"78.710938\" xlink:href=\"#DejaVuSans-62\"/><use x=\"142.1875\" xlink:href=\"#DejaVuSans-73\"/><use x=\"194.287109\" xlink:href=\"#DejaVuSans-65\"/><use x=\"255.810547\" xlink:href=\"#DejaVuSans-72\"/><use x=\"296.923828\" xlink:href=\"#DejaVuSans-76\"/><use x=\"356.103516\" xlink:href=\"#DejaVuSans-61\"/><use x=\"417.382812\" xlink:href=\"#DejaVuSans-62\"/><use x=\"480.859375\" xlink:href=\"#DejaVuSans-6c\"/><use x=\"508.642578\" xlink:href=\"#DejaVuSans-65\"/><use x=\"570.166016\" xlink:href=\"#DejaVuSans-73\"/></g><defs><path id=\"8ab080195b3\" d=\"m0 0h-3.5\" stroke=\"#000000\" stroke-width=\".8\"/></defs><use x=\"43.78125\" y=\"258.96822\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#8ab080195b3\"/><g transform=\"translate(20.878 262.77) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-30\" transform=\"scale(.015625)\" d=\"m2034 4250q-487 0-733-480-245-479-245-1442 0-959 245-1439 246-480 733-480 491 0 736 480 246 480 246 1439 0 963-246 1442-245 480-736 480zm0 500q785 0 1199-621 414-620 414-1801 0-1178-414-1799-414-620-1199-620-784 0-1198 620-414 621-414 1799 0 1181 414 1801 414 621 1198 621z\"/><path id=\"DejaVuSans-2e\" transform=\"scale(.015625)\" d=\"m684 794h660v-794h-660v794z\"/></defs><use xlink:href=\"#DejaVuSans-30\"/><use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/><use x=\"95.410156\" xlink:href=\"#DejaVuSans-30\"/></g><use x=\"43.78125\" y=\"214.717696\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#8ab080195b3\"/><g transform=\"translate(20.878 218.52) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-32\" transform=\"scale(.015625)\" d=\"m1228 531h2203v-531h-2962v531q359 372 979 998 621 627 780 809 303 340 423 576 121 236 121 464 0 372-261 606-261 235-680 235-297 0-627-103-329-103-704-313v638q381 153 712 231 332 78 607 78 725 0 1156-363 431-362 431-968 0-288-108-546-107-257-392-607-78-91-497-524-418-433-1181-1211z\"/></defs><use xlink:href=\"#DejaVuSans-30\"/><use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/><use x=\"95.410156\" xlink:href=\"#DejaVuSans-32\"/></g><use x=\"43.78125\" y=\"170.467171\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#8ab080195b3\"/><g transform=\"translate(20.878 174.27) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-34\" transform=\"scale(.015625)\" d=\"m2419 4116-1594-2491h1594v2491zm-166 550h794v-3041h666v-525h-666v-1100h-628v1100h-2106v609l1940 2957z\"/></defs><use xlink:href=\"#DejaVuSans-30\"/><use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/><use x=\"95.410156\" xlink:href=\"#DejaVuSans-34\"/></g><use x=\"43.78125\" y=\"126.216646\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#8ab080195b3\"/><g transform=\"translate(20.878 130.02) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-36\" transform=\"scale(.015625)\" d=\"m2113 2584q-425 0-674-291-248-290-248-796 0-503 248-796 249-292 674-292t673 292q248 293 248 796 0 506-248 796-248 291-673 291zm1253 1979v-575q-238 112-480 171-242 60-480 60-625 0-955-422-329-422-376-1275 184 272 462 417 279 145 613 145 703 0 1111-427 408-426 408-1160 0-719-425-1154-425-434-1131-434-810 0-1238 620-428 621-428 1799 0 1106 525 1764t1409 658q238 0 480-47t505-140z\"/></defs><use xlink:href=\"#DejaVuSans-30\"/><use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/><use x=\"95.410156\" xlink:href=\"#DejaVuSans-36\"/></g><use x=\"43.78125\" y=\"81.966121\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#8ab080195b3\"/><g transform=\"translate(20.878 85.765) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-38\" transform=\"scale(.015625)\" d=\"m2034 2216q-450 0-708-241-257-241-257-662 0-422 257-663 258-241 708-241t709 242q260 243 260 662 0 421-258 662-257 241-711 241zm-631 268q-406 100-633 378-226 279-226 679 0 559 398 884 399 325 1092 325 697 0 1094-325t397-884q0-400-227-679-226-278-629-378 456-106 710-416 255-309 255-755 0-679-414-1042-414-362-1186-362-771 0-1186 362-414 363-414 1042 0 446 256 755 257 310 713 416zm-231 997q0-362 226-565 227-203 636-203 407 0 636 203 230 203 230 565 0 363-230 566-229 203-636 203-409 0-636-203-226-203-226-566z\"/></defs><use xlink:href=\"#DejaVuSans-30\"/><use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/><use x=\"95.410156\" xlink:href=\"#DejaVuSans-38\"/></g><use x=\"43.78125\" y=\"37.715596\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#8ab080195b3\"/><g transform=\"translate(20.878 41.515) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-31\" transform=\"scale(.015625)\" d=\"m794 531h1031v3560l-1122-225v575l1116 225h631v-4135h1031v-531h-2687v531z\"/></defs><use xlink:href=\"#DejaVuSans-31\"/><use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/><use x=\"95.410156\" xlink:href=\"#DejaVuSans-30\"/></g><g transform=\"translate(14.798 156.59) rotate(-90) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-56\" transform=\"scale(.015625)\" d=\"m1831 0-1781 4666h659l1479-3928 1481 3928h656l-1778-4666h-716z\"/><path id=\"DejaVuSans-75\" transform=\"scale(.015625)\" d=\"m544 1381v2119h575v-2097q0-497 193-746 194-248 582-248 465 0 735 297 271 297 271 810v1984h575v-3500h-575v538q-209-319-486-474-276-155-642-155-603 0-916 375-312 375-312 1097zm1447 2203z\"/></defs><use xlink:href=\"#DejaVuSans-56\"/><use x=\"60.658203\" xlink:href=\"#DejaVuSans-61\"/><use x=\"121.9375\" xlink:href=\"#DejaVuSans-6c\"/><use x=\"149.720703\" xlink:href=\"#DejaVuSans-75\"/><use x=\"213.099609\" xlink:href=\"#DejaVuSans-65\"/><use x=\"274.623047\" xlink:href=\"#DejaVuSans-73\"/></g><path d=\"m60.014 255.58 64.931 2.7736 64.931-5.3777 64.931 8.2419 64.931-241.92 64.931 15.233\" clip-path=\"url(#ad151e343b8)\" fill=\"none\" stroke=\"#1f77b4\" stroke-linecap=\"square\" stroke-width=\"1.5\"/><defs><path id=\"b459fa79137\" d=\"m0 3c0.79561 0 1.5587-0.3161 2.1213-0.87868 0.56258-0.56258 0.87868-1.3257 0.87868-2.1213s-0.3161-1.5587-0.87868-2.1213c-0.56258-0.56258-1.3257-0.87868-2.1213-0.87868s-1.5587 0.3161-2.1213 0.87868c-0.56258 0.56258-0.87868 1.3257-0.87868 2.1213s0.3161 1.5587 0.87868 2.1213c0.56258 0.56258 1.3257 0.87868 2.1213 0.87868z\" stroke=\"#1f77b4\"/></defs><g clip-path=\"url(#ad151e343b8)\" fill=\"#1f77b4\" stroke=\"#1f77b4\"><use x=\"60.013977\" y=\"255.57831\" xlink:href=\"#b459fa79137\"/><use x=\"124.944886\" y=\"258.351873\" xlink:href=\"#b459fa79137\"/><use x=\"189.875795\" y=\"252.974142\" xlink:href=\"#b459fa79137\"/><use x=\"254.806705\" y=\"261.216\" xlink:href=\"#b459fa79137\"/><use x=\"319.737614\" y=\"19.296\" xlink:href=\"#b459fa79137\"/><use x=\"384.668523\" y=\"34.528939\" xlink:href=\"#b459fa79137\"/></g><path d=\"m43.781 273.31v-266.11\" fill=\"none\" stroke=\"#000000\" stroke-linecap=\"square\" stroke-width=\".8\"/><path d=\"m400.9 273.31v-266.11\" fill=\"none\" stroke=\"#000000\" stroke-linecap=\"square\" stroke-width=\".8\"/><path d=\"m43.781 273.31h357.12\" fill=\"none\" stroke=\"#000000\" stroke-linecap=\"square\" stroke-width=\".8\"/><path d=\"m43.781 7.2h357.12\" fill=\"none\" stroke=\"#000000\" stroke-linecap=\"square\" stroke-width=\".8\"/><defs><clipPath id=\"ad151e343b8\"><rect x=\"43.781\" y=\"7.2\" width=\"357.12\" height=\"266.11\"/></clipPath></defs></svg>"
|
|
],
|
|
"text/plain": [
|
|
"<Figure size 640x480 with 1 Axes>"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"# Plot the result\n",
|
|
"\n",
|
|
"from matplotlib import pyplot as plt\n",
|
|
"\n",
|
|
"values = pub_result.data.evs\n",
|
|
"\n",
|
|
"errors = pub_result.data.stds\n",
|
|
"\n",
|
|
"# plotting graph\n",
|
|
"plt.plot(observables_labels, values, \"-o\")\n",
|
|
"plt.xlabel(\"Observables\")\n",
|
|
"plt.ylabel(\"Values\")\n",
|
|
"plt.show()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "e6a9ba84",
|
|
"metadata": {},
|
|
"source": [
|
|
"Notice that for qubits 0 and 1, the independent expectation values of both X and Z are 0, while the correlations (`XX` and `ZZ`) are 1. This is a hallmark of quantum entanglement."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 8,
|
|
"id": "b8d8e086",
|
|
"metadata": {
|
|
"tags": [
|
|
"remove-cell"
|
|
]
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Make sure the results follow the claim the the previous markdown cell.\n",
|
|
"# This can happen when the device occasionally behaves strangely. If this cell\n",
|
|
"# fails, you may just need to run the notebook again.\n",
|
|
"\n",
|
|
"_results = {obs: val for obs, val in zip(observables_labels, values)}\n",
|
|
"for _label in [\"IZ\", \"IX\", \"ZI\", \"XI\"]:\n",
|
|
" assert abs(_results[_label]) < 0.2\n",
|
|
"for _label in [\"XX\", \"ZZ\"]:\n",
|
|
" assert _results[_label] > 0.8"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "0bc582d8",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Scale to large numbers of qubits\n",
|
|
"\n",
|
|
"In quantum computing, utility-scale work is crucial for making progress in the field. Such work requires computations to be done on a much larger scale; working with circuits that might use over 100 qubits and over 1000 gates. This example demonstrates how you can accomplish utility-scale work on IBM® QPUs by creating and analyzing a 100-qubit GHZ state. It uses the Qiskit patterns workflow and ends by measuring the expectation value $\\langle Z_0 Z_i \\rangle $ for each qubit.\n",
|
|
"\n",
|
|
"### Step 1. Map the problem\n",
|
|
"\n",
|
|
"Write a function that returns a `QuantumCircuit` that prepares an $n$-qubit GHZ state (essentially an extended Bell state), then use that function to prepare a 100-qubit GHZ state and collect the observables to be measured."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 9,
|
|
"id": "2ac02692",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from qiskit import QuantumCircuit\n",
|
|
"\n",
|
|
"\n",
|
|
"def get_qc_for_n_qubit_GHZ_state(n: int) -> QuantumCircuit:\n",
|
|
" \"\"\"This function will create a qiskit.QuantumCircuit (qc) for an n-qubit GHZ state.\n",
|
|
"\n",
|
|
" Args:\n",
|
|
" n (int): Number of qubits in the n-qubit GHZ state\n",
|
|
"\n",
|
|
" Returns:\n",
|
|
" QuantumCircuit: Quantum circuit that generate the n-qubit GHZ state, assuming all qubits start in the 0 state\n",
|
|
" \"\"\"\n",
|
|
" if isinstance(n, int) and n >= 2:\n",
|
|
" qc = QuantumCircuit(n)\n",
|
|
" qc.h(0)\n",
|
|
" for i in range(n - 1):\n",
|
|
" qc.cx(i, i + 1)\n",
|
|
" else:\n",
|
|
" raise Exception(\"n is not a valid input\")\n",
|
|
" return qc\n",
|
|
"\n",
|
|
"\n",
|
|
"# Create a new circuit with two qubits (first argument) and two classical\n",
|
|
"# bits (second argument)\n",
|
|
"n = 100\n",
|
|
"qc = get_qc_for_n_qubit_GHZ_state(n)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "5b3d0d74",
|
|
"metadata": {},
|
|
"source": [
|
|
"Next, map to the operators of interest. This example uses the `ZZ` operators between qubits to examine the behavior as they get farther apart. Increasingly inaccurate (corrupted) expectation values between distant qubits would reveal the level of noise present."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 10,
|
|
"id": "863a4ec9",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text":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|
"source": [
|
|
"from qiskit.quantum_info import SparsePauliOp\n",
|
|
"\n",
|
|
"# ZZII...II, ZIZI...II, ... , ZIII...IZ\n",
|
|
"operator_strings = [\n",
|
|
" \"Z\" + \"I\" * i + \"Z\" + \"I\" * (n - 2 - i) for i in range(n - 1)\n",
|
|
"]\n",
|
|
"print(operator_strings)\n",
|
|
"print(len(operator_strings))\n",
|
|
"\n",
|
|
"operators = [SparsePauliOp(operator) for operator in operator_strings]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "a0b462ce",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Step 2. Optimize the problem for execution on quantum hardware\n",
|
|
"\n",
|
|
"Transform the circuit and observables to match the backend's ISA."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 11,
|
|
"id": "428f05e7",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager\n",
|
|
"from qiskit_ibm_runtime import QiskitRuntimeService\n",
|
|
"\n",
|
|
"# If you did not previously save your credentials, use the following line instead:\n",
|
|
"# service = QiskitRuntimeService(channel=\"ibm_quantum\", token=\"<MY_IBM_QUANTUM_TOKEN>\")\n",
|
|
"service = QiskitRuntimeService()\n",
|
|
"\n",
|
|
"backend = service.least_busy(\n",
|
|
" simulator=False, operational=True, min_num_qubits=100\n",
|
|
")\n",
|
|
"pm = generate_preset_pass_manager(optimization_level=1, backend=backend)\n",
|
|
"\n",
|
|
"isa_circuit = pm.run(qc)\n",
|
|
"isa_operators_list = [op.apply_layout(isa_circuit.layout) for op in operators]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "2d2b5065",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Step 3. Execute on hardware\n",
|
|
"\n",
|
|
"Submit the job and enable error suppression by using a technique to reduce errors called [dynamical decoupling.](../api/qiskit-ibm-runtime/qiskit_ibm_runtime.options.DynamicalDecouplingOptions) The resilience level specifies how much resilience to build against errors. Higher levels generate more accurate results, at the expense of longer processing times. For further explanation of the options set in the following code, see [Configure error mitigation for Qiskit Runtime.](./configure-error-mitigation)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 12,
|
|
"id": "3aaa5025",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from qiskit_ibm_runtime import EstimatorOptions\n",
|
|
"from qiskit_ibm_runtime import EstimatorV2 as Estimator\n",
|
|
"\n",
|
|
"options = EstimatorOptions()\n",
|
|
"options.resilience_level = 1\n",
|
|
"options.dynamical_decoupling.enable = True\n",
|
|
"options.dynamical_decoupling.sequence_type = \"XY4\"\n",
|
|
"\n",
|
|
"# Create an Estimator object\n",
|
|
"estimator = Estimator(backend, options=options)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 13,
|
|
"id": "b4c3d3e7-0a0f-4023-8948-1082e225f46c",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"cva16pjemvv0008541g0\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# Submit the circuit to Estimator\n",
|
|
"job = estimator.run([(isa_circuit, isa_operators_list)])\n",
|
|
"job_id = job.job_id()\n",
|
|
"print(job_id)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "0bc64091",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Step 4. Post-process results\n",
|
|
"\n",
|
|
"After the job completes, plot the results and notice that $\\langle Z_0 Z_i \\rangle$ decreases with increasing $i$, even though in an ideal simulation all $\\langle Z_0 Z_i \\rangle$ should be 1."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 14,
|
|
"id": "de91ebd0",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"image/svg+xml": [
|
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg width=\"408.1pt\" height=\"310.89pt\" version=\"1.1\" viewBox=\"0 0 408.1 310.89\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs><style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style></defs><path d=\"m0 310.89h408.1v-310.89h-408.1z\" fill=\"#ffffff\"/><path d=\"m43.781 273.31h357.12v-266.11h-357.12z\" fill=\"#ffffff\"/><defs><path id=\"74202237dc5\" d=\"m0 0v3.5\" stroke=\"#000000\" stroke-width=\".8\"/></defs><use x=\"56.701176\" y=\"273.312\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#74202237dc5\"/><g transform=\"translate(53.52 287.91) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-30\" transform=\"scale(.015625)\" d=\"m2034 4250q-487 0-733-480-245-479-245-1442 0-959 245-1439 246-480 733-480 491 0 736 480 246 480 246 1439 0 963-246 1442-245 480-736 480zm0 500q785 0 1199-621 414-620 414-1801 0-1178-414-1799-414-620-1199-620-784 0-1198 620-414 621-414 1799 0 1181 414 1801 414 621 1198 621z\"/></defs><use xlink:href=\"#DejaVuSans-30\"/></g><use x=\"122.957205\" y=\"273.312\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#74202237dc5\"/><g transform=\"translate(116.59 287.91) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-32\" transform=\"scale(.015625)\" d=\"m1228 531h2203v-531h-2962v531q359 372 979 998 621 627 780 809 303 340 423 576 121 236 121 464 0 372-261 606-261 235-680 235-297 0-627-103-329-103-704-313v638q381 153 712 231 332 78 607 78 725 0 1156-363 431-362 431-968 0-288-108-546-107-257-392-607-78-91-497-524-418-433-1181-1211z\"/></defs><use xlink:href=\"#DejaVuSans-32\"/><use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/></g><use x=\"189.213235\" y=\"273.312\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#74202237dc5\"/><g transform=\"translate(182.85 287.91) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-34\" transform=\"scale(.015625)\" d=\"m2419 4116-1594-2491h1594v2491zm-166 550h794v-3041h666v-525h-666v-1100h-628v1100h-2106v609l1940 2957z\"/></defs><use xlink:href=\"#DejaVuSans-34\"/><use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/></g><use x=\"255.469265\" y=\"273.312\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#74202237dc5\"/><g transform=\"translate(249.11 287.91) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-36\" transform=\"scale(.015625)\" d=\"m2113 2584q-425 0-674-291-248-290-248-796 0-503 248-796 249-292 674-292t673 292q248 293 248 796 0 506-248 796-248 291-673 291zm1253 1979v-575q-238 112-480 171-242 60-480 60-625 0-955-422-329-422-376-1275 184 272 462 417 279 145 613 145 703 0 1111-427 408-426 408-1160 0-719-425-1154-425-434-1131-434-810 0-1238 620-428 621-428 1799 0 1106 525 1764t1409 658q238 0 480-47t505-140z\"/></defs><use xlink:href=\"#DejaVuSans-36\"/><use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/></g><use x=\"321.725295\" y=\"273.312\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#74202237dc5\"/><g transform=\"translate(315.36 287.91) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-38\" transform=\"scale(.015625)\" d=\"m2034 2216q-450 0-708-241-257-241-257-662 0-422 257-663 258-241 708-241t709 242q260 243 260 662 0 421-258 662-257 241-711 241zm-631 268q-406 100-633 378-226 279-226 679 0 559 398 884 399 325 1092 325 697 0 1094-325t397-884q0-400-227-679-226-278-629-378 456-106 710-416 255-309 255-755 0-679-414-1042-414-362-1186-362-771 0-1186 362-414 363-414 1042 0 446 256 755 257 310 713 416zm-231 997q0-362 226-565 227-203 636-203 407 0 636 203 230 203 230 565 0 363-230 566-229 203-636 203-409 0-636-203-226-203-226-566z\"/></defs><use xlink:href=\"#DejaVuSans-38\"/><use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/></g><use x=\"387.981324\" y=\"273.312\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#74202237dc5\"/><g transform=\"translate(378.44 287.91) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-31\" transform=\"scale(.015625)\" d=\"m794 531h1031v3560l-1122-225v575l1116 225h631v-4135h1031v-531h-2687v531z\"/></defs><use xlink:href=\"#DejaVuSans-31\"/><use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/><use x=\"127.246094\" xlink:href=\"#DejaVuSans-30\"/></g><g transform=\"translate(157.19 301.59) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-44\" transform=\"scale(.015625)\" d=\"m1259 4147v-3628h763q966 0 1414 437 448 438 448 1382 0 937-448 1373t-1414 436h-763zm-631 519h1297q1356 0 1990-564 635-564 635-1764 0-1207-638-1773-637-565-1987-565h-1297v4666z\"/><path id=\"DejaVuSans-69\" transform=\"scale(.015625)\" d=\"m603 3500h575v-3500h-575v3500zm0 1363h575v-729h-575v729z\"/><path id=\"DejaVuSans-73\" transform=\"scale(.015625)\" d=\"m2834 3397v-544q-243 125-506 187-262 63-544 63-428 0-642-131t-214-394q0-200 153-314t616-217l197-44q612-131 870-370t258-667q0-488-386-773-386-284-1061-284-281 0-586 55t-642 164v594q319-166 628-249 309-82 613-82 406 0 624 139 219 139 219 392 0 234-158 359-157 125-692 241l-200 47q-534 112-772 345-237 233-237 639 0 494 350 762 350 269 994 269 318 0 599-47 282-46 519-140z\"/><path id=\"DejaVuSans-74\" transform=\"scale(.015625)\" d=\"m1172 4494v-994h1184v-447h-1184v-1900q0-428 117-550t477-122h590v-481h-590q-666 0-919 248-253 249-253 905v1900h-422v447h422v994h578z\"/><path id=\"DejaVuSans-61\" transform=\"scale(.015625)\" d=\"m2194 1759q-697 0-966-159t-269-544q0-306 202-486 202-179 548-179 479 0 768 339t289 901v128h-572zm1147 238v-1997h-575v531q-197-318-491-470t-719-152q-537 0-855 302-317 302-317 808 0 590 395 890 396 300 1180 300h807v57q0 397-261 614t-733 217q-300 0-585-72-284-72-546-216v532q315 122 612 182 297 61 578 61 760 0 1135-394 375-393 375-1193z\"/><path id=\"DejaVuSans-6e\" transform=\"scale(.015625)\" d=\"m3513 2113v-2113h-575v2094q0 497-194 743-194 247-581 247-466 0-735-297-269-296-269-809v-1978h-578v3500h578v-544q207 316 486 472 280 156 646 156 603 0 912-373 310-373 310-1098z\"/><path id=\"DejaVuSans-63\" transform=\"scale(.015625)\" d=\"m3122 3366v-538q-244 135-489 202t-495 67q-560 0-870-355-309-354-309-995t309-996q310-354 870-354 250 0 495 67t489 202v-532q-241-112-499-168-257-57-548-57-791 0-1257 497-465 497-465 1341 0 856 470 1346 471 491 1290 491 265 0 518-55 253-54 491-163z\"/><path id=\"DejaVuSans-65\" transform=\"scale(.015625)\" d=\"m3597 1894v-281h-2644q38-594 358-905t892-311q331 0 642 81t618 244v-544q-310-131-635-200t-659-69q-838 0-1327 487-489 488-489 1320 0 859 464 1363 464 505 1252 505 706 0 1117-455 411-454 411-1235zm-575 169q-6 471-264 752-258 282-683 282-481 0-770-272t-333-766l2050 4z\"/><path id=\"DejaVuSans-62\" transform=\"scale(.015625)\" d=\"m3116 1747q0 634-261 995t-717 361q-457 0-718-361t-261-995 261-995 718-361q456 0 717 361t261 995zm-1957 1222q182 312 458 463 277 152 661 152 638 0 1036-506 399-506 399-1331t-399-1332q-398-506-1036-506-384 0-661 152-276 152-458 464v-525h-578v4863h578v-1894z\"/><path id=\"DejaVuSans-77\" transform=\"scale(.015625)\" d=\"m269 3500h575l719-2731 715 2731h678l719-2731 716 2731h575l-916-3500h-678l-753 2869-756-2869h-679l-915 3500z\"/><path id=\"DejaVuSans-71\" transform=\"scale(.015625)\" d=\"m947 1747q0-634 261-995t717-361 718 361q263 361 263 995t-263 995q-262 361-718 361t-717-361-261-995zm1959-1222q-181-312-458-464-276-152-664-152-634 0-1033 506-398 507-398 1332t398 1331q399 506 1033 506 388 0 664-152 277-151 458-463v531h575v-4831h-575v1856z\"/><path id=\"DejaVuSans-75\" transform=\"scale(.015625)\" d=\"m544 1381v2119h575v-2097q0-497 193-746 194-248 582-248 465 0 735 297 271 297 271 810v1984h575v-3500h-575v538q-209-319-486-474-276-155-642-155-603 0-916 375-312 375-312 1097zm1447 2203z\"/><path id=\"DejaVuSans-Oblique-69\" transform=\"scale(.015625)\" d=\"m1172 4863h575l-141-729h-575l141 729zm-263-1363h575l-684-3500h-575l684 3500z\"/></defs><use transform=\"translate(0 .015625)\" xlink:href=\"#DejaVuSans-44\"/><use transform=\"translate(77.002 .015625)\" xlink:href=\"#DejaVuSans-69\"/><use transform=\"translate(104.79 .015625)\" xlink:href=\"#DejaVuSans-73\"/><use transform=\"translate(156.88 .015625)\" xlink:href=\"#DejaVuSans-74\"/><use transform=\"translate(196.09 .015625)\" xlink:href=\"#DejaVuSans-61\"/><use transform=\"translate(257.37 .015625)\" xlink:href=\"#DejaVuSans-6e\"/><use transform=\"translate(320.75 .015625)\" xlink:href=\"#DejaVuSans-63\"/><use transform=\"translate(375.73 .015625)\" xlink:href=\"#DejaVuSans-65\"/><use transform=\"translate(437.26 .015625)\" xlink:href=\"#DejaVuSans-20\"/><use transform=\"translate(469.04 .015625)\" xlink:href=\"#DejaVuSans-62\"/><use transform=\"translate(532.52 .015625)\" xlink:href=\"#DejaVuSans-65\"/><use transform=\"translate(594.04 .015625)\" xlink:href=\"#DejaVuSans-74\"/><use transform=\"translate(633.25 .015625)\" xlink:href=\"#DejaVuSans-77\"/><use transform=\"translate(715.04 .015625)\" xlink:href=\"#DejaVuSans-65\"/><use transform=\"translate(776.56 .015625)\" xlink:href=\"#DejaVuSans-65\"/><use transform=\"translate(838.09 .015625)\" xlink:href=\"#DejaVuSans-6e\"/><use transform=\"translate(901.46 .015625)\" xlink:href=\"#DejaVuSans-20\"/><use transform=\"translate(933.25 .015625)\" xlink:href=\"#DejaVuSans-71\"/><use transform=\"translate(996.73 .015625)\" xlink:href=\"#DejaVuSans-75\"/><use transform=\"translate(1060.1 .015625)\" xlink:href=\"#DejaVuSans-62\"/><use transform=\"translate(1123.6 .015625)\" xlink:href=\"#DejaVuSans-69\"/><use transform=\"translate(1151.4 .015625)\" xlink:href=\"#DejaVuSans-74\"/><use transform=\"translate(1190.6 .015625)\" xlink:href=\"#DejaVuSans-73\"/><use transform=\"translate(1242.7 .015625)\" xlink:href=\"#DejaVuSans-20\"/><use transform=\"translate(1274.5 .015625)\" xlink:href=\"#DejaVuSans-Oblique-69\"/></g><defs><path id=\"a2b1e3c4c59\" d=\"m0 0h-3.5\" stroke=\"#000000\" stroke-width=\".8\"/></defs><use x=\"43.78125\" y=\"246.518078\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#a2b1e3c4c59\"/><g transform=\"translate(20.878 250.32) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-2e\" transform=\"scale(.015625)\" d=\"m684 794h660v-794h-660v794z\"/></defs><use xlink:href=\"#DejaVuSans-30\"/><use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/><use x=\"95.410156\" xlink:href=\"#DejaVuSans-30\"/></g><use x=\"43.78125\" y=\"201.073663\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#a2b1e3c4c59\"/><g transform=\"translate(20.878 204.87) scale(.1 -.1)\"><use xlink:href=\"#DejaVuSans-30\"/><use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/><use x=\"95.410156\" xlink:href=\"#DejaVuSans-32\"/></g><use x=\"43.78125\" y=\"155.629247\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#a2b1e3c4c59\"/><g transform=\"translate(20.878 159.43) scale(.1 -.1)\"><use xlink:href=\"#DejaVuSans-30\"/><use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/><use x=\"95.410156\" xlink:href=\"#DejaVuSans-34\"/></g><use x=\"43.78125\" y=\"110.184831\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#a2b1e3c4c59\"/><g transform=\"translate(20.878 113.98) scale(.1 -.1)\"><use xlink:href=\"#DejaVuSans-30\"/><use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/><use x=\"95.410156\" xlink:href=\"#DejaVuSans-36\"/></g><use x=\"43.78125\" y=\"64.740416\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#a2b1e3c4c59\"/><g transform=\"translate(20.878 68.54) scale(.1 -.1)\"><use xlink:href=\"#DejaVuSans-30\"/><use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/><use x=\"95.410156\" xlink:href=\"#DejaVuSans-38\"/></g><use x=\"43.78125\" y=\"19.296\" stroke=\"#000000\" stroke-width=\".8\" xlink:href=\"#a2b1e3c4c59\"/><g transform=\"translate(20.878 23.095) scale(.1 -.1)\"><use xlink:href=\"#DejaVuSans-31\"/><use x=\"63.623047\" xlink:href=\"#DejaVuSans-2e\"/><use x=\"95.410156\" xlink:href=\"#DejaVuSans-30\"/></g><g transform=\"translate(14.798 171.66) rotate(-90) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-27e8\" transform=\"scale(.015625)\" d=\"m572 2006 881 2850h531l-881-2850 881-2850h-531l-881 2850z\"/><path id=\"DejaVuSans-Oblique-5a\" transform=\"scale(.015625)\" d=\"m838 4666h3662l-91-482-3615-3653h2975l-100-531h-3810l91 481 3616 3653h-2828l100 532z\"/><path id=\"DejaVuSans-27e9\" transform=\"scale(.015625)\" d=\"m1925 2006-881-2850h-531l881 2850-881 2850h531l881-2850z\"/><path id=\"DejaVuSans-2f\" transform=\"scale(.015625)\" d=\"m1625 4666h531l-1625-5260h-531l1625 5260z\"/></defs><use transform=\"translate(0 .125)\" xlink:href=\"#DejaVuSans-27e8\"/><use transform=\"translate(39.014 .125)\" xlink:href=\"#DejaVuSans-Oblique-5a\"/><use transform=\"translate(107.52 -16.281) scale(.7)\" xlink:href=\"#DejaVuSans-Oblique-69\"/><use transform=\"translate(129.7 .125)\" xlink:href=\"#DejaVuSans-Oblique-5a\"/><use transform=\"translate(198.21 -16.281) scale(.7)\" xlink:href=\"#DejaVuSans-30\"/><use transform=\"translate(245.48 .125)\" xlink:href=\"#DejaVuSans-27e9\"/><use transform=\"translate(284.49 .125)\" xlink:href=\"#DejaVuSans-2f\"/><use transform=\"translate(318.18 .125)\" xlink:href=\"#DejaVuSans-27e8\"/><use transform=\"translate(357.2 .125)\" xlink:href=\"#DejaVuSans-Oblique-5a\"/><use transform=\"translate(425.7 -16.281) scale(.7)\" xlink:href=\"#DejaVuSans-31\"/><use transform=\"translate(472.97 .125)\" xlink:href=\"#DejaVuSans-Oblique-5a\"/><use transform=\"translate(541.48 -16.281) scale(.7)\" xlink:href=\"#DejaVuSans-30\"/><use transform=\"translate(588.75 .125)\" xlink:href=\"#DejaVuSans-27e9\"/></g><path d=\"m60.014 19.296 3.3128 76.268 3.3128 45.417 3.3128 42.391 3.3128 7.7808 3.3128 17.81 3.3128 12.112 3.3128 4.058 3.3128 9.249 3.3128 7.3814 3.3128 8.4569 3.3128-10.049 3.3128 0.27606 3.3128 8.8522 3.3128-3.8335 3.3128 8.5292 3.3128-10.444 3.3128 2.9666 3.3128-2.3334 3.3128-0.012702 3.3128 5.3823 3.3128-6.5394 3.3128-7.3678 3.3128 4.3376 3.3128 8.5939 3.3128 9.6503 3.3128-8.1579 3.3128-6.1662 3.3128 5.2924 3.3128 7.1015 3.3128-11.208 3.3128 9.2183 3.3128-2.2604 3.3128-1.4788 3.3128 1.8675 3.3128-0.15643 3.3128-10.575 3.3128 5.7116 3.3128-0.52306 3.3128-0.37675 3.3128 7.6277 3.3128 1.3937 3.3128-15.552 3.3128 15.749 3.3128 0.68308 3.3128 3.7595 3.3128-9.1715 3.3128-2.6536 3.3128-5.1582 3.3128 5.1028 3.3128-6.49 3.3128 4.7098 3.3128 6.6513 3.3128 5.0352 3.3128-6.4959 3.3128 9.5073 3.3128-16.633 3.3128 1.9353 3.3128 2.6503 3.3128-1.0445 3.3128-6.5841 3.3128 3.7335 3.3128-11.69 3.3128 4.1662 3.3128 3.9257 3.3128 3.2614 3.3128 4.4549 3.3128-3.0928 3.3128-0.65813 3.3128-1.6091 3.3128-8.4312 3.3128 5.955 3.3128-4.3057 3.3128 6.9243 3.3128 3.5894 3.3128-7.2226 3.3128 4.8992 3.3128 6.5723 3.3128-6.773 3.3128 8.9342 3.3128 3.0092 3.3128 3.2231 3.3128-1.8467 3.3128-16.664 3.3128 10.19 3.3128-0.6542 3.3128 2.6624 3.3128 4.2388 3.3128-15.121 3.3128 9.2987 3.3128-1.4166 3.3128 0.6962 3.3128 2.8512 3.3128-20.739 3.3128 22.002 3.3128-6.7789 3.3128 8.1954 3.3128-6.1119 3.3128-1.3685\" clip-path=\"url(#893fe9f7941)\" fill=\"none\" stroke=\"#1f77b4\" stroke-linecap=\"square\" stroke-width=\"1.5\"/><defs><path id=\"c8b4cf7db5a\" d=\"m0 3c0.79561 0 1.5587-0.3161 2.1213-0.87868 0.56258-0.56258 0.87868-1.3257 0.87868-2.1213s-0.3161-1.5587-0.87868-2.1213c-0.56258-0.56258-1.3257-0.87868-2.1213-0.87868s-1.5587 0.3161-2.1213 0.87868c-0.56258 0.56258-0.87868 1.3257-0.87868 2.1213s0.3161 1.5587 0.87868 2.1213c0.56258 0.56258 1.3257 0.87868 2.1213 0.87868z\" stroke=\"#1f77b4\"/></defs><g clip-path=\"url(#893fe9f7941)\" fill=\"#1f77b4\" stroke=\"#1f77b4\"><use x=\"60.013977\" y=\"19.296\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"63.326779\" y=\"95.564317\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"66.63958\" y=\"140.981466\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"69.952382\" y=\"183.372407\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"73.265183\" y=\"191.153161\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"76.577985\" y=\"208.962724\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"79.890786\" y=\"221.074413\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"83.203588\" y=\"225.132364\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"86.516389\" y=\"234.381334\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"89.829191\" y=\"241.762721\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"93.141992\" y=\"250.219597\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"96.454794\" y=\"240.171028\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"99.767595\" y=\"240.447084\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"103.080397\" y=\"249.299301\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"106.393198\" y=\"245.465819\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"109.706\" y=\"253.995012\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"113.018801\" y=\"243.55144\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"116.331603\" y=\"246.518078\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"119.644404\" y=\"244.184679\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"122.957205\" y=\"244.171977\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"126.270007\" y=\"249.554272\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"129.582808\" y=\"243.014855\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"132.89561\" y=\"235.647007\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"136.208411\" y=\"239.984561\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"139.521213\" y=\"248.578454\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"142.834014\" y=\"258.228787\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"146.146816\" y=\"250.070866\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"149.459617\" y=\"243.904671\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"152.772419\" y=\"249.197072\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"156.08522\" y=\"256.298533\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"159.398022\" y=\"245.090824\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"162.710823\" y=\"254.309079\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"166.023625\" y=\"252.048687\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"169.336426\" y=\"250.56992\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"172.649228\" y=\"252.437463\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"175.962029\" y=\"252.281031\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"179.274831\" y=\"241.706293\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"182.587632\" y=\"247.417886\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"185.900434\" y=\"246.894828\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"189.213235\" y=\"246.518078\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"192.526037\" y=\"254.14577\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"195.838838\" y=\"255.539492\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"199.15164\" y=\"239.987553\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"202.464441\" y=\"255.73628\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"205.777243\" y=\"256.419355\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"209.090044\" y=\"260.178881\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"212.402846\" y=\"251.007335\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"215.715647\" y=\"248.353685\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"219.028449\" y=\"243.195527\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"222.34125\" y=\"248.298301\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"225.654051\" y=\"241.808297\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"228.966853\" y=\"246.518078\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"232.279654\" y=\"253.169408\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"235.592456\" y=\"258.20458\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"238.905257\" y=\"251.70869\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"242.218059\" y=\"261.216\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"245.53086\" y=\"244.582774\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"248.843662\" y=\"246.518078\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"252.156463\" y=\"249.16842\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"255.469265\" y=\"248.123956\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"258.782066\" y=\"241.539813\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"262.094868\" y=\"245.273264\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"265.407669\" y=\"233.583099\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"268.720471\" y=\"237.749254\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"272.033272\" y=\"241.674945\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"275.346074\" y=\"244.936332\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"278.658875\" y=\"249.391202\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"281.971677\" y=\"246.298391\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"285.284478\" y=\"245.640264\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"288.59728\" y=\"244.031127\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"291.910081\" y=\"235.599895\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"295.222883\" y=\"241.554849\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"298.535684\" y=\"237.249171\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"301.848486\" y=\"244.173471\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"305.161287\" y=\"247.762892\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"308.474089\" y=\"240.540279\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"311.78689\" y=\"245.439484\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"315.099692\" y=\"252.011819\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"318.412493\" y=\"245.238839\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"321.725295\" y=\"254.173035\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"325.038096\" y=\"257.182273\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"328.350897\" y=\"260.405368\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"331.663699\" y=\"258.558717\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"334.9765\" y=\"241.894482\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"338.289302\" y=\"252.084756\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"341.602103\" y=\"251.430551\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"344.914905\" y=\"254.092963\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"348.227706\" y=\"258.331804\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"351.540508\" y=\"243.21031\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"354.853309\" y=\"252.509016\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"358.166111\" y=\"251.092435\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"361.478912\" y=\"251.788633\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"364.791714\" y=\"254.639871\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"368.104515\" y=\"233.901017\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"371.417317\" y=\"255.902693\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"374.730118\" y=\"249.12383\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"378.04292\" y=\"257.319239\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"381.355721\" y=\"251.207293\" xlink:href=\"#c8b4cf7db5a\"/><use x=\"384.668523\" y=\"249.838774\" xlink:href=\"#c8b4cf7db5a\"/></g><path d=\"m43.781 273.31v-266.11\" fill=\"none\" stroke=\"#000000\" stroke-linecap=\"square\" stroke-width=\".8\"/><path d=\"m400.9 273.31v-266.11\" fill=\"none\" stroke=\"#000000\" stroke-linecap=\"square\" stroke-width=\".8\"/><path d=\"m43.781 273.31h357.12\" fill=\"none\" stroke=\"#000000\" stroke-linecap=\"square\" stroke-width=\".8\"/><path d=\"m43.781 7.2h357.12\" fill=\"none\" stroke=\"#000000\" stroke-linecap=\"square\" stroke-width=\".8\"/><path d=\"m259.67 29.878h134.23q2 0 2-2v-13.678q0-2-2-2h-134.23q-2 0-2 2v13.678q0 2 2 2z\" fill=\"#ffffff\" opacity=\".8\" stroke=\"#cccccc\"/><path d=\"m261.67 20.298h10 10\" fill=\"none\" stroke=\"#1f77b4\" stroke-linecap=\"square\" stroke-width=\"1.5\"/><use x=\"271.666875\" y=\"20.298437\" fill=\"#1f77b4\" stroke=\"#1f77b4\" xlink:href=\"#c8b4cf7db5a\"/><g transform=\"translate(289.67 23.798) scale(.1 -.1)\"><defs><path id=\"DejaVuSans-2d\" transform=\"scale(.015625)\" d=\"m313 2009h1684v-512h-1684v512z\"/><path id=\"DejaVuSans-47\" transform=\"scale(.015625)\" d=\"m3809 666v1253h-1031v519h1656v-2004q-365-259-806-392-440-133-940-133-1094 0-1712 639-617 640-617 1780 0 1144 617 1783 618 639 1712 639 456 0 867-113 411-112 758-331v-672q-350 297-744 447t-828 150q-857 0-1287-478-429-478-429-1425 0-944 429-1422 430-478 1287-478 334 0 596 58 263 58 472 180z\"/><path id=\"DejaVuSans-48\" transform=\"scale(.015625)\" d=\"m628 4666h631v-1913h2294v1913h631v-4666h-631v2222h-2294v-2222h-631v4666z\"/><path id=\"DejaVuSans-5a\" transform=\"scale(.015625)\" d=\"m359 4666h3666v-482l-2950-3653h3022v-531h-3809v481l2950 3653h-2879v532z\"/></defs><use xlink:href=\"#DejaVuSans-31\"/><use x=\"63.623047\" xlink:href=\"#DejaVuSans-30\"/><use x=\"127.246094\" xlink:href=\"#DejaVuSans-30\"/><use x=\"190.869141\" xlink:href=\"#DejaVuSans-2d\"/><use x=\"226.953125\" xlink:href=\"#DejaVuSans-71\"/><use x=\"290.429688\" xlink:href=\"#DejaVuSans-75\"/><use x=\"353.808594\" xlink:href=\"#DejaVuSans-62\"/><use x=\"417.285156\" xlink:href=\"#DejaVuSans-69\"/><use x=\"445.068359\" xlink:href=\"#DejaVuSans-74\"/><use x=\"484.277344\" xlink:href=\"#DejaVuSans-20\"/><use x=\"516.064453\" xlink:href=\"#DejaVuSans-47\"/><use x=\"593.554688\" xlink:href=\"#DejaVuSans-48\"/><use x=\"668.75\" xlink:href=\"#DejaVuSans-5a\"/><use x=\"737.255859\" xlink:href=\"#DejaVuSans-20\"/><use x=\"769.042969\" xlink:href=\"#DejaVuSans-73\"/><use x=\"821.142578\" xlink:href=\"#DejaVuSans-74\"/><use x=\"860.351562\" xlink:href=\"#DejaVuSans-61\"/><use x=\"921.630859\" xlink:href=\"#DejaVuSans-74\"/><use x=\"960.839844\" xlink:href=\"#DejaVuSans-65\"/></g><defs><clipPath id=\"893fe9f7941\"><rect x=\"43.781\" y=\"7.2\" width=\"357.12\" height=\"266.11\"/></clipPath></defs></svg>"
|
|
],
|
|
"text/plain": [
|
|
"<Figure size 640x480 with 1 Axes>"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"import matplotlib.pyplot as plt\n",
|
|
"from qiskit_ibm_runtime import QiskitRuntimeService\n",
|
|
"\n",
|
|
"# data\n",
|
|
"data = list(range(1, len(operators) + 1)) # Distance between the Z operators\n",
|
|
"result = job.result()[0]\n",
|
|
"values = result.data.evs # Expectation value at each Z operator.\n",
|
|
"values = [\n",
|
|
" v / values[0] for v in values\n",
|
|
"] # Normalize the expectation values to evaluate how they decay with distance.\n",
|
|
"\n",
|
|
"# plotting graph\n",
|
|
"plt.plot(data, values, marker=\"o\", label=\"100-qubit GHZ state\")\n",
|
|
"plt.xlabel(\"Distance between qubits $i$\")\n",
|
|
"plt.ylabel(r\"$\\langle Z_i Z_0 \\rangle / \\langle Z_1 Z_0 \\rangle $\")\n",
|
|
"plt.legend()\n",
|
|
"plt.show()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "0afc307c",
|
|
"metadata": {},
|
|
"source": [
|
|
"The previous plot shows that as the distance between qubits increases, the signal decays because of the presence of noise."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "e7c24c81",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Next steps\n",
|
|
"\n",
|
|
"<Admonition type=\"tip\" title=\"Recommendations\">\n",
|
|
" - Learn how to [build circuits](./map-problem-to-circuits) in more detail.\n",
|
|
" - Try a [tutorial](https://learning.quantum.ibm.com/catalog/tutorials) in IBM Quantum Learning.\n",
|
|
"</Admonition>"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"celltoolbar": "Raw Cell Format",
|
|
"description": "Get started using Qiskit with IBM Quantum hardware in this Hello World example",
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3"
|
|
},
|
|
"title": "Hello world",
|
|
"widgets": {
|
|
"application/vnd.jupyter.widget-state+json": {
|
|
"state": {},
|
|
"version_major": 2,
|
|
"version_minor": 0
|
|
}
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|