localuf.codes

Module for CSS codes.

Available codes:

  • Repetition

  • Surface

Classes

Repetition(d, noise[, scheme, ...])

The decoding graph of a repetition code.

Surface(d, noise[, scheme, window_height, ...])

The decoding graph of an unrotated surface code with boundaries.

class localuf.codes.Repetition(d, noise, scheme='batch', window_height=None, commit_height=None, buffer_height=None, merge_equivalent_boundary_nodes=False, parametrization='balanced', demolition=False, monolingual=False, _merge_redundant_edges=True)[source]

Bases: Code

The decoding graph of a repetition code.

Extends Code class.

Parameters:
  • d (int)

  • noise (Literal['code capacity', 'phenomenological', 'circuit-level'])

  • scheme (Literal['batch', 'global batch', 'forward', 'frugal'])

  • window_height (int | None)

  • commit_height (int | None)

  • buffer_height (int | None)

  • merge_equivalent_boundary_nodes (bool)

  • parametrization (Literal['standard', 'balanced', 'ion trap'])

  • demolition (bool)

  • monolingual (bool)

  • _merge_redundant_edges (bool)

index_to_id(index)[source]

Return ID of node at index (j,) or (j, t).

Parameters:

index (tuple[int, ...])

get_pos(x_offset=0.2, nodelist=None)[source]

Compute coordinates of each node G for draw().

Parameters:
  • x_offset (float) – the ratio of out-of-screen to along-screen distance.

  • nodelist (None | Iterable[tuple[int, ...]]) – the nodes to draw. Default is self.NODES.

Returns pos:

a dictionary where each key a node index; value, position coordinate. E.g. for the surface code with perfect measurements, convert each matrix index to position coords via (i, j) -> (x, y) = (j, -i).

Return type:

dict[tuple[int, …], tuple]

class localuf.codes.Surface(d, noise, scheme='batch', window_height=None, commit_height=None, buffer_height=None, merge_equivalent_boundary_nodes=False, parametrization='balanced', demolition=False, monolingual=False, _merge_redundant_edges=True)[source]

Bases: Code

The decoding graph of an unrotated surface code with boundaries.

Extends Code class.

Parameters:
  • d (int)

  • noise (Literal['code capacity', 'phenomenological', 'circuit-level'])

  • scheme (Literal['batch', 'global batch', 'forward', 'frugal'])

  • window_height (int | None)

  • commit_height (int | None)

  • buffer_height (int | None)

  • merge_equivalent_boundary_nodes (bool)

  • parametrization (Literal['standard', 'balanced', 'ion trap'])

  • demolition (bool)

  • monolingual (bool)

  • _merge_redundant_edges (bool)

property DATA_QUBIT_COUNT: int

Number of data qubits.

index_to_label(index)[source]

Return node label of measure-Z qubit at index (i, j).

Parameters:

index (tuple[int, ...])

label_to_index(a)[source]

Return measure-Z qubit index (i, j) of node label a.

Parameters:

a (int)

Return type:

tuple[int, …]

index_to_id(index)[source]

Return ID of node at index (i, j) or (i, j, t).

Parameters:

index (tuple[int, ...])

get_pos(x_offset=0.2, nodelist=None)[source]

Compute coordinates of each node G for draw().

Parameters:
  • x_offset (float) – the ratio of out-of-screen to along-screen distance.

  • nodelist (None | Iterable[tuple[int, ...]]) – the nodes to draw. Default is self.NODES.

Returns pos:

a dictionary where each key a node index; value, position coordinate. E.g. for the surface code with perfect measurements, convert each matrix index to position coords via (i, j) -> (x, y) = (j, -i).

Return type:

dict[tuple[int, …], tuple]