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

Commit 98b1388

Browse files
authored
Merge branch 'master' into master
2 parents 9695208 + 6582fda commit 98b1388

61 files changed

Lines changed: 1157 additions & 580 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ qiskit/basics/Qconfig_IBMQ_experience_staging.py
2525

2626
qiskit/basics/Qconfig_IBMQ_network-dev.py
2727
.DS_Store
28+
29+
.stestr/

.stestr.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[DEFAULT]
2+
test_path=./utils/test

qiskit/advanced/aer/1_aer_provider.ipynb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"* `StatevectorSimulator`: Allows ideal single-shot execution of qiskit circuits and returns the final statevector of the simulator after application\n",
5656
"* `UnitarySimulator`: Allows ideal single-shot execution of qiskit circuits and returns the final unitary matrix of the circuit itself. Note that the circuit cannot contain measure or reset operations for this backend\n",
5757
"\n",
58-
"These backends are found in the `Aer` provider with the names `qasm_simulstor`, `statevector_simulator` and `unitary_simulator` respectively"
58+
"These backends are found in the `Aer` provider with the names `qasm_simulstor`, `statevector_simulator` and `unitary_simulator`, respectively."
5959
]
6060
},
6161
{
@@ -90,7 +90,7 @@
9090
"cell_type": "markdown",
9191
"metadata": {},
9292
"source": [
93-
"The simulator backends can also be directly and may be imported from `qiskit.providers.aer`"
93+
"The simulator backends can also be directly imported from `qiskit.providers.aer`"
9494
]
9595
},
9696
{
@@ -113,8 +113,8 @@
113113
"source": [
114114
"## QasmSimulator\n",
115115
"\n",
116-
"The `QasmSimulator` backend is designed to mimic an actual device. It executes a Qiskit `QuantumCircuit` and returns a count dictionary containing the final values of any classical registers in the circuit. The circuit may contain *gates*\n",
117-
"*measure*, *reset*, *conditionals*, and other advanced simulator options that will be discussed in another notebook.\n",
116+
"The `QasmSimulator` backend is designed to mimic an actual device. It executes a Qiskit `QuantumCircuit` and returns a count dictionary containing the final values of any classical registers in the circuit. The circuit may contain *gates*,\n",
117+
"*measurements*, *resets*, *conditionals*, and other advanced simulator options that will be discussed in another notebook.\n",
118118
"\n",
119119
"### Simulating a quantum circuit\n",
120120
"\n",
@@ -163,7 +163,7 @@
163163
"cell_type": "markdown",
164164
"metadata": {},
165165
"source": [
166-
"### Returning measurements outcomes for each shot\n",
166+
"### Returning measurement outcomes for each shot\n",
167167
"\n",
168168
"The `QasmSimulator` also supports returning a list of measurement outcomes for each individual shot. This is enabled by setting the keyword argument `memory=True` in the `assemble` or `execute` function."
169169
]
@@ -211,10 +211,10 @@
211211
"The `QasmSimulator` allows setting a custom initial statevector for the simulation. This means that all experiments in a Qobj will be executed starting in a state $|\\psi\\rangle$ rather than the all zero state $|0,0,..0\\rangle$. The custom state may be set in the circuit using the `initialize` method.\n",
212212
"\n",
213213
"**Note:**\n",
214-
"* The initial statevector must be a valid quantum state $|\\langle\\psi|\\psi\\rangle|=1$. If not an exception will be raised. \n",
214+
"* The initial statevector must be a valid quantum state $|\\langle\\psi|\\psi\\rangle|=1$. If not, an exception will be raised. \n",
215215
"* The simulator supports this option directly for efficiency, but it can also be unrolled to standard gates for execution on actual devices.\n",
216216
"\n",
217-
"We now demonstate this functionality by setting the simulator to be initialized in the the final Bell-state of the previous example:"
217+
"We now demonstrate this functionality by setting the simulator to be initialized in the the final Bell-state of the previous example:"
218218
]
219219
},
220220
{
@@ -261,7 +261,7 @@
261261
"## StatevectorSimulator\n",
262262
"\n",
263263
"\n",
264-
"The `StatevectorSimulator` executes a single shot of a Qiskit `QuantumCircuit` and returns the final quantum statevector of the simulation. The circuit may contain *gates*, and also *measure*, *reset*, and *conditional* operations.\n",
264+
"The `StatevectorSimulator` executes a single shot of a Qiskit `QuantumCircuit` and returns the final quantum statevector of the simulation. The circuit may contain *gates*, and also *measurements*, *resets*, and *conditional* operations.\n",
265265
"\n",
266266
"### Simulating a quantum circuit\n",
267267
"\n",
@@ -453,11 +453,11 @@
453453
"source": [
454454
"### Setting a custom initial unitary\n",
455455
"\n",
456-
"we may also set an initial state for the `UnitarySimulator`, however this state is an initial *unitary matrix* $U_i$, not a statevector. In this case the return unitary will be $U.U_i$ given by applying the circuit unitary to the initial unitary matrix.\n",
456+
"We may also set an initial state for the `UnitarySimulator`, however this state is an initial *unitary matrix* $U_i$, not a statevector. In this case the returned unitary will be $U.U_i$ given by applying the circuit unitary to the initial unitary matrix.\n",
457457
"\n",
458458
"**Note:**\n",
459-
"* The initial unitary must be a valid unitary matrix $U^\\dagger.U =\\mathbb{1}$. If not an exception will be raised. \n",
460-
"* If a Qobj contains multiple experiments, the initial unitary must be the correct size fo *all* experiments in the Qobj, otherwise an exception will be raised.\n",
459+
"* The initial unitary must be a valid unitary matrix $U^\\dagger.U =\\mathbb{1}$. If not, an exception will be raised. \n",
460+
"* If a `Qobj` contains multiple experiments, the initial unitary must be the correct size for *all* experiments in the `Qobj`, otherwise an exception will be raised.\n",
461461
"\n",
462462
"Let us consider preparing the output unitary of the previous circuit as the initial state for the simulator:"
463463
]

qiskit/advanced/aer/2_device_noise_simulation.ipynb

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
"source": [
2323
"## Introduction\n",
2424
"\n",
25-
"This notebook shows how to use the Qiskit Aer `noise.device` module to automatically generate a noise model for an IBMQ hardware device, and use this model to do noisy simulation of `QuantumCircuits` to study the effects of errors which occur on real devices.\n",
25+
"This notebook shows how to use the Qiskit Aer `noise.device` module to automatically generate a noise model for an IBMQ hardware device, and use this model to do noisy simulations of `QuantumCircuits` to study the effects of errors which occur on real devices.\n",
2626
"\n",
27-
"Note that these automatic models are only a highly simplified approximation of the real errors that occur on actual devices. The study of quantum errors on real devices is an active area of research and we discuss the Qiskit Aer tools for configuring more detailed noise models in another notebook."
27+
"Note, that these automatic models are only a highly simplified approximation of the real errors that occur on actual devices. The study of quantum errors on real devices is an active area of research and we discuss the Qiskit Aer tools for configuring more detailed noise models in another notebook."
2828
]
2929
},
3030
{
@@ -92,7 +92,7 @@
9292
"cell_type": "markdown",
9393
"metadata": {},
9494
"source": [
95-
"We will use the `ibmq_16_melbourne` device for this tutorial. We may get the properties of the backend using the `properties` method, the information in the returned `BackendProperties` object will be used to automatically generate a noise model for the device that can be used by the Qiskit Aer `QasmSimulator`. We will also want to get the `coupling_map` for the device from its `configuration` to use when compiling circuits for simulation to most closely mimic the gates that will be executed on a real device"
95+
"We will use the `ibmq_16_melbourne` device for this tutorial. We may get the properties of the backend using the `properties` method, the information in the returned `BackendProperties` object will be used to automatically generate a noise model for the device that can be used by the Qiskit Aer `QasmSimulator`. We will also want to get the `coupling_map` for the device from its `configuration` to use when compiling circuits for simulation to most closely mimic the gates that will be executed on a real device."
9696
]
9797
},
9898
{
@@ -173,15 +173,15 @@
173173
"\n",
174174
"* **Single-qubit gate errors** consisting of a single qubit depolarizing error followed by a single qubit thermal relaxation error.\n",
175175
"* **Two-qubit gate errors** consisting of a two-qubit depolarizing error followed by single-qubit thermal relaxation errors on both qubits in the gate.\n",
176-
"* **Single-qubit readout errors** on the classical bit value obtained from measurements on individual qubits\n",
176+
"* **Single-qubit readout errors** on the classical bit value obtained from measurements on individual qubits.\n",
177177
"\n",
178178
"For the gate errors the error parameter of the thermal relaxation errors is derived using the `thermal_relaxation_error` function from `aer.noise.errors` module, along with the individual qubit $T_1$ and $T_2$ parameters, and the `gate_time` parameter from the device backend properties. The probability of the depolarizing error is then set so that the combined average gate infidelity from the depolarizing error followed by the thermal relaxation is equal to the `gate_error` value from the backend properties.\n",
179179
"\n",
180180
"For the readout errors the probability that the recorded classical bit value will be flipped from the true outcome after a measurement is given by the qubit `readout_errors`.\n",
181181
"\n",
182182
"Let us construct the device noise model.\n",
183183
"\n",
184-
"**Note:** *Since the devices don't currently provide the gate times for gates we will manually provide them for the gates we are interested in using the optional `gate_times` argument for `basic_device_noise_model`.*"
184+
"**Note:** *Since the devices don't currently provide the gate times for gates we will manually provide them for the gates we are interested in using with the optional `gate_times` argument for `basic_device_noise_model`.*"
185185
]
186186
},
187187
{
@@ -236,7 +236,7 @@
236236
"\n",
237237
"* `noise_model`: This passes the noise model to the `QasmSimulator.run` method for noisy simulation.\n",
238238
"* `basis_gates`: A noise model is defined with respect to specific gates, we must pass these basis gates to the Qiskit compiler so that it compiles the circuit to the correct gates for the noise model. The basis gates of a noise model may be obtained from the `NoiseModel.basis_gates` property.\n",
239-
"* `coupling_map`: We also must make sure we provide the `coupling_map` for the real device so that the compiler will produce a Qobj for the simulator that will match the compiled experiment that can be executed on the real device.\n",
239+
"* `coupling_map`: We also must make sure we provide the `coupling_map` for the real device so that the compiler will produce a `Qobj` for the simulator that will match the compiled experiment that can be executed on the real device.\n",
240240
"\n",
241241
"### Local Simulator"
242242
]
@@ -725,12 +725,40 @@
725725
},
726726
{
727727
"cell_type": "code",
728-
"execution_count": null,
729-
"metadata": {
730-
"collapsed": true
731-
},
732-
"outputs": [],
733-
"source": []
728+
"execution_count": 1,
729+
"metadata": {},
730+
"outputs": [
731+
{
732+
"data": {
733+
"text/html": [
734+
"<h3>Version Information</h3><table><tr><th>Qiskit Software</th><th>Version</th></tr><tr><td>Qiskit</td><td>0.12.0</td></tr><tr><td>Terra</td><td>0.9.0</td></tr><tr><td>Aer</td><td>0.3.0</td></tr><tr><td>Ignis</td><td>0.2.0</td></tr><tr><td>Aqua</td><td>0.6.0</td></tr><tr><td>IBM Q Provider</td><td>0.3.2</td></tr><tr><th>System information</th></tr><tr><td>Python</td><td>3.7.4 (default, Jul 16 2019, 07:12:58) \n",
735+
"[GCC 9.1.0]</td></tr><tr><td>OS</td><td>Linux</td></tr><tr><td>CPUs</td><td>4</td></tr><tr><td>Memory (Gb)</td><td>15.560554504394531</td></tr><tr><td colspan='2'>Sat Sep 21 13:05:40 2019 CEST</td></tr></table>"
736+
],
737+
"text/plain": [
738+
"<IPython.core.display.HTML object>"
739+
]
740+
},
741+
"metadata": {},
742+
"output_type": "display_data"
743+
},
744+
{
745+
"data": {
746+
"text/html": [
747+
"<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, 2019.</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>"
748+
],
749+
"text/plain": [
750+
"<IPython.core.display.HTML object>"
751+
]
752+
},
753+
"metadata": {},
754+
"output_type": "display_data"
755+
}
756+
],
757+
"source": [
758+
"import qiskit.tools.jupyter\n",
759+
"%qiskit_version_table\n",
760+
"%qiskit_copyright"
761+
]
734762
}
735763
],
736764
"metadata": {

qiskit/advanced/aer/3_building_noise_models.ipynb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@
7070
"\n",
7171
"The `aer.noise` module contains Python classes to build customized noise models for simulation. There are three key classes:\n",
7272
"\n",
73-
"1. The `NoiseModel` class which stores a noise model used for noisy simulation \n",
74-
"2. The `QuantumError` class which describes CPTP gate errors. These can be applied\n",
73+
"1. The `NoiseModel` class which stores a noise model used for noisy simulation.\n",
74+
"2. The `QuantumError` class which describes CPTP gate errors. These can be applied:\n",
7575
" * After *gate* or *reset* instructions\n",
7676
" * Before *measure* instructions.\n",
7777
"\n",
@@ -212,7 +212,7 @@
212212
"source": [
213213
"### Converting to and from QuantumChannel operators\n",
214214
" \n",
215-
" We can also convert back and forth between `QuantumError` objects in Qiskit-Aer and `QuantumChannel` objects in Qiskit-Terra"
215+
"We can also convert back and forth between `QuantumError` objects in Qiskit Aer and `QuantumChannel` objects in Qiskit Terra."
216216
]
217217
},
218218
{
@@ -317,7 +317,7 @@
317317
" * $A$ is the *recorded* classical bit value\n",
318318
" * $B$ is the *true* bit value returned from the measurement \n",
319319
" \n",
320-
"E.g. for 1 qubits: $ P(A|B) = [P(A|0), P(A|1)]$"
320+
"E.g. for 1 qubits: $ P(A|B) = [P(A|0), P(A|1)]$."
321321
]
322322
},
323323
{
@@ -355,7 +355,7 @@
355355
"cell_type": "markdown",
356356
"metadata": {},
357357
"source": [
358-
"Readout errors may also be combined using `compose`, `tensor` and `expand` like with quantum errors"
358+
"Readout errors may also be combined using `compose`, `tensor` and `expand` like with quantum errors."
359359
]
360360
},
361361
{
@@ -509,7 +509,7 @@
509509
"* To execute a noisy simulation we pass the noise model object to `QasmSimulator.run` or `execute` using the `noise_model` kwarg.\n",
510510
"* Eg: `qiskit.execute(circuits, QasmSimulator(), noise_model=noise)`\n",
511511
"\n",
512-
"**Important:** *When running a noisy simulation make sure you compile your qobj to the same basis gates as the noise model!*\n",
512+
"**Important:** *When running a noisy simulation make sure you compile your `Qobj` to the same basis gates as the noise model!*\n",
513513
"\n",
514514
"This can be done using `NoiseModel.basis_gates`"
515515
]
@@ -524,7 +524,7 @@
524524
"source": [
525525
"# Noise Model Examples\n",
526526
"\n",
527-
"We will now give some examples of noise models For our demonstrations we wil use a simple test circuit generating a n-qubit GHZ state:"
527+
"We will now give some examples of noise models. For our demonstrations we will use a simple test circuit generating a n-qubit GHZ state:"
528528
]
529529
},
530530
{
@@ -631,8 +631,8 @@
631631
"\n",
632632
"* When applying a single qubit gate, flip the state of the qubit with probability `p_gate1`.\n",
633633
"* When applying a 2-qubit gate apply single-qubit errors to each qubit.\n",
634-
"* When reseting a qubit reset to 1 instead of 0 with probability `p_reset`\n",
635-
"* When measuring a qubit, flip the state of the qubit before with probability `p_meas`."
634+
"* When resetting a qubit reset to 1 instead of 0 with probability `p_reset`.\n",
635+
"* When measuring a qubit, flip the state of the qubit with probability `p_meas`."
636636
]
637637
},
638638
{
@@ -729,10 +729,10 @@
729729
"source": [
730730
"## Example 2: T1/T2 thermal relaxation\n",
731731
"\n",
732-
"* Now consider a more realistic error model based on thermal relaxation with the qubit environment\n",
733-
"* Each qubit parameterized by a thermal relaxation time constant $T_1$ and a dephasing time constant $T_2$.\n",
734-
"* Note that we must have $T_2 \\le 2 T_1$\n",
735-
"* Error rates on instructions are determined by gate time and qubit $T_1$, $T_2$ values"
732+
"Now consider a more realistic error model based on thermal relaxation with the qubit environment:\n",
733+
"* Each qubit is parameterized by a thermal relaxation time constant $T_1$ and a dephasing time constant $T_2$.\n",
734+
"* Note that we must have $T_2 \\le 2 T_1$.\n",
735+
"* Error rates on instructions are determined by gate times and qubit $T_1$, $T_2$ values."
736736
]
737737
},
738738
{

0 commit comments

Comments
 (0)