loom.eka.logical_state

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.eka.logical_state.LogicalState(*args, **kwargs)[source]

Bases: object

A logical state defined by its logical operators that stabilize it. The state is the statevector that is simultaneously the +1 eigenvector of all the logical operators stabilizing it. The operators are represented as sparse Pauli operators on the logical level.

Parameters:

sparse_logical_paulistrings (tuple[str, ...]) – A tuple of strings representing the logical state stabilizers as sparse Pauli operators expressed on the logical level. The strings should be in the format of a sparse Pauli operator, e.g. “+Z1Y3”.

classmethod cast_str_to_tuple(value)[source]

Cast the sparse_logical_paulistrings to a tuple if it is a single string.

static convert_logical_pauli_op_to_base_representation(log_op, x_log_stabarray, z_log_stabarray)[source]

Convert a logical Pauli operator to its base representation. The base representation is defined as the representation of the operator on the data qubits of a Block object. The logical Pauli operator is expected to be represented as a SignedPauliOp object, and the x_log_stabarray and z_log_stabarray are the StabArray representations of the logical X and Z operators, respectively.

Parameters:
  • log_op (SignedPauliOp) – The logical Pauli operator to convert.

  • x_log_stabarray (StabArray) – The StabArray representation of the logical X operators.

  • z_log_stabarray (StabArray) – The StabArray representation of the logical Z operators.

Returns:

The base representation of the logical Pauli operator.

Return type:

SignedPauliOp

classmethod convert_logical_to_base_representation(block, logical_stabarray)[source]

Convert a logical StabArray representation to the base StabArray representation of a Block object. If the Block object describes a code with n data qubits encoding k logical qubits, then the logical_stabarray should be indexing the logical qubits from 0 to k-1. The base representation that will be returned will be indexing the data qubits from 0 to n-1.

Parameters:
  • block (Block) – The Block object to use to convert the logical StabArray.

  • logical_stabarray (StabArray) – The logical StabArray representation to convert.

Returns:

The base StabArray representation of the input logical StabArray.

Return type:

StabArray

property destabarray: StabArray

Return the StabArray representation of the destabilizer array corresponding to the stabarray property.

classmethod from_stabarray(stabarray)[source]

Create a LogicalState from a StabArray. The StabArray should be on the logical level, meaning that every column corresponds to a logical qubit.

Return type:

LogicalState

get_tableau(block)[source]

Given a Block, return the tableau of the logical state. TODO: When shifting to multiple Blocks, we can instead take as input a list of Block objects and match for example a 6 logical qubit state on 3 Block objects that each have 2 logical qubits.

Parameters:

block (Block) – The Block object to use to generate the tableau.

Returns:

The tableau of the logical state.

Return type:

np.ndarray

property n_logical_qubits: int

Return the number of logical qubits.

sparse_logical_paulistrings: tuple[str, ...]
property stabarray: StabArray

Return the StabArray representation of the logical operator set that stabilizes the state. The representation is on the logical level which means that every column in the StabArray corresponds to a logical qubit rather than a data/physical qubit.