bragi_quantum.datalayer API#

The keeper of records — the device model and the data-management layer.

Data management#

Session#

The session abstraction: SessionOptions, SessionContext and the thread-safe ActiveSession singleton.

Session management for the Calibration Toolkit.

This module provides a validated context for calibration runs, ensuring that all nodes and analysis objects share the same persistence settings and device models without manual parameter passing.

pydantic model bragi_quantum.datalayer.managing.session.SessionOptions[source]#

Bases: BaseModel

Global configuration options for the current calibration run.

This includes both data handling/reporting options and cluster execution parameters that may vary between runs within a session.

Fields:
field session_name: str = 'default_session'#

Human-readable name for the calibration session. Used in result directory structure as run_{session_name}.

field qubits: str = 'all'#

Comma-separated list of qubits to include in the run.

field couplers: str = 'all'#

Comma-separated list of couplers to include in the run.

field last_cooldown: str | None = None#

The date or ID of the physical cooldown. Overrides the device config’s.

field is_internal: bool = True#

Flag for internal vs external report formatting.

Path to the logo for PDFs.

field pdf_report_filepath: Path | None = 'calibration_report.pdf'#

Path where the final PDF report will be saved. If relative, it will be saved in the session root directory.

field produce_support_figures: bool = True#

Whether to generate support figures. These are usually helpful when one needs to have a more fine-grained look at the data. We recommend setting this to False when running large-scale runs or a lightweight report is desired.

field execution_mode: str = 'measurement'#

Execution mode (‘measurement’ or ‘dummy’).

field cluster_ips: str | None = None#

Comma-separated list of cluster IP addresses. None means auto-detect.

field save_cluster_metadata_to_disk: bool = False#

Whether to save cluster snapshots, q1asm programs, and waveform plots to disk during execution. When False, timing and status are still printed to terminal.

field save_log_level: int = 20#

Logging level for local logs(e.g., logging.INFO, logging.DEBUG).

field spi_serial_port: str | None = None#

Serial port for SPI DAC rack connection (e.g. ‘/dev/ttyACM0’). None (the default) skips SPI hardware initialization entirely for this session — nodes that require the SPI DAC handler (e.g. resonator/qubit spectroscopy vs current) will raise a RuntimeError if they run without one, so sessions that sweep DC currents must set the port explicitly.

validator convert_pdf_path_to_pathlib  »  pdf_report_filepath[source]#

Convert string paths to Path objects.

pydantic model bragi_quantum.datalayer.managing.session.SessionContext[source]#

Bases: BaseModel

Pydantic model representing the active calibration session.

This context acts as the source of truth for all environment settings during an orchestrated execution run. It centralizes device, cluster, and hardware configuration to avoid passing parameters through the call stack.

Variables:
  • session_id (str) – Unique identifier for the calibration session.

  • run_name (str) – Optional human-readable label for the run this session belongs to, passed through from CalibrationOrchestrator.name and recorded as “run_name” in the session timeline.

  • root_path (Path) – Base directory for all data and reports.

  • device_config (Any) – Validated bragi_quantum.datalayer DeviceConfiguration instance. It is a quite sophisticated object, built around the Qblox QuantumDevice.

  • device (Any) – Fully configured QuantumDevice instance, hydrated from device_config. Available for immediate use by utilities and nodes.

  • hardware_agent (Any) – Reference to the qblox-scheduler HardwareAgent that owns the cluster connections; schedules are run via its run() method.

  • redis_connection (Optional[Any]) – Optional Redis connection object for nodes that require direct access. It can be None if using local snapshots instead of Redis.

  • spi_dac_handler (Optional[Any]) – Initialized SpiDAC instance for flux/coupler control. Contains all configured DACs based on the device template SPI configuration.

  • cluster_config (Optional[Any]) – Cluster configuration built from the device template, after bragi_quantum.api’s autocomplete_hardware_options() has filled in the physical-analog-path hardware_options (attenuation, gain, LO frequencies, mixer corrections) for related clocks sharing a physical port. This — not the raw template — is what the schedules compile against, and therefore what the session timeline records as the start config.

  • spi_config (Optional[Any]) – Raw SPI configuration dictionary from the device template.

  • session_options (SessionOptions) – Configuration options for the current calibration run, including cluster execution parameters, reporting options, and qubit/coupler selection.

