StabilizerCode

class guppyft.code_def.StabilizerCode(n_physical_qubits: int, n_logical_qubits: int, distance: int, generators: SignTermSet, x_logicals: SignTerms, z_logicals: SignTerms)[source]

Definition of a stabilizer code.

Stores the following information

  • n_physical_qubits (\(n\)) - Number of physical qubits in a code block.

  • n_logical_qubits (\(k\)) - Number of logical qubits in a code block

  • distance (\(d\)) - The distance of the stabilizer code.

  • generators - A set of \((n-k)\) commuting stabilizer generators.

  • x_logicals - The logical \(X\) operators of the stabilizer code.

  • z_logicals - The logical \(Z\) operators of the stabilizer code.

from guppyft.code_def import StabilizerCode

STEANE_DEF = StabilizerCode.from_python_strings(
    n_physical_qubits=7,
    n_logical_qubits=1,
    distance=3,
    generators=["XXXXIII", "IXXIXXI", "IIXXIXX",
                "ZZZZIII", "IZZIZZI", "IIZZIZZ"],
    x_logicals=["XXXXXXX"],
    z_logicals=["ZZZZZZZ"],
)
__eq__(other)

Return self==value.

__init__(n_physical_qubits: int, n_logical_qubits: int, distance: int, generators: SignTermSet, x_logicals: SignTerms, z_logicals: SignTerms) → None
__post_init__() → None[source]

Validate the stabilizer-code definition.

__repr__()

Return repr(self).

static from_python_strings(n_physical_qubits: int, n_logical_qubits: int, distance: int, generators: list[str], x_logicals: list[str], z_logicals: list[str]) → StabilizerCode[source]

Helper to create a StabilizerCode from lists of Python strings.

The strings must be defined over the alphabet \(\{I, X, Y, Z\}\) and must be of length equal to the number of physical qubits. A sign may be provided at the front. If a string is missing a sign, it is assumed to be positive.

Parameters:
  • n_physical_qubits – The number of physical qubits in the code.

  • n_logical_qubits – The number of logical qubits in the code.

  • distance – The distance of the code.

  • generators – A list of stabilizer generators as Pauli strings.

  • x_logicals – A list of \(X\) logical operators as Pauli strings.

  • z_logicals – A list of \(Z\) logical operators as Pauli strings.

Returns:

A StabilizerCode instance representing the code.

property y_logicals: SignTerms

Return the Y logical operators derived from X and Z logicals.