loom.eka.logical_state

Copyright 2024 Entropica Labs Pte Ltd

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

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.

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.