Fields:
field session_id: str [Required]#
field experiment_template_name: str | None = None#
field device_templates_dir: Path | None = None#
field run_name: str = ''#
field root_path: Path [Required]#
field device_config: Any [Required]#
field device: Any [Required]#
field hardware_agent: Any [Required]#
field redis_connection: Any | None [Required]#
field spi_dac_handler: Any | None = None#
field cluster_config: Any | None = None#
field spi_config: Any | None = None#
field session_options: SessionOptions [Optional]#
field wiring_config: Any | None = None#
get_session_timeline()[source]#
Return type:

Any

get_timing_trace_collector()[source]#
Return type:

Any

class bragi_quantum.datalayer.managing.session.ActiveSession[source]#

Bases: object

Global registry for the current calibration session context.

Uses a thread-safe singleton pattern to provide access to the session configuration across bragi_quantum.experiments and bragi_quantum.api nodes without explicit injection.

classmethod start(context)[source]#

Register a new session context.

Parameters:

context (SessionContext) – The validated SessionContext object.

Return type:

None

classmethod get()[source]#

Retrieve the current active session.

Returns:

The active session context.

Return type:

SessionContext

Raises:

RuntimeError – If no session has been initialized.

classmethod stop()[source]#

Clear the current session registry.

Return type:

None

classmethod next_node_dir_name(name)[source]#

Return a fresh, unique {name}_{uuid8} output-folder name.

Parameters:

name (str)

Return type:

str

classmethod get_session_timeline()[source]#

Retrieve the session timeline (ordered step log) for the current session.

Returns:

The timeline tracker.

Return type:

SessionTimeline

Raises:

RuntimeError – If no session has been initialized.

classmethod write_timing_trace_events(root_path)[source]#

Write the active session’s Chrome/Perfetto timing trace to root_path/timing_trace_events.json, logging (not raising) on failure.

Parameters:

root_path (Path)

Return type:

None

classmethod get_timing_trace_collector()[source]#

Retrieve the timing trace collector for the current session.

Every active session has one (tracing is always on — see start()). Unlike get_session_timeline(), this does not raise when there’s no active session at all, since timing trace collection is a best-effort side channel — callers should treat None as “skip recording this span”.

Returns:

The active collector, or None if no

session is active.

Return type:

TimingTraceCollector | None

classmethod record_node_boundary(node)[source]#

Mark this node’s start in the session trace (a labeled instant, not tied to any category swimlane), so bragi_quantum.gui can draw a divider between consecutive nodes’ spans. Best-effort: tracing is a side channel and must never break a measurement run.

Parameters:

node (Any)

Return type:

None

Session timeline#

Track an ordered timeline of session-level steps for a calibration session.

Where ExecutionHistory is keyed by element (q16, q17, …), SessionTimeline is ordered by step. Step 0 is always the session start configuration; every subsequent step is a node execution with the parameters used and the per-element results produced.

This is what the HTML “Pipeline” view consumes to render a clickable DAG.

class bragi_quantum.datalayer.managing.session_timeline.SessionTimeline(session_root_path)[source]#

Bases: object

Ordered, append-only log of session-level steps.

Parameters:

session_root_path (Path)

TIMELINE_FILENAME = 'session_timeline.json'#
record_start_config(session_id, template_name=None, device_templates_dir=None, run_name=None, toolkit_version=None, session_options=None, qubits=None, couplers=None, initial_configurations=None, redis_configurations=None)[source]#

Record step 0: the configuration snapshot at session start.

Parameters:
  • session_id (str)

  • template_name (str | None)

  • device_templates_dir (str | None)

  • run_name (str | None)

  • toolkit_version (str | None)

  • session_options (dict[str, Any] | None)

  • qubits (list[str] | None)

  • couplers (list[str] | None)

  • initial_configurations (dict[str, Any] | None)

  • redis_configurations (dict[str, Any] | None)

Return type:

None

finalize(status='complete')[source]#

Stamp the session’s completion status on the start-config step.

status is "complete" when the session scope closed cleanly or "error" when it aborted. Called once when the session ends, so readers can tell a finished session from one still measuring (which stays "running"). No-op if there is no start-config step yet.

