Skip to content

Commit 2e8fbc7

Browse files
authored
Reduce documentation build time and update docs (#1549)
* Reduce number of circuits in jupyter-execute examples where possible (T2 manual, tphi, quantum volume, randomized benchmarking, ramsey_xy) and re-run analysis rather than running a new experiment where possible (visualization tutorial, t2ramsey) * Remove outdated references to qiskit-dynamics * Use AerSimulator rather than a fake backend where possible * Fix misleading description of T2 delay meaning * Fix fit parameter guesses in t2ramsey.rst * Various wording and formatting fixes (print circuit with finite delay instead of 0 delay; fix indentation error in example visualization code; ...) * Remove old Qiskit Pulse warning filters
1 parent 9acc61f commit 2e8fbc7

File tree

12 files changed

+162
-211
lines changed

12 files changed

+162
-211
lines changed

docs/manuals/characterization/t2hahn.rst

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,14 @@ and can analytically extract the desired values.
6363

6464
qubit = 0
6565
conversion_factor = 1e-6 # our delay will be in micro-sec
66-
delays = list(range(0, 50, 1) )
67-
delays = [float(_) * conversion_factor for _ in delays]
66+
delays = list(range(0, 51, 5) )
67+
# Round so that the delay gates in the circuit display does not have trailing 9999's
68+
delays = [round(float(_) * conversion_factor, ndigits=6) for _ in delays]
6869
number_of_echoes = 1
6970

7071
# Create a T2Hahn experiment. Print the first circuit as an example
7172
exp1 = T2Hahn(physical_qubits=(qubit,), delays=delays, num_echoes=number_of_echoes)
72-
print(exp1.circuits()[0])
73+
print(exp1.circuits()[1])
7374

7475

7576
We run the experiment on a simple simulated backend tailored
@@ -118,7 +119,7 @@ curve is expected to decay toward :math:`0.5`, the natural choice for
118119
parameter :math:`B` is :math:`0.5`. When there is no :math:`T_2` error,
119120
we would expect that the probability to measure ``1`` is :math:`100\%`,
120121
therefore we will guess that A is :math:`0.5`. In this experiment,
121-
``t2hahn`` is the parameter of interest. Good estimate for it is the
122+
``t2hahn`` is the parameter of interest. A good estimate for it is the
122123
value computed in previous experiments on this qubit or a similar value
123124
computed for other qubits.
124125

@@ -143,61 +144,35 @@ Number of echoes
143144
----------------
144145

145146
The user can provide the number of echoes that the circuit will perform.
146-
This will determine the amount of delay and echo gates. As the number of
147-
echoes increases, the total time of the circuit will grow. The echoes
147+
This will determine the amount of delay and echo gates.
148+
The echoes
148149
decrease the effects of :math:`T_{1}` noise and frequency inaccuracy
149150
estimation. Due to that, the Hahn Echo experiment improves our estimate
150151
for :math:`T_{2}`. In the following code, we will compare results of the
151152
Hahn experiment with ``0`` echoes and ``1`` echo. The analysis should
152153
fail for the circuit with ``0`` echoes. In order to see it, we will add
153154
frequency to the qubit and see how it affect the estimated :math:`T_2`.
154-
The list ``delays`` is the times provided to each delay gate, not the
155-
total delay time.
156155

157156
.. jupyter-execute::
158157

159158
import numpy as np
160159

161160
qubit2 = 0
162-
# set the desired delays
163-
conversion_factor = 1e-6
164-
165-
# The delays aren't equally spaced due the behavior of the exponential
166-
# decay curve where the change in the result during earlier times is
167-
# larger than later times. In addition, since the total delay is
168-
# 'delay * 2 * num_of_echoes', the construction of the delays for
169-
# each experiment will be different such that their total length
170-
# will be the same.
171-
172-
# Delays for Hahn Echo Experiment with 0 echoes
173-
delays2 = np.append(
174-
(np.linspace(0.0, 51.0, num=26)).astype(float),
175-
(np.linspace(53, 100.0, num=25)).astype(float),
176-
)
177-
178-
delays2 = [float(_) * conversion_factor for _ in delays2]
179-
180-
# Delays for Hahn Echo Experiment with 1 echo
181-
delays3 = np.append(
182-
(np.linspace(0.0, 25.5, num=26)).astype(float),
183-
(np.linspace(26.5, 50, num=25)).astype(float),
184-
)
185-
delays3 = [float(_) * conversion_factor for _ in delays3]
186161

187162
num_echoes = 1
188-
estimated_t2hahn2 = 30 * conversion_factor
163+
estimated_t2hahn2 = 30e-6
189164

190165
# Create a T2Hahn experiment with 0 echoes
191-
exp2_0echoes = T2Hahn((qubit2,), delays2, num_echoes=0)
166+
exp2_0echoes = T2Hahn((qubit2,), delays, num_echoes=0)
192167
exp2_0echoes.analysis.set_options(p0={"amp": 0.5, "tau": estimated_t2hahn2, "base": 0.5})
193-
print("The first circuit of hahn echo experiment with 0 echoes:")
194-
print(exp2_0echoes.circuits()[0])
168+
print("The second circuit of hahn echo experiment with 0 echoes:")
169+
print(exp2_0echoes.circuits()[1])
195170

196171
# Create a T2Hahn experiment with 1 echo. Print the first circuit as an example
197-
exp2_1echoes = T2Hahn((qubit2,), delays3, num_echoes=num_echoes)
172+
exp2_1echoes = T2Hahn((qubit2,), delays, num_echoes=num_echoes)
198173
exp2_1echoes.analysis.set_options(p0={"amp": 0.5, "tau": estimated_t2hahn2, "base": 0.5})
199-
print("The first circuit of hahn echo experiment with 1 echo:")
200-
print(exp2_1echoes.circuits()[0])
174+
print("The second circuit of hahn echo experiment with 1 echo:")
175+
print(exp2_1echoes.circuits()[1])
201176

202177

203178

docs/manuals/characterization/t2ramsey.rst

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,13 @@ computed for other qubits.
117117
.. jupyter-execute::
118118

119119
user_p0={
120-
"A": 0.5,
121-
"T2star": 20e-6,
122-
"f": 110000,
120+
"amp": 0.5,
121+
"tau": 20e-6,
122+
"freq": 110000,
123123
"phi": 0,
124-
"B": 0.5
125-
}
126-
exp_with_p0 = T2Ramsey((qubit,), delays, osc_freq=1e5)
127-
exp_with_p0.analysis.set_options(p0=user_p0)
128-
exp_with_p0.set_transpile_options(scheduling_method='asap')
129-
expdata_with_p0 = exp_with_p0.run(backend=backend, shots=2000, seed_simulator=101)
124+
"base": 0.5
125+
}
126+
expdata_with_p0 = exp1.analysis.run(expdata1, p0=user_p0)
130127
expdata_with_p0.block_for_results()
131128

