loom.eka.operations.code_operation
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.operations.code_operation.CodeOperation(*args, **kwargs)[source]
Bases:
OperationParent class for all code operations. All code operations act on blocks
Properties
- _inputstuple[str, …]
Standardized way to access the input blocks names.
- _outputstuple[str, …]
Standardized way to access the output blocks names.
- class loom.eka.operations.code_operation.ConditionalLogicalX(*args, **kwargs)[source]
Bases:
CodeOperationApply a conditional logical X operator to a block.
- Parameters:
input_block_name (str) – Name of the block where the logical operator should be applied.
logical_qubit (int | None, optional) – Index of the logical qubit inside the specified block which should be acted on. For blocks with a single logical qubit, this parameter does not need to be provided. Then by default the index 0 is chosen for this single logical qubit. For blocks with multiple logical qubits, this parameter is required.
condition (LogicalMeasurement | None, optional) – Condition for logical pauli operation to be applied based on the value of the LogicalMeasurement provided.
-
condition:
LogicalMeasurement
-
input_block_name:
str
-
logical_qubit:
int= 0
- class loom.eka.operations.code_operation.ConditionalLogicalY(*args, **kwargs)[source]
Bases:
CodeOperationApply a conditional logical Y operator to a block.
- Parameters:
input_block_name (str) – Name of the block where the logical operator should be applied.
logical_qubit (int | None, optional) – Index of the logical qubit inside the specified block which should be acted on. For blocks with a single logical qubit, this parameter does not need to be provided. Then by default the index 0 is chosen for this single logical qubit. For blocks with multiple logical qubits, this parameter is required.
condition (LogicalMeasurement) – Condition for logical pauli operation to be applied based on the value of the LogicalMeasurement provided.
-
condition:
LogicalMeasurement
-
input_block_name:
str
-
logical_qubit:
int= 0
- class loom.eka.operations.code_operation.ConditionalLogicalZ(*args, **kwargs)[source]
Bases:
CodeOperationApply a conditional logical Z operator to a block.
- Parameters:
input_block_name (str) – Name of the block where the logical operator should be applied.
logical_qubit (int | None, optional) – Index of the logical qubit inside the specified block which should be acted on. For blocks with a single logical qubit, this parameter does not need to be provided. Then by default the index 0 is chosen for this single logical qubit. For blocks with multiple logical qubits, this parameter is required.
condition (LogicalMeasurement) – Condition for logical pauli operation to be applied based on the value of the LogicalMeasurement provided.
-
condition:
LogicalMeasurement
-
input_block_name:
str
-
logical_qubit:
int= 0
- class loom.eka.operations.code_operation.Grow(*args, **kwargs)[source]
Bases:
CodeOperationGrow operation.
- Parameters:
input_block_name (str) – Name of the block to grow.
direction (Direction) – Direction in which to grow the block.
length (int) – Length by which to grow the block.
-
input_block_name:
str
-
length:
int
- class loom.eka.operations.code_operation.LogicalX(*args, **kwargs)[source]
Bases:
CodeOperationApply a logical X operator to a block.
- Parameters:
input_block_name (str) – Name of the block where the logical operator should be applied.
logical_qubit (int | None, optional) – Index of the logical qubit inside the specified block which should be acted on. For blocks with a single logical qubit, this parameter does not need to be provided. Then by default the index 0 is chosen for this single logical qubit. For blocks with multiple logical qubits, this parameter is required.
-
input_block_name:
str
-
logical_qubit:
int= 0
- class loom.eka.operations.code_operation.LogicalY(*args, **kwargs)[source]
Bases:
CodeOperationApply a logical Y operator to a block.
- Parameters:
input_block_name (str) – Name of the block where the logical operator should be applied.
logical_qubit (int | None, optional) – Index of the logical qubit inside the specified block which should be acted on. For blocks with a single logical qubit, this parameter does not need to be provided. Then by default the index 0 is chosen for this single logical qubit. For blocks with multiple logical qubits, this parameter is required.
-
input_block_name:
str
-
logical_qubit:
int= 0
- class loom.eka.operations.code_operation.LogicalZ(*args, **kwargs)[source]
Bases:
CodeOperationApply a logical Z operator to a block.
- Parameters:
input_block_name (str) – Name of the block where the logical operator should be applied.
logical_qubit (int | None, optional) – Index of the logical qubit inside the specified block which should be acted on. For blocks with a single logical qubit, this parameter does not need to be provided. Then by default the index 0 is chosen for this single logical qubit. For blocks with multiple logical qubits, this parameter is required.
-
input_block_name:
str
-
logical_qubit:
int= 0
- class loom.eka.operations.code_operation.MeasureBlockSyndromes(*args, **kwargs)[source]
Bases:
CodeOperationPerforms a given number of rounds of syndrome measurements on a block.
- Parameters:
input_block_name (str) – Name of the block to measure.
n_cycles (int) – Number of cycles to measure. Default is 1.
-
input_block_name:
str
-
n_cycles:
int= 1
- class loom.eka.operations.code_operation.MeasureLogicalX(*args, **kwargs)[source]
Bases:
CodeOperationMeasure the logical X operator of a block.
- Parameters:
input_block_name (str) – Name of the block where the logical operator to be measured is located.
logical_qubit (int | None, optional) – Index of the logical qubit inside the specified block which should be measured. For blocks with a single logical qubit, this parameter does not need to be provided. Then by default the index 0 is chosen for this single logical qubit. For blocks with multiple logical qubits, this parameter is required.
-
input_block_name:
str
-
logical_qubit:
int= 0
- class loom.eka.operations.code_operation.MeasureLogicalY(*args, **kwargs)[source]
Bases:
CodeOperationMeasure the logical Y operator of a block.
- Parameters:
input_block_name (str) – Name of the block where the logical operator to be measured is located.
logical_qubit (int | None, optional) – Index of the logical qubit inside the specified block which should be measured. For blocks with a single logical qubit, this parameter does not need to be provided. Then by default the index 0 is chosen for this single logical qubit. For blocks with multiple logical qubits, this parameter is required.
-
input_block_name:
str
-
logical_qubit:
int= 0
- class loom.eka.operations.code_operation.MeasureLogicalZ(*args, **kwargs)[source]
Bases:
CodeOperationMeasure the logical Z operator of a block.
- Parameters:
input_block_name (str) – Name of the block where the logical operator to be measured is located.
logical_qubit (int | None, optional) – Index of the logical qubit inside the specified block which should be measured. For blocks with a single logical qubit, this parameter does not need to be provided. Then by default the index 0 is chosen for this single logical qubit. For blocks with multiple logical qubits, this parameter is required.
-
input_block_name:
str
-
logical_qubit:
int= 0
- class loom.eka.operations.code_operation.Merge(*args, **kwargs)[source]
Bases:
CodeOperationMerge operation.
- Parameters:
input_blocks_name (tuple[str, str]) – Names of the two blocks to merge.
output_block_name (str) – Name of the resulting block.
orientation (Orientation, optional) – Orientation along which to merge the blocks. E.g. if Orientation.HORIZONTAL, the blocks will be merged using their left and right boundaries (whichever is easiest). If None, the orientation will be derived from the blocks positions.
-
input_blocks_name:
tuple[str,str]
-
orientation:
Orientation|None= None
-
output_block_name:
str
- class loom.eka.operations.code_operation.ResetAllAncillaQubits(*args, **kwargs)[source]
Bases:
CodeOperationReset all ancilla qubits to a specific SingleQubitPauliEigenstate.
- Parameters:
input_block_name (str) – Name of the block where the logical operator should be applied.
state (SingleQubitPauliEigenstate | None, optional) – State to which the ancilla qubit should be reset. Default is SingleQubitPauliEigenstate.ZERO, i.e. the zero eigenstate of the Pauli Z operator.
-
input_block_name:
str
-
state:
SingleQubitPauliEigenstate= '0'
- class loom.eka.operations.code_operation.ResetAllDataQubits(*args, **kwargs)[source]
Bases:
CodeOperationReset all data qubits to a specific SingleQubitPauliEigenstate.
- input_block_namestr
Name of the block where the logical operator should be applied.
- state: SingleQubitPauliEigenstate | None, optional
State to which the logical qubit should be reset. Default is SingleQubitPauliEigenstate.ZERO, i.e. the zero eigenstate of the Pauli Z operator.
-
input_block_name:
str
-
state:
SingleQubitPauliEigenstate= '0'
- class loom.eka.operations.code_operation.Shrink(*args, **kwargs)[source]
Bases:
CodeOperationShrink operation.
- Parameters:
input_block_name (str) – Name of the block to shrink.
direction (Direction) – Direction in which to shrink the block.
length (int) – Length by which to shrink the block.
-
input_block_name:
str
-
length:
int
- class loom.eka.operations.code_operation.Split(*args, **kwargs)[source]
Bases:
CodeOperationSplit operation.
- Parameters:
input_block_name (str) – Name of the block to split.
output_blocks_name (tuple[str, str]) – Names of the resulting blocks.
orientation (Orientation) – Orientation along which to split the block. E.g. if Orientation.HORIZONTAL, the block will be split in a horizontal cut, leaving two blocks with adjacent top and bottom boundaries.
split_position (int) – Position at which to split the block, distance to the (0,0) corner of the block.
-
input_block_name:
str
-
orientation:
Orientation
-
output_blocks_name:
tuple[str,str]
-
split_position:
int
- class loom.eka.operations.code_operation.StateInjection(*args, **kwargs)[source]
Bases:
CodeOperationInject the given resource state into the specified block. This operation resets the central qubit of the block into the specified resource state and maximizes the number of stabilizers that can be initialized in a deterministic way.
E.g. a T state injection in a RotatedSurfaceCode block will reset the central qubit into the T state and reset the rest of the data qubits into four quadrants, such that two quadrants are in the
|0⟩state and two quadrants are in the|+⟩state. This ensures that the Z stabilizer measurements are deterministic in the|0⟩quadrants and the X stabilizer measurements are deterministic in the|+⟩quadrants.- Parameters:
input_block_name (str) – Name of the block to inject the resource state into.
resource_state (ResourceState) – The resource state to inject into the block. This can be one of the following: - ResourceState.T: T state - ResourceState.S: S state
-
input_block_name:
str
-
resource_state:
ResourceState