Parameters:

status (str)

Return type:

None

record_node_execution(node_name, node_class, parameters, target_qubits, results, replot_meta=None)[source]#

Record a node execution as the next step in the timeline.

Parameters:
  • node_name (str) – User-facing name of the node (parameters.name).

  • node_class (str) – Python class name (e.g., ‘ResonatorSpectroscopy’).

  • parameters (dict[str, Any]) – Parameter values used for this run.

  • target_qubits (list[str]) – Element ids touched by this node.

  • results (dict[str, dict[str, Any]]) – Mapping element_id -> qoi dict (the analysis output).

  • replot_meta (dict[str, Any] | None) – Optional metadata for replaying this node’s analysis: - analysis_module, analysis_class - parameters_module, parameters_class - qoi_module, qoi_class (optional) - dataset_dir, dataset_basename - element_kind (“qubit” or “coupler”)

Return type:

None

get_steps()[source]#
Return type:

list[dict[str, Any]]

Datasets#

HDF5 (netCDF) dataset I/O for measurement data.

bragi_quantum.datalayer.managing.dataset.to_real_dataset(iq_dataset)[source]#
Parameters:

iq_dataset (Dataset)

Return type:

Dataset

bragi_quantum.datalayer.managing.dataset.save_dataset(result_dataset, node_name, data_path)[source]#

Save the measurement dataset to a file.

Parameters:
  • result_dataset (xarray.Dataset) – The dataset to save.

  • node_name (str) – Name of the node being measured.

  • data_path (Path) – Path where the dataset will be saved.

Return type:

None

Redis#

The store of calibrated (trusted) values across runs.

bragi_quantum.datalayer.managing.redis.populate_initial_redis_parameters(device_config, redis_connection, force=False)[source]#

Seeds the initial parameters from the bragi_quantum.datalayer DeviceConfiguration into Redis.

By default this is a seed-if-missing operation (HSETNX): YAML provides topology and core defaults, but any field already present in Redis — typically a previously calibrated value — is left untouched. This is what lets the device.yaml stay authoritative for defaults while Redis stays authoritative for calibrated state.

Parameters:
  • device_config (DeviceConfiguration) – Source of the default parameters (_raw_device_data with all inheritance already applied).

  • redis_connection (Any) – Live Redis connection.

  • force (bool) – When True, overwrites existing fields too (HSET). Use only for a deliberate clean re-seed from the template.

bragi_quantum.datalayer.managing.redis.record_calibration_metadata(redis_connection, node, components, timestamp=None)[source]#

Update the global calibration metadata after a node finishes calibrating.

A node typically calibrates several components (qubits/couplers) in parallel, so last_calibrated_components holds the full list calibrated in the last node execution. Stored under the calibration:meta hash:

  • last_experiment_at: ISO timestamp of the last calibration experiment

  • last_node: name of the last calibrated node

  • last_calibrated_components: JSON list of the components calibrated by it

Parameters:
  • redis_connection (Any)

  • node (str)

  • components (list)

  • timestamp (str | None)

bragi_quantum.datalayer.managing.redis.read_calibration_metadata(redis_connection)[source]#

Return the global calibration metadata hash, decoding the components list.

Returns an empty dict if no calibration metadata has been recorded yet.

Parameters:

redis_connection (Any)

Return type:

dict

bragi_quantum.datalayer.managing.redis.read_calibration_values(redis_connection, key, elements)[source]#

Read the full calibration hash for each element under a key prefix.

Each element has its own Redis hash (e.g. transmons:q06, cs:q06), fetched in full via HGETALL. Elements that fail to read (e.g. Redis connection issues) are logged and resolve to None rather than raising, so one bad element doesn’t abort the whole batch.

Parameters:
  • redis_connection (Any)

  • key (str)

  • elements (list)

Return type:

dict

bragi_quantum.datalayer.managing.redis.read_all_calibration_values(redis_connection)[source]#

Read all calibration values from Redis, i.e. dump redis.

Parameters:

redis_connection (Any)

Return type:

dict

bragi_quantum.datalayer.managing.redis.update_redis_trusted_values(node, this_element, qoi=None, redis_connection=None)[source]#

