qibocal.protocols.randomized_benchmarking package#

Submodules#

qibocal.protocols.randomized_benchmarking.dict_utils module#

qibocal.protocols.randomized_benchmarking.dict_utils.find_cliffords(cz_list)[source]#

Splits a clifford (list of gates) into sublists based on the occurrence of the “CZ” gate.

qibocal.protocols.randomized_benchmarking.dict_utils.separator(clifford)[source]#

Separates values in the given clifford sublist based on certain conditions.

Returns:

A tuple containing three elements:
  • values_with_1 (str): A comma-separated string of values containing ‘1’.

  • values_with_2 (str): A comma-separated string of values containing ‘2’.

  • value_with_CZ (bool): True if ‘CZ’ is present in the clifford list, False otherwise.

Return type:

tuple

qibocal.protocols.randomized_benchmarking.dict_utils.clifford2gates(clifford)[source]#

Converts a Clifford string into a list of gates.

Parameters:

clifford (str) – A comma-separated string representing a sequence of gates that represent a Clifford gate.

qibocal.protocols.randomized_benchmarking.dict_utils.clifford_to_matrix(clifford)[source]#

Converts a Clifford gate as a string to its corresponding unitary matrix representation.

qibocal.protocols.randomized_benchmarking.dict_utils.generate_inv_dict_cliffords_file(two_qubit_cliffords, output_file=None)[source]#

Generate an inverse dictionary of Clifford matrices and save it to a npz file.

Parameters: two_qubit_cliffords (dict): A dictionary of two-qubit Cliffords. output_file (str): The path to the output npz file.

qibocal.protocols.randomized_benchmarking.dict_utils.clifford_to_pulses(clifford)[source]#

From a Clifford gate sequence into the number of pulses required to implement it.

Parameters:

clifford (str) – A comma-separated string representing the Clifford gate sequence.

Returns:

The number of pulses required to implement the given Clifford gate sequence.

Return type:

int

qibocal.protocols.randomized_benchmarking.dict_utils.calculate_pulses_clifford(cliffords)[source]#

Calculate the average number of pulses per Clifford operation.

Parameters: - cliffords (dict): A dictionary of Clifford operations.

Returns: - pulses_per_clifford (float): The average number of pulses per Clifford operation.

qibocal.protocols.randomized_benchmarking.dict_utils.load_inverse_cliffords(file_inv)[source]#
qibocal.protocols.randomized_benchmarking.dict_utils.load_cliffords(file_cliffords)[source]#

qibocal.protocols.randomized_benchmarking.filtered_rb module#

qibocal.protocols.randomized_benchmarking.fitting module#

In this python script the fitting methods for the gate set protocols are defined. They consist mostly of exponential decay fitting.

qibocal.protocols.randomized_benchmarking.fitting.exp1_func(x: ndarray, A: float, f: float) ndarray[source]#

Return \(A\cdot f^x\) where x is an np.ndarray and A, f are floats

qibocal.protocols.randomized_benchmarking.fitting.exp1B_func(x: ndarray, A: float, f: float, B: float) ndarray[source]#

Return \(A\cdot f^x+B\) where x is an np.ndarray and A, f, B are floats

qibocal.protocols.randomized_benchmarking.fitting.exp2_func(x: ndarray, A1: float, A2: float, f1: float, f2: float) ndarray[source]#

Return \(A_1\cdot f_1^x+A_2\cdot f_2^x\) where x is an np.ndarray and A1, f1, A2, f2 are floats. There is no linear offsett B.

qibocal.protocols.randomized_benchmarking.fitting.esprit(xdata: ndarray, ydata: ndarray, num_decays: int, hankel_dim: Optional[int] = None) ndarray[source]#

Implements the ESPRIT algorithm for peak detection.

Parameters:
  • xdata (np.ndarray) – Labels of data. Has to be equally spaced.

  • ydata (np.ndarray) – The data where multiple decays are fitted in.

  • num_decays (int) – How many decays should be fitted.

  • hankel_dim (int | None, optional) – The Hankel dimension. Defaults to None.

