Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create tutorials #97

Merged
merged 17 commits into from
Jan 24, 2022
Merged
734 changes: 734 additions & 0 deletions docs/tutorials/01_introduction_cloud_runtime.ipynb

Large diffs are not rendered by default.

598 changes: 598 additions & 0 deletions docs/tutorials/02_introduction_legacy_runtime.ipynb

Large diffs are not rendered by default.

334 changes: 334 additions & 0 deletions docs/tutorials/03_backends.ipynb

Large diffs are not rendered by default.

211 changes: 211 additions & 0 deletions docs/tutorials/04_account_management.ipynb

Large diffs are not rendered by default.

705 changes: 705 additions & 0 deletions docs/tutorials/05_uploading_program.ipynb

Large diffs are not rendered by default.

File renamed without changes
File renamed without changes
262 changes: 102 additions & 160 deletions tutorials/qka.ipynb → docs/tutorials/qka.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"source": [
"## Prerequisites\n",
"\n",
"- You must have Qiskit 0.32+ installed.\n",
"- You must have an IBM Quantum Experience account with the ability to upload a Runtime program. You can upload a program if you have access to more than just the open hub/group/project (ibm-q/open/main)."
"- You must have the latest Qiskit installed.\n",
"- You must have either an IBM Cloud or an IBM Quantum account that can access Qiskit Runtime."
]
},
{
Expand Down Expand Up @@ -211,7 +211,7 @@
"source": [
"from qiskit import QuantumCircuit\n",
"from qiskit.test.mock import FakeSantiago\n",
"from qiskit.providers.ibmq.runtime import UserMessenger\n",
"from qiskit_ibm_runtime import UserMessenger\n",
"msg = UserMessenger()\n",
"backend = FakeSantiago()"
]
Expand Down Expand Up @@ -240,7 +240,7 @@
{
"data": {
"text/plain": [
"array([0.974614 , 1. , 0.02428596])"
"array([0.97984243, 1. , 0.02518419])"
]
},
"execution_count": 4,
Expand Down Expand Up @@ -281,7 +281,7 @@
},
{
"cell_type": "code",
"execution_count": 297,
"execution_count": 5,
"id": "cdb8037d",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -357,44 +357,37 @@
"We are now in a position to upload the program. To do so we first uncomment and excute the line `%%writefile sample_expval.py` giving use the `sample_expval.py` file we need to upload. "
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "935a21d6",
"metadata": {},
"outputs": [],
"source": [
"from qiskit import IBMQ\n",
"IBMQ.load_account();"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "d93c23d6",
"id": "935a21d6",
"metadata": {},
"outputs": [],
"source": [
"provider = IBMQ.get_provider(group='deployed')"
"from qiskit_ibm_runtime import IBMRuntimeService\n",
"\n",
"service = IBMRuntimeService(auth=\"legacy\")"
]
},
{
"cell_type": "code",
"execution_count": 276,
"execution_count": 7,
"id": "59a3e697",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": "'sample-expval-KLGD4Kbn97'"
"text/plain": [
"'sample-expval-RL2YzPQEe1'"
]
},
"execution_count": 276,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"program_id = provider.runtime.upload_program(data='sample_expval.py', metadata=meta)\n",
"program_id = service.upload_program(data='sample_expval.py', metadata=meta)\n",
"program_id"
]
},
Expand All @@ -408,12 +401,12 @@
},
{
"cell_type": "code",
"execution_count": 255,
"execution_count": 8,
"id": "4ec662be",
"metadata": {},
"outputs": [],
"source": [
"#provider.runtime.delete_program(program_id)"
"#service.delete_program(program_id)"
]
},
{
Expand All @@ -428,7 +421,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 9,
"id": "c685ef09",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -484,7 +477,7 @@
" inputs['skip_transpilation'] = skip_transpilation\n",
" inputs['use_measurement_mitigation'] = use_measurement_mitigation\n",
" \n",
" return provider.runtime.run('sample-expval', options=options, inputs=inputs)"
" return service.run(program_id, options=options, inputs=inputs)"
]
},
{
Expand All @@ -494,17 +487,17 @@
"source": [
"### Trying it out\n",
"\n",
"Because we made our program public anyone can try it out. Lets do so here with our previously made GHZ state and running on the simulator."
"Lets try running the program here with our previously made GHZ state and running on the simulator."
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 10,
"id": "b9f2a955",
"metadata": {},
"outputs": [],
"source": [
"backend = provider.backend.ibmq_qasm_simulator\n",
"backend = \"ibmq_qasm_simulator\"\n",
"\n",
"all_zeros_proj = {'0000': 1}\n",
"all_ones_proj = {'1111': 1}\n",
Expand All @@ -513,17 +506,17 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 11,
"id": "beb8550b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0.50012207, 0.49987793, 1. ])"
"array([0.50024414, 0.49975586, 1. ])"
]
},
"execution_count": 9,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -542,7 +535,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 12,
"id": "5494d586",
"metadata": {},
"outputs": [],
Expand All @@ -556,7 +549,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 14,
"id": "2c326f9d",
"metadata": {},
"outputs": [],
Expand All @@ -568,17 +561,17 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 15,
"id": "58d9a637",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0.50415039, 0.49584961, 0.00830078])"
"array([ 0.49206543, 0.50793457, -0.01586914])"
]
},
"execution_count": 12,
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -601,7 +594,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 16,
"id": "778b6a77",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -633,7 +626,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 17,
"id": "20fab8af",
"metadata": {},
"outputs": [],
Expand All @@ -656,7 +649,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 18,
"id": "73d822cc",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -693,17 +686,17 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 20,
"id": "8d692921",
"metadata": {},
"outputs": [],
"source": [
"backend = provider.backend.ibmq_manila"
"backend = \"ibmq_manila\""
]
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 21,
"id": "5c169661",
"metadata": {},
"outputs": [],
Expand All @@ -715,18 +708,20 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 22,
"id": "98f6efd9",
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"array([0.52392578, 0.60400391, 0.57189941, 0.57897949, 0.7734375 ,\n",
" 0.65844727, 0.56225586, 0.73706055, 0.69030762, 0.61193848])"
"array([0.60327148, 0.38464355, 0.49145508, 0.59985352, 0.4375 ,\n",
" 0.40002441, 0.46362305, 0.48803711, 0.44165039, 0.54614258])"
]
},
"execution_count": 37,
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -746,18 +741,18 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 23,
"id": "3f6394d6",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([False, False, False, False, True, False, False, True, True,\n",
"array([False, False, False, False, False, False, False, False, False,\n",
" False])"
]
},
"execution_count": 38,
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -768,14 +763,14 @@
},
{
"cell_type": "code",
"execution_count": 39,
"execution_count": 24,
"id": "0a8fe223",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div style='width: 100%; background-color:#d5d9e0;padding-left: 10px; padding-bottom: 10px; padding-right: 10px; padding-top: 5px'><h3>This code is a part of Qiskit</h3><p>&copy; Copyright IBM 2017, 2021.</p><p>This code is licensed under the Apache License, Version 2.0. You may<br>obtain a copy of this license in the LICENSE.txt file in the root directory<br> of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.<p>Any modifications or derivative works of this code must retain this<br>copyright notice, and modified files need to carry a notice indicating<br>that they have been altered from the originals.</p></div>"
"<div style='width: 100%; background-color:#d5d9e0;padding-left: 10px; padding-bottom: 10px; padding-right: 10px; padding-top: 5px'><h3>This code is a part of Qiskit</h3><p>&copy; Copyright IBM 2017, 2022.</p><p>This code is licensed under the Apache License, Version 2.0. You may<br>obtain a copy of this license in the LICENSE.txt file in the root directory<br> of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.<p>Any modifications or derivative works of this code must retain this<br>copyright notice, and modified files need to carry a notice indicating<br>that they have been altered from the originals.</p></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
Expand All @@ -789,19 +784,11 @@
"from qiskit.tools.jupyter import *\n",
"%qiskit_copyright"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5c482e31",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -815,7 +802,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.7"
"version": "3.8.1"
}
},
"nbformat": 4,
Expand Down
Loading