Update the redis trusted values for the qubit or coupler. :param node: The node name :param this_element: The element name (qubit or coupler) :param qoi: The quantity of interest as QOI wrapped object :param redis_connection: The Redis connection object :param redis_fields: List of redis fields for additional verification

Parameters:
  • node (str)

  • this_element (str)

  • qoi (Any)

  • redis_connection (Any)

Device model#

The physical description of the chip — transmons, couplers, gates and pulses.

Device configuration#

pydantic model bragi_quantum.datalayer.models.device.DeviceConfiguration[source]#

Bases: BaseModel

Pydantic model managing the construction and hydration of the QuantumDevice. Supports loading from initial YAML configs or Qblox-standard JSON snapshots.

Fields:
field qubits: list[str] [Optional]#
field couplers: list[str] [Optional]#
field name: str = 'Unknown Device'#
field owner: str = 'Unknown Owner'#
field last_cooldown: str = 'Unknown'#
field layout: str | None = None#
field extended_state: dict[str, dict[str, Any]] [Optional]#
classmethod from_yaml(path)[source]#

Factory method to load initial hardware configuration from YAML.

Parameters:

path (Path)

Return type:

DeviceConfiguration

classmethod from_snapshot(path)[source]#

Factory method to load device state from a Qblox snapshot.json.

Parameters:

path (Path)

Return type:

DeviceConfiguration

configure_device(name, is_snapshot=False)[source]#

Creates and hydrates the live QuantumDevice.

Parameters:
Return type:

QuantumDevice

load_calibration_state(redis_connection)[source]#

Overlay previously calibrated values from Redis onto the live device.

Counterpart to the YAML hydration in configure_device(): it reuses the same set_nested_value mechanism, so any value backed by a real qblox-scheduler parameter (a Transmon/Edge attribute) is applied in place, while values without such an attribute are silently skipped by set_nested_value (those live in extended_state).

Each transmons:{q} / couplers:{c} hash holds calibrated values keyed by submodule:field; *_error companions and flat keys are ignored. Must be called after configure_device().

Parameters:

redis_connection (Any)

Return type:

None

record_analysis_results(element_id, node, qoi)[source]#

Record a node’s analysis QOIs for one element into extended_state.

Stores every quantity the analysis produced — including derived ones that have no qblox-scheduler attribute and are therefore not reflected in the live QuantumDevice — keyed by element and by node, giving a real-time, element-by-element / node-by-node record of calibration outputs.

Parameters:
Return type:

None

save_device(name, data_path, file_format='yaml')[source]#

Serializes the live QuantumDevice state to disk.

Parameters:
create_spi_dac(spi_config=None, spi_serial_port='/dev/ttyACM0', is_dummy=False)[source]#

Creates and initializes an SpiDAC instance using the device configuration.

This method reads the SPI hardware mapping from the provided spi_config dictionary and sets the initial currents based on the calibrated offsets or parking values from the device’s couplers.

Parameters:
  • spi_config (dict[str, Any] | None) – Dictionary mapping coupler names to SPI configuration. Expected format: {coupler_name: {spi_module_number, dac_name}}

  • spi_serial_port (str) – Serial port address for the SPI rack (e.g., ‘/dev/ttyACM0’, ‘COM4’).

  • is_dummy (bool) – If True, initializes a dummy interface for testing.

Returns:

A fully configured and initialized SpiDAC instance.

Return type:

SpiDAC

property transmons#
property edges#
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

Qubits#

pydantic model bragi_quantum.datalayer.models.qubit.ExtendedClockFreqsSubmodule[source]#

Bases: SchedulerSubmodule

Submodule for storing extra clock frequencies.

Fields:
field readout_1: float = nan#
Constraints:
  • allow_inf_nan = True

field readout_2: float = nan#
Constraints:
  • allow_inf_nan = True

field readout_2state_opt: float = nan#
Constraints:
  • allow_inf_nan = True

field readout_3state_opt: float = nan#
Constraints:
  • allow_inf_nan = True

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

pydantic model bragi_quantum.datalayer.models.qubit.SpectroscopySubmodule[source]#

Bases: SchedulerSubmodule

