Skip to content

Commit

Permalink
adding context
Browse files Browse the repository at this point in the history
  • Loading branch information
DanPuzzuoli committed Sep 24, 2024
1 parent ff7a4a7 commit 6a9408d
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/tutorials/Lindblad_dynamics_simulation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Below, we first set the number of qubits :math:`N` to be simulated, and then pre
single-qubit Pauli operators that will be used in the rest of this tutorial.

.. plot::
:context:
:include-source:

import numpy as np
Expand Down Expand Up @@ -102,6 +103,7 @@ derivatives of parameters, we do not use the :class:`Signal` class in this tutor
tutorials for various generalizations of this approach supported with ``qiskit-dynamics``.

.. plot::
:context:
:include-source:

from qiskit_dynamics import Solver, Signal
Expand Down Expand Up @@ -143,6 +145,7 @@ We now define the initial state for the simulation, the time span to simulate fo
intermediate times for which the solution is requested.

.. plot::
:context:
:include-source:

from qiskit.quantum_info import DensityMatrix
Expand Down Expand Up @@ -179,6 +182,7 @@ observing that this equality holds is a simple and useful verification of the nu
that will be added in the next section.

.. plot::
:context:
:include-source:

n_times = len(sol.y)
Expand Down Expand Up @@ -223,6 +227,7 @@ a mixed state), becoming tilted along :math:`-y`. This complex dependence of the
parameters can be systematically analyzed - we encourage you to try it!

.. plot::
:context:
:include-source:

from qiskit.visualization import plot_bloch_vector
Expand Down
4 changes: 4 additions & 0 deletions docs/tutorials/Rabi_oscillations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ using matrices and :class:`.Signal` instances. For the time-independent :math:`z
signal to a constant, while for the trasverse driving term we setup a harmonic signal.

.. plot::
:context:
:include-source:

import numpy as np
Expand Down Expand Up @@ -64,6 +65,7 @@ We now define the initial state for the simulation, the time span to simulate fo
intermediate times for which the solution is requested, and solve the evolution.

.. plot::
:context:
:include-source:

from qiskit.quantum_info.states import Statevector
Expand Down Expand Up @@ -99,6 +101,7 @@ gates used to manipulate quantum devices - in particular this is a realization o
gate.

.. plot::
:context:
:include-source:

from qiskit.visualization import plot_bloch_vector
Expand Down Expand Up @@ -165,6 +168,7 @@ state vectors and density matrices. The shrinking of the qubit’s state within
to the incoherent evolution can be clearly seen in the plots below.

.. plot::
:context:
:include-source:

Gamma_1 = .8
Expand Down
31 changes: 31 additions & 0 deletions docs/tutorials/dynamics_backend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ when using a JAX solver method. Here we configure JAX to run on CPU in 64 bit mo
array libraries>` for more information.

.. plot::
:context:

# a parallelism warning raised by JAX is being raised due to somethign outside of Dynamics
import warnings
warnings.filterwarnings("ignore", message="os.fork")

.. plot::
:context:
:include-source:

# Configure JAX
Expand Down Expand Up @@ -69,6 +71,7 @@ where
respectively.

.. plot::
:context:
:include-source:

import numpy as np
Expand Down Expand Up @@ -120,6 +123,7 @@ outcomes of :meth:`.DynamicsBackend.run` are independent of the choice of rotati
performance.

.. plot::
:context:
:include-source:

from qiskit_dynamics import Solver
Expand Down Expand Up @@ -149,6 +153,7 @@ Furthermore, note that in the solver options we set the max step size to the pul
variable step solvers from accidentally stepping over pulses in schedules with long idle times.

.. plot::
:context:
:include-source:

from qiskit_dynamics import DynamicsBackend
Expand Down Expand Up @@ -186,6 +191,7 @@ that the usual instructions work on the :class:`.DynamicsBackend`.


.. plot::
:context:
:include-source:

import time
Expand Down Expand Up @@ -221,6 +227,7 @@ that the usual instructions work on the :class:`.DynamicsBackend`.
Visualize one of the schedules.

.. plot::
:context:
:include-source:

schedules[3].draw()
Expand All @@ -229,6 +236,7 @@ Retrieve the counts for one of the experiments as would be done using the result
backend.

.. plot::
:context:
:include-source:

result.get_counts(3)
Expand All @@ -248,6 +256,7 @@ Build a simple circuit. Here we build one consisting of a single Hadamard gate o
followed by measurement.

