qermit.spectral_filtering

qermit.spectral_filtering.spectral_filtering.gen_spectral_filtering_MitEx(backend, n_vals, **kwargs)[source]

Generator function for the spectral filtering MitEx. This method acts on symbolic circuits, evaluating the circuit on a grid of symbol values and performing mitigation on the resulting landscape.

Parameters:
  • backend (Backend) – Backend on which all experiments are run.

  • n_vals (int) – The number of values each symbol should take. Each symbol will take n_vals equally spaced values in the range \([0, 2 U+03C0]\). The circuit will be evaluate at every permutation of the symbols evaluated at these points, giving a grid of circuit evaluations.

Key signal_filter:

Method for filtering the landscape of circuit evaluations. Defaults to SmallCoefficientSignalFilter.

Return type:

MitEx

Returns:

MitEx implementing spectral filtering.

qermit.spectral_filtering.spectral_filtering.gen_result_extraction_task()[source]

Generates task which extracts a result at coordinates specified by symbol values from grid of results.

Return type:

MitTask

Returns:

Task interpolating results.

qermit.spectral_filtering.spectral_filtering.gen_mitigation_task(signal_filter)[source]

Generates task acting signal_filter on the fourier coefficients of a grid of results.

Parameters:

signal_filter (SignalFilter) – Method of filtering the signal.

Return type:

MitTask

Returns:

Task performing filtering.

qermit.spectral_filtering.spectral_filtering.gen_fft_task()[source]

Generates task which performs Fast Fourier Transform of grids of values.

Return type:

MitTask

Returns:

Task performing Fast Fourier Transform

qermit.spectral_filtering.spectral_filtering.gen_ndarray_to_dict_task()[source]

Generates task reshaping an array of QubitPauliOperator into a dictionary with QubitPauliStrings as keys and an array of the appropriate coefficients as values.

Return type:

MitTask

Returns:

Task reshaping QubitPauliOperator into a dictionary with QubitPauliStrings as keys and an array of the appropriate coefficients as values.

qermit.spectral_filtering.spectral_filtering.gen_inv_fft_task()[source]

Generates task performing the inverse Fast Fourier Transform on each value in the list of dictionaries.

Return type:

MitTask

Returns:

Task performing Fast Fourier Transform.

qermit.spectral_filtering.spectral_filtering.gen_flatten_task()[source]

Generates task which transforms a list of ndarrays of ObservableExperiments into a list of ObservableExperiments. These ObservableExperiments can then be run in sequence.

Return type:

MitTask

Returns:

Generates task which transforms a list of ndarrays of ObservableExperiments into a list of ObservableExperiments

qermit.spectral_filtering.spectral_filtering.gen_reshape_task()[source]

Generates task which reshapes a list of QubitPauliOperator into a list of ndarrays of QubitPauliOperator. This can be used to have the effect for reversing the task generated by gen_flatten_task.

Return type:

MitTask

Returns:

Task which reshapes a list of QubitPauliOperator into a list of ndarrays of QubitPauliOperator.

qermit.spectral_filtering.spectral_filtering.gen_obs_exp_grid_gen_task()[source]

Generates task creating an ObservableExperiment for each point in the input meshgrid.

Return type:

MitTask

Returns:

Task generating grid of experiments.

qermit.spectral_filtering.spectral_filtering.gen_symbol_val_gen_task(n_sym_vals)[source]

Generates task which produces a grid of values. The values are generated uniformly in the interval [0,2] (factors of pi give full coverage of the Bloch sphere) for each symbol. The points on the grid are equally spaces, and the number of values is the same in each dimension. In the context of the spectral filtering MitEx, the given circuit will be evaluated at each point in the grid. This is to say that the symbols in the circuit will be substituted for the values at each point in the grid.

Parameters:

n_sym_vals (int) – The number of values to be taken by each symbol in the circuit.

Return type:

MitTask

Returns:

Task generating grid of symbol values.

qermit.spectral_filtering.spectral_filtering.gen_wire_copy_task(n_in_wires, n_wire_copies)[source]

Generates task which copies each of the input wires n_wire_copies times. The output wires are repeated in the same order as the input wires. This is to say that input wires 1,2,…n will be outputted as 1,2,…,n,…,1,2,…n.

Parameters:
  • n_in_wires (int) – The number of wires input into this task.

  • n_wire_copies (int) – The number of times the wires are to be copied.

Return type:

MitTask

Returns:

Task which copies input wires.

qermit.spectral_filtering.spectral_filtering.gen_param_grid_gen_task()[source]

Generates task converting lists of symbol values into a meshgrid.

Return type:

MitTask

Returns:

Task converting list of symbol values into a meshgrid.

class qermit.spectral_filtering.signal_filter.SmallCoefficientSignalFilter(tol)[source]

Child class of SignalFilter which filters results by reducing small Fourier coefficients to 0.

Initialisation method.

Parameters:

tol (float) – Value below which coefficients should be reduced to 0

filter(fft_result_val_grid)[source]

Filter method reducing values in fft_result_val_grid to 0 if they are less than tol.

Parameters:

fft_result_val_grid (ndarray[Any, dtype[float64]]) – Grid of values.

Return type:

ndarray[Any, dtype[float64]]

Returns:

Grid of values with values less than tol reduced to 0.

class qermit.spectral_filtering.signal_filter.SignalFilter[source]

Base class for signal filtering.

abstract filter(fft_result_val_grid)[source]

Method transforming array of floats into filtered array of floats.

Return type:

ndarray[Any, dtype[float64]]