Submodule for dedicated solely for spectroscopy parameters.

Fields:
field spec_duration: float = nan#
Constraints:
  • allow_inf_nan = True

field spec_duration_12: float = nan#
Constraints:
  • allow_inf_nan = True

field spec_amp: float = nan#
Constraints:
  • allow_inf_nan = True

field spec_ampl_optimal: float = nan#
Constraints:
  • allow_inf_nan = True

field spec_ampl_12_optimal: float = nan#
Constraints:
  • allow_inf_nan = True

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

pydantic model bragi_quantum.datalayer.models.qubit.R12[source]#

Bases: SchedulerSubmodule

Submodule for exciting the qubit using its 1->2 transition.

Fields:
field ef_amp180: float = nan#
Constraints:
  • allow_inf_nan = True

field ef_beta: float = 0.0#
Constraints:
  • ge = -1.0

  • le = 1.0

field ef_duration: float = nan#
Constraints:
  • allow_inf_nan = True

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

pydantic model bragi_quantum.datalayer.models.qubit.ExtendedTransmon[source]#

Bases: BasicTransmonElement

Fixed frequency qubit class with more submodules than the basic transmon object.

Fields:
field measure: MeasureReadoutSubmodule [Required]#
field extended_clock_freqs: ExtendedClockFreqsSubmodule [Required]#
field measure_1: Measure1ReadoutSubmodule [Required]#
field measure_2: Measure2ReadoutSubmodule [Required]#
field measure_2state_opt: TwoStateOptimalReadoutSubmodule [Required]#
field measure_3state_opt: ThreeStateOptimalReadoutSubmodule [Required]#
field spec: SpectroscopySubmodule [Required]#
field r12: R12 [Required]#
generate_device_config()[source]#

Generate a valid device config.

The config will be used for the qblox-scheduler making use of the compile_circuit_to_device_with_config_validation() function.

This enables the settings of this device element to be used in isolation.

Return type:

DeviceCompilationConfig

Couplers#

pydantic model bragi_quantum.datalayer.models.coupler.ParametricCZSubmodule[source]#

Bases: SchedulerSubmodule

Submodule containing parameters for performing a CZ operation.

Fields:
field square_amp: float = 0.5#

Amplitude of the square envelope.

Constraints:
  • allow_inf_nan = True

field square_duration: float = 2e-08#

The square pulse duration in seconds.

Constraints:
  • allow_inf_nan = True

field cz_freq: float = nan#

Frequency of the CZ pulse.

Constraints:
  • allow_inf_nan = True

field control_phase_correction: float = 0.0#

The phase correction for the control qubit after the square pulse operation has been performed.

Constraints:
  • allow_inf_nan = True

field target_phase_correction: float = 0.0#

The phase correction for the target qubit after the square pulse operation has been performed.

Constraints:
  • allow_inf_nan = True

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

pydantic model bragi_quantum.datalayer.models.coupler.ExtendedCompositeSquareEdge[source]#

Bases: Edge

Fields:
field edge_type: Literal['ExtendedCompositeSquareEdge'] = 'ExtendedCompositeSquareEdge'#
field cz: ParametricCZSubmodule [Required]#
generate_edge_config()[source]#

Generate the device configuration for an edge.

This method is intended to be used when this object is part of a device object containing multiple elements.

Return type:

dict[str, dict[str, OperationCompilationConfig]]

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

Gates#

class bragi_quantum.datalayer.models.gates.MeasureConfig(name_prefix: 'str', operation_type: 'str')[source]#

Bases: object

Parameters:
  • name_prefix (str)

  • operation_type (str)

name_prefix: str#
operation_type: str#
class bragi_quantum.datalayer.models.gates.Rxy_12(qubit, theta=180, phi=0, **device_overrides)[source]#

Bases: Rxy

A single qubit rotation on the 12 transition.

Parameters:
class bragi_quantum.datalayer.models.gates.BaseMeasureRO(*qubits, **kwargs)[source]#

Bases: Measure

Shared logic for all RO measurement classes.

Parameters:
CONFIG: MeasureConfig#
class bragi_quantum.datalayer.models.gates.Measure_RO1(*qubits, **kwargs)[source]#

Bases: BaseMeasureRO

