deltakit.explorer.codes.CSSCode#

class deltakit.explorer.codes.CSSCode(stabilisers: Sequence[Iterable[Stabiliser]], x_logical_operators: Sequence[Collection[PauliGate]] | None = None, z_logical_operators: Sequence[Collection[PauliGate]] | None = None, use_ancilla_qubits: bool = True, calculate_logical_operators: bool = False, check_logical_operators_are_independent: bool = False)#

Bases: StabiliserCode

Class representing a CSS code.

Parameters:
  • stabilisers (Sequence[Sequence[Stabiliser]]) –

    Stabilisers defining the code. The i-th element of stabilisers contains an Iterable of stabilisers measured during the i-th time step. For instance:

    • if we intend to measure all stabilisers simultaneously, then this parameter could be simply given as [{…all stabilisers…}],

    • if we intend to do a spaced syndrome extraction, then this parameter could be simply given as [{…all x stabilisers…}, {…all z stabilisers…}].

    If any stabilisers do not have ancilla qubits, the use_ancilla_qubits parameter must be set to False.

  • x_logical_operators (Optional[Sequence[Collection[PauliGate]]], optional) – An entry to provide manually the X logical operators of the CSS code. These operators must contain X Pauli terms only. If provided, then the Z logical operators must also be manually provided, otherwise a ValueError is raised. If check_logical_operators_are_independent is True, then each X logical operator must exactly only anticommute with the Z logical operator at the same index. There is also the possibility of automatically generating these logical operators, in which case neither should be provided and calculate_logical_operators should be set to True. To initialise with no logical operators, keep as None and set calculate_logical_operators to False. By default, None.

  • z_logical_operators (Optional[Sequence[Collection[PauliGate]]], optional) – An entry to provide manually the Z logical operators of the CSS code. These operators must contain Z Pauli terms only. If provided, then the X logical operators must also be manually provided, otherwise a ValueError is raised. If check_logical_operators_are_independent is True, then each Z logical operator must exactly only anticommute with the X logical operator at the same index. There is also the possibility of automatically generating these logical operators, in which case neither should be provided and calculate_logical_operators should be set to True. To initialise with no logical operators, keep as None and set calculate_logical_operators to False. By default, None.

  • use_ancilla_qubits (bool, optional) – Specifies whether ancilla qubits will be used for syndrome extraction. If this is True, the stabilisers must all have ancilla qubits and, in this case, the order the Paulis are given in the stabilisers will be the order in which information is extracted from the data qubits to the ancilla when performing syndrome extraction. By default, True.

  • calculate_logical_operators (bool, optional,) – Whether to automatically calculate the logical operators. If this is True, then x_logical_operators and z_logical_operators should be None. Otherwise, a ValueError is raised. If check_logical_operators_are_independent is set to True, then the calculated logical operators will either be guaranteed to be independent or an error will be raised indicating that it didn’t manage to meet this condition. By default, False.

  • check_logical_operators_are_independent (bool, optional) – Whether to check if logical X-Z operator pairs are independent. If True, then the commuting relations [X_k, Z_l] = 0 (k != l) are checked for the logical operators, ensuring that the logical operators correspond to separate logical qubits. If False, this check is ignored, in which case the logical operators can be dependent, e.g. instead of only accepting X_1, X_2 and Z_1, Z_2, the input X_1, X_1*X_2 and Z_1, Z_1*Z_2 is also accepted. If both this flag and calculate_logical_operators are True, then the calculated logical operators will either be guaranteed to be independent or an error will be raised indicating that it didn’t manage to meet this condition. By default, False.

Methods#

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

CSSCode.check_logical_operators_are_independent

Check that the logical operators are independent.

CSSCode.encode_logical_pluses

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

CSSCode.encode_logical_zeroes

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

CSSCode.from_matrix

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

CSSCode.measure_stabilisers

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

CSSCode.measure_x_logicals

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

CSSCode.measure_z_logicals

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

CSSCode.overwrite_logicals

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

CSSCode.x_and_z_operators_commute

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