Skip to main contentIBM Quantum Documentation Mirror

post_selection

qiskit_addon_utils.noise_management.post_selection

Functions and classes to perform Post Selection.

PostSelectionSummary

class PostSelectionSummary(primary_cregs, measure_map, edges, *, post_selection_suffix='_ps')

GitHub

Bases: object

A helper class to store the properties of a quantum circuit required to post select the results.

Initialize a PostSelectionSummary object.

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.

edges

Type: set[frozenset[int]]

A set of edges to consider for edge-based post selection.

from_circuit

classmethod from_circuit(circuit, coupling_map, *, post_selection_suffix='_ps')

GitHub

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

PostSelectionSummary

measure_map

Type: dict[int, tuple[str, int]]

A map from qubit indices to the register and clbit index used to measure those qubits.

post_selection_suffix

Type: str

The suffix of the post selection registers.

primary_cregs

Type: set[str]

The names of the “primary” classical registers.

PostSelector

class PostSelector(summary)

GitHub

Bases: object

A class to process the results of quantum programs based on the outcome of post selection measurements.

Initialize a PostSelector object.

Parameters

summary (PostSelectionSummary) – A summary of the circuit being post selected.

compute_mask

compute_mask(result, strategy=PostSelectionStrategy.NODE)

GitHub

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 True in the returned mask, those that should be discarded are marked as False.

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

  • result (dict[str, ndarray[tuple[int, ...], dtype[bool]]]) – The result to post-process. It must be a QuantumProgramResult containing a single item or a dictionary.
  • strategy (str | PostSelectionStrategy) – The post selection strategy used to process the result.

Return type

ndarray[tuple[int, …], dtype[bool]]

from_circuit

classmethod from_circuit(circuit, coupling_map, *, post_selection_suffix='_ps')

GitHub

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

PostSelector

summary

Type: PostSelectionSummary

A summary of the circuit being post selected.