Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.

TensoredFilter

class TensoredFilter(cal_matrices, substate_labels_list, mit_pattern)

GitHub

Bases: object

Tensored measurement error mitigation filter.

Produced from a tensored measurement calibration fitter and can be applied to data.

Initialize a tensored measurement error mitigation filter using the cal_matrices from a tensored measurement calibration fitter. A simple usage this class is explained [here] (https://qiskit.org/documentation/tutorials/noise/3_measurement_error_mitigation.html).

Parameters

  • cal_matrices (matrix) – the calibration matrices for applying the correction.
  • substate_labels_list (list) – for each calibration matrix a list of the states (as strings, states in the subspace)
  • mit_pattern (list) – for each calibration matrix a list of the logical qubit indices (as int, states in the subspace)

Methods

apply

TensoredFilter.apply(raw_data, method='least_squares', meas_layout=None)

Apply the calibration matrices to results.

Parameters

  • raw_data (dict or Result) –

    The data to be corrected. Can be in one of two forms:

    • A counts dictionary from results.get_counts
    • A Qiskit Result
  • method (str) –

    fitting method. The following methods are supported:

    • ’pseudo_inverse’: direct inversion of the cal matrices.

      Mitigated counts can contain negative values and the sum of counts would not equal to the shots. Mitigation is conducted qubit wise: For each qubit, mitigate the whole counts using the calibration matrices which affect the corresponding qubit. For example, assume we are mitigating the 3rd bit of the 4-bit counts using ‘2 imes 2’ calibration matrix A_3. When mitigating the count of ‘0110’ in this step, the following formula is applied: count[‘0110’] = A_3^{-1}[1, 0]*count[‘0100’] + A_3^{-1}[1, 1]*count[‘0110’].

      The total time complexity of this method is O(m2^{n + t}), where n is the size of calibrated qubits, m is the number of sets in mit_pattern, and t is the size of largest set of mit_pattern. If the mit_pattern is shaped like [[0], [1], [2], …, [n-1]], which corresponds to the tensor product noise model without cross-talk, then the time complexity would be O(n2^n). If the mit_pattern is shaped like [[0, 1, 2, …, n-1]], which exactly corresponds to the complete error mitigation, then the time complexity would be O(2^(n+n)) = O(4^n).

    • ’least_squares’: constrained to have physical probabilities.

      Instead of directly applying inverse calibration matrices, this method solve a constrained optimization problem to find the closest probability vector to the result from ‘pseudo_inverse’ method. Sequential least square quadratic programming (SLSQP) is used in the internal process. Every updating step in SLSQP takes O(m2^{n+t}) time. Since this method is using the SLSQP optimization over the vector with lenght 2^n, the mitigation for 8 bit counts with the mit_pattern = [[0], [1], [2], …, [n-1]] would take 10 seconds or more.

    • If None, ‘least_squares’ is used.

  • meas_layout (list of int) –

    the mapping from classical registers to qubits

    • If you measure qubit 2 to clbit 0, 0 to 1, and 1 to 2,

      the list becomes [2, 0, 1]

    • If None, flatten(mit_pattern) is used.

Returns

The corrected data in the same form as raw_data

Return type

dict or Result

Raises

QiskitError – if raw_data is not in a one of the defined forms.

compute_index_of_cal_mat

TensoredFilter.compute_index_of_cal_mat(state, pos_qubits, indices)

Return the index of (pseudo inverse) calibration matrix for the input quantum state

Return type

int

flip_state

TensoredFilter.flip_state(state, mat_index, flip_poses)

Flip the state according to the chosen qubit positions

Return type

str


Attributes

cal_matrices

Return cal_matrices.

nqubits

Return the number of qubits. See also MeasurementFilter.apply()

qubit_list_sizes

Return _qubit_list_sizes.

substate_labels_list

Return _substate_labels_list

Was this page helpful?
Report a bug or request content on GitHub.