loom.validator.check_stabilizer_measurement
Copyright (c) Entropica Labs Pte Ltd 2025.
Use, distribution and reproduction of this program in its source or compiled form is prohibited without the express written consent of Entropica Labs Pte Ltd.
- class loom.validator.check_stabilizer_measurement.StabilizerMeasurementCheck(*args, **kwargs)[source]
Bases:
AbstractValidityCheckDataclass to store the results of the Stabilizer Measurement check.
- Parameters:
output (StabilizerMeasurementCheckOutput) – An object containing the output of the check.
Properties
-----------
message (str) – A message indicating the result of the check. It will be empty if the check is valid, otherwise it will contain a message describing the issue.
valid (bool) – True if the check is valid (i.e., all measurements were deterministic and measured the assigned stabilizer), False otherwise.
- property message: str
A message indicating the result of the check. It will be empty if the check is valid, otherwise it will contain a message describing the issue.
- class loom.validator.check_stabilizer_measurement.StabilizerMeasurementCheckOutput(*args, **kwargs)[source]
Bases:
objectDataclass to store the output of the Stabilizer Measurement check.
- Parameters:
expected_vs_measured_stabs (tuple[tuple[str,Stabilizer,tuple[Stabilizer,...]],...]) – A tuple containing the stabilizers that were not measured correctly. Each tuple contains the measurement index, the stabilizer that was supposed to be measured by it, and the stabilizers that were measured instead.
probabilistic_measurements (tuple[str, ...]) – A tuple containing all the measurements that are probabilistic
-
expected_vs_measured_stabs:
tuple[tuple[str,Stabilizer,tuple[Stabilizer,...]],...]
-
probabilistic_measurements:
tuple[str,...]
- loom.validator.check_stabilizer_measurement.check_input_stabilizer_measurement(base_cliffordsim_operations, input_block, measurement_to_stabilizer_map, seed)[source]
Checks whether the measurement of the stabilizers happened and whether the result was registered at the correct place. This is done by running the circuit with an initial state of \(\ket{00...0}\) and recording the measurement results. Then, for each stabilizer, the stabilizer is flipped and the circuit is run again. The measurement results are compared to the reference results to check if the measurement was correct. The stabilizers that were not measured correctly are stored in the output.
- Parameters:
base_cliffordsim_operations (tuple[
loom.cliffordsim.operations.base_operation.Operation, …]) – The cliffordsim operations that represent the circuit to be checked.input_block (Block) – The Block object that represents the input code.
measurement_to_input_stabilizer_map (dict[str, Stabilizer]) – Dictionary matching the classical channel name of a measurement operation with a stabilizer in the input code.
seed (int | None) – The seed for the cliffordsim engine.
- Returns:
The result of the Stabilizer Measurement check.
- Return type:
- loom.validator.check_stabilizer_measurement.get_mresults_with_flipped_reduced_stabilizers(reduced_stab_idx_to_flip, base_cliffordsim_operations, input_block, seed)[source]
This function runs the circuit with some stabilizers flipped and returns the measurement results. The logical state that is used is the \(\ket{00...0}\) state.
- Parameters:
reduced_stab_idx_to_flip (np.ndarray | list[int]) – The indices of the reduced stabilizers to flip.
base_cliffordsim_operations (tuple[
loom.cliffordsim.operations.base_operation.Operation, …]) – The base cliffordsim operations that will be used to run the circuit.input_block (Block) – The Block object that represents the input code.
seed (int | None) – The seed for the cliffordsim engine.
- Returns:
A dictionary containing the names of the classical registers and their values, along with a boolean indicating whether the value is a result of a random measurement. If the value is not a result of a measurement, the boolean is None.
- Return type:
dict[str, tuple[int, bool | None]]