noise_management (qiskit_addon_utils.noise_management)¶
Noise management tools.
- trex_factors(measurement_noise_map, basis_dict, /)[source]¶
Calculates TREX mitigation algorithm’s expectation value scale factor for each Pauli term in
basis_dict.Calculates <Z^n> for each Pauli term in each observable, where n is the non identity indices in the Pauli term. The calculation is done using learned measurement noise.
- Parameters:
measurement_noise_map (PauliLindbladMap) – Learned measurement noise in PauliLindbladMap format.
basis_dict (dict[Pauli, list[SparsePauliOp | None]]) – Mapping between measure bases and observables in which the TREX algorithm mitigates their
calculation. (expectation value)
- Returns:
A list of numpy array of floats that represent the TREX mitigation algorithm’s expectation value scale factor for each Pauli term in each observable in each basis in the given basis_dict.
- gamma_from_noisy_boxes(noise_models, box_id_to_noise_id, noise_scales_each_box=None)[source]¶
Calculate the gamma factor for a circuit given the Pauli-Lindblad noise models for the boxes in that circuit.
This function expects the noise models to represent the noise in the circuit, and thus to have positive Lindblad rates. The returned gamma is that associated with the inverse noise maps needed to cancel the noise in the circuit.
- Parameters:
noise_models (dict[str, PauliLindbladMap]) – Dict of noise-model IDs (strings) and learned noise models for each unique noisy box in the circuit.
box_id_to_noise_id (dict[str, str]) – Dict of box IDs and noise-model IDs.
noise_scales_each_box (dict[str, ndarray] | None) – Dict of box IDs and factors by which to rescale the Lindblad error rates of each generator in the associated noise model.
- Returns:
The gamma factor.
- Raises:
ValueError if the length of an array in noise_scales_each_box does not equal the length of rates of the associated – PauliLindbladMap in noise_models.
- Return type:
- class PostSelectionSummary(primary_cregs, measure_map, edges, *, post_selection_suffix='_ps')[source]¶
Bases:
objectA helper class to store the properties of a quantum circuit required to post select the results.
Initialize a
PostSelectionSummaryobject.- Parameters:
primary_cregs (set[str]) – The names of the “primary” classical registers, namely those that do not end with the post selection suffix.
measure_map (dict[int, tuple[str, int]]) – A map between qubit indices to the register and clbits that uniquely define a measurement on those qubits.
edges (set[frozenset[int]]) – A list of tuples defining pairs of neighboring qubits.
post_selection_suffix (str) – The suffix of the post selection registers.
- classmethod from_circuit(circuit, coupling_map, *, post_selection_suffix='_ps')[source]¶
Initialize from quantum circuits.
- Parameters:
circuit (QuantumCircuit) – The circuit to create a summary of.
coupling_map (CouplingMap | list[tuple[int, int]]) – A coupling map or a list of tuples indicating pairs of neighboring qubits.
post_selection_suffix (str) – A fixed suffix to append to the names of the classical registers when copying them.
- Return type:
- class PostSelector(summary)[source]¶
Bases:
objectA class to process the results of quantum programs based on the outcome of post selection measurements.
Initialize a
PostSelectorobject.- Parameters:
summary (PostSelectionSummary) – A summary of the circuit being post selected.
- compute_mask(result, strategy=PostSelectionStrategy.NODE)[source]¶
Compute boolean masks indicating what shots should be kept or discarded for the given result.
This function compares the bits returned by every pair of measurement and post selection measurement, identifying all those that failed to flip. The shots that should be kept are marked as
Truein the returned mask, those that should be discarded are marked asFalse.By construction, the returned mask has the same shape as the arrays in corresponding result, but with one fewer dimension (the last axis of every array, over clbits, is not present in the mask).
- Parameters:
- Return type:
- classmethod from_circuit(circuit, coupling_map, *, post_selection_suffix='_ps')[source]¶
Initialize from quantum circuits.
- Parameters:
circuits – The circuits to process the results of.
coupling_map (CouplingMap | list[tuple[int, int]]) – A coupling map or a list of tuples indicating pairs of neighboring qubits.
post_selection_suffix (str) – A fixed suffix to append to the names of the classical registers when copying them.
circuit (QuantumCircuit)
- Return type:
- property summary: PostSelectionSummary¶
A summary of the circuit being post selected.