qibocal.auto package#
Autocalibration runner.
Submodules#
qibocal.auto.execute module#
Tasks execution.
- class qibocal.auto.execute.Executor(history: History, output: Path, targets: Union[list[Union[str, int]], list[Tuple[Union[str, int], Union[str, int]]], list[tuple[Union[str, int], ...]]], platform: Platform, update: bool = True)[source]#
Bases:
object
Execute a tasks’ graph and tracks its history.
- targets: Union[list[Union[str, int]], list[Tuple[Union[str, int], Union[str, int]]], list[tuple[Union[str, int], ...]]]#
Qubits/Qubit Pairs to be calibrated.
- platform: Platform#
Qubits’ platform.
- qibocal.auto.execute.run(runcard: Runcard, output: Path, mode: ExecutionMode)[source]#
Run runcard and dump to output.
qibocal.auto.history module#
Track execution history.
- class qibocal.auto.history.History[source]#
-
Execution history.
This is not only used for logging and debugging, but it is an actual part of the execution itself, since later routines can retrieve the output of former ones from here.
- clear() None. Remove all items from D. #
- copy() a shallow copy of D #
- fromkeys(value=None, /)#
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)#
Return the value for key if key is in the dictionary, else default.
- items() a set-like object providing a view on D's items #
- keys() a set-like object providing a view on D's keys #
- pop(k[, d]) v, remove specified key and return the corresponding value. #
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()#
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- setdefault(key, default=None, /)#
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- update([E, ]**F) None. Update D from dict/iterable E and F. #
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values() an object providing a view on D's values #
qibocal.auto.mode module#
- class qibocal.auto.mode.ExecutionMode(value)[source]#
Bases:
Flag
Different execution modes
- ACQUIRE = 1#
Peform acquisition only.
- FIT = 2#
Perform fitting only
- qibocal.auto.mode.AUTOCALIBRATION = ExecutionMode.None#
Perform acquisition and fitting.
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'#
Name of the file where data are dumped.
- qibocal.auto.operation.RESULTSFILE = 'results'#
Name of the file where results are dumped.
- qibocal.auto.operation.DEFAULT_PARENT_PARAMETERS = {'nshots': None, 'relaxation_time': None}#
Default values of the parameters of Parameters
- 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.AbstractData(data: dtype[+_ScalarType_co]]]] = None)[source]#
Bases:
object
Abstract data class.
- class qibocal.auto.operation.Data(data: dtype[+_ScalarType_co]]]] = None)[source]#
Bases:
AbstractData
Data resulting from acquisition routine.
- property qubits#
Access qubits from data structure.
- property pairs#
Access qubit pairs ordered alphanumerically from data structure.
- class qibocal.auto.operation.Results[source]#
Bases:
AbstractData
Generic runcard update.
- class qibocal.auto.operation.Routine(acquisition: Callable[[_ParametersT], _DataT], fit: Optional[Callable[[_DataT], _ResultsT]] = None, report: Optional[Callable[[_DataT, _ResultsT], None]] = None, update: Optional[Callable[[_ResultsT, Platform], None]] = None, two_qubit_gates: Optional[bool] = False)[source]#
Bases:
Generic
[_ParametersT
,_DataT
,_ResultsT
]A wrapped calibration routine.
- _is_protocol = False#
- two_qubit_gates: Optional[bool] = False#
Flag to determine whether to allocate list of Qubits or Pairs.
- property parameters_type#
Input parameters type.
- property data_type#
“Data object type return by data acquisition.
- property results_type#
Results object type returned by data acquisition.
- property platform_dependent#
Check if acquisition involves platform.
- property targets_dependent#
Check if acquisition involves qubits.
- class qibocal.auto.operation.DummyPars[source]#
Bases:
Parameters
Dummy parameters.
- class qibocal.auto.operation.DummyData[source]#
Bases:
Data
Dummy data.
- _to_npz(path: Path, filename: str)#
Helper function to use np.savez while converting keys into strings.
- property pairs#
Access qubit pairs ordered alphanumerically from data structure.
- property qubits#
Access qubits from data structure.
- register_qubit(dtype, data_keys, data_dict)#
Store output for single qubit.
- class qibocal.auto.operation.DummyRes[source]#
Bases:
Results
Dummy results.
- qibocal.auto.operation._dummy_acquisition(pars: DummyPars, platform: Platform) DummyData [source]#
Dummy data acquisition.
- qibocal.auto.operation._dummy_update(results: DummyRes, platform: Platform, qubit: Union[str, int, Tuple[Union[str, int], Union[str, int]]]) None [source]#
Dummy update function
- qibocal.auto.operation.dummy_operation = Routine(acquisition=<function _dummy_acquisition>, fit=<function show_logs.<locals>.wrapper>, report=None, update=<function _dummy_update>, two_qubit_gates=False)#
Example of a dummy operation.
qibocal.auto.runcard module#
Specify runcard layout, handles (de)serialization.
- qibocal.auto.runcard.Targets#
Elements to be calibrated by a single protocol.
alias of
Union
[list
[Union
[str
,int
]],list
[Tuple
[Union
[str
,int
],Union
[str
,int
]]],list
[tuple
[Union
[str
,int
], …]]]
- qibocal.auto.runcard.RUNCARD = 'runcard.yml'#
Runcard filename.
- class qibocal.auto.runcard.Action(id: Id, operation: OperationId, targets: Optional[Union[list[Union[str, int]], list[Tuple[Union[str, int], Union[str, int]]], list[tuple[Union[str, int], ...]]]] = None, update: bool = True, parameters: Optional[dict[str, Any]] = None)[source]#
Bases:
object
Action specification in the runcard.
- id: Id#
Action unique identifier.
- operation: OperationId#
Operation to be performed by the executor.
- class qibocal.auto.runcard.Runcard(actions: list[qibocal.auto.runcard.Action], targets: Optional[Union[list[Union[str, int]], list[Tuple[Union[str, int], Union[str, int]]], list[tuple[Union[str, int], ...]]]] = None, backend: str = 'qibolab', platform: str = 'dummy', update: bool = True)[source]#
Bases:
object
Structure of an execution runcard.
- actions: list[qibocal.auto.runcard.Action]#
List of action to be executed.
- targets: Optional[Union[list[Union[str, int]], list[Tuple[Union[str, int], Union[str, int]]], list[tuple[Union[str, int], ...]]]] = None#
Qubits to be calibrated. If None the protocols will be executed on all qubits available in the platform.
- property backend_obj: Backend#
Allocate backend.
- property platform_obj: Platform#
Allocate platform.
qibocal.auto.serialize module#
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.DEFAULT_NSHOTS = 100#
Default number on shots when the platform is not provided.
- qibocal.auto.task.TaskId#
Unique identifier for executed tasks.
- qibocal.auto.task.PLATFORM_DIR = 'platform'#
Folder where platform will be dumped.
- class qibocal.auto.task.Task(action: qibocal.auto.runcard.Action, operation: qibocal.auto.operation.Routine)[source]#
Bases:
object
- property targets: Union[list[Union[str, int]], list[Tuple[Union[str, int], Union[str, int]]], list[tuple[Union[str, int], ...]]]#
Protocol targets.
- property id: Id#
Task Id.
- property parameters#
Inputs parameters for self.operation.
- property update#
Local update parameter.
- run(platform: ~typing.Optional[~qibolab.platform.platform.Platform] = None, targets: ~typing.Union[list[typing.Union[str, int]], list[typing.Tuple[typing.Union[str, int], typing.Union[str, int]]], list[tuple[typing.Union[str, int], ...]]] = <class 'list'>, mode: ~typing.Optional[~qibocal.auto.mode.ExecutionMode] = None, folder: ~typing.Optional[~pathlib.Path] = None)[source]#
- class qibocal.auto.task.Completed(task: Task, folder: Path, _data: Optional[Data] = None, _results: Optional[Results] = None, data_time: float = 0, results_time: float = 0)[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.transpile module#
- qibocal.auto.transpile.execute_transpiled_circuits(circuits: list[qibo.models.circuit.Circuit], qubit_maps: list[list[int]], backend: Backend, initial_states=None, nshots=1000, transpiler: Optional[Passes] = None)[source]#
If the qibolab backend is used, this function pads the circuits in new ones with a number of qubits equal to the one provided by the platform. At the end, the circuits are transpiled, executed and the results returned. The input transpiler is optional, but it should be provided if the backend is qibolab. For the qubit map look
dummy_transpiler()
. This function returns the list of transpiled circuits and the execution results.
- qibocal.auto.transpile.execute_transpiled_circuit(circuit: Circuit, qubit_map: list[int], backend: Backend, initial_state=None, nshots=1000, transpiler: Optional[Passes] = None)[source]#
If the qibolab backend is used, this function pads the circuit in new a one with a number of qubits equal to the one provided by the platform. At the end, the circuit is transpiled, executed and the results returned. The input transpiler is optional, but it should be provided if the backend is qibolab. For the qubit map look
dummy_transpiler()
. This function returns the transpiled circuit and the execution results.