132129
# Display fit figure

docs/manuals/characterization/tphi.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ From the :math:`T_1` and :math:`T_2` estimates, we compute the results for
4545
backend = AerSimulator.from_backend(FakePerth(), noise_model=noise_model)
4646

4747
# Time intervals to wait before measurement for t1 and t2
48-
delays_t1 = np.arange(1e-6, 300e-6, 10e-6)
49-
delays_t2 = np.arange(1e-6, 50e-6, 2e-6)
48+
delays_t1 = np.arange(1e-6, 300e-6, 30e-6)
49+
delays_t2 = np.arange(1e-6, 600e-6, 30e-6)
5050

5151
By default, the :class:`.Tphi` experiment will use the Hahn echo experiment for its transverse
5252
relaxation time estimate. We can see that the component experiments of the batch
@@ -65,7 +65,7 @@ Run the experiment and print results:
6565

6666
.. jupyter-execute::
6767

68-
expdata = exp.run(backend=backend, seed_simulator=100).block_for_results()
68+
expdata = exp.run(backend=backend, seed_simulator=100, shots=2000).block_for_results()
6969
display(expdata.analysis_results("T_phi", dataframe=True))
7070

7171
You can also retrieve the results and figures of the constituent experiments. :class:`.T1`:
@@ -88,19 +88,20 @@ experiment:
8888

8989
.. jupyter-execute::
9090

91+
delays_t2ramsey = np.arange(1e-6, 200e-6, 10e-6)
9192
exp = Tphi(physical_qubits=(0,),
9293
delays_t1=delays_t1,
93-
delays_t2=delays_t2,
94+
delays_t2=delays_t2ramsey,
9495
t2type="ramsey",
95-
osc_freq=1e5)
96+
osc_freq=15e3)
9697