Returns:

The decay parameters.

Return type:

np.ndarray

Raises:

ValueError – When the x-labels are not equally spaced the algorithm does not work.

qibocal.protocols.randomized_benchmarking.fitting.fit_exp1B_func(xdata: Union[ndarray, list], ydata: Union[ndarray, list], **kwargs) tuple[tuple, tuple][source]#

Calculate an single exponential A*p^m+B fit to the given ydata.

Parameters:
  • xdata (Union[np.ndarray, list]) – The x-labels.

  • ydata (Union[np.ndarray, list]) – The data to be fitted.

Returns:

The fitting parameters (A, p, B) and the estimated error

(A_err, p_err, B_err)

Return type:

tuple[tuple, tuple]

qibocal.protocols.randomized_benchmarking.fitting.fit_exp1_func(xdata: Union[ndarray, list], ydata: Union[ndarray, list], **kwargs) tuple[tuple, tuple][source]#

Calculate an single exponential A*p^m fit to the given ydata, no linear offset.

Parameters:
  • xdata (Union[np.ndarray, list]) – The x-labels.

  • ydata (Union[np.ndarray, list]) – The data to be fitted.

Returns:

The fitting parameters (A, p) and the estimated error (A_err, p_err).

Return type:

tuple[tuple, tuple]

qibocal.protocols.randomized_benchmarking.fitting.fit_expn_func(xdata: Union[ndarray, list], ydata: Union[ndarray, list], n: int = 2) tuple[tuple, tuple][source]#

Calculate n exponentials on top of each other, fit to the given ydata. No linear offset, the ESPRIT algorithm is used to identify n exponential decays.

Parameters:
  • xdata (Union[np.ndarray, list]) – The x-labels.

  • ydata (Union[np.ndarray, list]) – The data to be fitted.

  • n (int) – number of decays to fit. Default is 2.

Returns:

(A1, …, An, f1, …, fn) with f* the decay parameters.

Return type:

tuple[tuple, tuple]

qibocal.protocols.randomized_benchmarking.fitting.fit_exp2_func(xdata: Union[ndarray, list], ydata: Union[ndarray, list]) tuple[tuple, tuple][source]#

Calculate 2 exponentials on top of each other, fit to the given ydata.

No linear offset, the ESPRIT algorithm is used to identify the two exponential decays.

Parameters:
  • xdata (Union[np.ndarray, list]) – The x-labels.

  • ydata (Union[np.ndarray, list]) – The data to be fitted

Returns:

(A1, A2, f1, f2) with f* the decay parameters.

Return type:

tuple[tuple, tuple]

qibocal.protocols.randomized_benchmarking.standard_rb module#

class qibocal.protocols.randomized_benchmarking.standard_rb.StandardRBParameters(depths: Union[list, Depthsdict], niter: int, uncertainties: Optional[float] = None, unrolling: bool = False, seed: Optional[int] = None, nshots: int = 10)[source]#

Bases: Parameters

Standard Randomized Benchmarking runcard inputs.

depths: Union[list, Depthsdict]#

A list of depths/sequence lengths.

If a dictionary is given the list will be build.

niter: int#

Sets how many iterations over the same depth value.

uncertainties: Optional[float] = None#

Method of computing the error bars of the signal and uncertainties of the fit.

If None, it computes the standard deviation. Otherwise it computes the corresponding confidence interval. Defaults None.

unrolling: bool = False#

If True it uses sequence unrolling to deploy multiple circuits in a single instrument call.

Defaults to False.

seed: Optional[int] = None#

A fixed seed to initialize np.random.Generator.

If None, uses a random seed. Defaults is None.

nshots: int = 10#

Just to add the default value.

hardware_average: bool = False#

By default hardware average will be performed.

relaxation_time: float#

Wait time for the qubit to decohere back to the gnd state.

