iqm.error_reduction_tools.readout_characterization.readout_error_characterization.ReadoutErrorCharacterization#
- class iqm.error_reduction_tools.readout_characterization.readout_error_characterization.ReadoutErrorCharacterization(client)#
Bases:
objectHigh-level interface for readout error characterization.
Wraps the lower-level functions in
iqm.error_reduction_tools.readout_characterization.data_collectionandiqm.error_reduction_tools.readout_characterization.data_processingbehind a clean, lifecycle-oriented API.Typical online usage:
config = RECConfiguration(shots=20_000, qubits=["QB1", "QB2", "QB5"]) rec = ReadoutErrorCharacterization(client) rec.submit_job(config) rec.retrieve_results() probs = rec.get_readout_error_probabilities()
Chained usage:
probs = ( ReadoutErrorCharacterization(client) .submit_job(config) .retrieve_results() .get_readout_error_probabilities() )
Offline usage (reload saved results):
rec = ReadoutErrorCharacterization.load("charact_garnet_20260311.json") probs = rec.get_readout_error_probabilities()
Methods
__repr__()Printable representation.
from_dict(data)Construct a
ReadoutErrorCharacterizationfrom a dictionary.Return per-qubit readout error probabilities.
load(path)Reconstruct a
ReadoutErrorCharacterizationfrom a JSON file.plot_error_probabilities(**kwargs)Plot per-qubit readout error probabilities.
retrieve_results([job, job_info])Retrieve measurement results from the calibration job.
save(path)Serialize the characterization state to a JSON file.
submit_job([config])Submit calibration circuits to the quantum computer.
to_dict()Serialize the characterization state to a JSON-compatible dictionary.
- Parameters:
client (Pulla | None)
- submit_job(config=None)#
Submit calibration circuits to the quantum computer.
Stores the returned
PullaJoband job metadata internally.- Parameters:
config (RECConfiguration | None) – Characterization configuration. Defaults to
RECConfigurationwith all default values whenNone.- Returns:
The current instance for method chaining.
- Raises:
RuntimeError – If no client was provided at construction time.
- Return type:
- retrieve_results(job=None, job_info=None)#
Retrieve measurement results from the calibration job.
Wraps
retrieve_calibration_results()and stores the raw counts internally.jobandjob_infoare always treated as a matched pair from the same calibration run. Either supply both to use an externally obtained job, or omit both to use the job stored internally bysubmit_job(). Passing only one of the two is an error.- Parameters:
job (PullaJob | None) – Job to fetch results from.
job_info (CalibrationJobInfo | None) –
CalibrationJobInfothat accompaniesjob(preparation strings, qubit list, etc.).
- Returns:
The current instance for method chaining.
- Raises:
ValueError – If exactly one of
job/job_infois provided.RuntimeError – If neither explicit arguments nor internal state are available.
- Return type:
- get_readout_error_probabilities()#
Return per-qubit readout error probabilities.
Computes the probabilities on the first call (lazy evaluation) and caches the result internally. Subsequent calls return the cached value without recomputation.
- Returns:
Per-qubit readout error probabilities. See
ErrorProbabilitiesfor the structure.- Raises:
RuntimeError – If
retrieve_results()has not been called.- Return type:
- to_dict()#
Serialize the characterization state to a JSON-compatible dictionary.
The serialized form contains everything required to reconstruct a post-retrieval object offline via
from_dict():Key
Contents
counts_by_prepRaw calibration counts
measured_qubitsQubit labels
configRECConfigurationusedcharact_dataCached assignment matrices (optional, present only if already computed)
charact_data_stdMatching standard deviations (optional, present only if already computed)
timestampISO-8601 creation timestamp, in UTC
- Returns:
JSON-serializable dictionary.
- Raises:
RuntimeError – If
retrieve_results()has not been called.- Return type:
- classmethod from_dict(data)#
Construct a
ReadoutErrorCharacterizationfrom a dictionary.The reconstructed object holds raw results and cached error probabilities (when available). It has no client or job handle, but all analysis and visualization methods work normally.
- save(path)#
Serialize the characterization state to a JSON file.
- Parameters:
path (str) – Destination file path (file will be overwritten if it exists).
- Raises:
RuntimeError – If
retrieve_results()has not been called yet.- Return type:
None
- classmethod load(path)#
Reconstruct a
ReadoutErrorCharacterizationfrom a JSON file.- Parameters:
- Returns:
New
ReadoutErrorCharacterizationinstance ready for offline analysis.- Return type:
- plot_error_probabilities(**kwargs)#
Plot per-qubit readout error probabilities.
Thin convenience wrapper around
plot_error_probabilities(). All keyword arguments are forwarded verbatim (e.g.title,show_plot).The visualization module is imported lazily to avoid pulling in
matplotlibat package import time.- Raises:
RuntimeError – If
retrieve_results()has not been called yet.- Return type:
None