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.
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