class qibocal.protocols.randomized_benchmarking.standard_rb.RBData(depths: list, uncertainties: ~typing.Optional[float], seed: ~typing.Optional[int], nshots: int, niter: int, data: dict[typing.Union[int, str, tuple[typing.Union[int, str], typing.Union[int, str]]], numpy.ndarray[typing.Any, numpy.dtype[dtype([('samples', '<i4')])]]] = <factory>, circuits: dict[typing.Union[int, str, tuple[typing.Union[int, str], typing.Union[int, str]]], list[list[int]]] = <factory>, npulses_per_clifford: float = 1.875)[source]#

Bases: Data

The output of the acquisition function.

depths: list#

Circuits depths.

uncertainties: Optional[float]#

Parameters uncertainties.

seed: Optional[int]#
nshots: int#

Number of shots.

niter: int#

Number of iterations for each depth.

data: dict[typing.Union[int, str, tuple[typing.Union[int, str], typing.Union[int, str]]], numpy.ndarray[typing.Any, numpy.dtype[dtype([('samples', '<i4')])]]]#

Raw data acquired.

circuits: dict[Union[int, str, tuple[Union[int, str], Union[int, str]]], list[list[int]]]#

Clifford gate indexes executed.

npulses_per_clifford: float = 1.875#

Number of pulses for an average clifford.

extract_probabilities(qubit)[source]#

Extract the probabilities given qubit

_to_json(path: Path, filename: str)#

Helper function to dump to json.

_to_npz(path: Path, filename: str)#

Helper function to use np.savez while converting keys into strings.

static load_data(path: Path, filename: str)#

Load data stored in a npz file.

static load_params(path: Path, filename: str)#

Load parameters stored in a json file.

property pairs#

Access qubit pairs ordered alphanumerically from data structure.

property params: dict#

Convert non-arrays attributes into dict.

property qubits#

Access qubits from data structure.

register_qubit(dtype, data_keys, data_dict)#

Store output for single qubit.

Parameters:
  • data_keys (tuple) – Keys of Data.data.

  • data_dict (dict) – The keys are the fields of dtype and

  • arrays. (the values are the related) –

save(path: Path)#

Store data to file.

qibocal.protocols.randomized_benchmarking.standard_rb._plot(data: RBData, fit: StandardRBResult, target: Union[int, str]) tuple[list[plotly.graph_objs._figure.Figure], str][source]#

Builds the table for the qq pipe, calls the plot function of the result object and returns the figure es list.

Parameters:
  • data (RBData) – Data object used for the table.

  • fit (StandardRBResult) – Is called for the plot.

  • target (_type_) – Not used yet.

Return type:

tuple[list[go.Figure], str]

qibocal.protocols.randomized_benchmarking.standard_rb_2q module#

class qibocal.protocols.randomized_benchmarking.standard_rb_2q.StandardRB2QParameters(depths: Union[list, Depthsdict], niter: int, uncertainties: Optional[float] = None, unrolling: bool = False, seed: Optional[int] = None, nshots: int = 10, file: str = '2qubitCliffs.json', file_inv: str = '2qubitCliffsInv.npz')[source]#

Bases: StandardRBParameters

Parameters for the standard 2q randomized benchmarking protocol.

file: str = '2qubitCliffs.json'#

File with the cliffords to be used.

file_inv: str = '2qubitCliffsInv.npz'#

File with the cliffords to be used in an inverted dict.

hardware_average: bool = False#

By default hardware average will be performed.

nshots: int = 10#

Just to add the default value.

seed: Optional[int] = None#

A fixed seed to initialize np.random.Generator.

If None, uses a random seed. Defaults is None.

uncertainties: Optional[float] = None#

Method of computing the error bars of the signal and uncertainties of the fit.

If None, it computes the standard deviation. Otherwise it computes the corresponding confidence interval. Defaults None.

unrolling: bool = False#

If True it uses sequence unrolling to deploy multiple circuits in a single instrument call.

Defaults to False.

depths: Union[list, Depthsdict]#

A list of depths/sequence lengths.

If a dictionary is given the list will be build.

niter: int#

Sets how many iterations over the same depth value.

relaxation_time: float#

Wait time for the qubit to decohere back to the gnd state.

qibocal.protocols.randomized_benchmarking.standard_rb_2q_inter module#

