loom_rotated_surface_code.applicator.auxcnot
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.auxcnot.auxcnot(interpretation_step, operation, same_timeslice, debug_mode)[source]
Apply an auxiliary CNOT operation using a Grow - Shrink - Merge - Split approach.
The algorithm is the following: - A) Grow control block - B) Measure syndromes of grown_control and target blocks - C) Split grown_control into control and auxiliary blocks - D) Measure syndromes of control, auxiliary and target blocks - E) Merge auxiliary and target blocks - F) Measure syndromes of control and merged_target blocks - G) Apply conditionallogicalz conditioned on joint measurement - H) Shrink the new target block - I) Wrap the auxcnot circuit in a single circuit
- Parameters:
interpretation_step (InterpretationStep) – Input interpretation step.
operation (AuxCNOT) – The CNOT operation to apply.
same_timeslice (bool) – Flag indicating whether the operation is part of the same timestep as the input.
debug_mode (bool) – Flag indicating whether the interpretation should be done in debug mode. Activating debug mode will enable commutation validation for Block.
- Returns:
The updated interpretation step after applying the auxiliary CNOT operation.
- Return type:
- loom_rotated_surface_code.applicator.auxcnot.auxcnot_conditional_logical_z(interpretation_step, new_control, initial_target, aux_block, new_target, shrink_direction, same_timeslice, debug_mode)[source]
Applies ConditionalLogicalZ to the blocks conditioned on the value of the joint measurement obtained from Merge.
- Parameters:
interpretation_step (InterpretationStep) – Input interpretation step.
new_control (RotatedSurfaceCode) – New control block after the AuxCNOT operations.
initial_target (RotatedSurfaceCode) – Target block before the the AuxCNOT operations.
aux_block (RotatedSurfaceCode) – Auxiliary block for the AuxCNOT operation.
new_target (RotatedSurfaceCode) – New target block after the AuxCNOT operations.
shrink_direction (Direction) – Direction in which the target block was shrunk.
same_timeslice (bool) – Flag indicating whether the operation is part of the same timestep as the input.
debug_mode (bool) – Flag indicating whether the interpretation should be done in debug mode.
- Returns:
The updated interpretation step after applying the LogicalZ
- Return type:
- loom_rotated_surface_code.applicator.auxcnot.auxcnot_consistency_check(c_block, t_block)[source]
Perform multiple checks to ensure that the auxiliary CNOT operation can be applied. The blocks must be of the correct type, have the same size, the same boundary orientations and be in a specific configuration.
The configuration is the following, the upper left corners of the two blocks must satisfy the following relations:
|t_block.upper_left_qubit[0] - c_block.upper_left_qubit[0]| = c_block.size[0]|t_block.upper_left_qubit[1] - c_block.upper_left_qubit[1]| = c_block.size[1]
- Parameters:
c_block (RotatedSurfaceCode) – Control block for the auxiliary CNOT operation.
t_block (RotatedSurfaceCode) – Target block for the auxiliary CNOT operation.
- loom_rotated_surface_code.applicator.auxcnot.auxcnot_grow_control(interpretation_step, control, target, grow_direction, same_timeslice, debug_mode)[source]
Grow the control block for the auxiliary CNOT operation.
- Parameters:
interpretation_step (InterpretationStep) – Input interpretation step.
control (RotatedSurfaceCode) – Control block for the auxiliary CNOT operation.
target (RotatedSurfaceCode) – Target block for the auxiliary CNOT operation.
grow_direction (Direction) – Direction in which to grow the control block.
same_timeslice (bool) – Flag indicating whether the operation is part of the same timestep as the input.
debug_mode (bool) – Flag indicating whether the interpretation should be done in debug mode.
- Returns:
The updated interpretation step after growing the control block.
- Return type:
- loom_rotated_surface_code.applicator.auxcnot.auxcnot_merge_aux_target(interpretation_step, aux, target, same_timeslice, debug_mode)[source]
Merge the auxiliary block with the target block.
- Parameters:
interpretation_step (InterpretationStep) – Input interpretation step.
aux (RotatedSurfaceCode) – Auxiliary block for the auxiliary CNOT operation.
target (RotatedSurfaceCode) – Target block for the auxiliary CNOT operation.
same_timeslice (bool) – Flag indicating whether the operation is part of the same timestep as the input.
debug_mode (bool) – Flag indicating whether the interpretation should be done in debug mode.
- Returns:
The updated interpretation step after merging the auxiliary and target blocks.
- Return type:
- loom_rotated_surface_code.applicator.auxcnot.auxcnot_shrink_target(interpretation_step, initial_target, merged_target, shrink_direction, same_timeslice, debug_mode)[source]
Shrink the target block after merging with the auxiliary block.
- Parameters:
interpretation_step (InterpretationStep) – Input interpretation step.
initial_target (RotatedSurfaceCode) – Initial target block for the auxiliary CNOT operation.
merged_target (RotatedSurfaceCode) – Merged target block after merging with the auxiliary block.
same_timeslice (bool) – Flag indicating whether the operation is part of the same timestep as the input.
debug_mode (bool) – Flag indicating whether the interpretation should be done in debug mode.
- Returns:
The updated interpretation step after shrinking the target block.
- Return type:
- loom_rotated_surface_code.applicator.auxcnot.auxcnot_split_control(interpretation_step, aux_unique_label, initial_control, initial_target, grown_control, same_timeslice, debug_mode)[source]
Split the grown control block into the control and auxiliary blocks.
- Parameters:
interpretation_step (InterpretationStep) – Input interpretation step.
aux_unique_label (str) – Unique label for the auxiliary block that will be created after the split.
initial_control (RotatedSurfaceCode) – Initial control block before it was grown.
initial_target (RotatedSurfaceCode) – Initial target block before the auxiliary CNOT operation.
grown_control (RotatedSurfaceCode) – Control block for the auxiliary CNOT operation that was just grown.
same_timeslice (bool) – Flag indicating whether the operation is part of the same timestep as the input.
debug_mode (bool) – Flag indicating whether the interpretation should be done in debug mode.
- Returns:
The updated interpretation step after splitting the grown control block.
- Return type:
- loom_rotated_surface_code.applicator.auxcnot.get_grow_shrink_directions(control, target)[source]
Get the grow and shrink directions for the auxiliary CNOT operation. The grow direction is the direction of the X operator of the control block, and the shrink direction is the direction normal to the X operator of the target block.
- Parameters:
control (RotatedSurfaceCode) – Control block for the auxiliary CNOT operation.
target (RotatedSurfaceCode) – Target block for the auxiliary CNOT operation.
- Returns:
The grow and shrink directions.
- Return type: