TREX (qiskit_mitigation.trex)
TREX
class TREX
Bases: object
Mitigates readout errors in expectation values using the Twirled Readout Error eXtinction (TREX) method.
The class enables adding a readout error calibration item to a QuantumProgram shared by one or more mitigation tasks, that can be executed on hardware using the Executor. The calibration results are post processed into a measurement noise model, which is used to calculate scale factors that correct the expectation values computed by the connected mitigation tasks.
Instantiate a TREX task.
Methods
prepare
prepare(num_randomizations, quantum_program, custom_boxing_options=None)
Adds a TREX calibration item to the quantum program.
The created calibration circuit measures the union of the qubits measured by the tasks connected to this instance. A task that does not trim its measurements contributes all the qubits of its circuit. The classical register of the measurement is named _meas and has m + 1 bits, where m is the largest measured qubit index, so that column i of the calibration is always circuit qubit i. Columns of qubits that no task measures are not measured and always hold zeros.
The calibration item is built without noise maps, so if custom_boxing_options sets inject_noise_targets to "all" or "measures", it is replaced with "none" in the calibration circuit.
Parameters
- num_randomizations (int) – Number of randomizations for the TREX calibration.
- quantum_program (QuantumProgram) – The quantum program to add an item for.
- custom_boxing_options (dict | None) – The custom boxing options that will be used by
generate_boxing_pass_manager()function.
Returns
The input QuantumProgram instance with added TREX calibration item.
Return type
calculate_trex_factor
static calculate_trex_factor(noise_data, observable_term)
Calculate TREX factor relevant for a given observable term based on noise model.
Parameters
- noise_data (PauliLindbladMap |ndarray) – PauliLindbladMap containing measurement noise model or a result of TREX calibration execution.
- observable_term (Pauli |QubitSparsePauli |str) – observable term to calculate TREX factor for.
Returns
TREX factor for the observable term.
Return type
trex_factors_each_term
static trex_factors_each_term(measurement_noise_map, observables)
Calculates TREX mitigation algorithm’s expectation value scale factor for each Pauli term in each observable.
Calculates for each non-identity Pauli term in each observable using learned measurement noise, where are the non-identity indices in the term.
Parameters
- measurement_noise_map (PauliLindbladMap) – Learned measurement noise in PauliLindbladMap format.
- observables (ObservablesArray |Sequence[SparsePauliOp]) – Observables in which the TREX algorithm mitigates their expectation values.
Returns
A dictionary mapping Pauli terms to their expectation values scale factors.
Return type
compute_noise_model
compute_noise_model(results)
Compute noise model from program results.
Parameters
results (QuantumProgramResult) – QuantumProgramResult which contains the TREX calibration circuit results.
Returns
The learned readout noise model as a PauliLindbladMap.
Return type