Parameters:
CONFIG: MeasureConfig = MeasureConfig(name_prefix='Measure_RO1', operation_type='measure_1')#
class bragi_quantum.datalayer.models.gates.Measure_RO2(*qubits, **kwargs)[source]#

Bases: BaseMeasureRO

Parameters:
CONFIG: MeasureConfig = MeasureConfig(name_prefix='Measure_RO2', operation_type='measure_2')#
class bragi_quantum.datalayer.models.gates.Measure_RO_3state_Opt(*qubits, **kwargs)[source]#

Bases: BaseMeasureRO

Parameters:
CONFIG: MeasureConfig = MeasureConfig(name_prefix='Measure_RO_3state_Opt', operation_type='measure_3state_opt')#
class bragi_quantum.datalayer.models.gates.Measure_RO_2state_Opt(*qubits, **kwargs)[source]#

Bases: BaseMeasureRO

Parameters:
CONFIG: MeasureConfig = MeasureConfig(name_prefix='Measure_RO_2state_Opt', operation_type='measure_2state_opt')#

Pulses#

bragi_quantum.datalayer.models.pulses.parametric_cz_soft_square_pulse(square_amp, square_duration, square_port, square_clock, cz_pulse_frequency, virt_z_control_qubit_phase, virt_z_control_qubit_clock, virt_z_target_qubit_phase, virt_z_target_qubit_clock)[source]#
Parameters:
  • square_amp (float)

  • square_duration (float)

  • square_port (str)

  • square_clock (str)

  • cz_pulse_frequency (float)

  • virt_z_control_qubit_phase (float)

  • virt_z_control_qubit_clock (str)

  • virt_z_target_qubit_phase (float)

  • virt_z_target_qubit_clock (str)

Return type:

Schedule

Data visualization#

Utility module for standardizing plot figures and metadata headers.

bragi_quantum.datalayer.visualization.figure_utils.node_metadata_text(node_name)[source]#

Return the branded one-line metadata header for a node’s figures.

{owner} {chip} | {Nice Node Name} | CL: {cooldown} | Acquisition: … | Analysis: … [| Internal] — read from the active session. Falls back to just the nice node name when no session/metadata is available (e.g. a standalone reanalysis).

Parameters:

node_name (str)

Return type:

str

bragi_quantum.datalayer.visualization.figure_utils.qc2_logo_data_uri()[source]#

Return the QC2 logo as an SVG data: URI for embedding in plotly figures.

Looks for docs/public/qc2_logo_dark.svg walking up from this file; returns None if not found (the logo is then simply omitted).

Return type:

str | None

Utilities for creating PDF reports with images and text pages.

bragi_quantum.datalayer.visualization.pdf_report.merge_pdfs(base_pdf, new_pdf, output)[source]#

Append new_pdf to base_pdf, writing result to output.

Parameters:
bragi_quantum.datalayer.visualization.pdf_report.create_image_page(image_path, output_path, node_name=None, custom_name=None, unique_id=None)[source]#

Render a PDF page with an image and three optional identification lines.

Parameters:
  • image_path (Path)

  • output_path (Path)

  • node_name (str | None)

  • custom_name (str | None)

  • unique_id (str | None)

bragi_quantum.datalayer.visualization.pdf_report.create_text_page(paragraphs, output_path, title=None, device_config=None)[source]#

Create a one-page PDF with a title, paragraphs, and optional ‘.all’ table.

Parameters:
bragi_quantum.datalayer.visualization.pdf_report.create_default_header(timestring)[source]#

Utilities#

bragi_quantum.datalayer.utils.nested.get_nested_value(obj, path)[source]#

Recursively navigate a dotted path and return the value at its end.

Counterpart to set_nested_value(); used to snapshot a value before overriding it (e.g. by the bragi_quantum.datalayer.utils.context managers). Unlike set_nested_value this does not swallow missing attributes — a bad path raises AttributeError so typos fail fast rather than silently no-op.

Parameters:
Return type:

Any

bragi_quantum.datalayer.utils.nested.set_nested_value(obj, path, value)[source]#

