diff --git a/qiskit/ignis/mitigation/measurement/filters.py b/qiskit/ignis/mitigation/measurement/filters.py index e8a9f69fd..81197e9fd 100644 --- a/qiskit/ignis/mitigation/measurement/filters.py +++ b/qiskit/ignis/mitigation/measurement/filters.py @@ -19,6 +19,8 @@ Measurement correction filters. """ + +from typing import List, Union from copy import deepcopy from scipy.optimize import minimize import scipy.linalg as la @@ -219,15 +221,20 @@ class TensoredFilter(): def __init__(self, cal_matrices: np.matrix, - substate_labels_list: list): + substate_labels_list: list, + mit_pattern: list): """ 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). Args: cal_matrices: the calibration matrices for applying the correction. substate_labels_list: for each calibration matrix a list of the states (as strings, states in the subspace) + mit_pattern: for each calibration matrix + a list of the logical qubit indices (as int, states in the subspace) """ self._cal_matrices = cal_matrices @@ -235,6 +242,7 @@ def __init__(self, self._indices_list = [] self._substate_labels_list = [] self.substate_labels_list = substate_labels_list + self._mit_pattern = mit_pattern @property def cal_matrices(self): @@ -279,7 +287,10 @@ def nqubits(self): """Return the number of qubits. See also MeasurementFilter.apply() """ return sum(self._qubit_list_sizes) - def apply(self, raw_data, method='least_squares'): + def apply(self, + raw_data: Union[qiskit.result.result.Result, dict], + method: str = 'least_squares', + meas_layout: List[int] = None): """ Apply the calibration matrices to results. @@ -293,11 +304,50 @@ def apply(self, raw_data, method='least_squares'): 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\times 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: dict or Result: The corrected data in the same form as raw_data @@ -308,6 +358,11 @@ def apply(self, raw_data, method='least_squares'): all_states = count_keys(self.nqubits) num_of_states = 2**self.nqubits + if meas_layout is None: + meas_layout = [] + for qubits in self._mit_pattern: + meas_layout += qubits + # check forms of raw_data if isinstance(raw_data, dict): # counts dictionary @@ -326,7 +381,7 @@ def apply(self, raw_data, method='least_squares'): new_counts_list = parallel_map( self._apply_correction, [resultidx for resultidx, _ in enumerate(raw_data.results)], - task_args=(raw_data, method)) + task_args=(raw_data, method, meas_layout)) for resultidx, new_counts in new_counts_list: new_result.results[resultidx].data.counts = new_counts @@ -341,73 +396,49 @@ def apply(self, raw_data, method='least_squares'): for cal_mat in self._cal_matrices: pinv_cal_matrices.append(la.pinv(cal_mat)) + meas_layout = meas_layout[::-1] # reverse endian + qubits_to_clbits = [-1 for _ in range(max(meas_layout) + 1)] + for i, qubit in enumerate(meas_layout): + qubits_to_clbits[qubit] = i + # Apply the correction for data_idx, _ in enumerate(raw_data2): if method == 'pseudo_inverse': - inv_mat_dot_raw = np.zeros([num_of_states], dtype=float) - for state1_idx, state1 in enumerate(all_states): - for state2_idx, state2 in enumerate(all_states): - if raw_data2[data_idx][state2_idx] == 0: - continue - - product = 1. - end_index = self.nqubits - for p_ind, pinv_mat in enumerate(pinv_cal_matrices): - - start_index = end_index - \ - self._qubit_list_sizes[p_ind] - - state1_as_int = \ - self._indices_list[p_ind][ - state1[start_index:end_index]] - - state2_as_int = \ - self._indices_list[p_ind][ - state2[start_index:end_index]] - - end_index = start_index - product *= \ - pinv_mat[state1_as_int][state2_as_int] - if product == 0: - break - inv_mat_dot_raw[state1_idx] += \ - (product * raw_data2[data_idx][state2_idx]) - raw_data2[data_idx] = inv_mat_dot_raw + for pinv_cal_mat, pos_qubits, indices in zip(pinv_cal_matrices, + self._mit_pattern, + self._indices_list): + inv_mat_dot_x = np.zeros([num_of_states], dtype=float) + pos_clbits = [qubits_to_clbits[qubit] for qubit in pos_qubits] + for state_idx, state in enumerate(all_states): + first_index = self.compute_index_of_cal_mat(state, pos_clbits, indices) + for i in range(len(pinv_cal_mat)): # i is index of pinv_cal_mat + source_state = self.flip_state(state, i, pos_clbits) + second_index = self.compute_index_of_cal_mat(source_state, + pos_clbits, + indices) + inv_mat_dot_x[state_idx] += pinv_cal_mat[first_index, second_index]\ + * raw_data2[data_idx][int(source_state, 2)] + raw_data2[data_idx] = inv_mat_dot_x elif method == 'least_squares': - def fun(x): - mat_dot_x = np.zeros([num_of_states], dtype=float) - for state1_idx, state1 in enumerate(all_states): - mat_dot_x[state1_idx] = 0. - for state2_idx, state2 in enumerate(all_states): - if x[state2_idx] != 0: - product = 1. - end_index = self.nqubits - for c_ind, cal_mat in \ - enumerate(self._cal_matrices): - - start_index = end_index - \ - self._qubit_list_sizes[c_ind] - - state1_as_int = \ - self._indices_list[c_ind][ - state1[start_index:end_index]] - - state2_as_int = \ - self._indices_list[c_ind][ - state2[start_index:end_index]] - - end_index = start_index - product *= \ - cal_mat[state1_as_int][state2_as_int] - if product == 0: - break - mat_dot_x[state1_idx] += \ - (product * x[state2_idx]) - return sum( - (raw_data2[data_idx] - mat_dot_x)**2) + mat_dot_x = deepcopy(x) + for cal_mat, pos_qubits, indices in zip(self._cal_matrices, + self._mit_pattern, + self._indices_list): + res_mat_dot_x = np.zeros([num_of_states], dtype=float) + pos_clbits = [qubits_to_clbits[qubit] for qubit in pos_qubits] + for state_idx, state in enumerate(all_states): + second_index = self.compute_index_of_cal_mat(state, pos_clbits, indices) + for i in range(len(cal_mat)): + target_state = self.flip_state(state, i, pos_clbits) + first_index =\ + self.compute_index_of_cal_mat(target_state, pos_clbits, indices) + res_mat_dot_x[int(target_state, 2)]\ + += cal_mat[first_index, second_index] * mat_dot_x[state_idx] + mat_dot_x = res_mat_dot_x + return sum((raw_data2[data_idx] - mat_dot_x) ** 2) x0 = np.random.rand(num_of_states) x0 = x0 / sum(x0) @@ -429,8 +460,32 @@ def fun(x): return new_count_dict - def _apply_correction(self, resultidx, raw_data, method): + def flip_state(self, state: str, mat_index: int, flip_poses: List[int]) -> str: + """Flip the state according to the chosen qubit positions""" + flip_poses = [pos for i, pos in enumerate(flip_poses) if (mat_index >> i) & 1] + flip_poses = sorted(flip_poses) + new_state = "" + pos = 0 + for flip_pos in flip_poses: + new_state += state[pos:flip_pos] + new_state += str(int(state[flip_pos], 2) ^ 1) # flip the state + pos = flip_pos + 1 + new_state += state[pos:] + return new_state + + def compute_index_of_cal_mat(self, state: str, pos_qubits: List[int], indices: dict) -> int: + """Return the index of (pseudo inverse) calibration matrix for the input quantum state""" + sub_state = "" + for pos in pos_qubits: + sub_state += state[pos] + return indices[sub_state] + + def _apply_correction(self, + resultidx: int, + raw_data: qiskit.result.result.Result, + method: str, + meas_layout: List[int]): """Wrapper to call apply with a counts dictionary.""" new_counts = self.apply( - raw_data.get_counts(resultidx), method=method) + raw_data.get_counts(resultidx), method=method, meas_layout=meas_layout) return resultidx, new_counts diff --git a/qiskit/ignis/mitigation/measurement/fitters.py b/qiskit/ignis/mitigation/measurement/fitters.py index cef15a4da..7420cdb00 100644 --- a/qiskit/ignis/mitigation/measurement/fitters.py +++ b/qiskit/ignis/mitigation/measurement/fitters.py @@ -258,6 +258,7 @@ def __init__(self, self._result_list = [] self._cal_matrices = None self._circlabel = circlabel + self._mit_pattern = mit_pattern self._qubit_list_sizes = \ [len(qubit_list) for qubit_list in mit_pattern] @@ -298,7 +299,7 @@ def substate_labels_list(self): @property def filter(self): """Return a measurement filter using the cal matrices.""" - return TensoredFilter(self._cal_matrices, self._substate_labels_list) + return TensoredFilter(self._cal_matrices, self._substate_labels_list, self._mit_pattern) @property def nqubits(self): diff --git a/test/measurement_calibration/generate_data.py b/test/measurement_calibration/generate_data.py index 50ea7982b..ca2b34177 100644 --- a/test/measurement_calibration/generate_data.py +++ b/test/measurement_calibration/generate_data.py @@ -67,6 +67,7 @@ def tensored_calib_circ_creation(): """ mit_pattern = [[2], [4, 1]] + meas_layout = [2, 4, 1] qr = qiskit.QuantumRegister(5) # Generate the calibration circuits meas_calibs, mit_pattern = tensored_meas_cal(mit_pattern, qr=qr) @@ -79,7 +80,7 @@ def tensored_calib_circ_creation(): ghz_circ.measure(mit_pattern[0][0], cr[0]) ghz_circ.measure(mit_pattern[1][0], cr[1]) ghz_circ.measure(mit_pattern[1][1], cr[2]) - return meas_calibs, mit_pattern, ghz_circ + return meas_calibs, mit_pattern, ghz_circ, meas_layout def meas_calibration_circ_execution(shots: int, seed: int): @@ -127,7 +128,7 @@ def tensored_calib_circ_execution(shots: int, seed: int): dict: dictionary of results counts of GHZ circuit simulation with measurement errors """ # define the circuits - meas_calibs, mit_pattern, ghz_circ = tensored_calib_circ_creation() + meas_calibs, mit_pattern, ghz_circ, meas_layout = tensored_calib_circ_creation() # define noise prob = 0.2 error_meas = pauli_error([('X', prob), ('I', 1 - prob)]) @@ -142,7 +143,7 @@ def tensored_calib_circ_execution(shots: int, seed: int): ghz_results = qiskit.execute(ghz_circ, backend=backend, shots=shots, noise_model=noise_model, seed_simulator=seed).result() - return cal_results, mit_pattern, ghz_results + return cal_results, mit_pattern, ghz_results, meas_layout def generate_meas_calibration(results_file_path: str, runs: int): @@ -198,7 +199,7 @@ def generate_tensormeas_calibration(results_file_path: str): Args: results_file_path: path of the json file of the results file """ - cal_results, mit_pattern, circuit_results = \ + cal_results, mit_pattern, circuit_results, meas_layout = \ tensored_calib_circ_execution(1000, SEED) meas_cal = TensoredMeasFitter(cal_results, mit_pattern=mit_pattern) @@ -206,12 +207,13 @@ def generate_tensormeas_calibration(results_file_path: str): # Calculate the results after mitigation results_pseudo_inverse = meas_filter.apply( - circuit_results.get_counts(), method='pseudo_inverse') + circuit_results.get_counts(), method='pseudo_inverse', meas_layout=meas_layout) results_least_square = meas_filter.apply( - circuit_results.get_counts(), method='least_squares') + circuit_results.get_counts(), method='least_squares', meas_layout=meas_layout) results = {"cal_results": cal_results.to_dict(), "results": circuit_results.to_dict(), "mit_pattern": mit_pattern, + "meas_layout": meas_layout, "fidelity": meas_cal.readout_fidelity(), "results_pseudo_inverse": results_pseudo_inverse, "results_least_square": results_least_square} diff --git a/test/measurement_calibration/test_meas.py b/test/measurement_calibration/test_meas.py index c1f2091bb..beb010d5a 100644 --- a/test/measurement_calibration/test_meas.py +++ b/test/measurement_calibration/test_meas.py @@ -294,6 +294,7 @@ def test_ideal_tensored_meas_cal(self): """Test ideal execution, without noise.""" mit_pattern = [[1, 2], [3, 4, 5], [6]] + meas_layout = [1, 2, 3, 4, 5, 6] # Generate the calibration circuits meas_calibs, _ = tensored_meas_cal(mit_pattern=mit_pattern) @@ -332,9 +333,11 @@ def test_ideal_tensored_meas_cal(self): # Apply the calibration matrix to results # in list and dict forms using different methods results_dict_1 = meas_filter.apply(results_dict, - method='least_squares') + method='least_squares', + meas_layout=meas_layout) results_dict_0 = meas_filter.apply(results_dict, - method='pseudo_inverse') + method='pseudo_inverse', + meas_layout=meas_layout) # Assert that the results are equally distributed self.assertDictEqual(results_dict, results_dict_0) @@ -347,7 +350,7 @@ def test_tensored_meas_cal_on_circuit(self): """Test an execution on a circuit.""" # Generate the calibration circuits - meas_calibs, mit_pattern, ghz = tensored_calib_circ_creation() + meas_calibs, mit_pattern, ghz, meas_layout = tensored_calib_circ_creation() # Run the calibration circuits backend = Aer.get_backend('qasm_simulator') @@ -375,9 +378,9 @@ def test_tensored_meas_cal_on_circuit(self): # Calculate the results after mitigation output_results_pseudo_inverse = meas_filter.apply( - results, method='pseudo_inverse').get_counts(0) + results, method='pseudo_inverse', meas_layout=meas_layout).get_counts(0) output_results_least_square = meas_filter.apply( - results, method='least_squares').get_counts(0) + results, method='least_squares', meas_layout=meas_layout).get_counts(0) # Compare with expected fidelity and expected results self.assertAlmostEqual(fidelity, 1.0) @@ -427,9 +430,11 @@ def test_tensored_meas_fitter_with_noise(self): # Calculate the results after mitigation output_results_pseudo_inverse = meas_filter.apply( - saved_info['results'].get_counts(0), method='pseudo_inverse') + saved_info['results'].get_counts(0), + method='pseudo_inverse', + meas_layout=saved_info['meas_layout']) output_results_least_square = meas_filter.apply( - saved_info['results'], method='least_squares') + saved_info['results'], method='least_squares', meas_layout=saved_info['meas_layout']) self.assertAlmostEqual( output_results_pseudo_inverse['000'], @@ -467,9 +472,11 @@ def test_tensored_meas_fitter_with_noise(self): # Calculate the results after mitigation output_results_pseudo_inverse = meas_filter.apply( - saved_info['results'].get_counts(0), method='pseudo_inverse') + saved_info['results'].get_counts(0), + method='pseudo_inverse', + meas_layout=saved_info['meas_layout']) output_results_least_square = meas_filter.apply( - saved_info['results'], method='least_squares') + saved_info['results'], method='least_squares', meas_layout=saved_info['meas_layout']) self.assertAlmostEqual( output_results_pseudo_inverse['000'], diff --git a/test/measurement_calibration/test_meas_results.json b/test/measurement_calibration/test_meas_results.json index 033cfb269..69f25b53f 100644 --- a/test/measurement_calibration/test_meas_results.json +++ b/test/measurement_calibration/test_meas_results.json @@ -1 +1 @@ -[{"cal_matrix": [[0.44238281, 0.05566406, 0.06152344, 0.00976562, 0.05078125, 0.00878906, 0.00683594, 0.00195312], [0.16015625, 0.50195312, 0.0234375, 0.07910156, 0.01464844, 0.07324219, 0.00390625, 0.00585938], [0.12597656, 0.02050781, 0.50390625, 0.05566406, 0.02148438, 0.00097656, 0.06445312, 0.00488281], [0.0390625, 0.1875, 0.16015625, 0.62011719, 0.01171875, 0.02539062, 0.02441406, 0.07324219], [0.140625, 0.02050781, 0.01367188, 0.00195312, 0.50195312, 0.06933594, 0.06640625, 0.015625], [0.04199219, 0.15820312, 0.00292969, 0.02441406, 0.15332031, 0.61425781, 0.02050781, 0.078125], [0.0390625, 0.00683594, 0.17675781, 0.0234375, 0.1875, 0.02539062, 0.61523438, 0.08886719], [0.01074219, 0.04882812, 0.05761719, 0.18554688, 0.05859375, 0.18261719, 0.19824219, 0.73144531]], "fidelity": 0.5626220703125, "results": {"001": 75, "010": 75, "100": 73, "000": 209, "110": 63, "101": 73, "111": 399, "011": 57}, "results_pseudo_inverse": {"000": 467.50917920701283, "001": -9.531737085939437, "010": 29.558556028438662, "011": -6.008851307135412, "100": -4.093789013503745, "101": 22.63568794725104, "110": -12.630370153454054, "111": 536.5613240573772}, "results_least_square": {"000": 459.020911256551, "001": 7.341523222681445e-14, "010": 18.895659397949345, "011": 2.4304993781476547e-14, "100": 6.01205283473627e-14, "101": 16.439452980690653, "110": 6.432126966465779e-14, "111": 529.6439763648087}}, {"cal_matrix": [[0.4052734375, 0.0634765625, 0.0615234375, 0.009765625, 0.0517578125, 0.0087890625, 0.0087890625, 0.0], [0.12890625, 0.4873046875, 0.017578125, 0.0673828125, 0.021484375, 0.056640625, 0.0009765625, 0.0068359375], [0.146484375, 0.0244140625, 0.5234375, 0.0771484375, 0.01953125, 0.0009765625, 0.07421875, 0.0068359375], [0.041015625, 0.17578125, 0.1484375, 0.59765625, 0.00390625, 0.025390625, 0.0263671875, 0.08203125], [0.1748046875, 0.0185546875, 0.0224609375, 0.001953125, 0.5078125, 0.0751953125, 0.0703125, 0.0107421875], [0.0498046875, 0.162109375, 0.005859375, 0.0224609375, 0.16796875, 0.6259765625, 0.025390625, 0.0947265625], [0.0380859375, 0.0126953125, 0.16015625, 0.025390625, 0.1640625, 0.01953125, 0.578125, 0.078125], [0.015625, 0.0556640625, 0.060546875, 0.1982421875, 0.0634765625, 0.1875, 0.2158203125, 0.720703125]], "fidelity": 0.5557861328125, "results": {"001": 71, "011": 60, "111": 393, "110": 64, "101": 69, "000": 217, "100": 74, "010": 76}, "results_pseudo_inverse": {"011": -6.8815256891790195, "110": 22.619248458685863, "111": 534.6299647735469, "101": 0.9243073704424183, "010": -14.241362831443489, "001": -2.1230898660093067, "100": -55.62171263469475, "000": 544.6941704186509}, "results_least_square": {"111": 526.9381028692694, "101": 5.535363833963913e-13, "010": 3.6472908027107565e-13, "011": 1.9366452885805074e-14, "001": 1.4224732503009818e-13, "100": 1.485506162524075e-12, "000": 497.0618971307282}}, {"cal_matrix": [[0.419921875, 0.0595703125, 0.05859375, 0.00390625, 0.05859375, 0.0078125, 0.0107421875, 0.001953125], [0.123046875, 0.48828125, 0.0205078125, 0.06640625, 0.017578125, 0.068359375, 0.00390625, 0.0048828125], [0.1337890625, 0.0224609375, 0.46484375, 0.0673828125, 0.0224609375, 0.0029296875, 0.05078125, 0.0146484375], [0.048828125, 0.189453125, 0.1865234375, 0.6005859375, 0.005859375, 0.0234375, 0.02734375, 0.08984375], [0.1630859375, 0.017578125, 0.0185546875, 0.0029296875, 0.5009765625, 0.07421875, 0.06640625, 0.005859375], [0.048828125, 0.1640625, 0.00390625, 0.01953125, 0.1689453125, 0.603515625, 0.021484375, 0.0849609375], [0.048828125, 0.0078125, 0.17578125, 0.0263671875, 0.1630859375, 0.01953125, 0.62890625, 0.0732421875], [0.013671875, 0.05078125, 0.0712890625, 0.212890625, 0.0625, 0.2001953125, 0.1904296875, 0.724609375]], "fidelity": 0.553955078125, "results": {"110": 56, "011": 61, "101": 72, "000": 214, "100": 85, "010": 73, "111": 389, "001": 74}, "results_pseudo_inverse": {"101": -2.238556155943683, "100": 0.3942157002026464, "000": 504.5427395146546, "001": 23.025360373240567, "111": 537.1157356019106, "110": -11.579410856888408, "010": -1.169412176840766, "011": -26.090672000335474}, "results_least_square": {"101": 1.6470194662123887, "100": 3.704068302079477e-15, "000": 495.51971581347107, "001": 6.66022993369183, "111": 520.1730347866247, "110": 2.3160726808635346e-15, "010": 5.309554879096012e-15, "011": 1.8772526935717515e-14}}] \ No newline at end of file +[{"cal_matrix": [[0.525, 0.139, 0.138, 0.029, 0.111, 0.04, 0.034, 0.001], [0.12, 0.479, 0.027, 0.119, 0.034, 0.135, 0.008, 0.021], [0.12, 0.029, 0.498, 0.125, 0.028, 0.006, 0.122, 0.044], [0.025, 0.15, 0.112, 0.518, 0.004, 0.031, 0.036, 0.115], [0.127, 0.027, 0.039, 0.006, 0.527, 0.136, 0.137, 0.032], [0.034, 0.133, 0.006, 0.041, 0.125, 0.496, 0.04, 0.124], [0.041, 0.008, 0.152, 0.03, 0.129, 0.026, 0.502, 0.12], [0.008, 0.035, 0.028, 0.132, 0.042, 0.13, 0.121, 0.543]], "fidelity": 0.511, "results": {"000": 262, "001": 78, "010": 80, "011": 71, "100": 81, "101": 74, "110": 83, "111": 271}, "results_pseudo_inverse": {"000": 492.9099388325381, "001": 22.153517062888962, "010": -4.706727014444115, "011": -1.0935083046270806, "100": 6.291603927125484, "101": -15.708122757406755, "110": 7.696572307119034, "111": 492.4567259468068}, "results_least_square": {"000": 492.7043000854257, "001": 13.992127258631626, "010": 5.054252372529988e-15, "101": 1.0988822699009582e-14, "110": 7.097419553444617, "111": 486.2061531024981}}, {"cal_matrix": [[0.52, 0.136, 0.13, 0.034, 0.108, 0.035, 0.035, 0.002], [0.122, 0.49, 0.026, 0.114, 0.035, 0.128, 0.008, 0.026], [0.125, 0.03, 0.494, 0.123, 0.027, 0.006, 0.121, 0.045], [0.027, 0.145, 0.116, 0.518, 0.006, 0.03, 0.036, 0.114], [0.128, 0.027, 0.043, 0.005, 0.53, 0.13, 0.136, 0.033], [0.032, 0.13, 0.005, 0.038, 0.127, 0.522, 0.042, 0.128], [0.038, 0.007, 0.158, 0.028, 0.121, 0.022, 0.507, 0.119], [0.008, 0.035, 0.028, 0.14, 0.046, 0.127, 0.115, 0.533]], "fidelity": 0.5142500000000001, "results": {"000": 244, "001": 78, "010": 85, "011": 75, "100": 80, "101": 72, "110": 82, "111": 284}, "results_pseudo_inverse": {"000": 458.84390608495875, "001": 23.71396253316134, "010": 6.762483857315876, "011": -2.4674433514126566, "100": 12.842449625711403, "101": -29.165658616184817, "110": -1.3420304222666584, "111": 530.8123302887168}, "results_least_square": {"000": 463.4366567294065, "001": 8.196674750914557, "010": 4.602402340695803, "011": 2.925240286661958, "100": 1.5559737743045532e-14, "110": 2.9911168174649756, "111": 517.8479090748565}}, {"cal_matrix": [[0.516, 0.136, 0.127, 0.039, 0.111, 0.038, 0.038, 0.002], [0.12, 0.502, 0.028, 0.123, 0.037, 0.12, 0.007, 0.028], [0.129, 0.029, 0.498, 0.119, 0.028, 0.006, 0.127, 0.044], [0.031, 0.141, 0.118, 0.508, 0.008, 0.029, 0.035, 0.099], [0.125, 0.025, 0.04, 0.006, 0.535, 0.135, 0.133, 0.037], [0.028, 0.128, 0.006, 0.034, 0.125, 0.536, 0.041, 0.132], [0.043, 0.005, 0.152, 0.027, 0.118, 0.021, 0.509, 0.123], [0.008, 0.034, 0.031, 0.144, 0.038, 0.115, 0.11, 0.535]], "fidelity": 0.517375, "results": {"000": 239, "001": 82, "010": 84, "011": 74, "100": 82, "101": 73, "110": 81, "111": 285}, "results_pseudo_inverse": {"000": 450.4898299766947, "001": 29.559626796806434, "010": 3.877053701424604, "011": 8.158454396430441, "100": 19.97830096423125, "101": -28.96199670741543, "110": -12.06277910481976, "111": 528.9615099766486}, "results_least_square": {"000": 454.73293276857305, "001": 15.227175183932054, "010": 8.397362666334729e-15, "011": 13.22438568080568, "100": 3.419967048340725, "111": 513.3955393183487}}] \ No newline at end of file diff --git a/test/measurement_calibration/test_tensored_meas_results.json b/test/measurement_calibration/test_tensored_meas_results.json index 3787b96c6..9e6f8d337 100644 --- a/test/measurement_calibration/test_tensored_meas_results.json +++ b/test/measurement_calibration/test_tensored_meas_results.json @@ -1 +1 @@ -{"cal_results": {"success": true, "qobj_id": "de919c7b-8630-4eb7-abbb-0965f73ce0f0", "job_id": "65ff8a63-4fa1-4464-ac67-313ee9066441", "backend_name": "qasm_simulator", "results": [{"shots": 10000, "success": true, "meas_level": 2, "status": "DONE", "seed": 2728198423, "header": {"n_qubits": 5, "creg_sizes": [["c0", 3]], "memory_slots": 3, "name": "cal_000", "clbit_labels": [["c0", 0], ["c0", 1], ["c0", 2]], "qreg_sizes": [["q0", 5]], "compiled_circuit_qasm": "OPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q0[5];\ncreg c0[3];\nbarrier q0[0],q0[1],q0[2],q0[3],q0[4];\nmeasure q0[1] -> c0[2];\nmeasure q0[4] -> c0[1];\nmeasure q0[2] -> c0[0];\n", "qubit_labels": [["q0", 0], ["q0", 1], ["q0", 2], ["q0", 3], ["q0", 4]]}, "data": {"counts": {"0x3": 28, "0x5": 619, "0x1": 259, "0x0": 2436, "0x2": 288, "0x6": 643, "0x7": 71, "0x4": 5656}}, "metadata": {"method": "stabilizer", "omp_shot_threads": 1, "omp_state_threads": 4}, "time_taken": 0.441063949}, {"shots": 10000, "success": true, "meas_level": 2, "status": "DONE", "seed": 3271195829, "header": {"n_qubits": 5, "creg_sizes": [["c0", 3]], "memory_slots": 3, "name": "cal_010", "clbit_labels": [["c0", 0], ["c0", 1], ["c0", 2]], "qreg_sizes": [["q0", 5]], "compiled_circuit_qasm": "OPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q0[5];\ncreg c0[3];\nx q0[4];\nbarrier q0[0],q0[1],q0[2],q0[3],q0[4];\nmeasure q0[1] -> c0[2];\nmeasure q0[4] -> c0[1];\nmeasure q0[2] -> c0[0];\n", "qubit_labels": [["q0", 0], ["q0", 1], ["q0", 2], ["q0", 3], ["q0", 4]]}, "data": {"counts": {"0x3": 234, "0x5": 199, "0x1": 85, "0x0": 816, "0x2": 1870, "0x6": 4450, "0x7": 494, "0x4": 1852}}, "metadata": {"method": "stabilizer", "omp_shot_threads": 1, "omp_state_threads": 4}, "time_taken": 0.45755808800000003}, {"shots": 10000, "success": true, "meas_level": 2, "status": "DONE", "seed": 3279238272, "header": {"n_qubits": 5, "creg_sizes": [["c0", 3]], "memory_slots": 3, "name": "cal_101", "clbit_labels": [["c0", 0], ["c0", 1], ["c0", 2]], "qreg_sizes": [["q0", 5]], "compiled_circuit_qasm": "OPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q0[5];\ncreg c0[3];\nx q0[2];\nx q0[1];\nbarrier q0[0],q0[1],q0[2],q0[3],q0[4];\nmeasure q0[1] -> c0[2];\nmeasure q0[4] -> c0[1];\nmeasure q0[2] -> c0[0];\n", "qubit_labels": [["q0", 0], ["q0", 1], ["q0", 2], ["q0", 3], ["q0", 4]]}, "data": {"counts": {"0x3": 665, "0x5": 586, "0x1": 5737, "0x0": 2392, "0x2": 259, "0x6": 25, "0x7": 69, "0x4": 267}}, "metadata": {"method": "stabilizer", "omp_shot_threads": 1, "omp_state_threads": 4}, "time_taken": 0.40785874200000005}, {"shots": 10000, "success": true, "meas_level": 2, "status": "DONE", "seed": 699020541, "header": {"n_qubits": 5, "creg_sizes": [["c0", 3]], "memory_slots": 3, "name": "cal_111", "clbit_labels": [["c0", 0], ["c0", 1], ["c0", 2]], "qreg_sizes": [["q0", 5]], "compiled_circuit_qasm": "OPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q0[5];\ncreg c0[3];\nx q0[4];\nx q0[2];\nx q0[1];\nbarrier q0[0],q0[1],q0[2],q0[3],q0[4];\nmeasure q0[1] -> c0[2];\nmeasure q0[4] -> c0[1];\nmeasure q0[2] -> c0[0];\n", "qubit_labels": [["q0", 0], ["q0", 1], ["q0", 2], ["q0", 3], ["q0", 4]]}, "data": {"counts": {"0x3": 4422, "0x5": 186, "0x1": 1964, "0x0": 771, "0x2": 1885, "0x6": 210, "0x7": 474, "0x4": 88}}, "metadata": {"method": "stabilizer", "omp_shot_threads": 1, "omp_state_threads": 4}, "time_taken": 0.44443157600000005}], "backend_version": "0.1.1", "status": "COMPLETED", "header": {"backend_name": "qasm_simulator"}, "date": "2019-04-14T09:49:37.988099", "metadata": {"omp_available_threads": 4, "omp_circuit_threads": 1, "omp_enabled": true, "time_taken": 1.7525742190000002}, "time_taken": 1.7591159343719482}, "results": {"success": true, "qobj_id": "bd90e3e6-69b7-4b0b-8ba1-24cad0097880", "job_id": "fdfbcfaf-b2e3-401f-89ba-9aa6c358b6c9", "backend_name": "qasm_simulator", "results": [{"shots": 10000, "success": true, "meas_level": 2, "status": "DONE", "seed": 2312113352, "header": {"n_qubits": 5, "creg_sizes": [["c1", 3]], "memory_slots": 3, "name": "circuit4", "clbit_labels": [["c1", 0], ["c1", 1], ["c1", 2]], "qreg_sizes": [["q0", 5]], "compiled_circuit_qasm": "OPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q0[5];\ncreg c1[3];\nh q0[2];\ncx q0[2],q0[4];\nmeasure q0[4] -> c1[1];\ncx q0[2],q0[1];\nmeasure q0[1] -> c1[2];\nmeasure q0[2] -> c1[0];\n", "qubit_labels": [["q0", 0], ["q0", 1], ["q0", 2], ["q0", 3], ["q0", 4]]}, "data": {"counts": {"0x3": 2246, "0x5": 405, "0x1": 1051, "0x0": 1618, "0x2": 1115, "0x6": 426, "0x7": 282, "0x4": 2857}}, "metadata": {"method": "stabilizer", "omp_shot_threads": 1, "omp_state_threads": 4}, "time_taken": 0.5319719380000001}], "backend_version": "0.1.1", "status": "COMPLETED", "header": {"backend_name": "qasm_simulator"}, "date": "2019-04-14T09:49:38.599101", "metadata": {"omp_available_threads": 4, "omp_circuit_threads": 1, "omp_enabled": true, "time_taken": 0.533921553}, "time_taken": 0.5382938385009766}, "mit_pattern": [[2], [4, 1]], "fidelity": 0.12717144000000002, "results_pseudo_inverse": {"010": -4.762260577621191, "000": 4983.13545892477, "111": 5013.092344396212, "001": 1.0257066860828559, "011": 14.63828774235185, "110": 74.90993623485235, "101": -93.14464986971788, "100": 11.1051764630743}, "results_least_square": {"010": 1.2095280562792334, "000": 4962.8015572363365, "111": 4952.072339561697, "001": 3.014328860511122e-12, "011": 5.054465201387589, "110": 78.862109944323, "101": 8.314347279223015e-12, "100": 1.4251742183764198e-12}} \ No newline at end of file +{"cal_results": {"backend_name": "qasm_simulator", "backend_version": "0.7.2", "qobj_id": "3c1f231c-2426-424d-93cb-dd92eaff71e3", "job_id": "c6a240a3-f4f2-40c1-8b6b-d327b4d4cb76", "success": true, "results": [{"shots": 1000, "success": true, "data": {"counts": {"0x0": 525, "0x1": 120, "0x2": 120, "0x3": 25, "0x4": 127, "0x5": 34, "0x6": 41, "0x7": 8}}, "meas_level": 2, "header": {"clbit_labels": [["c3", 0], ["c3", 1], ["c3", 2]], "creg_sizes": [["c3", 3]], "global_phase": 0.0, "memory_slots": 3, "n_qubits": 5, "name": "cal_000", "qreg_sizes": [["q12", 5]], "qubit_labels": [["q12", 0], ["q12", 1], ["q12", 2], ["q12", 3], ["q12", 4]]}, "status": "DONE", "seed_simulator": 42, "time_taken": 0.015758243, "metadata": {"fusion": {"enabled": false}, "measure_sampling": false, "method": "stabilizer", "parallel_shots": 8, "parallel_state_update": 1}}, {"shots": 1000, "success": true, "data": {"counts": {"0x0": 150, "0x1": 29, "0x2": 479, "0x3": 139, "0x4": 35, "0x5": 8, "0x6": 133, "0x7": 27}}, "meas_level": 2, "header": {"clbit_labels": [["c3", 0], ["c3", 1], ["c3", 2]], "creg_sizes": [["c3", 3]], "global_phase": 0.0, "memory_slots": 3, "n_qubits": 5, "name": "cal_010", "qreg_sizes": [["q12", 5]], "qubit_labels": [["q12", 0], ["q12", 1], ["q12", 2], ["q12", 3], ["q12", 4]]}, "status": "DONE", "seed_simulator": 2155, "time_taken": 0.015917254000000002, "metadata": {"fusion": {"enabled": false}, "measure_sampling": false, "method": "stabilizer", "parallel_shots": 8, "parallel_state_update": 1}}, {"shots": 1000, "success": true, "data": {"counts": {"0x0": 28, "0x1": 152, "0x2": 6, "0x3": 39, "0x4": 112, "0x5": 498, "0x6": 27, "0x7": 138}}, "meas_level": 2, "header": {"clbit_labels": [["c3", 0], ["c3", 1], ["c3", 2]], "creg_sizes": [["c3", 3]], "global_phase": 0.0, "memory_slots": 3, "n_qubits": 5, "name": "cal_101", "qreg_sizes": [["q12", 5]], "qubit_labels": [["q12", 0], ["q12", 1], ["q12", 2], ["q12", 3], ["q12", 4]]}, "status": "DONE", "seed_simulator": 4268, "time_taken": 0.016279841, "metadata": {"fusion": {"enabled": false}, "measure_sampling": false, "method": "stabilizer", "parallel_shots": 8, "parallel_state_update": 1}}, {"shots": 1000, "success": true, "data": {"counts": {"0x0": 6, "0x1": 41, "0x2": 30, "0x3": 132, "0x4": 29, "0x5": 119, "0x6": 125, "0x7": 518}}, "meas_level": 2, "header": {"clbit_labels": [["c3", 0], ["c3", 1], ["c3", 2]], "creg_sizes": [["c3", 3]], "global_phase": 0.0, "memory_slots": 3, "n_qubits": 5, "name": "cal_111", "qreg_sizes": [["q12", 5]], "qubit_labels": [["q12", 0], ["q12", 1], ["q12", 2], ["q12", 3], ["q12", 4]]}, "status": "DONE", "seed_simulator": 6381, "time_taken": 0.016813655, "metadata": {"fusion": {"enabled": false}, "measure_sampling": false, "method": "stabilizer", "parallel_shots": 8, "parallel_state_update": 1}}], "date": "2021-02-01T05:21:53.208856", "status": "COMPLETED", "header": {"backend_name": "qasm_simulator", "backend_version": "0.7.2"}, "metadata": {"max_memory_mb": 8192, "omp_enabled": true, "parallel_experiments": 1, "time_taken": 0.06574745800000001}, "time_taken": 0.06785917282104492}, "results": {"backend_name": "qasm_simulator", "backend_version": "0.7.2", "qobj_id": "20e245c0-992b-45a8-a8c6-c3ff4a7dec54", "job_id": "7e77540d-5444-4cad-ab45-fc3423d195f6", "success": true, "results": [{"shots": 1000, "success": true, "data": {"counts": {"0x0": 262, "0x1": 78, "0x2": 80, "0x3": 71, "0x4": 81, "0x5": 74, "0x6": 83, "0x7": 271}}, "meas_level": 2, "header": {"clbit_labels": [["c4", 0], ["c4", 1], ["c4", 2]], "creg_sizes": [["c4", 3]], "global_phase": 0.0, "memory_slots": 3, "n_qubits": 5, "name": "circuit110", "qreg_sizes": [["q12", 5]], "qubit_labels": [["q12", 0], ["q12", 1], ["q12", 2], ["q12", 3], ["q12", 4]]}, "status": "DONE", "seed_simulator": 42, "time_taken": 0.016886205, "metadata": {"fusion": {"enabled": false}, "measure_sampling": false, "method": "stabilizer", "parallel_shots": 8, "parallel_state_update": 1}}], "date": "2021-02-01T05:21:53.232665", "status": "COMPLETED", "header": {"backend_name": "qasm_simulator", "backend_version": "0.7.2"}, "metadata": {"max_memory_mb": 8192, "omp_enabled": true, "parallel_experiments": 1, "time_taken": 0.017087917}, "time_taken": 0.017798900604248047}, "mit_pattern": [[2], [4, 1]], "meas_layout": [2, 4, 1], "fidelity": 0.81175, "results_pseudo_inverse": {"000": 490.09920463808, "001": 1.1855217632343553, "010": 6.856561953208232, "011": -13.925536339030689, "100": 21.080379879311838, "101": -19.929567717733956, "110": 2.4129313160877572, "111": 512.2205045068418}, "results_least_square": {"000": 488.0082369172743, "010": 1.3316040978206267e-13, "100": 10.266384716944353, "110": 7.968172262046004, "111": 493.75720610373577}} \ No newline at end of file