qibocal.protocols.randomized_benchmarking.utils module#

qibocal.protocols.randomized_benchmarking.utils.NPULSES_PER_CLIFFORD = 1.875#

Global phases that could appear in the Clifford group we defined in the “2q_cliffords.json” file due to the gates we selected to generate the Clifford group.

qibocal.protocols.randomized_benchmarking.utils.RBType = dtype([('samples', '<i4')])#

Custom dtype for RB.

qibocal.protocols.randomized_benchmarking.utils.random_clifford(random_index_gen)[source]#

Generates random Clifford operator.

qibocal.protocols.randomized_benchmarking.utils.random_2q_clifford(random_index_gen, two_qubit_cliffords)[source]#

Generates random two qubit Clifford operator.

qibocal.protocols.randomized_benchmarking.utils.random_circuits(depth: int, targets: list[Union[int, str, tuple[Union[int, str], Union[int, str]]]], niter, rb_gen, inverse_layer=True, single_qubit=True, file_inv=PosixPath('.'), interleave=None) Iterable[source]#

Returns random (self-inverting) Clifford circuits.

qibocal.protocols.randomized_benchmarking.utils.number_to_str(value: Number, uncertainty: Optional[Union[Number, list, tuple, ndarray]] = None, precision: Optional[int] = None)[source]#

Converts a number into a string.

Parameters:
  • value (Number) – the number to display

  • uncertainty (Number or list or tuple or np.ndarray, optional) – number or 2-element interval with the low and high uncertainties of value. Defaults to None.

  • precision (int, optional) – nonnegative number of floating points of the displayed value. If None, defaults to the second significant digit of uncertainty or 3 if uncertainty is None. Defaults to None.

Returns:

The number expressed as a string, with the uncertainty if given.

Return type:

str

qibocal.protocols.randomized_benchmarking.utils.data_uncertainties(data, method=None, data_median=None, homogeneous=True)[source]#

Compute the uncertainties of the median (or specified) values.

Parameters:
  • data (list or np.ndarray) – 2d array with rows containing data points from which the median value is extracted.

  • method (float, optional) – method of computing the method. If it is None, computes the standard deviation, otherwise it computes the corresponding confidence interval using np.percentile. Defaults to None.

  • data_median (list or np.ndarray, optional) – 1d array for computing the errors from the confidence interval. If None, the median values are computed from data.

  • homogeneous (bool) – if True, assumes that all rows in data are of the same size and returns np.ndarray. Default is True.

Returns:

uncertainties of the data.

Return type:

np.ndarray

class qibocal.protocols.randomized_benchmarking.utils.RB_Generator(seed, file=None)[source]#

Bases: object

This class generates random two qubit cliffords for randomized benchmarking.

random_index(gate_dict)[source]#

Generates a random index within the range of the given file len.

layer_gen_single_qubit()[source]#

Generates a random single-qubit clifford gate.

layer_gen_two_qubit()[source]#

Generates a random two-qubit clifford gate.

calculate_average_pulses()[source]#

Average number of pulses per clifford.

class qibocal.protocols.randomized_benchmarking.utils.RBData(depths: list, uncertainties: ~typing.Optional[float], seed: ~typing.Optional[int], nshots: int, niter: int, data: dict[typing.Union[int, str, tuple[typing.Union[int, str], typing.Union[int, str]]], numpy.ndarray[typing.Any, numpy.dtype[dtype([('samples', '<i4')])]]] = <factory>, circuits: dict[typing.Union[int, str, tuple[typing.Union[int, str], typing.Union[int, str]]], list[list[int]]] = <factory>, npulses_per_clifford: float = 1.875)[source]#

Bases: Data

The output of the acquisition function.

depths: list#

Circuits depths.

uncertainties: Optional[float]#

Parameters uncertainties.

seed: Optional[int]#
nshots: int#

Number of shots.

niter: int#

Number of iterations for each depth.

data: dict[typing.Union[int, str, tuple[typing.Union[int, str], typing.Union[int, str]]], numpy.ndarray[typing.Any, numpy.dtype[dtype([('samples', '<i4')])]]]#

