Skip to content
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ install_requires =
h5py
scikit-learn
multipledispatch
pymatching
cma
qcecircuits @ git+https://github.com/MiniSean/QCoCircuits.git # QCoCircuits
# Required additional data files
Expand Down
4 changes: 2 additions & 2 deletions src/qce_interp/data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ def from_file_path(cls, file_path: Path, qec_rounds: List[int], heralded_initial

for qubit_id in tqdm(involved_qubit_ids, desc='Processing data file'):
channel_identifier: IAcquisitionChannelIdentifier = channel_identifier_lookup[qubit_id]
raw_shots: NDArray[np.float64] = data_dict[cls.data_key()][:, channel_identifier.channel_indices]
raw_complex_shots: NDArray[np.complex128] = StateAcquisitionContainer.real_imag_to_complex(raw_shots)
raw_shots: NDArray[np.float32] = data_dict[cls.data_key()][:, channel_identifier.channel_indices]
raw_complex_shots: NDArray[np.complex64] = StateAcquisitionContainer.real_imag_to_complex(raw_shots)

# Qutrit calibration points
calibration_points: StateAcquisitionContainer = StateAcquisitionContainer.from_state_acquisitions(
Expand Down
11 changes: 11 additions & 0 deletions src/qce_interp/decoder_examples/lookup_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,13 @@ def get_fidelity(self, cycle_stabilizer_count: int, target_state: np.ndarray) ->
cycle_stabilizer_count=cycle_stabilizer_count,
target_state=target_state,
)

def get_fidelity_uncertainty(self, cycle_stabilizer_count: int, target_state: np.ndarray) -> float:
""":return: Uncertainty in Logical fidelity based on target state and stabilizer round-count."""
return self._syndrome_decoder.get_fidelity_uncertainty(
cycle_stabilizer_count=cycle_stabilizer_count,
target_state=target_state,
)
# endregion


Expand Down Expand Up @@ -354,3 +361,7 @@ def binary_syndrome_lookup(self) -> Dict[tuple, tuple]:
return result
# endregion

# region Interface Methods
def get_fidelity_uncertainty(self, cycle_stabilizer_count: int, target_state: np.ndarray) -> float:
raise NotImplemented
# endregion
11 changes: 11 additions & 0 deletions src/qce_interp/decoder_examples/majority_voting.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,16 @@ def get_fidelity(self, cycle_stabilizer_count: int, target_state: np.ndarray) ->
counter += 1
equal_fraction = counter / len(corrected_binary_output)
return equal_fraction

def get_fidelity_uncertainty(self, cycle_stabilizer_count: int, target_state: np.ndarray) -> float:
""":return: Uncertainty in Logical fidelity based on target state and stabilizer round-count."""
logical_fidelity: float = self.get_fidelity(
cycle_stabilizer_count=cycle_stabilizer_count,
target_state=target_state,
)
# (N, 1, D)
binary_projected_classification: np.ndarray = self._error_identifier.get_binary_projected_classification(cycle_stabilizer_count=cycle_stabilizer_count)
number_of_samples: int = binary_projected_classification.shape[0]
return float(np.sqrt(logical_fidelity * (1.0 - logical_fidelity) / number_of_samples))
# endregion

22 changes: 22 additions & 0 deletions src/qce_interp/decoder_examples/mwpm_decoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,17 @@ def get_fidelity(self, cycle_stabilizer_count: int, target_state: np.ndarray) ->
equal_rows_count = np.sum(np.all(logical_error == 0, axis=1))
equal_fraction: float = equal_rows_count / len(logical_error)
return equal_fraction

def get_fidelity_uncertainty(self, cycle_stabilizer_count: int, target_state: np.ndarray) -> float:
""":return: Uncertainty in Logical fidelity based on target state and stabilizer round-count."""
logical_fidelity: float = self.get_fidelity(
cycle_stabilizer_count=cycle_stabilizer_count,
target_state=target_state,
)
# (N, 1, D)
binary_projected_classification: np.ndarray = self._error_identifier.get_binary_projected_classification(cycle_stabilizer_count=cycle_stabilizer_count)
number_of_samples: int = binary_projected_classification.shape[0]
return float(np.sqrt(logical_fidelity * (1.0 - logical_fidelity) / number_of_samples))
# endregion

# region Class Methods
Expand Down Expand Up @@ -429,6 +440,17 @@ def get_fidelity(self, cycle_stabilizer_count: int, target_state: np.ndarray = N
error_rate = error_rate if self.initial_state == 0 else 1 - error_rate

return 1 - error_rate

def get_fidelity_uncertainty(self, cycle_stabilizer_count: int, target_state: np.ndarray) -> float:
""":return: Uncertainty in Logical fidelity based on target state and stabilizer round-count."""
logical_fidelity: float = self.get_fidelity(
cycle_stabilizer_count=cycle_stabilizer_count,
target_state=target_state,
)
# (N, 1, D)
binary_projected_classification: np.ndarray = self._error_identifier.get_binary_projected_classification(cycle_stabilizer_count=cycle_stabilizer_count)
number_of_samples: int = binary_projected_classification.shape[0]
return float(np.sqrt(logical_fidelity * (1.0 - logical_fidelity) / number_of_samples))
# endregion

# region Class Methods
Expand Down
Loading