bragi_quantum.api API#
The orchestration layer and the main public API of the toolkit.
Main tool: the calibration orchestrator 🤹#
CalibrationOrchestrator is the interface to any
calibration or characterization pipeline: it loads the device template, connects
the hardware, opens sessions, runs nodes, and produces the output artifacts.
Module containing the main orchestrator for the QC2 Calibration Toolkit.
- pydantic model bragi_quantum.api.orchestra.CalibrationOrchestrator[source]#
Bases:
BaseModelThe Calibration Orchestrator is the main API tool in the QC2 Lab calibration toolkit.
This is the interface to any calibration or characterization pipeline, and can be used to execute experiments, modify device parameters, customize data handling and experiments’ report.
The orchestrator automatically initializes on instantiation by: 1. Loading device configuration from device_templates_dir/{experiment_template_name}/device.yaml 2. Loading cluster configuration from device_templates_dir/{experiment_template_name}/cluster.yaml 3. Loading SPI DAC configuration from device_templates_dir/{experiment_template_name}/spi.yaml 4. Connecting to the cluster
All context variables are exposed through SessionContext, and run-specific options (execution_mode, timeouts, IPs, etc.) are managed via SessionOptions.
- Minimal Args:
experiment_template_name: String identifier linking to device_templates_dir/{name}/ directory. data_handler: Data storage backend (RedisConfig or SnapshotConfig). Defaults to RedisConfig.
- Fields:
- field data_handler: RedisDataHandler | SnapshotDataHandler [Optional]#
- field load_calibration_state: bool = False#
When True, after building the device from device.yaml (topology + core defaults), overlay previously calibrated values stored in Redis onto the live device. Seeding then preserves existing Redis values; when False, Redis is re-seeded from the template and the device keeps the YAML defaults.
- field output_root: Path = PosixPath('.')#
Directory under which calibration_outputs/ is written. Defaults to the current working directory.
- field device_templates_dir: Path | None = None#
Base directory containing {experiment_template_name}/{device,cluster,spi}.yaml. Not required to be named device_templates. Defaults to output_root/device_templates; set this explicitly to keep templates elsewhere, e.g. outside version control. This is a special case: most templates should live in the default, version-controlled location, and this field is only for situations such as trying out untracked template variants. Overriding it carelessly can lead to unexpected code execution.
- field generate_pdf_report: bool = True#
Whether to generate the per-run PDF calibration report. When False, no PDF is initialized or written and SessionOptions.pdf_report_filepath is forced to None for every session in this run.
- field reset_clusters: bool = False#
Whether to reset every connected cluster instrument the first time this orchestrator connects to hardware (or on any real <-> dummy reconnect). Cluster connections are cached for the orchestrator’s lifetime.
- field noisy_loggers: tuple[str, ...] = ('qcodes', 'qblox_scheduler', 'quantify_scheduler', 'quantify_core', 'kaleido', 'choreographer')#
Third-party loggers restricted to WARNING and above on instantiation, to cut down on chatter from dependencies during a calibration run. Override with your own set of logger names to silence a different list.
- property device_config: Any#
Expose the DeviceConfiguration wrapping the device.
This is the structure that also holds
extended_state— the analysis quantities not reflected in the live QuantumDevice, kept element-by-element and node-by-node.
- calibration_session(session_options=None)[source]#
Context manager that provisions a single ActiveSession for the lifetime of the with block.
- Parameters:
session_options (SessionOptions | None)
- Return type:
Generator[None]
- run_node(node, session_options=None)[source]#
Executes a single calibration node.
This method safely wraps the node execution in calibration_session. If called standalone, it starts and stops the session. If called within an existing with orchestrator.calibration_session(): block, it reuses the ongoing session — the same session_id, root path, PDF report, and timeline are shared across all nodes run inside the outer block, so a multi-node script produces a single set of output artifacts.
- Parameters:
node (Any) – An instantiated calibration node (e.g., QubitSpectroscopyNode).
session_options (Optional[SessionOptions]) – Configuration options for the run. Ignored when running inside an existing session — the outer session’s options take precedence.
- Returns:
The result of the node’s execution (typically the aggregated QOI).
- Return type:
- generate_html_report()[source]#
Generate a master HTML file that aggregates all executed sessions.
This method should be called after all sessions are complete to create a single HTML page with tabs for each session.
- Return type:
None
- model_post_init(context, /)#
This function is meant to behave like a BaseModel method to initialize private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self (BaseModel) – The BaseModel instance.
context (Any) – The context.
- Return type:
None
Data handlers#
The pluggable persistence backend. RedisDataHandler
(default) uses a live Redis store; SnapshotDataHandler
uses a file-based Qblox snapshot for offline work.
- pydantic model bragi_quantum.api.handlers.data.RedisDataHandler[source]#
Bases:
BaseModelConfiguration for Redis data handling.
redis_port=Noneconnects an in-memoryfakeredisstore instead of a Redis server — for tests and hardware-free dummy runs.- field database_type: Literal['redis'] = 'redis'#
- model_post_init(_RedisDataHandler__context)[source]#
Initialize the Redis connection after Pydantic validation.
- property conn: redis.Redis#
Public getter for the connection.
Hardware#
Helpers that connect and configure the Qblox cluster.
- bragi_quantum.api.handlers.hardware.create_hardware_agent(cluster_config, quantum_device, *, reset_clusters=False, is_dummy=False, output_dir=None)[source]#
Create and configure HardwareAgent with cluster connections and AMC settings.
- bragi_quantum.api.handlers.hardware.autocomplete_hardware_options(hardware_config)[source]#
Fill in physical-analog-path hardware options for related clocks.
The compiler looks these options up by exact portclock string, so a clock the device template doesn’t define gets no attenuation/gain/mixer correction at all, instead of inheriting from the related clock sharing its output. Called once per cluster config, from the orchestrator’s
_load_cluster_config().- Parameters:
hardware_config (QbloxHardwareCompilationConfig) – Cluster configuration, completed in place.
- Returns:
The same object, with missing related-clock keys added. Existing keys are never overwritten.
- Return type:
QbloxHardwareCompilationConfig