deltakit.explorer.codes.UnrotatedToricCode#

class deltakit.explorer.codes.UnrotatedToricCode(horizontal_distance: int, vertical_distance: int, schedule_type: ScheduleType = ScheduleType.SIMULTANEOUS, schedule_order: ScheduleOrder = ScheduleOrder.STANDARD, use_ancilla_qubits: bool = True)#

Bases: PlanarCode

Class representing the default unrotated toric code. The code has a periodic boundary and encodes two logical qubits. Logical operators are formed of loops around the torus. See the graph below showing a default 3x3 toric code. Open edges are connected to qubits on opposite sides. The distance of the code is given by the min(horizontal_distance, vertical_distance).

This class also contains methods that help set up circuits for memory experiments.

6├
|    |      |      |      |      |      |
5├    X ---- o ---- X ---- o ---- X ---- o ----
|    |      |      |      |      |      |
4├    ○ ---- Z ---- ○ ---- Z ---- ○ ---- Z ----
│    |      |      |      |      |      |
3├    X ---- ○ ---- X ---- ○ ---- X ---- o ----
│    |      |      |      |      |      |
2├    ○ ---- Z ---- ○ ---- Z ---- ○ ---- Z ----
│    |      |      |      |      |      |
1├    X ---- ○ ---- X ---- ○ ---- X ---- o ----
│    |      |      |      |      |      |
0├    ○ ---- Z ---- ○ ---- Z ---- ○ ---- Z ----
└----┴------┴------┴------┴------┴------┴------┴
    0      1      2      3      4      5      6
Parameters:
  • horizontal_distance (int) – The width of the toric code patch, which defines the distance for the horizontal logical operators X1 and Z2.

  • vertical_distance (int) – The height of the toric code patch, which defines the distance for the vertical logical operators X2 and Z1.

Methods#

UnrotatedToricCode.calculate_number_of_logical_qubits

Calculate the maximum number of logical qubits that are encoded into the code by subtracting the rank of Hx and Hz parity matrices from the number of (data) qubits.

UnrotatedToricCode.check_logical_operators_are_independent

Check that the logical operators are independent.

UnrotatedToricCode.draw_patch

UnrotatedToricCode.encode_logical_pluses

Set up the CSSStage which represents the encoding of a logical \(\ket{+}\dots\ket{+}\)

UnrotatedToricCode.encode_logical_zeroes

Set up the CSSStage which represents the encoding of a logical \(\ket{0}\dots\ket{0}\).

UnrotatedToricCode.from_matrix

Return a CSSCode object with stabilisers that have no ancilla qubits.

UnrotatedToricCode.get_shifted_logicals

Given a boolean specifying whether to modify X or Z logicals, and a Coord2DDelta, modify the relevant logical(s) by adding the Coord2DDelta to the coordinates of each qubit making up the logical.

UnrotatedToricCode.measure_stabilisers

Set up the CSSStage which represents measuring the stabilisers for num_rounds rounds.

UnrotatedToricCode.measure_x_logicals

Set up the CSSStage which represents measuring all logical X operators simultaneously.

UnrotatedToricCode.measure_z_logicals

Set up the CSSStage which represents measuring all logical Z operators simultaneously.

UnrotatedToricCode.overwrite_logicals

Method to allow for updating both X and Z logicals simultaneously.

UnrotatedToricCode.x_and_z_operators_commute

Compute whether an X-type stabiliser commutes with a Z-type stabiliser.