Skip to content
This repository was archived by the owner on Aug 21, 2023. It is now read-only.

Fix Aer tutorials #1074

Merged
merged 5 commits into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 24 additions & 23 deletions tutorials/simulators/1_aer_provider.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tutorials/simulators/2_device_noise_simulation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.7"
"version": "3.6.8"
},
"varInspector": {
"cols": {
Expand Down
81 changes: 45 additions & 36 deletions tutorials/simulators/3_building_noise_models.ipynb

Large diffs are not rendered by default.

20 changes: 8 additions & 12 deletions tutorials/simulators/4_custom_gate_noise.ipynb

Large diffs are not rendered by default.

187 changes: 85 additions & 102 deletions tutorials/simulators/6_extended_stabilizer_tutorial.ipynb

Large diffs are not rendered by default.

46 changes: 20 additions & 26 deletions tutorials/simulators/7_matrix_product_state_method.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"metadata": {},
"source": [
"## Using the matrix product state simulation method\n",
"The matrix product state simulation method is invoked in the `QasmSimulator` by setting the `simulation_method`. \n",
"The matrix product state simulation method is invoked in the `QasmSimulator` by setting the simulation method. \n",
"Other than that, all operations are controlled by the `QasmSimulator` itself, as in the following example:"
]
},
Expand All @@ -65,7 +65,7 @@
{
"data": {
"text/plain": [
"{'11': 532, '00': 492}"
"{'00': 519, '11': 505}"
]
},
"execution_count": 1,
Expand All @@ -78,7 +78,7 @@
"\n",
"# Import Qiskit\n",
"from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister\n",
"from qiskit import Aer, execute\n",
"from qiskit import execute\n",
"from qiskit.providers.aer import QasmSimulator\n",
"\n",
"# Construct quantum circuit\n",
Expand All @@ -88,13 +88,10 @@
"circ.measure([0,1], [0,1])\n",
"\n",
"# Select the QasmSimulator from the Aer provider\n",
"simulator = Aer.get_backend('qasm_simulator')\n",
"\n",
"# Define the simulation method\n",
"backend_opts_mps = {\"method\":\"matrix_product_state\"}\n",
"simulator = QasmSimulator(method='matrix_product_state')\n",
"\n",
"# Execute and get counts, using the matrix_product_state method\n",
"result = execute(circ, simulator, backend_options=backend_opts_mps).result()\n",
"result = execute(circ, simulator).result()\n",
"counts = result.get_counts(circ)\n",
"counts"
]
Expand All @@ -117,7 +114,6 @@
},
"outputs": [],
"source": [
"from qiskit.extensions.simulator import Snapshot\n",
"from qiskit.extensions.simulator.snapshot import snapshot"
]
},
Expand All @@ -134,7 +130,7 @@
{
"data": {
"text/plain": [
"[(0.7071067811865475+0j), 0j, 0j, (0.7071067811865475+0j)]"
"array([0.70710678+0.j, 0. +0.j, 0. +0.j, 0.70710678+0.j])"
]
},
"execution_count": 3,
Expand All @@ -152,7 +148,7 @@
"circ.measure([0,1], [0,1])\n",
"\n",
"# Execute\n",
"job_sim = execute([circ], QasmSimulator(), backend_options=backend_opts_mps)\n",
"job_sim = execute(circ, simulator)\n",
"result = job_sim.result()\n",
"\n",
"#print the state vector\n",
Expand All @@ -172,7 +168,7 @@
{
"data": {
"text/plain": [
"{'11': 516, '00': 508}"
"{'00': 520, '11': 504}"
]
},
"execution_count": 4,
Expand Down Expand Up @@ -208,14 +204,14 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Time taken: 0.677933931350708 sec\n"
"Time taken: 0.5306055545806885 sec\n"
]
},
{
"data": {
"text/plain": [
"{'11111111111111111111111111111111111111111111111111': 543,\n",
" '00000000000000000000000000000000000000000000000000': 481}"
"{'00000000000000000000000000000000000000000000000000': 484,\n",
" '11111111111111111111111111111111111111111111111111': 540}"
]
},
"execution_count": 5,
Expand All @@ -225,19 +221,17 @@
],
"source": [
"num_qubits = 50\n",
"qr = QuantumRegister(num_qubits)\n",
"cr = ClassicalRegister(num_qubits)\n",
"circ = QuantumCircuit(qr, cr)\n",
"circ = QuantumCircuit(num_qubits, num_qubits)\n",
"\n",
"# Create EPR state\n",
"circ.h(qr[0])\n",
"for i in range (0,num_qubits-1):\n",
" circ.cx(qr[i], qr[i+1])\n",
"circ.h(0)\n",
"for i in range (0, num_qubits-1):\n",
" circ.cx(i, i+1)\n",
"\n",
"# Measure\n",
"circ.measure(qr, cr)\n",
"circ.measure(range(num_qubits), range(num_qubits))\n",
"\n",
"job_sim = execute([circ], QasmSimulator(), backend_options=backend_opts_mps)\n",
"job_sim = execute(circ, simulator)\n",
"result = job_sim.result()\n",
"print(\"Time taken: {} sec\".format(result.time_taken))\n",
"result.get_counts()"
Expand All @@ -256,8 +250,8 @@
{
"data": {
"text/html": [
"<h3>Version Information</h3><table><tr><th>Qiskit Software</th><th>Version</th></tr><tr><td>Qiskit</td><td>0.19.6</td></tr><tr><td>Terra</td><td>0.14.2</td></tr><tr><td>Aer</td><td>0.5.2</td></tr><tr><td>Ignis</td><td>0.3.3</td></tr><tr><td>Aqua</td><td>0.7.3</td></tr><tr><td>IBM Q Provider</td><td>0.7.2</td></tr><tr><th>System information</th></tr><tr><td>Python</td><td>3.8.5 (default, Jul 27 2020, 08:42:51) \n",
"[GCC 10.1.0]</td></tr><tr><td>OS</td><td>Linux</td></tr><tr><td>CPUs</td><td>32</td></tr><tr><td>Memory (Gb)</td><td>125.72603988647461</td></tr><tr><td colspan='2'>Mon Aug 10 13:36:15 2020 EDT</td></tr></table>"
"<h3>Version Information</h3><table><tr><th>Qiskit Software</th><th>Version</th></tr><tr><td>Qiskit</td><td>0.23.0</td></tr><tr><td>Terra</td><td>0.16.0</td></tr><tr><td>Aer</td><td>0.7.0</td></tr><tr><td>Ignis</td><td>0.5.0</td></tr><tr><td>Aqua</td><td>0.8.0</td></tr><tr><td>IBM Q Provider</td><td>0.11.0</td></tr><tr><th>System information</th></tr><tr><td>Python</td><td>3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34) \n",
"[GCC 7.3.0]</td></tr><tr><td>OS</td><td>Linux</td></tr><tr><td>CPUs</td><td>8</td></tr><tr><td>Memory (Gb)</td><td>62.916805267333984</td></tr><tr><td colspan='2'>Thu Nov 05 08:56:38 2020 IST</td></tr></table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
Expand Down Expand Up @@ -309,7 +303,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.6.8"
},
"varInspector": {
"cols": {
Expand Down