Skip to content

Commit

Permalink
Circuit runner tutorial not using proper format (Qiskit#74)
Browse files Browse the repository at this point in the history
* add binary_probabilities

* remove has_service call

* use quasi obj

* fix max execution time
  • Loading branch information
jyu00 authored Sep 29, 2021
1 parent 6477a46 commit 02a6aa5
Showing 1 changed file with 31 additions and 51 deletions.
82 changes: 31 additions & 51 deletions 01_circuit_runner.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,6 @@
"provider = IBMQ.get_provider(project='qiskit-runtime')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "90a4c6ef",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"provider.has_service('runtime')"
]
},
{
"cell_type": "markdown",
"id": "ee1e3511",
Expand All @@ -83,7 +62,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"id": "84785ee9",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -160,7 +139,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"id": "e01c0503",
"metadata": {
"tags": [
Expand All @@ -175,7 +154,7 @@
"<Figure size 839.279x445.48 with 1 Axes>"
]
},
"execution_count": 6,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -197,7 +176,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"id": "f36f8eb8",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -227,7 +206,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"id": "08de9773",
"metadata": {},
"outputs": [],
Expand All @@ -237,7 +216,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"id": "8356e156",
"metadata": {},
"outputs": [],
Expand All @@ -247,7 +226,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"id": "738dbad1",
"metadata": {},
"outputs": [],
Expand All @@ -257,7 +236,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 10,
"id": "4cf377ee",
"metadata": {},
"outputs": [
Expand All @@ -268,7 +247,7 @@
"<Figure size 1080x432 with 1 Axes>"
]
},
"execution_count": 11,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -287,7 +266,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 11,
"id": "3dfd52a7",
"metadata": {},
"outputs": [
Expand All @@ -297,7 +276,7 @@
"0.839082737475692"
]
},
"execution_count": 12,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -318,7 +297,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 12,
"id": "23de57a7",
"metadata": {},
"outputs": [
Expand All @@ -331,7 +310,7 @@
" Description: A runtime program that takes one or more circuits, compiles them, executes them, and optionally applies measurement error mitigation.\n",
" Version: 1\n",
" Creation date: 2021-05-07T00:17:07Z\n",
" Max execution time: 1800\n",
" Max execution time: 28800\n",
" Input parameters:\n",
" - circuits:\n",
" Description: A circuit or a list of circuits.\n",
Expand Down Expand Up @@ -405,7 +384,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 13,
"id": "204aad90",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -433,7 +412,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 14,
"id": "9955d4d3",
"metadata": {},
"outputs": [],
Expand All @@ -443,7 +422,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 15,
"id": "55c59d81",
"metadata": {},
"outputs": [
Expand All @@ -453,7 +432,7 @@
"0.794535071278472"
]
},
"execution_count": 16,
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -474,7 +453,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 16,
"id": "b2c1990e",
"metadata": {},
"outputs": [],
Expand All @@ -485,7 +464,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 17,
"id": "e0b476e8",
"metadata": {},
"outputs": [],
Expand All @@ -503,7 +482,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 18,
"id": "fb8676ac",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -563,14 +542,15 @@
" '111111': 0.4123394393204907}"
]
},
"execution_count": 19,
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"quasi = res3.get_quasiprobabilities()\n",
"quasi"
"quasi_binary = quasi.binary_probabilities()\n",
"quasi_binary"
]
},
{
Expand All @@ -583,7 +563,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 19,
"id": "fd8b7452",
"metadata": {},
"outputs": [
Expand All @@ -599,7 +579,7 @@
],
"source": [
"print(\"Raw expectation value:\", expectation_value(res3.get_counts())[0])\n",
"print(\"Mitigated expectation value:\", expectation_value(quasi)[0])\n",
"print(\"Mitigated expectation value:\", expectation_value(quasi_binary)[0])\n",
"print(\"Exact expectation value:\", expectation_value(exact_dist)[0])"
]
},
Expand All @@ -613,17 +593,17 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 20,
"id": "c5daccf0",
"metadata": {},
"outputs": [],
"source": [
"nearest_probs = quasi.nearest_probability_distribution()"
"nearest_probs = quasi.nearest_probability_distribution().binary_probabilities()"
]
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 21,
"id": "e5c7f20e",
"metadata": {},
"outputs": [
Expand All @@ -634,7 +614,7 @@
"<Figure size 1080x432 with 1 Axes>"
]
},
"execution_count": 22,
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -645,7 +625,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 22,
"id": "32e72f51",
"metadata": {},
"outputs": [
Expand All @@ -655,7 +635,7 @@
"0.9255895675305238"
]
},
"execution_count": 25,
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
Expand Down

0 comments on commit 02a6aa5

Please sign in to comment.