Raw data acquired.

circuits: dict[Union[int, str, tuple[Union[int, str], Union[int, str]]], list[list[int]]]#

Clifford gate indexes executed.

npulses_per_clifford: float = 1.875#

Number of pulses for an average clifford.

extract_probabilities(qubit)[source]#

Extract the probabilities given qubit

_to_json(path: Path, filename: str)#

Helper function to dump to json.

_to_npz(path: Path, filename: str)#

Helper function to use np.savez while converting keys into strings.

static load_data(path: Path, filename: str)#

Load data stored in a npz file.

static load_params(path: Path, filename: str)#

Load parameters stored in a json file.

property pairs#

Access qubit pairs ordered alphanumerically from data structure.

property params: dict#

Convert non-arrays attributes into dict.

property qubits#

Access qubits from data structure.

register_qubit(dtype, data_keys, data_dict)#

Store output for single qubit.

Parameters:
  • data_keys (tuple) – Keys of Data.data.

  • data_dict (dict) – The keys are the fields of dtype and

  • arrays. (the values are the related) –

save(path: Path)#

Store data to file.

class qibocal.protocols.randomized_benchmarking.utils.RB2QData(depths: list, uncertainties: ~typing.Optional[float], seed: ~typing.Optional[int], nshots: int, niter: int, data: dict[typing.Union[int, str, tuple[typing.Union[int, str], typing.Union[int, str]]], numpy.ndarray[typing.Any, numpy.dtype[dtype([('samples', '<i4')])]]] = <factory>, circuits: dict[typing.Union[int, str, tuple[typing.Union[int, str], typing.Union[int, str]]], list[list[int]]] = <factory>, npulses_per_clifford: float = 8.6)[source]#

Bases: RBData

The output of the acquisition function.

npulses_per_clifford: float = 8.6#

Number of pulses for an average clifford.

extract_probabilities(qubits)[source]#

Extract the probabilities given (qubit, qubit)

_to_json(path: Path, filename: str)#

Helper function to dump to json.

_to_npz(path: Path, filename: str)#

Helper function to use np.savez while converting keys into strings.

static load_data(path: Path, filename: str)#

Load data stored in a npz file.

static load_params(path: Path, filename: str)#

Load parameters stored in a json file.

property pairs#

Access qubit pairs ordered alphanumerically from data structure.

property params: dict#

Convert non-arrays attributes into dict.

property qubits#

Access qubits from data structure.

register_qubit(dtype, data_keys, data_dict)#

Store output for single qubit.

Parameters:
  • data_keys (tuple) – Keys of Data.data.

  • data_dict (dict) – The keys are the fields of dtype and

  • arrays. (the values are the related) –

save(path: Path)#

Store data to file.

depths: list#

Circuits depths.

uncertainties: Optional[float]#

Parameters uncertainties.

seed: Optional[int]#
nshots: int#

Number of shots.

niter: int#

Number of iterations for each depth.

data: dict[typing.Union[int, str, tuple[typing.Union[int, str], typing.Union[int, str]]], numpy.ndarray[typing.Any, numpy.dtype[dtype([('samples', '<i4')])]]]#

Raw data acquired.

circuits: dict[Union[int, str, tuple[Union[int, str], Union[int, str]]], list[list[int]]]#

Clifford gate indexes executed.

class qibocal.protocols.randomized_benchmarking.utils.RB2QInterData(depths: list, uncertainties: ~typing.Optional[float], seed: ~typing.Optional[int], nshots: int, niter: int, data: dict[typing.Union[int, str, tuple[typing.Union[int, str], typing.Union[int, str]]], numpy.ndarray[typing.Any, numpy.dtype[dtype([('samples', '<i4')])]]] = <factory>, circuits: dict[typing.Union[int, str, tuple[typing.Union[int, str], typing.Union[int, str]]], list[list[int]]] = <factory>, npulses_per_clifford: float = 8.6, fidelity: dict[tuple[typing.Union[int, str], typing.Union[int, str]], list] = <factory>)[source]#