9798
exp.component_experiment(1).circuits()[-1].draw(output="mpl", style="iqp")
9899

99100
Run and display results:
100101

101102
.. jupyter-execute::
102103

103-
expdata = exp.run(backend=backend, seed_simulator=100).block_for_results()
104+
expdata = exp.run(backend=backend, seed_simulator=100, shots=2000).block_for_results()
104105
display(expdata.analysis_results("T_phi", dataframe=True))
105106
display(expdata.figure(1))
106107

docs/manuals/verification/quantum_volume.rst

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ probability` > 2/3 with confidence level > 0.977 (corresponding to
2525
z_value = 2), and at least 100 trials have been ran.
2626

2727
.. note::
28-
This tutorial requires the :external+qiskit_aer:doc:`qiskit-aer <index>` and :external+qiskit_ibm_runtime:doc:`qiskit-ibm-runtime <index>`
29-
packages to run simulations. You can install them with ``python -m pip
30-
install qiskit-aer qiskit-ibm-runtime``.
28+
This tutorial requires the :external+qiskit_aer:doc:`qiskit-aer <index>`
29+
package to run simulations. You can install it with ``python -m pip
30+
install qiskit-aer``.
3131

3232
.. jupyter-execute::
3333

@@ -36,9 +36,13 @@ z_value = 2), and at least 100 trials have been ran.
3636

3737
# For simulation
3838
from qiskit_aer import AerSimulator
39-
from qiskit_ibm_runtime.fake_provider import FakeSydneyV2
40-
41-
backend = AerSimulator.from_backend(FakeSydneyV2())
39+
from qiskit_aer.noise import NoiseModel, depolarizing_error
40+
41+
noise_model = NoiseModel()
42+
noise_model.add_all_qubit_quantum_error(depolarizing_error(5e-4, 1), ["sx", "x"])
43+
noise_model.add_all_qubit_quantum_error(depolarizing_error(0, 1), ["rz"])
44+
noise_model.add_all_qubit_quantum_error(depolarizing_error(1e-2, 2), ["cx"])
45+
backend = AerSimulator(noise_model=noise_model, seed_simulator=42)
4246

4347
QV experiment
4448
-------------
@@ -70,7 +74,7 @@ The analysis results of the QV Experiment are:
7074

7175
- The mean heavy-output probabilities (HOP) and standard deviation
7276

73-
- The calculated quantum volume, which will be None if the experiment
77+
- The calculated quantum volume, which will be 1 if the experiment
7478
does not pass the threshold
7579

7680
Extra data included in the analysis results includes
@@ -114,7 +118,7 @@ re-running the experiment.
114118

115119
.. jupyter-execute::
116120

117-
qv_exp.set_experiment_options(trials=60)
121+
qv_exp.set_experiment_options(trials=10)
118122
expdata2 = qv_exp.run(backend, analysis=None).block_for_results()
119123
expdata2.add_data(expdata.data())
120124
qv_exp.analysis.run(expdata2).block_for_results()
@@ -134,7 +138,7 @@ enhancements might be required (See Ref. [2]_ for details).
134138

135139
.. jupyter-execute::
136140

137-
exps = [QuantumVolume(tuple(range(i)), trials=200) for i in range(3, 6)]
141+
exps = [QuantumVolume(tuple(range(i))) for i in range(3, 5)]
138142

139143
batch_exp = BatchExperiment(exps)
140144
batch_exp.set_transpile_options(optimization_level=3)

docs/manuals/verification/randomized_benchmarking.rst

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ error estimates for the quantum device, by calculating the Error Per Clifford. S
1212
explanation on the RB method, which is based on Refs. [1]_ [2]_.
1313

1414
.. note::
15-
This tutorial requires the :external+qiskit_aer:doc:`qiskit-aer <index>` and :external+qiskit_ibm_runtime:doc:`qiskit-ibm-runtime <index>`
16-
packages to run simulations. You can install them with ``python -m pip
17-
install qiskit-aer qiskit-ibm-runtime``.
15+
This tutorial requires the :external+qiskit_aer:doc:`qiskit-aer <index>`
16+
package to run simulations. You can install it with ``python -m pip
17+
install qiskit-aer``.
1818

1919
.. jupyter-execute::
2020

@@ -25,9 +25,13 @@ explanation on the RB method, which is based on Refs. [1]_ [2]_.
2525

2626
# For simulation
2727
from qiskit_aer import AerSimulator
28-
from qiskit_ibm_runtime.fake_provider import FakePerth
29-
30-
backend = AerSimulator.from_backend(FakePerth())
28+
from qiskit_aer.noise import NoiseModel, depolarizing_error
29+
30+
noise_model = NoiseModel()
31+
noise_model.add_all_qubit_quantum_error(depolarizing_error(5e-3, 1), ["sx", "x"])
32+
noise_model.add_all_qubit_quantum_error(depolarizing_error(0, 1), ["rz"])
33+
noise_model.add_all_qubit_quantum_error(depolarizing_error(5e-2, 2), ["cx"])
34+
backend = AerSimulator(noise_model=noise_model)
3135

3236
Standard RB experiment
3337
----------------------
@@ -51,6 +55,12 @@ in order to generate the RB circuits and run them on a backend:
5155
sequences are constructed by appending additional Clifford samples to
5256
shorter sequences. The default is ``False``
5357

58+
.. note::
59+
In the examples here, the sequence lengths and number of samples are chosen
60+
to be as low as possible while still producing typical results in order to
61+
minimize the simulation times. For accurate results, larger numbers may be
62+
necessary.
63+
5464
The analysis results of the RB Experiment may include:
5565

5666
- ``EPC``: The estimated Error Per Clifford
@@ -101,8 +111,8 @@ interleaved RB experiment will always give you accurate error value :math:`e_i`.
101111

102112
.. jupyter-execute::
103113

104-
lengths = np.arange(1, 800, 200)
105-
num_samples = 10
114+
lengths = [1, 10, 30, 80, 150] + np.arange(200, 1100, 200).tolist()
115+
num_samples = 5
106116
seed = 1010
107117
qubits = [0]
108118

@@ -168,9 +178,9 @@ The EPGs of two-qubit RB are analyzed with the corrected EPC if available.
168178

169179
.. jupyter-execute::
170180

171-
lengths_2_qubit = np.arange(1, 200, 30)
172-
lengths_1_qubit = np.arange(1, 800, 200)
173-
num_samples = 10
181+
lengths_2_qubit = np.arange(1, 80, 10)
182+
lengths_1_qubit = [1, 10, 30, 80, 150] + np.arange(200, 1100, 200).tolist()
183+
num_samples = 5
174184
seed = 1010
175185
qubits = (1, 2)
176186

@@ -266,8 +276,8 @@ Let's run an interleaved RB experiment on two qubits:
266276

267277
.. jupyter-execute::
268278

269-
lengths = np.arange(1, 200, 30)
270-
num_samples = 10
279+
lengths = [1, 2, 4, 8] + np.arange(10, 80, 10).tolist()
280+
num_samples = 3
271281
seed = 1010
272282
qubits = (1, 2)
273283

@@ -278,8 +288,6 @@ Let's run an interleaved RB experiment on two qubits:
278288
int_expdata2 = int_exp2.run(backend).block_for_results()
279289
int_results2 = int_expdata2.analysis_results(dataframe=True)
280290

281-
.. jupyter-execute::
282-
283291
# View result data
284292
display(int_expdata2.figure(0))
285293
display(int_results2)

docs/tutorials/data_processor.rst

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,6 @@ To illustrate the data processing module, we consider an example
6464
in which we measure qubit relaxation with different data levels.
6565
The code below sets up the :class:`.T1` experiment.
6666

67-
.. jupyter-execute::
68-
:hide-code:
69-
70-
import warnings
71-
72-
warnings.filterwarnings(
73-
"ignore",
74-
message=".*Due to the deprecation of Qiskit Pulse.*",
75-
category=DeprecationWarning,
76-
)
77-
warnings.filterwarnings(
78-
"ignore",
79-
message=".*The entire Qiskit Pulse package is being deprecated.*",
80-
category=DeprecationWarning,
81-
)
82-
8367
.. jupyter-execute::
8468

8569
import numpy as np

0 commit comments

Comments
 (0)