loom_rotated_surface_code.applicator.split

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.

loom_rotated_surface_code.applicator.split.create_split_circuit(interpretation_step, block, operation, qubits_to_measure, boundary_type)[source]

Create the circuit for the split operation.

Parameters:
  • interpretation_step (InterpretationStep) – Interpretation step containing the block to split.

  • block (RotatedSurfaceCode) – Block to split.

  • operation (Split) – Split operation to perform.

  • qubits_to_measure (tuple[tuple[int, ...], ...]) – Qubits to be measured in the split operation.

  • boundary_type (str) – Type of the boundary of the block.

Returns:

Circuit for the split operation.

Return type:

Circuit

loom_rotated_surface_code.applicator.split.find_split_stabilizer_to_circuit_mappings(block, new_block_stabilizers, new_boundary_direction)[source]

Finds the mapping between the stabilizers in the new block and the associated syndrome circuits.

Parameters:
  • block (RotatedSurfaceCode) – Initial block to be split

  • new_block_stabilizers (list[Stabilizer]) – List of stabilizers in the one of the new blocks

  • new_boundary_direction (Direction) – Direction of the the new boundary in the new block

Returns:

New mapping of stabilizers to syndrome circuits for the block.

Return type:

dict[str, tuple[str, …]]

loom_rotated_surface_code.applicator.split.split(interpretation_step, operation, same_timeslice, debug_mode)[source]

Applicator to split a block using the Split description.

The algorithm is the following:

  • A.) DATA QUBITS

    • Find data qubits to be measured, the initial block will be split into two

  • B.) CIRCUIT

    • B.1) Create classical channels for all data qubit measurements

    • B.2) Create a measurement circuit for every measured data qubit

    • B.3) Append the measurement circuits to the InterpretationStep circuit. If needed, apply a basis change

  • C.) STABILIZERS

    • C.1) Find stabilizers which are completely removed

    • C.2) Find stabilizers which have to be reduced in weight

    • C.3) Create new stabilizers with reduced weight

    • C.4) Create two sets of stabilizers, one for each new block

    • C.5) Update stabilizer_evolution and stabilizer_updates for the stabilizers which have been reduced in weight

    • C.6) Create the new stabilizer_to_circuit mapping

  • D.) LOGICAL OPERATORS

    • D.1) Find logical operators which are not partially measured

    • D.2) Find logical operators which have to be split

    • D.3) Create new logical operators and final to initial mapping

    • D.4) Update logical_x/z_evolution

    • D.5) Update logical_x/z_updates

  • E.) NEW BLOCK AND NEW INTERPRETATION STEP

    • E.1) Create the new blocks

    • E.2) Update the block history

Parameters:
  • interpretation_step (InterpretationStep) – Interpretation step containing the block to split.

  • operation (Split) – Split operation description.

  • same_timeslice (bool) – Flag indicating whether the operation is part of the same timestep as the previous operation.

  • debug_mode (bool) – Flag indicating whether the interpretation should be done in debug mode. Activating debug mode will enable commutation validation for Block

Returns:

Interpretation step after the split operation.

Return type:

InterpretationStep

loom_rotated_surface_code.applicator.split.split_consistency_check(interpretation_step, operation)[source]

Check that the split operation can be performed on the given block.

Parameters:
  • interpretation_step (InterpretationStep) – Interpretation step containing the block to split.

  • operation (Split) – Split operation to perform.

Returns:

The block to split.

Return type:

RotatedSurfaceCode

Raises:

ValueError – If the split position is larger than the width or height of the block.

loom_rotated_surface_code.applicator.split.split_logical_operators(interpretation_step, block, qubits_to_measure, operation, upleft_qubit_block_1, upleft_qubit_block_2)[source]

Finds the logical operators for the new blocks after the split operation. If an operator is partially measured, it will be split into two operators. If it is fully measured, it is shifted to the new block, adding stabilizers to the operator evolution.

Parameters:
  • interpretation_step (InterpretationStep) – Interpretation step containing the block to split.

  • block (RotatedSurfaceCode) – Block to split.

  • qubits_to_measure (tuple[tuple[int, ...], ...]) – Qubits involved in the split operation.

  • operation (Split) – Split operation description.

  • upleft_qubit_block_1 (tuple[int, ...]) – Upper left qubit of the first new block.

  • upleft_qubit_block_2 (tuple[int, ...]) – Upper left qubit of the second new block.

Return type:

tuple[InterpretationStep, tuple[PauliOperator, PauliOperator], tuple[PauliOperator, PauliOperator], dict[str, tuple[Union[tuple[str, int], Literal[1, 0]], ...]], dict[str, tuple[Union[tuple[str, int], Literal[1, 0]], ...]]]

Returns:

  • tuple[ – InterpretationStep, tuple[PauliOperator, PauliOperator], tuple[PauliOperator, PauliOperator] dict[str, tuple[Cbit, …]], dict[str, tuple[Cbit, …]],

  • ] – The interpretation step updated with the logical operator evolutions, logical X and logical Z operators for the first block, logical X and logical Z operators for the second block, updates for the logical X and Z operators.

Raises:

NotImplementedError – If the initial block encodes more than one logical qubit.

loom_rotated_surface_code.applicator.split.split_stabilizers(block, operation, qubits_to_measure)[source]

Split the initial block’s stabilizers into two lists of stabilizers, once for each block, and the list of old stabilizers that are gonna be replaced and the new stabilizers that will replace them.

Parameters:
  • block (RotatedSurfaceCode) – Initial block to be split

  • operation (Split) – Split operation description

  • qubits_to_measure (tuple[tuple[int, ...], ...]) – Qubits to be measured in the split operation.

Returns:

A tuple of four lists of stabilizers, one for each block, the old stabilizers that are gonna be replaced and the new stabilizers that will replace them (in the same order).

Return type:

tuple[list[Stabilizer], list[Stabilizer], list[Stabilizer], list[Stabilizer]]