Bases: RB2QData

The output of the acquisition function.

fidelity: dict[tuple[Union[int, str], Union[int, str]], list]#

The interleaved fidelity of this qubit.

_to_json(path: Path, filename: str)#

Helper function to dump to json.

_to_npz(path: Path, filename: str)#

Helper function to use np.savez while converting keys into strings.

extract_probabilities(qubits)#

Extract the probabilities given (qubit, qubit)

static load_data(path: Path, filename: str)#

Load data stored in a npz file.

static load_params(path: Path, filename: str)#

Load parameters stored in a json file.

npulses_per_clifford: float = 8.6#

Number of pulses for an average clifford.

property pairs#

Access qubit pairs ordered alphanumerically from data structure.

property params: dict#

Convert non-arrays attributes into dict.

property qubits#

Access qubits from data structure.

register_qubit(dtype, data_keys, data_dict)#

Store output for single qubit.

Parameters:
  • data_keys (tuple) – Keys of Data.data.

  • data_dict (dict) – The keys are the fields of dtype and

  • arrays. (the values are the related) –

save(path: Path)#

Store data to file.

depths: list#

Circuits depths.

uncertainties: Optional[float]#

Parameters uncertainties.

seed: Optional[int]#
nshots: int#

Number of shots.

niter: int#

Number of iterations for each depth.

data: dict[typing.Union[int, str, tuple[typing.Union[int, str], typing.Union[int, str]]], numpy.ndarray[typing.Any, numpy.dtype[dtype([('samples', '<i4')])]]]#

Raw data acquired.

circuits: dict[Union[int, str, tuple[Union[int, str], Union[int, str]]], list[list[int]]]#

Clifford gate indexes executed.

class qibocal.protocols.randomized_benchmarking.utils.StandardRBResult(fidelity: dict[typing.Union[int, str], float], pulse_fidelity: dict[typing.Union[int, str], float], fit_parameters: dict[typing.Union[int, str], list[float]], fit_uncertainties: dict[typing.Union[int, str], list[float]], error_bars: dict[typing.Union[int, str], typing.Union[float, list[float], NoneType]] = <factory>)[source]#

Bases: Results

Standard RB outputs.

fidelity: dict[Union[int, str], float]#

The overall fidelity of this qubit.

_to_json(path: Path, filename: str)#

Helper function to dump to json.

_to_npz(path: Path, filename: str)#

Helper function to use np.savez while converting keys into strings.

static load_data(path: Path, filename: str)#

Load data stored in a npz file.

static load_params(path: Path, filename: str)#

Load parameters stored in a json file.

property params: dict#

Convert non-arrays attributes into dict.

save(path: Path)#

Store results to file.

pulse_fidelity: dict[Union[int, str], float]#

The pulse fidelity of the gates acting on this qubit.

fit_parameters: dict[Union[int, str], list[float]]#

Raw fitting parameters.

fit_uncertainties: dict[Union[int, str], list[float]]#

Fitting parameters uncertainties.

error_bars: dict[Union[int, str], Union[float, list[float], NoneType]]#

Error bars for y.

qibocal.protocols.randomized_benchmarking.utils.setup(params: Parameters, platform: CalibrationPlatform, single_qubit: bool = True, interleave: Optional[str] = None)[source]#

Set up the randomized benchmarking experiment backend and data class.

Parameters:
  • params (Parameters) – The parameters for the experiment.

  • single_qubit (bool, optional) – Flag indicating whether the experiment is for a single qubit or two qubits. Defaults to True.

  • interleave – (str, optional): The type of interleaving to apply. Defaults to None.

Returns:

A tuple containing the experiment data and backend.

Return type:

tuple

qibocal.protocols.randomized_benchmarking.utils.get_circuits(params, targets, add_inverse_layer, interleave, single_qubit=True)[source]#

Generate randomized benchmarking circuits.

