loom_repetition_code.applicator.shrink

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_repetition_code.applicator.shrink.find_new_stabilizers(block, qubits_to_measure)[source]

Find the new set of stabilizers after the shrink operation. We also compute the uuids of the stabilizers that need to be removed, if the block shrunk from the left, as they will be used to update one of the logical operators.

Parameters:
  • block (RepetitionCode) – Block to shrink.

  • qubits_to_measure (list[tuple[int,int]]) – List of qubits to measure.

Returns:

new_stabs – New set of stabilizers after the shrink operation.

Return type:

list[Stabilizer]

loom_repetition_code.applicator.shrink.find_shrink_circuit(interpretation_step, check_type, qubits_to_measure, circuit_name)[source]

Generate a circuit to measure the qubits to be shrunk. Qubits are measured in the Z basis. If the check type is Z, the qubits are measured directly, else they are applied a Hadamard gate before measurement.

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

  • check_type (str) – Type of the stabilizer operators.

  • qubits_to_measure (list[tuple[int,int]]) – List of qubits to measure.

  • circuit_name (str) – Name of the circuit.

Returns:

Tuple containing the shrink circuit and the classical bits associated with the measured qubits.

Return type:

tuple[Circuit, list[Cbit]]

loom_repetition_code.applicator.shrink.get_logical_operator_and_updates(interpretation_step, block, check_type, is_left, qubits_to_measure, cbits)[source]

Generate new logical operators and their respective evolution and updates to be added to the interpretation step. We treat the two logicals separately in as “long” and “short”. The long corresponds to the one covering the entire chain, with type opposite to the check type. The short corresponds to the one covering the left boundary qubit by default, with type equal to the check type.

Parameters:
  • interpretation_step (InterpretationStep) – The interpretation step.

  • block (RepetitionCode) – Block to shrink.

  • check_type (str) – Type of the stabilizer operators.

  • is_left (bool) – Boolean defining whether shrink operations is performed from right or left.

  • qubits_to_measure (list[tuple[int,int]]) – List of qubits to measure.

  • cbits (list[Cbit]) – List of classical bits associated with measured qubits.

Return type:

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

Returns:

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

  • ] – Tuple containing the new logical operators, their evolution and updates.

loom_repetition_code.applicator.shrink.get_qubits_to_measure(block, direction, length)[source]

Find the qubits to measure during the shrink operation.

Parameters:
  • block (RepetitionCode) – Block to shrink.

  • direction (Direction) – Direction of the shrink operation.

  • length (int) – Length of the shrink operation.

Returns:

List containing the qubits to measure.

Return type:

list[tuple[int, int]]

loom_repetition_code.applicator.shrink.shrink(interpretation_step, operation, same_timeslice, debug_mode)[source]

Shrink a Repetition Code chain in the left or right specified direction.

The algorithm is the following:

  • A.) DATA QUBITS

    • A.1) Find measured data qubits during shrink

  • B.) CIRCUIT

    • B.1) Generate shrink circuit and classical bits

    • B.2) Add circuit to the interpretation step

  • C.) - STABILIZERS

    • C.1) Find new set of stabilizers

  • D.) LOGICAL OPERATORS

    • D.1) Extract logical operators and updates

    • D.2) Update the logical operator history

  • E.) NEW BLOCK AND NEW INTERPRETATION STEP
    • E.1) Create the new block

    • E.2) Update the block history

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

  • operation (Shrink) – Shrink 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 shrink operation.

Return type:

InterpretationStep

loom_repetition_code.applicator.shrink.shrink_consistency_check(interpretation_step, operation)[source]

Check the consistency of the shrink operation.

Parameters:
  • interpretation_step (InterpretationStep) – InterpretationStep containing the block to shrink.

  • operation (Shrink) – Shrink operation description.

Returns:

Block to shrink.

Return type:

RepetitionCode