qibocal.auto package#
Autocalibration runner.
Submodules#
qibocal.auto.draw module#
Drawing utilities for execution graphs.
qibocal.auto.execute module#
Tasks execution.
- class qibocal.auto.execute.Executor(graph: ~qibocal.auto.graph.Graph, history: ~qibocal.auto.history.History, output: ~pathlib.Path, qubits: dict[typing.Union[str, int], qibolab.qubits.Qubit], platform: ~qibolab.platform.Platform, update: bool = True, head: ~typing.Optional[~qibocal.auto.runcard.Id] = None, pending: ~typing.Set[~qibocal.auto.runcard.Id] = <factory>)[source]#
Bases:
object
Execute a tasks’ graph and tracks its history.
- platform: Platform#
Qubits’ platform.
- classmethod load(card: Runcard, output: Path, platform: Optional[Platform] = None, qubits: Optional[dict[Union[str, int], qibolab.qubits.Qubit]] = None, update: bool = True)[source]#
Load execution graph and associated executor from a runcard.
- next() Optional[Id] [source]#
Resolve the next task to be executed.
Returns None if the execution is completed.
- property current#
Retrieve current task, associated to the head pointer.
qibocal.auto.graph module#
Execution graph and navigation utilities.
- class qibocal.auto.graph.Graph(incoming_graph_data=None, **attr)[source]#
Bases:
DiGraph
Execution graph.
- classmethod load(actions: list[dict])[source]#
Load graph from list of actions dump.
Useful to load the graph from its description in a runcard.
- classmethod from_actions(actions: list[qibocal.auto.runcard.Action])[source]#
Load graph from list of actions.
One node is added to the graph for each action, and the edges are created to represent the execution normal flow, according to the action.main and action.next attributes.
- property start: Id#
Retrieve the graph starting point.
Note that this method is potentially unsafe, since it is not checking for the existence of multiple starting points (defined by a node.priority == 0 condition), and trust the graph to be a valid one.
To validate a graph for a single starting point check
qibocal.auto.validate.starting_point()
.
qibocal.auto.history module#
Track execution history.
- class qibocal.auto.history.Completed(task: Task, status: Status, folder: Path, _data: Optional[Data] = None, _results: Optional[Results] = None)[source]#
Bases:
object
A completed task.
- property datapath#
Path contaning data and results file for task.
- property results#
Access task’s results.
- property data#
Access task’s data.
qibocal.auto.operation module#
- qibocal.auto.operation.ParameterValue#
Valid value for a routine and runcard parameter.
- qibocal.auto.operation.Qubits#
Convenient way of passing qubit pairs in the routines.
- qibocal.auto.operation.DATAFILE = 'data.npz'#
Name of the file where data acquired (arrays) by calibration are dumped.
- qibocal.auto.operation.JSONFILE = 'conf.json'#
Name of the file where data acquired (global configuration) by calibration are dumped.
- qibocal.auto.operation.RESULTSFILE = 'results.json'#
Name of the file where results are dumped.
- class qibocal.auto.operation.Parameters[source]#
Bases:
object
Generic action parameters.
Implement parameters as Algebraic Data Types (similar to), by subclassing this marker in actual parameters specification for each calibration routine.
The actual parameters structure is only used inside the routines themselves.
- class qibocal.auto.operation.Data[source]#
Bases:
object
Data resulting from acquisition routine.
- data: dict[typing.Union[tuple[typing.Union[str, int], int], str, int], numpy.ndarray[typing.Any, numpy.dtype[+ScalarType]]]#
Data object to store arrays
- property qubits#
Access qubits from data structure.
- property pairs#
Access qubit pairs ordered alphanumerically from data structure.
- property global_params_dict#
Convert non-arrays attributes into dict.
- class qibocal.auto.operation.Results[source]#
Bases:
object
Generic runcard update.
As for the case of
Parameters
the explicit structure is only useful to fill the specific update, but in this case there should be a generic wayEach field might be annotated with an
update
metadata field, in order to mark them for later use in the runcard:@dataclass class Cmd1Res(Results): res: str = field(metadata=dict(update="myres")) num: int
- class qibocal.auto.operation.Routine(acquisition: Callable[[_ParametersT], _DataT], fit: Optional[Callable[[_DataT], _ResultsT]] = None, report: Optional[Callable[[_DataT, _ResultsT], None]] = None)[source]#
Bases:
Generic
[_ParametersT
,_DataT
,_ResultsT
]A wrapped calibration routine.
- property parameters_type#
Input parameters type.
- property data_type#
“Data object type return by data acquisition.
- property results_type#
“Results object type return by data acquisition.
- property platform_dependent#
Check if acquisition involves platform.
- property qubits_dependent#
Check if acquisition involves qubits.
- class qibocal.auto.operation.DummyPars[source]#
Bases:
Parameters
Dummy parameters.
- qibocal.auto.operation.dummy_operation = Routine(acquisition=<function _dummy_acquisition>, fit=<function _dummy_fit>, report=<function _dummy_report>)#
Example of a dummy operation.
qibocal.auto.runcard module#
Specify runcard layout, handles (de)serialization.
- class qibocal.auto.runcard.Action(id: ~qibocal.auto.runcard.Id, operation: ~typing.Optional[~qibocal.auto.operation.OperationId] = None, main: ~typing.Optional[~qibocal.auto.runcard.Id] = None, next: ~typing.Optional[~typing.Union[list[qibocal.auto.runcard.Id], ~qibocal.auto.runcard.Id]] = None, priority: ~typing.Optional[int] = None, qubits: ~typing.Union[list[typing.Union[str, int]], list[tuple[typing.Union[str, int], typing.Union[str, int]]]] = FieldInfo(default=PydanticUndefined, default_factory=<class 'list'>, extra={}), update: bool = True, parameters: ~typing.Optional[dict[str, typing.Any]] = None)[source]#
Bases:
object
Action specification in the runcard.
- id: Id#
Action unique identifier.
- next: Optional[Union[list[qibocal.auto.runcard.Id], Id]] = None#
Alternative subsequent actions, branching from the current one.
- class qibocal.auto.runcard.Runcard(actions: list[qibocal.auto.runcard.Action], qubits: Union[list[Union[str, int]], list[tuple[Union[str, int], Union[str, int]]]], backend: str = 'qibolab', platform: str = 'dummy')[source]#
Bases:
object
Structure of an execution runcard.
- actions: list[qibocal.auto.runcard.Action]#
- property backend_obj: Backend#
Allocate backend.
- property platform_obj: Platform#
Allocate platform.
qibocal.auto.status module#
Describe the status of a completed task.
Simple and general statuses are defined here, but more of them can be defined by individual calibrations routines, and user code as well:
class PinkFirst(Status):
'''Follow the pink arrow as the next one.'''
@dataclass
class ParametrizedException(Status):
'''Trigger exceptional workflow, passing down a further parameter.
Useful if the handler function is using some kind of threshold, or can
make somehow use of the parameter to decide, but in a way that is not
completely established, so it should not be hardcoded in the status
type.
'''
myvalue: int
@dataclass
class ExceptionWithInput(Status):
'''Pass to next routine as input.'''
routine_x_input: float
In general, statuses can encode a predetermined decision about what to do next, so the decision has been handled by the fitting function, or an open decision, that is left up to the handler function.
qibocal.auto.task module#
Action execution tracker.
- qibocal.auto.task.MAX_PRIORITY = 1000000000#
A number bigger than whatever will be manually typed. But not so insanely big not to fit in a native integer.
- qibocal.auto.task.TaskId#
Unique identifier for executed tasks.
- class qibocal.auto.task.Task(action: qibocal.auto.runcard.Action, iteration: int = 0, qubits: list[typing.Union[str, int]] = <factory>)[source]#
Bases:
object
- property id: Id#
Task Id.
- property operation#
Routine object from Operation Enum.
- property main#
Main node to be executed next.
- property priority#
Priority level.
- property parameters#
Inputs parameters for self.operation.
- property update#
Local update parameter.
- run(platform: Platform, qubits: Union[dict[Union[str, int], qibolab.qubits.Qubit], dict[tuple[Union[str, int], Union[str, int]], qibolab.qubits.Qubit]]) Iterator[Union[Data, Results]] [source]#
Generator functions for data acquisition and fitting:
- Parameters
platform (Platform) – Qibolab’s platform
qubits (Union[Qubits, QubitsPairs]) – Qubit or QubitPairs dict.
- Yields
data (Data) – data acquisition output results (`Results): data fitting output.
qibocal.auto.validate module#
Extra tools to validate an execution graph.
- qibocal.auto.validate.starting_point(graph: Graph)[source]#
Check graph starting point.
Since a graph is designed to work with a unique starting point, the user has to make sure to specify a single one, since the starting point is identified only by a 0 priority (i.e. top-priority).
The execution of a graph with multiple starting points has to be considered undefined behavior.