Parameters:
  • params (Parameters) – Experiment parameters.

  • targets (list) – List of target qubit IDs.

  • add_inverse_layer (bool) – Flag indicating whether to add an inverse layer to the circuits.

  • interleave (str) – String indicating whether to interleave the circuits with the given gate.

  • single_qubit (bool, optional) – Flag indicating whether to generate single qubit circuits.

Returns:

A tuple containing the generated circuits, indexes, and the number of pulses per Clifford.
  • circuits (list): List of generated circuits.

  • indexes (dict): Dictionary containing the random indexes for each qubit and depth.

  • npulses_per_clifford (float): Number of pulses per Clifford.

Return type:

tuple

qibocal.protocols.randomized_benchmarking.utils.execute_circuits(circuits, targets, params, backend, single_qubit=True)[source]#

Executes a list of circuits on a given backend.

Parameters:
  • circuits (list) – List of quantum circuits to be executed.

  • targets (list) – List of target qubits for each circuit.

  • params (Parameters) – Experiment parameters.

  • backend (object) – Backend to execute the circuits on.

  • single_qubit (bool) – Flag indicating whether the circuits are single-qubit or multi-qubit.

Returns:

List of executed circuits.

Return type:

list

qibocal.protocols.randomized_benchmarking.utils.rb_acquisition(params: Parameters, platform: CalibrationPlatform, targets: list[Union[int, str]], add_inverse_layer: bool = True, interleave: str = None) RBData[source]#

RB data acquisition function.

This function performs data acquisition for randomized benchmarking experiments.

Parameters:
  • params (RBParameters) – All parameters in one object.

  • targets (dict[int, Union[str, int]] or list[Union[str, int]]) – List of qubits the experiment is executed on.

  • add_inverse_layer (bool, optional) – Whether to add an inverse layer to the circuits. Defaults to True.

  • interleave (str, optional) – Interleaving pattern for the circuits. Defaults to None.

Returns:

The depths, samples, and ground state probability of each experiment in the scan.

Return type:

RBData

qibocal.protocols.randomized_benchmarking.utils.twoq_rb_acquisition(params: Parameters, platform: CalibrationPlatform, targets: list[tuple[Union[int, str], Union[int, str]]], add_inverse_layer: bool = True, interleave: str = None) Union[RB2QData, RB2QInterData][source]#

The data acquisition stage of two qubit Standard Randomized Benchmarking.

Parameters:
  • params (RB2QParameters) – The parameters for the randomized benchmarking experiment.

  • targets (list[QubitPairId]) – The list of qubit pair IDs on which to perform the benchmarking.

  • add_inverse_layer (bool, optional) – Whether to add an inverse layer to the circuits. Defaults to True.

  • interleave (str, optional) – The type of interleaving to apply. Defaults to None.

Returns:

The acquired data for two qubit randomized benchmarking.

Return type:

RB2QData

qibocal.protocols.randomized_benchmarking.utils.layer_circuit(rb_gen: Callable, depth: int, target, interleave: str = None) tuple[qibo.models.circuit.Circuit, list][source]#

Creates a circuit of depth layers from a generator layer_gen yielding Circuit or Gate and a dictionary with random indexes used to select the clifford gates.

Parameters:
  • layer_gen (Callable) – Should return gates or a full circuit specifying a layer.

  • depth (int) – Number of layers.

  • interleave (str, optional) – Interleaving pattern for the circuits. Defaults to None.

Returns:

with depth many layers.

Return type:

Circuit

qibocal.protocols.randomized_benchmarking.utils.add_inverse_layer(circuit: Circuit, rb_gen: RB_Generator, single_qubit=True, file_inv=PosixPath('.'))[source]#

Adds an inverse gate/inverse gates at the end of a circuit (in place).

Parameters:

circuit (Circuit) – circuit

qibocal.protocols.randomized_benchmarking.utils.add_measurement_layer(circuit: Circuit)[source]#

Adds a measurement layer at the end of the circuit.

Parameters:

circuit (Circuit) – Measurement gates added in place to end of this circuit.

qibocal.protocols.randomized_benchmarking.utils.fit(qubits, data)[source]#

Takes data, extracts the depths and the signal and fits it with an exponential function y = Ap^x+B.