uniqc.calibration.results module

Calibration result schemas for UnifiedQuantum.

All calibration results include a calibrated_at ISO-8601 timestamp set by the calibration module. Results are saved to ~/.uniqc/calibration_cache/.

class uniqc.calibration.results.CalibrationResult(calibrated_at, backend, type)[source]

Bases: object

Base class for all calibration results.

Parameters:
  • calibrated_at (str)

  • backend (str)

  • type (str)

backend: str
calibrated_at: str
classmethod from_dict(d)[source]
Parameters:

d (dict[str, Any])

Return type:

CalibrationResult

to_dict()[source]
Return type:

dict[str, Any]

type: str
class uniqc.calibration.results.ReadoutCalibrationResult(calibrated_at, backend, type='readout_1q', qubit=0, confusion_matrix=(), assignment_fidelity=0.0)[source]

Bases: CalibrationResult

Result of a readout calibration experiment.

Variables:
  • type (Literal['readout_1q', 'readout_2q']) – “readout_1q” or “readout_2q”

  • qubit (int | tuple[int, int]) – int for 1q, tuple[int, int] for 2q

  • confusion_matrix (tuple[tuple[float, ...], ...]) –

    1q: 2x2 matrix where rows=measured, cols=prepared.

    confusion_matrix[i][j] = P(measure=i | prep=j), so the diagonal is [P(0|0), P(1|1)].

    2q: 4x4 matrix where rows=measured, cols=prepared (|00⟩,|01⟩,|10⟩,|11⟩)

  • assignment_fidelity (float) – average diagonal element = (p00+p11)/2 (1q) or avg(diagonal) (2q)

Parameters:
assignment_fidelity: float
confusion_matrix: tuple[tuple[float, ...], ...]
classmethod from_dict(d)[source]
Parameters:

d (dict[str, Any])

Return type:

ReadoutCalibrationResult

qubit: int | tuple[int, int]
to_dict()[source]
Return type:

dict[str, Any]

class uniqc.calibration.results.XEBResult(calibrated_at, backend, type='xeb_1q', qubit=None, pairs=None, fidelity_per_layer=0.0, fidelity_std_error=0.0, fit_a=0.0, fit_b=0.0, fit_r=0.0, depths=(), n_circuits=0, shots=0)[source]

Bases: CalibrationResult

Result of a cross-entropy benchmarking experiment.

Parameters:
depths: tuple[int, ...]
fidelity_per_layer: float
fidelity_std_error: float
fit_a: float
fit_b: float
fit_r: float
classmethod from_dict(d)[source]
Parameters:

d (dict[str, Any])

Return type:

XEBResult

n_circuits: int
pairs: list[tuple[int, int]] | None
qubit: int | None
shots: int
to_dict()[source]
Return type:

dict[str, Any]

uniqc.calibration.results.ensure_cache_dir()[source]

Ensure the calibration cache directory exists.

Return type:

Path

uniqc.calibration.results.find_cached_results(backend, result_type, *, max_age_hours=None, cache_dir=None)[source]

Find cached calibration result files matching backend + type.

Optionally filters by age.

Parameters:
  • backend (str)

  • result_type (str)

  • max_age_hours (float | None)

  • cache_dir (Path | str | None)

Return type:

list[Path]

uniqc.calibration.results.load_calibration_result(path)[source]

Load a calibration result from a cache file.

Parameters:

path (str | Path)

Return type:

CalibrationResult

uniqc.calibration.results.save_calibration_result(result, *, type_prefix, cache_dir=None)[source]

Save a calibration result to the cache and return the file path.

Parameters:
Return type:

str