loom_rotated_surface_code.applicator.state_injection

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.state_injection.create_deterministic_syndromes(interpretation_step, block, deterministic_stabs)[source]

Create syndromes that are deterministic for the given state.

Parameters:
  • interpretation_step (InterpretationStep) – The interpretation step containing the input block.

  • block (RotatedSurfaceCode) – The input block to create syndromes for.

  • deterministic_stabs (tuple[Stabilizer, ...]) – The stabilizers that have a deterministic value after the state injection.

Returns:

The tuple of deterministic syndromes.

Return type:

tuple[Syndrome, …]

loom_rotated_surface_code.applicator.state_injection.find_centered_logical_operators(input_block, center_qubit)[source]

Create new logical operators that go through the center of the block such that the state injection can be measured directly by the given logical operators.

Parameters:
  • input_block (RotatedSurfaceCode) – The input block that may or may not have centered logical operators.

  • center_qubit (tuple[int, int, int]) – The qubit onto which the state is injected.

Returns:

The centered logical operators.

Return type:

tuple[PauliOperator, PauliOperator]

loom_rotated_surface_code.applicator.state_injection.find_qubits_quadrant(block, quadrant)[source]

Finds the qubits in a specific quadrant of a rotated surface code block.

Parameters:
  • block (RotatedSurfaceCode) – The rotated surface code block containing the stabilizers.

  • quadrant (Direction) – The direction of the quadrant to search for qubits.

Returns:

The qubits found in the specified quadrant.

Return type:

tuple[tuple[int, int, int], …]

Raises:

ValueError – If there is more than one pauli type in the boundary stabilizers.

loom_rotated_surface_code.applicator.state_injection.get_physical_state_reset(interpretation_step, input_block, qubit_to_reset, resource_state)[source]

Resets a physical qubit in the given resource state. The given qubit must be a data qubit in the input block.

Parameters:
  • interpretation_step (InterpretationStep) – The interpretation step containing the input block.

  • input_block (RotatedSurfaceCode) – The input block containing the data qubits.

  • qubit_to_reset (tuple[int, int, int]) – The qubit to reset into the given state. It must be a data qubit in the input block.

  • resource_state (ResourceState) – The resource state to reset the qubit into. Currently, only T and S states are supported.

Returns:

A circuit that resets the specified qubit into the given resource state, which consists of a reset operation in $|+⟩$ followed by a physical gate that depends on the resource state.

Return type:

Circuit

loom_rotated_surface_code.applicator.state_injection.reset_into_four_quadrants(interpretation_step, block)[source]

Reset the rest of the data qubits of the block into four quadrants, such that two quadrants are in the $|0⟩$ state, making the Z stabilizer measurements deterministic and two quadrants are in the $|+⟩$ state, making the X stabilizer measurements deterministic.

E.g. for a distance 5 block, the reset will look like this:

           d           d
  + --- 0 --- 0 --- 0 --- 0
d |     |     |  d  |     |
  + --- + --- 0 --- 0 --- +
  |  d  |     |     |     | d
  + --- + --- 𝛙 --- + --- +
d |     |     |     |  d  |
  + --- 0 --- 0 --- + --- +
  |     |  d  |     |     | d
  0 --- 0 --- 0 --- 0 --- +
     d           d

“d” denotes a deterministic stabilizer measurement in the above figure.

Parameters:
Returns:

The circuit resetting all qubits aside from the central qubit and the stabilizers that are initialized in a deterministic state because of these resets.

Return type:

tuple[Circuit, tuple[Stabilizer, …]]

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

Inject a resource state into the specified block. This operation resets the central qubit of the block into the T state and resets 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.

Note: the syndromes are measured once at the end of the operation in order to displace the logical operators to the top-left corner of the block.

The algorithm is the following:

  • A.) CIRCUIT

    • A.1) Resets the central qubit in a physical T state.

    • A.2) Resets 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.

  • B.) LOGICAL OPERATORS

    • B.1) Displace the logical operators to the center of the block.

  • C.) SYNDROMES

    • C.1) Creates syndromes for the block after the T state injection. Only the stabilizers that are deterministic generate syndromes.

  • D.) MEASURE BLOCK SYNDROMES

    • D.1) Measure the block syndromes.

  • E.) DISPLACE LOGICAL OPERATORS

    • E.1) Create the new logical operators on the top-left corner of the block.

  • F.) WRAP THE CIRCUIT

    • F.1) Wrap the state injection circuit in a single circuit with the correct duration and empty timeslices.

Parameters:
  • interpretation_step (InterpretationStep) – The interpretation step containing the input block.

  • operation (StateInjection) – The operation containing the name of the input block to inject the T state into.

  • same_timeslice (bool) – Whether to append the circuit to the same timeslice as the current interpretation step.

  • debug_mode (bool) – Flag indicating whether the interpretation should be done in debug mode. Currently, the effects of debug mode are: - Disabling the commutation validation of Block