Recursively navigates a dotted path and sets the value. Includes automatic float conversion for YAML scientific notation, and automatic JSON decoding for values Redis can only store as a string (e.g. a list-valued QOI field JSON-encoded before being hset — see bragi_quantum.datalayer.managing.redis._redis_safe_value), so load_calibration_state hands the live device back a real list/dict instead of that raw string.

Parameters:
class bragi_quantum.datalayer.utils.mode.ExecutionMode(*values)[source]#

Bases: Enum

Used to set the type of execution.

measurement = 0#
dummy = 1#

Module for controlling the Qblox SPI Rack DACs.

This module provides the SpiDAC class to manage S4g modules for coupler biasing and flux control within the bragi_quantum.datalayer framework.

class bragi_quantum.datalayer.utils.device.spi.SpiDAC(port, is_dummy=False)[source]#

Bases: object

Expert handler for the Qblox SPI Rack and its S4g DAC modules.

This class manages the connection to the physical SPI rack and provides methods for safe, ramped current control.

Variables:
  • port (str) – Serial port address for the SPI rack.

  • is_dummy (bool) – Whether to run in dummy mode.

  • spi (SpiRack) – The QCoDeS driver for the SPI rack.

  • dacs_dictionary (dict) – Mapping of coupler names to QCoDeS DAC objects.

Parameters:
add_coupler_dac(coupler_name, module_number, dac_name)[source]#

Registers and configures a specific DAC channel for a coupler.

Parameters:
  • coupler_name (str) – Name of the coupler (e.g., ‘c0_c1’).

  • module_number (int) – Slot number of the S4g module in the rack.

  • dac_name (str) – Name of the DAC channel (e.g., ‘dac0’).

set_dacs_zero()[source]#

Sets all registered DACs to zero current safely.

Return type:

None

set_dac_currents(dac_values, simultaneous=True)[source]#

Sets currents for multiple couplers using either simultaneous or serial ramping.

Parameters:
  • dac_values (dict[str, float]) – Dictionary mapping coupler names to current values in Amperes.

  • simultaneous (bool) – If True, ramps all channels at once.

Return type:

None

ramp_current_simultaneously(dac_values)[source]#

Starts ramping all specified DACs and waits for all to finish.

Parameters:

dac_values (dict[str, float]) – Mapping of coupler names to target currents (A).

ramp_current_serially(dac_values)[source]#

Ramps currents one by one with a progress bar for detailed monitoring.

Parameters:

dac_values (dict[str, float]) – Mapping of coupler names to target currents (A).

print_currents()[source]#

Prints the current of all registered DACs.

close()[source]#

Safely closes the connection to the SPI Rack.

class bragi_quantum.datalayer.utils.logging.ExtendedLogger(*args, **kwargs)[source]#

Bases: Logger

Adds a custom logger class

STATUS_LEVEL = 25#
property log_dir#
status(message, *args, **kwargs)[source]#

Adds a custom log level for the logger This works similar to logging.info() or logging.debug(), just that the level is 25 in this case

Parameters:

message – Message to log

add_console_handler(log_level=25)[source]#

Adds a console handler to the logger

Parameters:

log_level (int) – Log level for the output on the console

add_file_handler(log_level=10, log_file='autocalibration.log')[source]#

Adds a file handler to the logger

Parameters:
  • log_level (int) – Log level for the file handler. Defaults to logging.DEBUG to have more granular information

  • log_file (str) – Path to log file. Defaults to “autocalibration.log”

bragi_quantum.datalayer.utils.logging.visuals.log_timing(label, duration, suffix='')[source]#

Log a timing status message with the duration highlighted in cyan.

Parameters:
Return type:

None

bragi_quantum.datalayer.utils.logging.visuals.log_snapshot_size(file_path)[source]#

Log the on-disk size of a cluster snapshot/diff file in MB, highlighted in red.

Return type:

None

bragi_quantum.datalayer.utils.logging.visuals.log_size_on_disk(label, paths)[source]#

Log on-disk file size(s) in MB, highlighted in red.

Pass a single Path (or str) for a single-file report:

log_size_on_disk("Dataset saved:", data_path / "dataset.hdf5")

Pass an iterable of paths for an aggregated count + total-size report:

log_size_on_disk("Plots saved:", list(data_path.glob("*.png")))
Parameters:

label (str)

Return type:

None