uniqc.qem.readout_em module¶
Unified readout error mitigation.
Provides a single interface for applying readout EM to measurement counts,
automatically dispatching to 1-qubit or 2-qubit calibration as needed.
Internally calls the ReadoutCalibrator from uniqc.calibration.readout.
- class uniqc.qem.readout_em.ReadoutEM(adapter, max_age_hours=24.0, cache_dir=None, shots=1000)[source]¶
Bases:
objectUnified readout error mitigator.
This is the primary interface for applying readout EM to measurement results. It wraps a
ReadoutCalibratorand provides mitigation for arbitrary measurement counts.The mitigator automatically selects: - 1-qubit calibration for single-qubit measurement results - 2-qubit calibration for two-qubit joint measurement results - Per-qubit 1-qubit calibration (sequential approximation) for >2 qubits
- Parameters:
adapter (QuantumAdapter) – A
QuantumAdapterinstance for running calibration circuits.max_age_hours (float) – Maximum acceptable age of cached calibration data in hours.
cache_dir (str | None) – Directory for calibration cache. Defaults to
~/.uniqc/calibration_cache/.shots (int) – Number of shots per calibration circuit.
- apply(result, measured_qubits=None)[source]¶
Apply readout mitigation to a
UnifiedResult.Pipeline-style API: returns a new
UnifiedResultready to be consumed by the rest of uniqc.measured_qubitsdefaults tolist(range(width))inferred from the bitstring length.
- mitigate_counts(counts, measured_qubits)[source]¶
Apply readout EM to measurement counts.
Automatically dispatches to the appropriate calibration: - 1 qubit → 1q calibrator - 2 qubits → 2q calibrator - N>2 qubits → sequential per-qubit 1q mitigation
- Parameters:
- Returns:
Dict mapping outcome → corrected count (float, total preserved).
- Return type: