You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
``protocol`` is a `Routine <https://qibo.science/qibocal/stable/api-reference/qibocal.auto.html#qibocal.auto.operation.Routine>`_ object which contains all the necessary
31
+
The executor is responsible of running the routines on a platform and eventually store the history of multiple experiments.
32
+
``t1_signal``, that we import, is a :class:`qibocal.auto.operation.Routine` object which contains all the necessary
27
33
methods to execute the experiment.
28
34
29
-
In order to run a protocol the user needs to specify the parameters.
35
+
In order to run an experiment the user needs to specify its parameters.
30
36
The user can check which parameters need to be provided either by checking the
31
37
documentation of the specific protocol or by simply inspecting ``protocol.parameters_type``.
32
-
For ``single_shot_classification`` we can pass just the number of shots
33
-
in the following way:
38
+
For ``t1_signal`` we define the parameters in the following way:
"targets": [0], # we are defining here which qubits to analyze
45
+
"operation": "t1_signal",
46
+
"parameters": {
47
+
"delay_before_readout_start": 0,
48
+
"delay_before_readout_end": 20_000,
49
+
"delay_before_readout_step": 50,
50
+
},
51
+
}
38
52
39
53
40
54
After defining the parameters, the user can perform the acquisition using
41
-
``experiment.acquisition`` which accepts the following parameters:
42
-
43
-
* ``params`` (`experiment.parameters_type <https://qibo.science/qibocal/latest/api-reference/qibocal.auto.html#qibocal.auto.operation.Routine.parameters_type>`_): input parameters for the experiment
44
-
* ``platform`` (`qibolab.platform.Platform <https://qibo.science/qibolab/latest/api-reference/qibolab.html#qibolab.platform.Platform>`_): Qibolab platform class
45
-
* ``targets`` (Union[list[`QubitId <https://qibo.science/qibolab/latest/api-reference/qibolab.html#qibolab.qubits.QubitId>`_],list[`QubitPairId <https://qibo.science/qibolab/latest/api-reference/qibolab.html#qibolab.qubits.QubitPairId>`_], list[list[`QubitId <https://qibo.science/qibolab/latest/api-reference/qibolab.html#qibolab.qubits.QubitId>`_]]]) list with qubits where the acquisition will run
46
-
47
-
and returns the following:
55
+
``executor.run_protocol`` which accepts the following parameters:
48
56
49
-
* ``data`` (`experiment.data_type <https://qibo.science/qibocal/latest/api-reference/qibocal.auto.html#qibocal.auto.operation.Routine.data_type>`_): data acquired
50
-
* ``acquisition_time`` (float): acquisition time on hardware
In this way we have first executed the acquisition part of the experiment and then performed the fit on the acquired data.
56
67
57
68
The user can now use the raw data acquired by the quantum processor to perform
58
69
an arbitrary post-processing analysis. This is one of the main advantages of this API
59
70
compared to the cli execution.
60
71
61
-
The fitting corresponding to the experiment (``experiment.fit``) can be launched in the
62
-
following way:
63
-
64
-
.. code-block:: python
65
-
66
-
fit, fit_time = experiment.fit(data)
67
-
68
-
To be more specific the user should pass as input ``data`` which is of type
69
-
``experiment.data_type`` and the outputs are the following:
70
-
71
-
* ``fit``: (`experiment.results_type <https://qibo.science/qibocal/latest/api-reference/qibocal.auto.html#qibocal.auto.operation.Routine.results_type>`_) input parameters for the experiment
72
-
* ``fit_time`` (float): post-processing time
73
-
74
-
75
-
It is also possible to access the plots and the tables generated in the
76
-
report using ``experiment.report`` which accepts the following parameters:
77
-
78
-
* ``data``: (`experiment.data_type <https://qibo.science/qibocal/latest/api-reference/qibocal.auto.html#qibocal.auto.operation.Routine.data_type>`_) data structure used by ``experiment``
79
-
* ``target`` (dict[`QubitId <https://qibo.science/qibolab/latest/api-reference/qibolab.html#qibolab.qubits.QubitId>`_, `QubitPairId <https://qibo.science/qibolab/latest/api-reference/qibolab.html#qibolab.qubits.QubitPairId>`_]): qubit / qubit pair to be plotted
80
-
* ``fit``: (`experiment.results_type <https://qibo.science/qibocal/latest/api-reference/qibocal.auto.html#qibocal.auto.operation.Routine.results_type>`_): data structure for post-processing used by ``experiment``
* html_content: raw html with additional information usually in the form of a table
92
-
93
-
In our case we get the following figure for qubit 0:
94
-
95
-
.. code-block:: python
96
-
97
-
figs[0]
98
-
99
-
100
-
.. image:: classification_plot.png
101
-
102
-
and we can render the html content in the following way:
72
+
The history, that contains both the raw data (added with :attr:`qibocal.auto.mode.ExecutionMode.ACQUIRE`) and the fit data (added with :attr:`qibocal.auto.mode.ExecutionMode.FIT`) can be accessed:
103
73
104
74
.. code-block:: python
105
75
106
-
import IPython
107
-
IPython.display.HTML(html_content)
76
+
history = executor.history
77
+
t1_res = history["t1_experiment"] # id of the protocol
108
78
109
-
.. image:: classification_table.png
79
+
data = t1_res.data # raw data
80
+
results = t1_res.results # fit data
110
81
82
+
In particular, the history object returns a dictionary that links the id of the experiments with the :class:`qibocal.auto.task.Completed` object
111
83
112
84
How to add a new protocol
113
85
-------------------------
@@ -131,11 +103,11 @@ This approach is flexible enough to allow the data acquisition without performin
131
103
Step by step tutorial
132
104
~~~~~~~~~~~~~~~~~~~~~
133
105
134
-
All protocols are located in ``src/qibocal/protocols/characterization <https://github.com/qiboteam/qibocal/tree/main/src/qibocal/protocols/characterization>``_.
106
+
All protocols are located in :mod:`qibocal.protocols`.
135
107
Suppose that we want to code a protocol to perform a RX rotation for different
136
108
angles.
137
109
138
-
We create a file ``rotate.py`` in ``src/qibocal/protocols/characterization``.
110
+
We create a file ``rotate.py`` in ``src/qibocal/protocols``.
139
111
140
112
141
113
@@ -219,7 +191,7 @@ In the acquisition function we are going to perform the experiment.
@@ -432,17 +404,18 @@ Add routine to `Operation` Enum
432
404
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
433
405
434
406
The last step is to add the routine that we just created
435
-
to the ``Operation`` `Enum` in `src/qibocal/protocols/characterization/__init__.py <https://github.com/qiboteam/qibocal/tree/main/src/qibocal/protocols/characterization/__init__.py>`_:
407
+
to the available protocols in `src/qibocal/protocols/__init__.py <https://github.com/qiboteam/qibocal/tree/main/src/qibocal/protocols/__init__.py>`_:
436
408
437
409
.. code-block:: python
438
410
439
411
# other imports...
440
412
from rotate import rotation
441
413
442
414
443
-
class Operation(Enum):
444
-
### other protocols...
445
-
rotation = rotation
415
+
__all__ = [
416
+
# other protocols....
417
+
"rotation",
418
+
]
446
419
447
420
Write a runcard
448
421
^^^^^^^^^^^^^^^
@@ -459,7 +432,6 @@ To launch the protocol a possible runcard could be the following one:
0 commit comments