loom.validator.check_logical_ops

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_logical_ops.LogicalOperatorCheck(*args, **kwargs)[source]

Bases: AbstractValidityCheck

Dataclass to store the results of the Logical Operator check.

Parameters:
  • output (LogicalOperatorCheckOutput) – An object containing the output of the check, including any failed logical state transformations and the expected vs actual logical transformations with parity flips for each logical state.

  • 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 logical states were transformed correctly), 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.

output: LogicalOperatorCheckOutput
class loom.validator.check_logical_ops.LogicalOperatorCheckOutput(*args, **kwargs)[source]

Bases: object

Dataclass to store the output of the Logical Operator check.

Parameters:
  • input_vs_expected_vs_actual_logicals_multi (tuple[) – tuple[LogicalState, tuple[LogicalState, …], LogicalState | None], …

  • ] – A tuple containing the input logical states, the expected output logical states, and the actual output logical state. If the actual output state is None, it means that no valid logical state was found in the output.

  • input_vs_expected_vs_actual_logicals_with_parity (tuple[) – tuple[LogicalState, tuple[LogicalState, tuple[int, …]], LogicalState | None], …

  • ] – A tuple containing the input logical states, the expected output logical states with parity flips, and the actual output logical state. If the actual output state is None, it means that no valid logical state was found in the output.

input_vs_expected_vs_actual_logicals_multi: tuple[tuple[LogicalState, tuple[LogicalState, ...], LogicalState | None], ...]
input_vs_expected_vs_actual_logicals_with_parity: tuple[tuple[LogicalState, tuple[LogicalState, tuple[int, ...]], LogicalState | None], ...]
loom.validator.check_logical_ops.check_logical_operators_transformation(base_cliffordsim_operations, input_block, output_block, logical_state_transformations_with_parity, logical_state_transformations, seed)[source]

Checks whether the logical operators are transformed correctly.

Parameters:
  • base_cliffordsim_operations (tuple[ loom.cliffordsim.operations.base_operation.Operation, …]) – A tuple of base cliffordsim operations that will be used to run the circuit.

  • input_block (Block) – The Block object that represents the input code.

  • output_block (Block) – The Block object that represents the output code.

  • logical_state_transformations_with_parity (dict[) – LogicalState, tuple[LogicalState, dict[int, tuple[str | int, …]]],

  • ] – Dictionary where the keys are the input logical states and the values are tuples containing the output logical state and a dictionary of parity flips that correspond to each logical operator. The keys of the dictionary are the logical operator indices, and the values are lists of strings or integers (0 or 1) that represent the classical channels and parity flips applied to the logical operators.

  • logical_state_transformations (list[tuple[LogicalState, tuple[LogicalState, ...]]]) – A list of tuples where each tuple contains an input logical state and a tuple of expected output logical states. When the circuit is run for a given input logical state, at least one of the expected output logical states should be found in the output.

  • seed (int | None) – The seed for the cliffordsim engine.

Returns:

The result of the Logical Operator check.

Return type:

LogicalOperatorCheck

loom.validator.check_logical_ops.find_logical_state(block, output_stabarray)[source]

Finds the logical state from the output stabilizer array. If the output stabilizer array does not contain a full set of logical operators, the logical state is not well-defined and None is returned.

Parameters:
  • block (Block) – The Block object that represents the code.

  • output_stabarray (StabArray) – The stabilizer array from the output of the circuit.

Returns:

The logical state if it is well-defined, otherwise None.

Return type:

LogicalState | None