.. plot::
:context:
:include-source:

from qiskit import QuantumCircuit
Expand All @@ -263,6 +272,7 @@ we are only demonstrating the mechanics of adding a calibration; we have not att
the schedule to implement the Hadamard gate with high fidelity.

.. plot::
:context:
:include-source:

with pulse.build() as h_q0:
Expand All @@ -276,6 +286,7 @@ the schedule to implement the Hadamard gate with high fidelity.
Call run on the circuit, and get counts as usual.

.. plot::
:context:
:include-source:

start_time = time.time()
Expand All @@ -294,6 +305,7 @@ Hadamard gate on qubit :math:`0` to `backend.target`, which impacts how jobs are
backend. See the :class:`~qiskit.transpiler.Target` class documentation for further information.

.. plot::
:context:
:include-source:

from qiskit.circuit.library import HGate
Expand All @@ -305,6 +317,7 @@ Rebuild the same circuit, however this time we do not need to add the calibratio
gate to the circuit object.

.. plot::
:context:
:include-source:

circ2 = QuantumCircuit(1, 1)
Expand All @@ -318,6 +331,7 @@ gate to the circuit object.
print(f"Run time: {time.time() - start_time}")

.. plot::
:context:
:include-source:

result.get_counts(0)
Expand Down Expand Up @@ -348,6 +362,7 @@ To enable running of the single qubit experiments, we add the following to the `
will pass.

.. plot::
:context:
:include-source:

from qiskit.circuit.library import XGate, SXGate, RZGate, CXGate
Expand Down Expand Up @@ -389,6 +404,7 @@ object. Here we use the
template library to initialize our calibrations.

.. plot::
:context:
:include-source:

import pandas as pd
Expand All @@ -406,6 +422,7 @@ Next, run a rough amplitude calibration for ``X`` and ``SX`` gates for both qubi
experiments.

.. plot::
:context:
:include-source:

from qiskit_experiments.library.calibration import RoughXSXAmplitudeCal
Expand All @@ -419,6 +436,7 @@ experiments.
Run the Rabi experiments.

.. plot::
:context:
:include-source:

start_time = time.time()
Expand All @@ -431,18 +449,21 @@ Run the Rabi experiments.
Plot the results.

.. plot::
:context:
:include-source:

rabi0_data.figure(0)

.. plot::
:context:
:include-source:

rabi1_data.figure(0)

Observe the updated parameters for qubit 0.

.. plot::
:context:
:include-source:

pd.DataFrame(**cals.parameters_table(qubit_list=[0, ()], parameters="amp"))
Expand All @@ -454,6 +475,7 @@ Run rough Drag parameter calibration for the ``X`` and ``SX`` gates. This follow
as above.

.. plot::
:context:
:include-source:

from qiskit_experiments.library.calibration import RoughDragCal
Expand All @@ -467,6 +489,7 @@ as above.
cal_drag0.circuits()[5].draw(output="mpl")

.. plot::
:context:
:include-source:

start_time = time.time()
Expand All @@ -477,19 +500,22 @@ as above.
print(f"Run time: {time.time() - start_time}")

.. plot::
:context:
:include-source:

drag0_data.figure(0)


.. plot::
:context:
:include-source:

drag1_data.figure(0)

The updated calibrations object:

.. plot::
:context:
:include-source:

pd.DataFrame(**cals.parameters_table(qubit_list=[0, ()], parameters="amp"))
Expand All @@ -505,6 +531,7 @@ the control channel index used to drive the corresponding cross-resonance intera
required by the experiment to determine which channel to drive for each control-target pair.

.. plot::
:context:
:include-source:

# set the control channel map
Expand All @@ -514,6 +541,7 @@ Build the characterization experiment object, and update gate definitions in ``t
values for the single qubit gates calibrated above.

.. plot::
:context:
:include-source:

from qiskit_experiments.library import CrossResonanceHamiltonian
Expand All @@ -527,13 +555,15 @@ values for the single qubit gates calibrated above.
backend.target.update_from_instruction_schedule_map(cals.get_inst_map())

.. plot::
:context:
:include-source:

cr_ham_experiment.circuits()[10].draw("mpl")

Run the simulation.

.. plot::
:context:
:include-source:

start_time = time.time()
Expand All @@ -544,6 +574,7 @@ Run the simulation.


.. plot::
:context:
:include-source:

data_cr.figure(0)
Loading

0 comments on commit 6a9408d

Please sign in to comment.