deltakit.explorer.codes.RepetitionCode#

class deltakit.explorer.codes.RepetitionCode(distance: int, stabiliser_type: PauliBasis = PauliBasis.Z, use_ancilla_qubits: bool = True, use_looping_stabiliser: bool = False, default_schedule: bool = True, odd_data_qubit_coords: bool = False)#

Bases: CSSCode

Class representing an n-qubit repetition code for memory and stability experiments. Qubits are laid out in a line alternating between data and ancilla. Connectivity is only required between neighbouring pairs of qubits. See graph below for a distance 3 code.

User can specify whether they want to implement a bit-flip code (with Z stabilisers) or a phase-flip code (with X stabilisers)

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

0├    o --- Z/X --- o --- Z/X --- o
 |
 └----┴------┴------┴------┴------┴
      0      1      2      3      4
Parameters:
  • distance (int) – Minimum weight for a logical operator.

  • stabiliser_type (PauliBasis) – Sets the stabiliser type for the repetition code e.g. PauliBasis.Z for a bit-flip code.

  • use_ancilla_qubits (bool, optional) – Sets whether stabilisers have ancilla qubits for full circuit simulations. Setting this to False will compile the output circuit with MPP measurements for phenomenological noise. By default, True.

  • use_looping_stabiliser (bool, optional) – Sets whether a looping stabiliser (between first and last data qubits) is defined. By default, False.

  • default_schedule (bool, optional) – Whether to use the default schedule to use for syndrome extraction. If True, the syndrome extraction is performed on the qubit to the left of the ancilla first, and then on the qubit to the right. If False, it is the opposite way round. By default, True.

  • odd_data_qubit_coords (bool, optional) – Whether the data qubits should have odd x-coordinates (True) or even (False). By default, False.

Methods#

RepetitionCode.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.

RepetitionCode.check_logical_operators_are_independent

Check that the logical operators are independent.

RepetitionCode.encode_logical_pluses

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

RepetitionCode.encode_logical_zeroes

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

RepetitionCode.from_matrix

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

RepetitionCode.measure_stabilisers

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

RepetitionCode.measure_x_logicals

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

RepetitionCode.measure_z_logicals

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

RepetitionCode.overwrite_logicals

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

RepetitionCode.x_and_z_operators_commute

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