qibocal.auto package¶
Autocalibration runner.
Submodules¶
qibocal.auto.execute module¶
Tasks execution.
- qibocal.auto.execute.PLATFORM_DIR = 'platform'¶
Folder where platform will be dumped.
- qibocal.auto.execute._register(name: str, obj)[source]¶
Register object as module.
With a small abuse of the Python module system, the object is registered as a module, with the given name. name may contain dots, cf.
Executor.namefor clarifications about their meaning.Note
This is mainly used to register executors, such that the protocols can be bound to it through the import keyword, in order to construct an intuitive syntax, apparently purely functional, maintaining the context in a single Executor “global” object.
- class qibocal.auto.execute.Executor(history: ~qibocal.auto.history.History, targets: list[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]] | list[~typing.Annotated[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], ~pydantic.functional_validators.BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), ~pydantic.functional_serializers.PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]] | list[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ...]], platform: ~qibocal.calibration.platform.CalibrationPlatform, update: bool = True, name: str | None = None, path: ~pathlib.Path | None = None, meta: ~qibocal.auto.output.Metadata | None = None)[source]¶
Bases:
objectExecute a tasks’ graph and tracks its history.
- targets: list[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]] | list[~typing.Annotated[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], ~pydantic.functional_validators.BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), ~pydantic.functional_serializers.PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]] | list[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ...]]¶
Qubits/Qubit Pairs to be calibrated.
- platform: CalibrationPlatform¶
Qubits’ platform.
- name: str | None = None¶
Symbol for the executor.
This can be used generically to distinguish the executor, but its specific use is to register a module with this name in sys.modules. They can contain dots, ., that are interpreted as usual by the Python module system.
Note
As a special case, mainly used for internal purposes, names starting with . are also allowed, and they are interpreted relative to this package (in the top scope).
- classmethod create(name: str, platform: CalibrationPlatform | str | None = None)[source]¶
Load list of protocols.
- run_protocol(protocol: ~qibocal.auto.operation.Routine, parameters: ~qibocal.auto.task.Action, mode: ~qibocal.auto.mode.ExecutionMode = <ExecutionMode.ACQUIRE|FIT: 3>, output: ~pathlib.Path | None = None) Completed[source]¶
Run single protocol in ExecutionMode mode.
- _wrapped_protocol(protocol: Routine, operation: str)[source]¶
Create a bound protocol.
Returns a closure, already wrapping the current Executor instance, but specific to the protocol chosen. The parameters of this wrapper function maps to protocol’s ones, in particular:
the keyword argument mode is used as the execution mode (defaults to AUTOCALIBRATION)
the keyword argument id is used as the id for the given operation (defaults to protocol identifier, the same used to import and invoke it)
then the protocol specific are resolved, with the following priority:
explicit keyword arguments have the highest priorities
items in the dictionary passed with the keyword parameters
positional arguments, which are associated to protocols parameters in the same order in which they are defined (and documented) in their respective parameters classes
Attention
Despite the priority being clear, it is advised to use only one of the former schemes to pass parameters, to avoid confusion due to unexpected overwritten arguments.
E.g. for:
resonator_spectroscopy(1e7, 1e5, freq_width=1e8)
the freq_width will be 1e8, and 1e7 will be silently overwritten and ignored (as opposed to a regular Python function, where a TypeError would be raised).
The priority defined above is strictly and silently respected, so just pay attention during invocations.
- init(path: ~os.PathLike, force: bool = False, platform: ~qibocal.calibration.platform.CalibrationPlatform | str | None = None, update: bool | None = None, targets: list[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]] | list[~typing.Annotated[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], ~pydantic.functional_validators.BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), ~pydantic.functional_serializers.PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]] | list[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ...]] | None = None)[source]¶
Initialize execution.
- classmethod open(name: str, path: ~os.PathLike, force: bool = False, platform: ~qibocal.calibration.platform.CalibrationPlatform | str | None = None, update: bool | None = None, targets: list[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]] | list[~typing.Annotated[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], ~pydantic.functional_validators.BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), ~pydantic.functional_serializers.PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]] | list[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ...]] | None = None)[source]¶
Enter the execution context.
qibocal.auto.history module¶
Track execution history.
- qibocal.auto.history.HISTORY = 'history.json'¶
File where protocols order is dumped.
- class qibocal.auto.history.History(_tasks: dict[~qibocal.auto.task.Id, list[~qibocal.auto.task.Completed]] = <factory>, _order: list[~qibocal.auto.task.TaskId] = <factory>)[source]¶
Bases:
objectExecution 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.
- _tasks: dict[Id, list[Completed]]¶
List of completed tasks.
Note
Representing the object as a map of sequences makes it smoother to identify the iterations of a given task, since they are already grouped together.
- property _serialized_order: list[str]¶
JSON friendly _order attribute.
_order, which is a list of TaskId objects, is not JSON serializable, it is converted into a list of strings which match the data folder for each protocol.
- items() Iterator[tuple[TaskId, Completed]][source]¶
Consistent iteration over individual tasks and their ids.
qibocal.auto.mode module¶
- class qibocal.auto.mode.ExecutionMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
FlagDifferent execution modes.
- ACQUIRE = 1¶
Peform acquisition only.
- FIT = 2¶
Perform fitting only.
- _generate_next_value_(start, count, last_values)¶
Generate the next value when not given.
name: the name of the member start: the initial start value or None count: the number of existing members last_values: the last value assigned or None
- _numeric_repr_()¶
Return the canonical string representation of the object.
For many object types, including most builtins, eval(repr(obj)) == obj.
- classmethod _iter_member_by_value_(value)¶
Extract all members from the value in definition (i.e. increasing value) order.
- classmethod _iter_member_(value)¶
Extract all members from the value in definition (i.e. increasing value) order.
- classmethod _iter_member_by_def_(value)¶
Extract all members from the value in definition order.
- classmethod _missing_(value)¶
Create a composite member containing all canonical members present in value.
If non-member values are present, result depends on _boundary_ setting.
- _get_value(flag)¶
- _boundary_ = 'strict'¶
- _flag_mask_ = 3¶
- _singles_mask_ = 3¶
- _all_bits_ = 3¶
- _inverted_ = None¶
- qibocal.auto.mode.AUTOCALIBRATION = <ExecutionMode.ACQUIRE|FIT: 3>¶
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.
alias of
dict[Annotated[int|str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode=’left_to_right’)])],Qubit]
- 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:
objectGeneric 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: dict[tuple[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], int] | Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ndarray[tuple[int, ...], dtype[_ScalarType_co]]] = None)[source]¶
Bases:
objectAbstract data class.
- class qibocal.auto.operation.Data(data: dict[tuple[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], int] | Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ndarray[tuple[int, ...], dtype[_ScalarType_co]]] = None)[source]¶
Bases:
AbstractDataData resulting from acquisition routine.
- property qubits: list[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]]¶
Access qubits from data structure.
- property pairs¶
Access qubit pairs from data structure.
- class qibocal.auto.operation.Results[source]¶
Bases:
AbstractDataGeneric runcard update.
- class qibocal.auto.operation.Routine(acquisition: Callable[[_ParametersT], _DataT], fit: Callable[[_DataT], _ResultsT] = None, report: Callable[[_DataT, _ResultsT], None] = None, update: Callable[[_ResultsT, Platform], None] = None, two_qubit_gates: bool | None = False)[source]¶
Bases:
Generic[_ParametersT,_DataT,_ResultsT]A wrapped calibration routine.
- _is_protocol = False¶
- two_qubit_gates: bool | None = 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:
ParametersDummy parameters.
- class qibocal.auto.operation.DummyData[source]¶
Bases:
DataDummy data.
- _to_npz(path: Path, filename: str)¶
Helper function to use np.savez while converting keys into strings.
- property pairs¶
Access qubit pairs from data structure.
- property qubits: list[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]]¶
Access qubits from data structure.
- register_qubit(dtype, data_keys, data_dict)¶
Store output for single qubit.
- class qibocal.auto.operation.DummyRes[source]¶
Bases:
ResultsDummy results.
- qibocal.auto.operation._dummy_acquisition(pars: DummyPars, platform: Platform) DummyData[source]¶
Dummy data acquisition.
- qibocal.auto.operation._dummy_update(results: ~qibocal.auto.operation.DummyRes, platform: ~qibolab._core.platform.platform.Platform, qubit: ~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])] | ~typing.Annotated[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], ~pydantic.functional_validators.BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), ~pydantic.functional_serializers.PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]) 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.output module¶
- class qibocal.auto.output.Versions(other: dict, qibocal: str = '0.2.5')[source]¶
Bases:
objectVersions of the main software used.
- class qibocal.auto.output.TaskStats(acquisition: float, fit: float)[source]¶
Bases:
objectStatistics about task execution.
- class qibocal.auto.output.Metadata(title: str, backend: str, platform: str, start_time: ~datetime.datetime | None, end_time: ~datetime.datetime | None, stats: dict[str, ~qibocal.auto.output.TaskStats], versions: ~qibocal.auto.output.Versions, author: str | None = None, tag: str | None = None, targets: list[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]] | list[~typing.Annotated[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], ~pydantic.functional_validators.BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), ~pydantic.functional_serializers.PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]] | list[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ...]] | None = None)[source]¶
Bases:
objectExecution metadata.
- targets: list[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]] | list[~typing.Annotated[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], ~pydantic.functional_validators.BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), ~pydantic.functional_serializers.PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]] | list[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ...]] | None = None¶
- class qibocal.auto.output.Output(history: History, meta: Metadata, platform: CalibrationPlatform | None = None)[source]¶
Bases:
objectOutput manager.
This object represents the output folder, serializing from and deserialing to it.
- platform: CalibrationPlatform | None = None¶
- static mkdir(path: Path | None = None, force: bool = False) Path[source]¶
Create output directory.
If a path is given and existing, it is overwritten only in the case force is enabled, otherwise an error is thrown. If not already existing, it is just used.
If no path is given, a default one is generated (according to user name and time stamp).
- static update_platform(platform: CalibrationPlatform, path: Path)[source]¶
Dump platform used.
If the original one is not defined, use the current one as the original, else update the new one.
qibocal.auto.runcard module¶
Specify runcard layout, handles (de)serialization.
- qibocal.auto.runcard.RUNCARD = 'runcard.yml'¶
Runcard filename.
- class qibocal.auto.runcard.Runcard(actions: list[~qibocal.auto.task.Action], targets: list[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]] | list[~typing.Annotated[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], ~pydantic.functional_validators.BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), ~pydantic.functional_serializers.PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]] | list[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ...]] | None = None, backend: str = 'qibolab', platform: str = 'mock', update: bool = True)[source]¶
Bases:
objectStructure of an execution runcard.
- targets: list[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]] | list[~typing.Annotated[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], ~pydantic.functional_validators.BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), ~pydantic.functional_serializers.PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]] | list[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ...]] | None = None¶
Qubits to be calibrated.
If None the protocols will be executed on all qubits available in the 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.Targets¶
Elements to be calibrated by a single protocol.
alias of
list[Annotated[int|str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode=’left_to_right’)])]] |list[Annotated[tuple[Annotated[int|str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode=’left_to_right’)])],Annotated[int|str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode=’left_to_right’)])]],BeforeValidator(func=~qibocal.calibration.calibration., json_schema_input_type=PydanticUndefined),PlainSerializer(func=~qibocal.calibration.calibration., return_type=PydanticUndefined, when_used=always)]] |list[tuple[Annotated[int|str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode=’left_to_right’)])], …]]
- class qibocal.auto.task.Action(id: ~qibocal.auto.task.Id, operation: ~qibocal.auto.operation.OperationId, targets: list[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]] | list[~typing.Annotated[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], ~pydantic.functional_validators.BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), ~pydantic.functional_serializers.PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]] | list[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ...]] | None = None, update: bool = True, parameters: dict[str, ~typing.Any] | None = None)[source]¶
Bases:
objectAction specification in the runcard.
- operation: OperationId¶
Operation to be performed by the executor.
- targets: list[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]] | list[~typing.Annotated[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], ~pydantic.functional_validators.BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), ~pydantic.functional_serializers.PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]] | list[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ...]] | None = None¶
Local qubits (optional).
- class qibocal.auto.task.TaskId(id: Id, iteration: int)[source]¶
Bases:
objectUnique identifier for executed tasks.
- qibocal.auto.task.DEFAULT_NSHOTS = 100¶
Default number on shots when the platform is not provided.
- class qibocal.auto.task.Task(action: qibocal.auto.task.Action, operation: qibocal.auto.operation.Routine)[source]¶
Bases:
object- property targets: list[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]] | list[~typing.Annotated[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], ~pydantic.functional_validators.BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), ~pydantic.functional_serializers.PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]] | list[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ...]]¶
Protocol targets.
- property parameters¶
Inputs parameters for self.operation.
- property update¶
Local update parameter.
- run(platform: ~qibolab._core.platform.platform.Platform | None = None, targets: list[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]] | list[~typing.Annotated[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], ~pydantic.functional_validators.BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), ~pydantic.functional_serializers.PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]] | list[tuple[~typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ...]] | None = None, mode: ~qibocal.auto.mode.ExecutionMode | None = None, folder: ~pathlib.Path | None = None) Completed[source]¶
qibocal.auto.transpile module¶
- qibocal.auto.transpile._string_to_integer_qubit_maps(qubit_maps: list[list[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]]], platform: Platform) list[list[int]][source]¶
QubitId can be integers or strings.
pad_circuitonly works with integer qubit IDs, so if the qubit maps contain string IDs, we convert them to integer indices based on the platform’s qubit order.
- qibocal.auto.transpile._pad_circuit(nqubits: int, circuit: Circuit, qubit_map: list[int]) Circuit[source]¶
Pad circuit in a new one with nqubits qubits, according to qubit_map. qubit_map is a list [i, j, k, …], where physical qubit i is mapped into the 0th logical qubit and so on.
- Parameters:
nqubits – The total number of qubits in the new circuit.
circuit – The original quantum circuit to be padded.
qubit_map – A list mapping physical qubits to logical qubits in the new circuit.
- Returns:
A Circuit instance with nqubits qubits, containing the original circuit’s gates mapped according to qubit_map.
- qibocal.auto.transpile._transpile_circuits(circuits: list[Circuit], qubit_maps: list[list[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]]], platform: Platform, transpiler: Passes) list[Circuit][source]¶
Transpile and pad circuits according to the platform.
Apply the transpiler to circuits and pad them in circuits with the same number of qubits in the platform. Before manipulating the circuits, this function check that the qubit_maps contain string ids and in the positive case it remap them in integers, following the ids order provided by the platform.
Note
In this function we are implicitly assume that the qubit ids are all string or all integers.
- Returns:
List of transpiled and padded Circuit instances, one per input circuit.
- qibocal.auto.transpile._validate_gate(gate, qubit_map)[source]¶
Validate measurement gate against qubit map.
- qibocal.auto.transpile._validate_sequence(sequence, readout)[source]¶
Validate measurement sequence against readout results.
- qibocal.auto.transpile._validate_measurement(gate, sequence, qubit_map, readout)[source]¶
Validate measurement gate and sequence consistency.
- qibocal.auto.transpile._counts_with_hardware_averaging(qubit_maps: list[list[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]]], measurement_maps, readout, nshots: int) list[Counter[str]][source]¶
Build Counters when hardware averaging is enabled.
- qibocal.auto.transpile._counts_with_singleshot(qubit_maps: list[list[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]]], measurement_maps, readout) list[Counter[str]][source]¶
Build Counters when single-shot measurements are available.
- qibocal.auto.transpile._execute_circuits(platform: Platform, compiler: Compiler, circuits: list[Circuit], qubit_maps: list[list[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]]], nshots: int, averaging_mode: AveragingMode = AveragingMode.SINGLESHOT) list[Counter[str]][source]¶
Executes multiple quantum circuits with a single communication with the control electronics.
Circuits are unrolled to a single pulse sequence.
- qibocal.auto.transpile.execute_circuits(circuits: list[Circuit], qubit_maps: list[list[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]]], platform: Platform, transpiler: Passes, compiler: Compiler, nshots: int, averaging_mode: AveragingMode = AveragingMode.SINGLESHOT) list[Counter[str]][source]¶
Execute multiple quantum circuits.
Combines
transpile_circuits()andexecute_circuits()into a single call.- Parameters:
circuits – List of quantum circuits to transpile and execute.
qubit_maps – List of qubit maps, one per circuit. Each qubit map maps physical qubit IDs to logical qubit indices.
platform – The platform to transpile circuits for and execute on.
transpiler – The transpiler to apply to the circuits.
compiler – The compiler to use for circuit compilation.
nshots – Number of times to sample from the experiment.
averaging_mode – Averaging mode for measurements. Default is single-shot.
- Returns:
List of measurement outcome as Counter objects, one per circuit. Each Counter maps measurement outcome states as strings (e.g., “01”, “10”) to their occurrence counts. Total counts per counter equals nshots.
Examples
from qibo import Circuit, gates from qibolab import create_platform from qibocal.auto.transpile import (
dummy_transpiler, set_compiler, execute_circuits,
)
platform = create_platform(“dummy”) transpiler = dummy_transpiler(platform) compiler = set_compiler(platform)
circuit = Circuit(1) circuit.add(gates.M(0))
qubit = next(iter(platform.qubits)) [counts] = execute_circuits(
circuits=[circuit], qubit_maps=[[qubit]], platform=platform, transpiler=transpiler, compiler=compiler, nshots=100,
)
assert sum(counts.values()) == 100
- qibocal.auto.transpile._natives(platform: Platform) dict[str, NativeContainer][source]¶
Return the dict of native gates name with the associated native container defined in the platform. This function assumes the native gates to be the same for each qubit and pair.
- qibocal.auto.transpile._create_rule(name: str, natives: NativeContainer) Callable[source]¶
Create rule for gate name given container natives.
- qibocal.auto.transpile.build_native_gate_compiler(platform: Platform) Compiler[source]¶
Build a compiler that follows the native gates defined by platform.
Starting from
Compiler.default(), this function overrides and extends gate rules using the native containers available on the platform so circuit compilation is consistent with the selected hardware configuration.- Parameters:
platform – The quantum platform containing native gate definitions.
- Returns:
A Compiler instance with rules set according to the platform’s native gates.
- qibocal.auto.transpile.build_native_gate_transpiler(platform: Platform) Passes[source]¶
If the backend is qibolab, a transpiler with just an unroller is returned, otherwise None. This function overwrites the compiler defined in the backend, taking into account the native gates defined in the`platform` (see
build_native_gate_compiler()).- Parameters:
platform – The quantum platform containing native gate definitions.
- Returns:
A Passes instance with an unroller set according to the platform’s native gates.